Skip to content

Commit a27a17a

Browse files
committed
MC-41499: Missing Bundled Products on Category Pages
1 parent be82efb commit a27a17a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\CatalogInventory\Model\Indexer\Stock;
88

9+
use Magento\Catalog\Model\Category;
910
use Magento\CatalogInventory\Api\StockConfigurationInterface;
1011
use Magento\Framework\App\ResourceConnection;
1112
use Magento\Framework\App\ObjectManager;
@@ -88,6 +89,11 @@ public function clean(array $productIds, callable $reindex)
8889
if ($productIds) {
8990
$this->cacheContext->registerEntities(Product::CACHE_TAG, array_unique($productIds));
9091
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
92+
$categoryIds = $this->getCategoryIdsByProductIds($productIds);
93+
if ($categoryIds){
94+
$this->cacheContext->registerEntities(Category::CACHE_TAG, array_unique($categoryIds));
95+
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
96+
}
9197
}
9298
}
9399

@@ -159,6 +165,22 @@ private function getProductIdsForCacheClean(array $productStatusesBefore, array
159165
return $productIds;
160166
}
161167

168+
/**
169+
* Get category ids for products
170+
*
171+
* @param array $productIds
172+
* @return array
173+
*/
174+
private function getCategoryIdsByProductIds(array $productIds): array
175+
{
176+
$categoryProductTable = $this->getConnection()->getTableName('catalog_category_product');
177+
$select = $this->getConnection()->select()
178+
->from(['catalog_category_product' => $categoryProductTable], ['category_id'])
179+
->where('product_id IN (?)', $productIds);
180+
181+
return $this->getConnection()->fetchCol($select);
182+
}
183+
162184
/**
163185
* Get database connection.
164186
*

0 commit comments

Comments
 (0)