Skip to content

Commit a14f7a9

Browse files
committed
MC-19652: Product Categories Indexer stuck
1 parent 9d16144 commit a14f7a9

File tree

1 file changed

+14
-14
lines changed
  • app/code/Magento/Catalog/Model/Indexer/Product/Category/Action

1 file changed

+14
-14
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
105105
* @throws \Exception if metadataPool doesn't contain metadata for ProductInterface
106106
* @throws \DomainException
107107
*/
108-
private function getProductIdsWithParents(array $childProductIds)
108+
private function getProductIdsWithParents(array $childProductIds): array
109109
{
110110
/** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */
111111
$metadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
@@ -220,28 +220,28 @@ protected function isRangingNeeded()
220220
* Returns a list of category ids which are assigned to product ids in the index
221221
*
222222
* @param array $productIds
223-
* @return \Magento\Framework\Indexer\CacheContext
223+
* @return array
224224
*/
225-
private function getCategoryIdsFromIndex(array $productIds)
225+
private function getCategoryIdsFromIndex(array $productIds): array
226226
{
227227
$categoryIds = [];
228228
foreach ($this->storeManager->getStores() as $store) {
229-
$categoryIds = array_merge(
230-
$categoryIds,
231-
$this->connection->fetchCol(
232-
$this->connection->select()
233-
->from($this->getIndexTable($store->getId()), ['category_id'])
234-
->where('product_id IN (?)', $productIds)
235-
->distinct()
236-
)
229+
$storeCategories = $this->connection->fetchCol(
230+
$this->connection->select()
231+
->from($this->getIndexTable($store->getId()), ['category_id'])
232+
->where('product_id IN (?)', $productIds)
233+
->distinct()
237234
);
235+
$categoryIds[] = $storeCategories;
238236
}
239-
$parentCategories = $categoryIds;
237+
$categoryIds = array_merge(...$categoryIds);
238+
239+
$parentCategories = [$categoryIds];
240240
foreach ($categoryIds as $categoryId) {
241241
$parentIds = explode('/', $this->getPathFromCategoryId($categoryId));
242-
$parentCategories = array_merge($parentCategories, $parentIds);
242+
$parentCategories[] = $parentIds;
243243
}
244-
$categoryIds = array_unique($parentCategories);
244+
$categoryIds = array_unique(array_merge(...$parentCategories));
245245

246246
return $categoryIds;
247247
}

0 commit comments

Comments
 (0)