Skip to content

Commit a86e9b0

Browse files
authored
MAGETWO-65607: [GitHub][PR] Check return value for getProduct() in getPrice(). #7794
2 parents 309b4be + 6752968 commit a86e9b0

File tree

1 file changed

+9
-4
lines changed
  • app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable

1 file changed

+9
-4
lines changed

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ public function getFinalPrice($qty, $product)
3939
*/
4040
public function getPrice($product)
4141
{
42-
if ($product->getCustomOption('simple_product')) {
43-
return $product->getCustomOption('simple_product')->getProduct()->getPrice();
44-
} else {
45-
return 0;
42+
if (!empty($product)) {
43+
$simpleProductOption = $product->getCustomOption('simple_product');
44+
if (!empty($simpleProductOption)) {
45+
$simpleProduct = $simpleProductOption->getProduct();
46+
if (!empty($simpleProduct)) {
47+
return $simpleProduct->getPrice();
48+
}
49+
}
4650
}
51+
return 0;
4752
}
4853
}

0 commit comments

Comments
 (0)