Skip to content

Commit 2035467

Browse files
committed
ACP2E-1388, fixed static and unit
1 parent e38b0b5 commit 2035467

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ 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'] && $this->isWithinDynamicPriceBundle($priceTable->getTableName(), (int) $row['product_id'])) {
124+
if ($row['product_id'] &&
125+
$this->isWithinDynamicPriceBundle($priceTable->getTableName(), (int) $row['product_id'])
126+
) {
125127
$productIds[] = (int) $row['product_id'];
126128
}
127129
}
@@ -144,12 +146,16 @@ private function isWithinDynamicPriceBundle(string $priceTableName, int $product
144146
$connection = $this->resourceConnection->getConnection($this->connectionName);
145147
$select = $connection->select();
146148
$select->from(['selection' => 'catalog_product_bundle_selection'], 'selection_id');
147-
$select->joinInner(['entity' => 'catalog_product_entity'], implode(' AND ', ['selection.parent_product_id = entity.entity_id']), null);
148-
$select->joinInner(['price' => $priceTableName], implode(' AND ', ['price.entity_id = selection.product_id']), null);
149+
$select->joinInner(['entity' => 'catalog_product_entity'],
150+
implode(' AND ', ['selection.parent_product_id = entity.entity_id']), null
151+
);
152+
$select->joinInner(['price' => $priceTableName],
153+
implode(' AND ', ['price.entity_id = selection.product_id']), null
154+
);
149155
$select->where('selection.product_id = ?', $productId);
150156
$select->where('entity.type_id = ?', \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
151157
$select->where('price.tax_class_id = ?', \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC);
152158

153-
return intval($connection->fetchOne($select)) != 0;
159+
return (int) $connection->fetchOne($select) != 0;
154160
}
155161
}

app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ public function testModifyPrice(): void
7878
$entityIds = [1, 2, 3];
7979
$indexTableStructure = $this->createMock(IndexTableStructure::class);
8080
$connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
81-
$this->resourceConnection->expects($this->once())->method('getConnection')->willReturn($connectionMock);
81+
$this->resourceConnection->expects($this->exactly(6))->method('getConnection')->willReturn($connectionMock);
8282
$selectMock = $this->createMock(Select::class);
83-
$connectionMock->expects($this->once())->method('select')->willReturn($selectMock);
84-
$selectMock
85-
->method('where')
86-
->withConsecutive([], [], ['stock_item.product_id IN (?)', $entityIds])
87-
->willReturnOnConsecutiveCalls(null, null, $selectMock);
83+
$connectionMock->expects($this->exactly(6))->method('select')->willReturn($selectMock);
84+
8885
$this->generator->expects($this->once())
8986
->method('generate')
9087
->willReturnCallback(

app/code/Magento/CatalogInventory/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"magento/module-eav": "*",
1414
"magento/module-quote": "*",
1515
"magento/module-store": "*",
16-
"magento/module-ui": "*"
16+
"magento/module-ui": "*",
17+
"magento/module-bundle": "*"
1718
},
1819
"type": "magento2-module",
1920
"license": [

0 commit comments

Comments
 (0)