Skip to content

Commit

Permalink
MSI-1487: Bundle product support.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Feb 17, 2020
1 parent 7779a32 commit cc124d7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 186 deletions.
5 changes: 5 additions & 0 deletions InventoryBundleProduct/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
<type name="Magento\InventorySalesApi\Model\GetSkuFromOrderItemInterface">
<plugin name="get_bundle_selection_sku_from_order" type="Magento\InventoryBundleProduct\Plugin\InventorySalesApi\Model\GetSkuFromOrderItem\AdaptGetSkuFromOrderItemPlugin"/>
</type>
<type name="Magento\Bundle\Api\ProductLinkManagementInterface">
<plugin name="process_source_items_after_add_bundle_selection" type="Magento\InventoryBundleProduct\Plugin\Bundle\Model\LinkManagement\ProcessSourceItemsAfterAddBundleSelectionPlugin"/>
<plugin name="process_source_items_after_save_bundle_selection" type="Magento\InventoryBundleProduct\Plugin\Bundle\Model\LinkManagement\ProcessSourceItemsAfterSaveBundleSelectionPlugin"/>
<plugin name="process_source_items_after_remove_bundle_selection" type="Magento\InventoryBundleProduct\Plugin\Bundle\Model\LinkManagement\ProcessSourceItemsAfterRemoveBundleSelectionPlugin"/>
</type>
</config>
14 changes: 0 additions & 14 deletions InventoryBundleProduct/etc/webapi_rest/di.xml

This file was deleted.

14 changes: 0 additions & 14 deletions InventoryBundleProduct/etc/webapi_soap/di.xml

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions InventoryBundleProductAdminUi/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@
<plugin name="append_quantity_per_source" type="Magento\InventoryBundleProductAdminUi\Plugin\Bundle\Ui\DataProvider\Product\Form\AddQuantityPerSourceToProductsData" />
<plugin name="append_column_quantity_per_source" type="Magento\InventoryBundleProductAdminUi\Plugin\Bundle\Ui\DataProvider\Product\Form\AddColumnQuantityPerSource" />
</type>
<type name="Magento\Catalog\Model\Product">
<plugin name="process_source_items_plugin" type="Magento\InventoryBundleProductAdminUi\Plugin\Catalog\Model\Product\ProcessSourceItemsPlugin"/>
</type>
</config>
24 changes: 3 additions & 21 deletions InventoryBundleProductIndexer/Indexer/SelectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Exception;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\MetadataPool;
Expand Down Expand Up @@ -44,30 +43,22 @@ class SelectBuilder
*/
private $metadataPool;

/**
* @var ScopeConfigInterface
*/
private $config;

/**
* @param ResourceConnection $resourceConnection
* @param IndexNameBuilder $indexNameBuilder
* @param IndexNameResolverInterface $indexNameResolver
* @param MetadataPool $metadataPool
* @param ScopeConfigInterface $config
*/
public function __construct(
ResourceConnection $resourceConnection,
IndexNameBuilder $indexNameBuilder,
IndexNameResolverInterface $indexNameResolver,
MetadataPool $metadataPool,
ScopeConfigInterface $config
MetadataPool $metadataPool
) {
$this->resourceConnection = $resourceConnection;
$this->indexNameBuilder = $indexNameBuilder;
$this->indexNameResolver = $indexNameResolver;
$this->metadataPool = $metadataPool;
$this->config = $config;
}

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

$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
$linkField = $metadata->getLinkField();
$manageStock = (int)$this->config->getValue('cataloginventory/item_options/manage_stock');
$isSalableExpr = $manageStock
? 'IF(MAX(parent_stock.manage_stock = 0), MAX(stock.is_salable), IF(MAX(parent_stock.is_in_stock) = 1, '
. 'MAX(stock.is_salable), 0))'
: 'IF(MAX(parent_stock.use_config_manage_stock) = 0, IF(MAX(parent_stock.manage_stock) = 1 AND '
. 'MAX(parent_stock.is_in_stock = 0), 0, MAX(stock.is_salable)), MAX(stock.is_salable))';

$select = $connection->select()
->from(
['stock' => $indexTableName],
[
IndexStructure::SKU => 'parent_product_entity.sku',
IndexStructure::QUANTITY => 'SUM(stock.quantity)',
IndexStructure::IS_SALABLE => $isSalableExpr,
IndexStructure::IS_SALABLE => 'MAX(stock.is_salable)',
]
)->joinInner(
['product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
Expand All @@ -117,10 +103,6 @@ public function execute(int $stockId): Select
['parent_product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
'parent_product_entity.' . $linkField . ' = parent_link.parent_product_id',
[]
)->joinInner(
['parent_stock' => $this->resourceConnection->getTableName('cataloginventory_stock_item')],
'parent_product_entity.entity_id = parent_stock.product_id',
[]
)
->group(['parent_product_entity.sku']);

Expand Down

0 comments on commit cc124d7

Please sign in to comment.