From 33dc53162d92f76ccf350b0cb4359630e9277a9a Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Wed, 19 Feb 2025 13:48:40 +0100 Subject: [PATCH] Fix possible issue with non-existing getProduct() method --- DataLayer/Mapper/ProductDataMapper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DataLayer/Mapper/ProductDataMapper.php b/DataLayer/Mapper/ProductDataMapper.php index a710472..8c42909 100644 --- a/DataLayer/Mapper/ProductDataMapper.php +++ b/DataLayer/Mapper/ProductDataMapper.php @@ -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()); }