Skip to content

Commit 4e9c011

Browse files
committed
Merge branch 'ACP2E-1772' of https://github.com/magento-l3/magento2ce into PR-VK-2023-04-05-CE
2 parents 8af9d33 + 74527a0 commit 4e9c011

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

app/code/Magento/CatalogInventory/Model/Indexer/Stock/CacheCleaner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function clean(array $productIds, callable $reindex)
9090
$this->cacheContext->registerEntities(Product::CACHE_TAG, array_unique($productIds));
9191
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
9292
$categoryIds = $this->getCategoryIdsByProductIds($productIds);
93-
if ($categoryIds){
93+
if ($categoryIds) {
9494
$this->cacheContext->registerEntities(Category::CACHE_TAG, array_unique($categoryIds));
9595
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
9696
}
@@ -162,7 +162,7 @@ private function getProductIdsForCacheClean(array $productStatusesBefore, array
162162
}
163163
}
164164

165-
return $productIds;
165+
return array_map('intval', $productIds);
166166
}
167167

168168
/**
@@ -176,7 +176,7 @@ private function getCategoryIdsByProductIds(array $productIds): array
176176
$categoryProductTable = $this->resource->getTableName('catalog_category_product');
177177
$select = $this->getConnection()->select()
178178
->from(['catalog_category_product' => $categoryProductTable], ['category_id'])
179-
->where('product_id IN (?)', $productIds);
179+
->where('product_id IN (?)', $productIds, \Zend_Db::INT_TYPE);
180180

181181
return $this->getConnection()->fetchCol($select);
182182
}

app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/CacheCleanerTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ public function testClean($stockStatusBefore, $stockStatusAfter, $qtyAfter, $sto
122122
$this->selectMock->expects($this->any())
123123
->method('from')
124124
->willReturnSelf();
125-
$this->selectMock->expects($this->any())
126-
->method('where')
127-
->willReturnSelf();
128125
$this->selectMock->expects($this->any())
129126
->method('joinLeft')
130127
->willReturnSelf();
@@ -141,6 +138,21 @@ public function testClean($stockStatusBefore, $stockStatusAfter, $qtyAfter, $sto
141138
['product_id' => $productId, 'stock_status' => $stockStatusAfter, 'qty' => $qtyAfter],
142139
]
143140
);
141+
$this->connectionMock->expects($this->exactly(3))
142+
->method('select')
143+
->willReturn($this->selectMock);
144+
$this->selectMock->expects($this->exactly(7))
145+
->method('where')
146+
->withConsecutive(
147+
['product_id IN (?)'],
148+
['stock_id = ?'],
149+
['website_id = ?'],
150+
['product_id IN (?)'],
151+
['stock_id = ?'],
152+
['website_id = ?'],
153+
['product_id IN (?)', [123], \Zend_Db::INT_TYPE]
154+
)
155+
->willReturnSelf();
144156
$this->connectionMock->expects($this->exactly(1))
145157
->method('fetchCol')
146158
->willReturn([$categoryId]);

0 commit comments

Comments
 (0)