Skip to content

Commit 8618bd6

Browse files
committed
ACP2E-1388, refactor solution using an interceptor
1 parent e234229 commit 8618bd6

File tree

3 files changed

+5
-34
lines changed

3 files changed

+5
-34
lines changed

app/code/Magento/Bundle/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
<type name="Magento\Sales\Model\Order\Item">
9797
<plugin name="bundle" type="Magento\Bundle\Model\Sales\Order\Plugin\Item" sortOrder="100" />
9898
</type>
99+
<type name="Magento\CatalogInventory\Model\Indexer\ProductPriceIndexFilter">
100+
<plugin name="price_modifier" type="Magento\Bundle\Model\Plugin\ProductPriceIndexModifier" sortOrder="100" />
101+
</type>
99102
<type name="Magento\Framework\EntityManager\Operation\ExtensionPool">
100103
<arguments>
101104
<argument name="extensionActions" xsi:type="array">

app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
121121
foreach ($batchSelectIterator as $select) {
122122
$productIds = null;
123123
foreach ($connection->query($select)->fetchAll() as $row) {
124-
if ($row['product_id'] &&
125-
$this->isWithinDynamicPriceBundle($priceTable->getTableName(), (int) $row['product_id'])
126-
) {
124+
if ($row['product_id']) {
127125
$productIds[] = (int) $row['product_id'];
128126
}
129127
}
@@ -133,33 +131,4 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
133131
}
134132
}
135133
}
136-
137-
/**
138-
* Check if the product is part of a dynamic price bundle configuration
139-
*
140-
* @param string $priceTableName
141-
* @param int $productId
142-
* @return bool
143-
*/
144-
private function isWithinDynamicPriceBundle(string $priceTableName, int $productId): bool
145-
{
146-
$connection = $this->resourceConnection->getConnection($this->connectionName);
147-
$select = $connection->select();
148-
$select->from(['selection' => 'catalog_product_bundle_selection'], 'selection_id');
149-
$select->joinInner(
150-
['entity' => 'catalog_product_entity'],
151-
implode(' AND ', ['selection.parent_product_id = entity.entity_id']),
152-
null
153-
);
154-
$select->joinInner(
155-
['price' => $priceTableName],
156-
implode(' AND ', ['price.entity_id = selection.product_id']),
157-
null
158-
);
159-
$select->where('selection.product_id = ?', $productId);
160-
$select->where('entity.type_id = ?', \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
161-
$select->where('price.tax_class_id = ?', \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC);
162-
163-
return (int) $connection->fetchOne($select) != 0;
164-
}
165134
}

app/code/Magento/CatalogInventory/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"magento/module-eav": "*",
1414
"magento/module-quote": "*",
1515
"magento/module-store": "*",
16-
"magento/module-ui": "*",
17-
"magento/module-bundle": "*"
16+
"magento/module-ui": "*"
1817
},
1918
"type": "magento2-module",
2019
"license": [

0 commit comments

Comments
 (0)