|
| 1 | +diff -Nuar a/vendor/magento/module-inventory-configurable-product-indexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php b/vendor/magento/module-inventory-configurable-product-indexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php |
| 2 | +--- a/vendor/magento/module-inventory-configurable-product-indexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php |
| 3 | ++++ b/vendor/magento/module-inventory-configurable-product-indexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php |
| 4 | +@@ -31,10 +31,6 @@ class SiblingSkuListInStockProvider |
| 5 | + */ |
| 6 | + private $skuListInStockFactory; |
| 7 | + |
| 8 | +- /** |
| 9 | +- * @var int |
| 10 | +- */ |
| 11 | +- private $groupConcatMaxLen; |
| 12 | + /** |
| 13 | + * @var MetadataPool |
| 14 | + */ |
| 15 | +@@ -56,7 +52,6 @@ class SiblingSkuListInStockProvider |
| 16 | + * @param ResourceConnection $resourceConnection |
| 17 | + * @param SkuListInStockFactory $skuListInStockFactory |
| 18 | + * @param MetadataPool $metadataPool |
| 19 | +- * @param int $groupConcatMaxLen |
| 20 | + * @param string $tableNameSourceItem |
| 21 | + * @param string $tableNameStockSourceLink |
| 22 | + */ |
| 23 | +@@ -64,13 +59,11 @@ public function __construct( |
| 24 | + ResourceConnection $resourceConnection, |
| 25 | + SkuListInStockFactory $skuListInStockFactory, |
| 26 | + MetadataPool $metadataPool, |
| 27 | +- int $groupConcatMaxLen, |
| 28 | + $tableNameSourceItem, |
| 29 | + $tableNameStockSourceLink |
| 30 | + ) { |
| 31 | + $this->resourceConnection = $resourceConnection; |
| 32 | + $this->skuListInStockFactory = $skuListInStockFactory; |
| 33 | +- $this->groupConcatMaxLen = $groupConcatMaxLen; |
| 34 | + $this->metadataPool = $metadataPool; |
| 35 | + $this->tableNameSourceItem = $tableNameSourceItem; |
| 36 | + $this->tableNameStockSourceLink = $tableNameStockSourceLink; |
| 37 | +@@ -91,15 +84,13 @@ public function execute(array $sourceItemIds): array |
| 38 | + |
| 39 | + $metadata = $this->metadataPool->getMetadata(ProductInterface::class); |
| 40 | + $linkField = $metadata->getLinkField(); |
| 41 | ++ $items = []; |
| 42 | + |
| 43 | + $select = $connection |
| 44 | + ->select() |
| 45 | + ->from( |
| 46 | + ['source_item' => $sourceItemTable], |
| 47 | +- [ |
| 48 | +- SourceItemInterface::SKU => |
| 49 | +- "GROUP_CONCAT(DISTINCT sibling_product_entity." . SourceItemInterface::SKU . " SEPARATOR ',')" |
| 50 | +- ] |
| 51 | ++ [SourceItemInterface::SKU => 'sibling_product_entity.' . SourceItemInterface::SKU] |
| 52 | + )->joinInner( |
| 53 | + ['stock_source_link' => $sourceStockLinkTable], |
| 54 | + sprintf( |
| 55 | +@@ -124,11 +115,17 @@ public function execute(array $sourceItemIds): array |
| 56 | + ['sibling_product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')], |
| 57 | + 'sibling_product_entity.' . $linkField . ' = sibling_link.product_id', |
| 58 | + [] |
| 59 | +- )->where('source_item.source_item_id IN (?)', $sourceItemIds) |
| 60 | +- ->group(['stock_source_link.' . StockSourceLinkInterface::STOCK_ID]); |
| 61 | ++ )->where( |
| 62 | ++ 'source_item.source_item_id IN (?)', |
| 63 | ++ $sourceItemIds |
| 64 | ++ ); |
| 65 | ++ |
| 66 | ++ $dbStatement = $connection->query($select); |
| 67 | ++ while ($item = $dbStatement->fetch()) { |
| 68 | ++ $items[$item[StockSourceLinkInterface::STOCK_ID]][$item[SourceItemInterface::SKU]] = |
| 69 | ++ $item[SourceItemInterface::SKU]; |
| 70 | ++ } |
| 71 | + |
| 72 | +- $connection->query('SET group_concat_max_len = ' . $this->groupConcatMaxLen); |
| 73 | +- $items = $connection->fetchAll($select); |
| 74 | + return $this->getStockIdToSkuList($items); |
| 75 | + } |
| 76 | + |
| 77 | +@@ -141,11 +138,11 @@ public function execute(array $sourceItemIds): array |
| 78 | + private function getStockIdToSkuList(array $items): array |
| 79 | + { |
| 80 | + $skuListInStockList = []; |
| 81 | +- foreach ($items as $item) { |
| 82 | ++ foreach ($items as $stockId => $skuList) { |
| 83 | + /** @var SkuListInStock $skuListInStock */ |
| 84 | + $skuListInStock = $this->skuListInStockFactory->create(); |
| 85 | +- $skuListInStock->setStockId((int)$item[StockSourceLinkInterface::STOCK_ID]); |
| 86 | +- $skuListInStock->setSkuList(explode(',', $item[SourceItemInterface::SKU])); |
| 87 | ++ $skuListInStock->setStockId((int)$stockId); |
| 88 | ++ $skuListInStock->setSkuList($skuList); |
| 89 | + $skuListInStockList[] = $skuListInStock; |
| 90 | + } |
| 91 | + return $skuListInStockList; |
| 92 | +diff -Nuar a/vendor/magento/module-inventory-configurable-product-indexer/etc/di.xml b/vendor/magento/module-inventory-configurable-product-indexer/etc/di.xml |
| 93 | +--- a/vendor/magento/module-inventory-configurable-product-indexer/etc/di.xml |
| 94 | ++++ b/vendor/magento/module-inventory-configurable-product-indexer/etc/di.xml |
| 95 | +@@ -27,7 +27,6 @@ |
| 96 | + </type> |
| 97 | + <type name="Magento\InventoryConfigurableProductIndexer\Indexer\SourceItem\SiblingSkuListInStockProvider"> |
| 98 | + <arguments> |
| 99 | +- <argument name="groupConcatMaxLen" xsi:type="number">2000</argument> |
| 100 | + <argument name="tableNameSourceItem" xsi:type="const">Magento\Inventory\Model\ResourceModel\SourceItem::TABLE_NAME_SOURCE_ITEM</argument> |
| 101 | + <argument name="tableNameStockSourceLink" xsi:type="const">Magento\Inventory\Model\ResourceModel\StockSourceLink::TABLE_NAME_STOCK_SOURCE_LINK</argument> |
| 102 | + </arguments> |
0 commit comments