Skip to content

Commit

Permalink
Fix possible issue with non-existing getProduct() method
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed Feb 19, 2025
1 parent c830209 commit 33dc531
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions DataLayer/Mapper/ProductDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public function mapByProduct(ProductInterface $product): array
}

$productData['price'] = $this->priceFormatter->format((float) $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
$simpleProduct = $product->getCustomOption('simple_product')->getProduct();

$simpleProductOption = $product->getCustomOption('simple_product');
if ($simpleProductOption && method_exists($simpleProductOption, 'getProduct') && $simpleProductOption->getProduct()) {
$simpleProduct = $simpleProductOption->getProduct();
$productData['price'] = $this->priceFormatter->format((float) $simpleProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
}

Expand Down

0 comments on commit 33dc531

Please sign in to comment.