From 2c6023cf89078682de963d2795b23b920ee2140d Mon Sep 17 00:00:00 2001 From: stack Date: Mon, 26 Oct 2020 15:29:42 +0100 Subject: [PATCH] Correctly pick product id for configurable products --- src/Model/Resolver/ProductResolver.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Model/Resolver/ProductResolver.php b/src/Model/Resolver/ProductResolver.php index d39d3c6..dea036f 100755 --- a/src/Model/Resolver/ProductResolver.php +++ b/src/Model/Resolver/ProductResolver.php @@ -86,6 +86,9 @@ public function resolve( } $productIds = array_map(function ($item) { + foreach ($item->getChildrenItems() as $item){ + return $item->getProduct()->getId(); + } return $item['product_id']; }, $value['products']); @@ -117,7 +120,8 @@ public function resolve( foreach ($value['products'] as $key => $item) { /** @var $item Item */ - $data[$key] = $productsData[$item->getProductId()]; + $productId = $item->getChildrenItems() ? $item->getChildrenItems()[0]->getProduct()->getId() : $item->getProductId(); + $data[$key] = $productsData[$productId]; $data[$key]['qty'] = $item->getQtyOrdered(); $data[$key]['row_total'] = $item->getBaseRowTotalInclTax(); $data[$key]['original_price'] = $item->getBaseOriginalPrice();