Created
September 15, 2016 06:07
-
-
Save mrkhoa99/bd43fe34fc51d1f7fd38fbf7d13d384b to your computer and use it in GitHub Desktop.
Set related products programatically Magento 2
Hi,
This code is working for me but when I added the related products with this code. Other up-sell and cross-sell removed issues. When I added the related, cross-sell, and up-sell together then only the last value inserted in the product.
Can you please guide me?
Hi,
This code is working for me but when I added the related products with this code. Other up-sell and cross-sell removed issues. When I added the related, cross-sell, and up-sell together then only the last value inserted in the product.
Can you please guide me?
pls use class Magento\Catalog\Api\Data\ProductLinkInterfaceFactory instead of Magento\Catalog\Api\Data\ProductLinkInterface
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using
$product->save();
is deprecated and should be avoided. You should use theProductRepositoryInterface
to save the product.And ofcourse, using the
ObjectManager
is bad behavior and should not be used on production environments.