Magento 2 I am trying to change product data - first time it is working fine, when i tried to change same attribute second time it not updating which i selected data
-
any error message or any log generated ??– Ronak RathodCommented May 8, 2019 at 15:37
-
@RkRathod No,it showing You saved the product. if i change default magento attributes those working fine custom attributes means if create new attribute pawan if i change this attribute it not working– PawankumarCommented May 9, 2019 at 9:58
Add a comment
|
1 Answer
In my case the product class overrided Magento\Catalog\Model\Product and using
$this->load($this->getId())->getData('My_Custom_Attribute');
to get my attribute because $this->getData('My_Custom_Attribute');
was returning Null;
Reloading the product cause to un-updating the product "using load() function"
so recheck your plugin and try to disable them 1 by 1
here is my problem: plugin code:
$product->load($product->getId()); //Here my main product get overrided
Replaced with:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objectManager->create('Magento\Catalog\Model\Product')->load($product->getId());