diff --git a/vendor/magento/module-inventory-bundle-product/Model/GetChidrenSkusByParentIds.php b/vendor/magento/module-inventory-bundle-product/Model/GetChidrenSkusByParentIds.php index 102d534997dd..a7703b4f1e8a 100644 --- a/vendor/magento/module-inventory-bundle-product/Model/GetChidrenSkusByParentIds.php +++ b/vendor/magento/module-inventory-bundle-product/Model/GetChidrenSkusByParentIds.php @@ -1,7 +1,7 @@ selectionCollectionFactory = $selectionCollectionFactory; $this->selectionCollectionFilterApplier = $selectionCollectionFilterApplier; $this->batchSize = $batchSize; + $this->metadataPool = $metadataPool ?: + ObjectManager::getInstance()->get(MetadataPool::class); } /** @@ -53,6 +67,7 @@ public function __construct( * * @param array $parentIds * @return array + * @throws Zend_Db_Select_Exception */ public function execute(array $parentIds): array { @@ -60,6 +75,13 @@ public function execute(array $parentIds): array $collection = $this->selectionCollectionFactory->create(); $collection->addFilterByRequiredOptions(); $collection->setFlag('product_children', true); + $linkField = $this->metadataPool->getMetadata(ProductInterface::class) + ->getLinkField(); + $collection->getSelect()->group('e.' . $linkField); + $collection->getSelect()->columns([ + 'parent_product_id' => + new Zend_Db_Expr('GROUP_CONCAT(selection.parent_product_id)') + ]); $this->selectionCollectionFilterApplier->apply( $collection, 'parent_product_id',