Skip to content

Commit

Permalink
Backport of MAGETWO-65607 for Magento 2.1: [GitHub][PR] Check return …
Browse files Browse the repository at this point in the history
…value for getProduct() in getPrice(). #7794

 - Merge Pull Request #7794 from pbaylies/magento2:patch-2

(cherry picked from commit 6752968)
  • Loading branch information
vrann authored and hostep committed Sep 2, 2017
1 parent 6065b1c commit ad07888
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -39,10 +39,15 @@ public function getFinalPrice($qty, $product)
*/
public function getPrice($product)
{
if ($product->getCustomOption('simple_product')) {
return $product->getCustomOption('simple_product')->getProduct()->getPrice();
} else {
return 0;
if (!empty($product)) {
$simpleProductOption = $product->getCustomOption('simple_product');
if (!empty($simpleProductOption)) {
$simpleProduct = $simpleProductOption->getProduct();
if (!empty($simpleProduct)) {
return $simpleProduct->getPrice();
}
}
}
return 0;
}
}

0 comments on commit ad07888

Please sign in to comment.