0

I am using the following code in a plugin's aroundGetItemData() method.

$product->getTypeInstance(true)->getOrderOptions($product)

It's returning me the following error,

Fatal error: Uncaught Error: Call to a member function getName() on null in /vendor/magento/module-configurable-product/Model/Product/Type/Configurable.php:992 Stack trace: #0 /generated/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Interceptor.php(310):

When I investigated, I found that some of the selected attributes are not valid for this product as the simple products as out of stock.

How to handle this error? Any help will be greatly appreciated.

3
  • Have you get data in $product? Commented Nov 12, 2019 at 11:27
  • Yes, I'm getting data in the product object. Commented Nov 12, 2019 at 11:37
  • Open /vendor/magento/module-configurable-product/Model/Product/Type/Configurable.php file and see in getOrderOptions function $product->getCustomOption('simple_product') getting or not. Commented Nov 12, 2019 at 11:52

0

Your Answer

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