From a452475d8b437f495d47a9f04e09c24349fe2d5e Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Wed, 31 Jul 2024 15:21:23 +0200 Subject: [PATCH 1/2] Fixes issue with grouped product on orders-endpoint --- Service/WebApi/Order.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Service/WebApi/Order.php b/Service/WebApi/Order.php index 547bc62..567c5e3 100755 --- a/Service/WebApi/Order.php +++ b/Service/WebApi/Order.php @@ -11,6 +11,8 @@ use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository; use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; use Magento\Framework\Api\SearchCriteriaInterface; +use Magento\Framework\App\ResourceConnection; +use Magento\GroupedProduct\Model\ResourceModel\Product\Link; use Magento\Sales\Model\ResourceModel\Order\Collection; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; use Magento\Sales\Model\Order as OrderModel; @@ -48,20 +50,28 @@ class Order * @var CollectionProcessorInterface */ private $collectionProcessor; + /** + * @var ResourceConnection + */ + private $resourceConnection; /** - * Product constructor. + * Order constructor. * @param CollectionFactory $orderCollectionFactory * @param CustomerRepository $customerRepository + * @param CollectionProcessorInterface $collectionProcessor + * @param ResourceConnection $resourceConnection */ public function __construct( CollectionFactory $orderCollectionFactory, CustomerRepository $customerRepository, - CollectionProcessorInterface $collectionProcessor + CollectionProcessorInterface $collectionProcessor, + ResourceConnection $resourceConnection ) { $this->orderCollectionFactory = $orderCollectionFactory; $this->customerRepository = $customerRepository; $this->collectionProcessor = $collectionProcessor; + $this->resourceConnection = $resourceConnection; } /** @@ -182,6 +192,23 @@ private function getProducts(OrderModel $order): array $item->getParentItem()->getProductType() == Type::TYPE_BUNDLE) { $orderedProduct['parent_id'] = $item->getParentItem()->getProductId(); } + + if ($item->getProductType() == 'grouped') { + $connection = $this->resourceConnection->getConnection(); + $parentProduct = $connection->select()->from( + $this->resourceConnection->getTableName('catalog_product_link'), + ['product_id'] + )->where( + 'link_type_id = ?', + Link::LINK_TYPE_GROUPED + )->where( + 'linked_product_id = ?', + $item->getProductId() + ); + $orderedProduct['id'] = $connection->fetchOne($parentProduct); + $orderedProduct['variant_id'] = $item->getProductId(); + } + $orderedProducts[] = $orderedProduct; } From 39d03e663b77ec918f3e13fa5f514c226c985337 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Wed, 31 Jul 2024 15:21:40 +0200 Subject: [PATCH 2/2] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0efa59e..b7c3b5e 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magmodules/magento2-reloadify", "description": "Reloadify extension for Magento 2", "type": "magento2-module", - "version": "1.10.0", + "version": "1.10.1", "license": [ "BSD-2-Clause" ], diff --git a/etc/config.xml b/etc/config.xml index 245500a..e2dcffc 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -10,7 +10,7 @@ - v1.10.0 + v1.10.1 0 0