Skip to content

Commit cc124d7

Browse files
committed
MSI-1487: Bundle product support.
1 parent 7779a32 commit cc124d7

6 files changed

Lines changed: 8 additions & 186 deletions

File tree

InventoryBundleProduct/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@
1818
<type name="Magento\InventorySalesApi\Model\GetSkuFromOrderItemInterface">
1919
<plugin name="get_bundle_selection_sku_from_order" type="Magento\InventoryBundleProduct\Plugin\InventorySalesApi\Model\GetSkuFromOrderItem\AdaptGetSkuFromOrderItemPlugin"/>
2020
</type>
21+
<type name="Magento\Bundle\Api\ProductLinkManagementInterface">
22+
<plugin name="process_source_items_after_add_bundle_selection" type="Magento\InventoryBundleProduct\Plugin\Bundle\Model\LinkManagement\ProcessSourceItemsAfterAddBundleSelectionPlugin"/>
23+
<plugin name="process_source_items_after_save_bundle_selection" type="Magento\InventoryBundleProduct\Plugin\Bundle\Model\LinkManagement\ProcessSourceItemsAfterSaveBundleSelectionPlugin"/>
24+
<plugin name="process_source_items_after_remove_bundle_selection" type="Magento\InventoryBundleProduct\Plugin\Bundle\Model\LinkManagement\ProcessSourceItemsAfterRemoveBundleSelectionPlugin"/>
25+
</type>
2126
</config>

InventoryBundleProduct/etc/webapi_rest/di.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

InventoryBundleProduct/etc/webapi_soap/di.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

InventoryBundleProductAdminUi/Plugin/Catalog/Model/Product/ProcessSourceItemsPlugin.php

Lines changed: 0 additions & 134 deletions
This file was deleted.

InventoryBundleProductAdminUi/etc/adminhtml/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@
2020
<plugin name="append_quantity_per_source" type="Magento\InventoryBundleProductAdminUi\Plugin\Bundle\Ui\DataProvider\Product\Form\AddQuantityPerSourceToProductsData" />
2121
<plugin name="append_column_quantity_per_source" type="Magento\InventoryBundleProductAdminUi\Plugin\Bundle\Ui\DataProvider\Product\Form\AddColumnQuantityPerSource" />
2222
</type>
23-
<type name="Magento\Catalog\Model\Product">
24-
<plugin name="process_source_items_plugin" type="Magento\InventoryBundleProductAdminUi\Plugin\Catalog\Model\Product\ProcessSourceItemsPlugin"/>
25-
</type>
2623
</config>

InventoryBundleProductIndexer/Indexer/SelectBuilder.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Exception;
1111
use Magento\Catalog\Api\Data\ProductInterface;
12-
use Magento\Framework\App\Config\ScopeConfigInterface;
1312
use Magento\Framework\App\ResourceConnection;
1413
use Magento\Framework\DB\Select;
1514
use Magento\Framework\EntityManager\MetadataPool;
@@ -44,30 +43,22 @@ class SelectBuilder
4443
*/
4544
private $metadataPool;
4645

47-
/**
48-
* @var ScopeConfigInterface
49-
*/
50-
private $config;
51-
5246
/**
5347
* @param ResourceConnection $resourceConnection
5448
* @param IndexNameBuilder $indexNameBuilder
5549
* @param IndexNameResolverInterface $indexNameResolver
5650
* @param MetadataPool $metadataPool
57-
* @param ScopeConfigInterface $config
5851
*/
5952
public function __construct(
6053
ResourceConnection $resourceConnection,
6154
IndexNameBuilder $indexNameBuilder,
6255
IndexNameResolverInterface $indexNameResolver,
63-
MetadataPool $metadataPool,
64-
ScopeConfigInterface $config
56+
MetadataPool $metadataPool
6557
) {
6658
$this->resourceConnection = $resourceConnection;
6759
$this->indexNameBuilder = $indexNameBuilder;
6860
$this->indexNameResolver = $indexNameResolver;
6961
$this->metadataPool = $metadataPool;
70-
$this->config = $config;
7162
}
7263

7364
/**
@@ -91,19 +82,14 @@ public function execute(int $stockId): Select
9182

9283
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
9384
$linkField = $metadata->getLinkField();
94-
$manageStock = (int)$this->config->getValue('cataloginventory/item_options/manage_stock');
95-
$isSalableExpr = $manageStock
96-
? 'IF(MAX(parent_stock.manage_stock = 0), MAX(stock.is_salable), IF(MAX(parent_stock.is_in_stock) = 1, '
97-
. 'MAX(stock.is_salable), 0))'
98-
: 'IF(MAX(parent_stock.use_config_manage_stock) = 0, IF(MAX(parent_stock.manage_stock) = 1 AND '
99-
. 'MAX(parent_stock.is_in_stock = 0), 0, MAX(stock.is_salable)), MAX(stock.is_salable))';
85+
10086
$select = $connection->select()
10187
->from(
10288
['stock' => $indexTableName],
10389
[
10490
IndexStructure::SKU => 'parent_product_entity.sku',
10591
IndexStructure::QUANTITY => 'SUM(stock.quantity)',
106-
IndexStructure::IS_SALABLE => $isSalableExpr,
92+
IndexStructure::IS_SALABLE => 'MAX(stock.is_salable)',
10793
]
10894
)->joinInner(
10995
['product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
@@ -117,10 +103,6 @@ public function execute(int $stockId): Select
117103
['parent_product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
118104
'parent_product_entity.' . $linkField . ' = parent_link.parent_product_id',
119105
[]
120-
)->joinInner(
121-
['parent_stock' => $this->resourceConnection->getTableName('cataloginventory_stock_item')],
122-
'parent_product_entity.entity_id = parent_stock.product_id',
123-
[]
124106
)
125107
->group(['parent_product_entity.sku']);
126108

0 commit comments

Comments
 (0)