Magento2.2.3 Fatal Error – Fix Call to Undefined Method in Configurable Product

configurable-productfatal errormagento2.2.3

When I add a configurable product in Magento CE 2.2.3, I try to add variations. No problems so far. When I return to the product edit screen I see the variations. When I try to save the product I get the following error (changed user and domain).

Got error

PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method Magento\\Catalog\\Model\\Product\\Type\\Simple::getConfigurableAttributeCollection() in vendor/magento/module-configurable-product/Helper/Product/Options/Loader.php:52
Stack trace:
#0 vendor/magento/module-configurable-product/Model/Product/ReadHandler.php(48): Magento\\ConfigurableProduct\\Helper\\Product\\Options\\Loader->load(Object(Magento\\Catalog\\Model\\Product\\Interceptor))
#1 vendor/magento/framework/EntityManager/Operation/Read/ReadExtensions.php(48): Magento\\ConfigurableProduct\\Model\\Product\\ReadHandler->execute(Object(Magento\\Catalog\\Model\\Product\\Interceptor), Array)
#2 vendor/magento/framework/EntityManager/Operation/Read.php(112): Magento\\Framework\\EntityManager\\Operation\\Read\\ReadExtensions->execute(Object(Magento\\Catalog\\Model\\Product\\Interce...', 
referer: http://domain.com/admin/catalog/product/edit/id/4670/set/54/type/configurable/store/0/key/3c6931241c19f977a1c6f03ae3207a09140b29c47712291add87d3fcd84df4da/back/edit/

Please help.

Best Answer

I had the same problem and when I changed

$objectManager->get('\Magento\Catalog\Model\Product')->load($productId)

into

$objectManager->create('\Magento\Catalog\Model\Product')->load($productId)

the problem disappeared.

Related Topic