Skip to content

Commit e234229

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

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
135135
}
136136

137137
/**
138-
* Check if the product is used within a dynamic price bundle configuration
138+
* Check if the product is part of a dynamic price bundle configuration
139139
*
140140
* @param string $priceTableName
141141
* @param int $productId
@@ -146,11 +146,15 @@ private function isWithinDynamicPriceBundle(string $priceTableName, int $product
146146
$connection = $this->resourceConnection->getConnection($this->connectionName);
147147
$select = $connection->select();
148148
$select->from(['selection' => 'catalog_product_bundle_selection'], 'selection_id');
149-
$select->joinInner(['entity' => 'catalog_product_entity'],
150-
implode(' AND ', ['selection.parent_product_id = entity.entity_id']), null
149+
$select->joinInner(
150+
['entity' => 'catalog_product_entity'],
151+
implode(' AND ', ['selection.parent_product_id = entity.entity_id']),
152+
null
151153
);
152-
$select->joinInner(['price' => $priceTableName],
153-
implode(' AND ', ['price.entity_id = selection.product_id']), null
154+
$select->joinInner(
155+
['price' => $priceTableName],
156+
implode(' AND ', ['price.entity_id = selection.product_id']),
157+
null
154158
);
155159
$select->where('selection.product_id = ?', $productId);
156160
$select->where('entity.type_id = ?', \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,33 @@ public function testModifyPrice(): void
9696
$this->productPriceIndexFilter->modifyPrice($indexTableStructure, $entityIds);
9797
}
9898

99+
public function testModifyPriceDynamicPriceBundle(): void
100+
{
101+
$indexTableStructure = $this->createMock(IndexTableStructure::class);
102+
$indexTableStructure->expects($this->any())->method('getTableName')
103+
->willReturn('price_table');
104+
$this->stockConfiguration->expects($this->once())->method('isShowOutOfStock')->willReturn(false);
105+
$connectionMock = $this->getMockForAbstractClass(AdapterInterface::class);
106+
$this->resourceConnection->expects($this->exactly(2))->method('getConnection')->willReturn($connectionMock);
107+
108+
$selectMock = $this->createMock(Select::class);
109+
$connectionMock->expects($this->exactly(2))->method('select')->willReturn($selectMock);
110+
$this->generator->expects($this->once())
111+
->method('generate')
112+
->willReturnCallback(
113+
$this->getBatchIteratorCallback($selectMock, 1)
114+
);
115+
$fetchStmtMock = $this->createPartialMock(\Zend_Db_Statement_Pdo::class, ['fetchAll']);
116+
$fetchStmtMock->expects($this->any())
117+
->method('fetchAll')
118+
->willReturn([['product_id' => 1]]);
119+
$connectionMock->expects($this->any())->method('query')->willReturn($fetchStmtMock);
120+
$connectionMock->expects($this->once())->method('fetchOne')->willReturn(1);
121+
$connectionMock->expects($this->once())->method('delete')->with('price_table', [' IN (?)' => [1]]);
122+
123+
$this->productPriceIndexFilter->modifyPrice($indexTableStructure);
124+
}
125+
99126
/**
100127
* Returns batches.
101128
*

0 commit comments

Comments
 (0)