Seems to have happened while I was testing enabling/disabling child products. Saw it just later in the error.log on our testserver and because our customer got the error cached in firefox.
Magento 2.1.7
hard to reproduce. maybe it helps to deactive/delete a child product in the backend product listing without further steps. then have the given configured product in the wishlist or cart.
nothing
[11-Jul-2017 08:38:42 UTC] PHP Fatal error: Uncaught Error: Call to a member function getPrice() on null in /srv/httpd/test/src/www/vendor/magento/module-configurable-product/Model/Product/Type/Configurable/Price.php:43
Stack trace:
The Fix is already given in Issue #5519
https://github.com/magento/magento2/issues/5519
But you closed the issue before actual all possible causes were fixed. I applied the following patch to prevent a future circumstancial call on null in the getPrice() function:
diff --git a/www/vendor/magento/module-configurable-product/Model/Product/Type/Configurable/Price.php b/www/vendor/magento/module-configurable-product/Model/Product/Type/Configurable/Price.php
index 9c7efd803..db45d8ece 100644
--- a/www/vendor/magento/module-configurable-product/Model/Product/Type/Configurable/Price.php
+++ b/www/vendor/magento/module-configurable-product/Model/Product/Type/Configurable/Price.php
@@ -39,7 +39,9 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price
*/
public function getPrice($product)
{
- if ($product->getCustomOption('simple_product')) {
+ // REF-MOD START under certain circumstances getPrice is called on null
+ if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
+ // REF-MOD END
return $product->getCustomOption('simple_product')->getProduct()->getPrice();
} else {
return 0;
Seeing exactly the same issue.
Due to a disabled child I believe, but haven't confirmed as such. The getProduct() returns null.
After a bit of debugging and confusion on what was going on i tried changing the stock settings for a Configurable product.
Namely by changing "Manage Stock" from Yes to No as this is what we generally use ourselves.
This somehow solved the issue for this specific product (do note we did several other changes on the product which had no effect).
Strangely once i change the settings back to what they were it will no longer give this error so it is not reliant on this setting.
Hence i believe this goes wrong in the indexing process, but as to why / where i am not yet sure.
Perhaps this information somehow helps others find the cause.
this problem is caused by the flat catalog cache and not only affects the wishlist, but also the checkout.
when the child product is disabled and the catalog_product_flat reindexed, the now disabled product is not in the index anymore. loading the product options (Magento\ConfigurableProduct\Model\Product\Type\Configurable::getOrderOptions()) now fail, as the quote_item table contains a simple_product entry. the $simpleOption->getProduct()->getName() errors out.
the root cause is Magento\Quote\Model\ResourceModel\Quote\Item\Collection::_assignProducts() using the flat table, and thus does not load the assigned product for the simple_product entry.
the flat index tables should also contain disabled products and not just enabled ones. a workaround would be to add an additional checks if $itemOption->getProduct() is not returning null.
Looks like the fatal error's been taken care since this commit
https://github.com/magento/magento2/commit/c6946f66ef3099dd4913bd21424b7540da874dbc
unfortunately only at this one place, the same construct is used at multiple other places as well, f.e. https://github.com/magento/magento2/blob/2.2/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php#L984
Internal ticket to track issue progress: MAGETWO-72251
@jhruehl Closing, as issue is already fixed in 2.2.0 and develop. Fix for 2.1.x will be released soon.
Hi @magento-engcom-team , could you please be a little bit more specific regarding the "soon" part?
Do you mean the upcoming 2.1.10 version?