0

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

2
  • any error message or any log generated ?? Commented 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
    – Pawankumar
    Commented May 9, 2019 at 9:58

1 Answer 1

0

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());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.