Skip to content

Commit c6946f6

Browse files
authored
Check return value for getProduct() in getPrice().
If getProduct() returns a NULL value then this code will generate a PHP warning and potentially crash the page; let's not do that, and check our return values before we try to call methods on them.
1 parent 9b9c992 commit c6946f6

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getFinalPrice($qty, $product)
3939
*/
4040
public function getPrice($product)
4141
{
42-
if ($product->getCustomOption('simple_product')) {
42+
if ( !empty( $product ) && !empty( $product->getCustomOption('simple_product') ) && !empty( $product->getCustomOption('simple_product')->getProduct() ) ) {
4343
return $product->getCustomOption('simple_product')->getProduct()->getPrice();
4444
} else {
4545
return 0;

0 commit comments

Comments
 (0)