Skip to content

Commit dfe3a59

Browse files
authored
Update Price.php
Save results of methods called and clean up code in response to feedback and tests.
1 parent c6946f6 commit dfe3a59

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 ( !empty( $product ) && !empty( $product->getCustomOption('simple_product') ) && !empty( $product->getCustomOption('simple_product')->getProduct() ) ) {
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)