@@ -105,7 +105,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
105
105
* @throws \Exception if metadataPool doesn't contain metadata for ProductInterface
106
106
* @throws \DomainException
107
107
*/
108
- private function getProductIdsWithParents (array $ childProductIds )
108
+ private function getProductIdsWithParents (array $ childProductIds ): array
109
109
{
110
110
/** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */
111
111
$ metadata = $ this ->metadataPool ->getMetadata (\Magento \Catalog \Api \Data \ProductInterface::class);
@@ -220,28 +220,28 @@ protected function isRangingNeeded()
220
220
* Returns a list of category ids which are assigned to product ids in the index
221
221
*
222
222
* @param array $productIds
223
- * @return \Magento\Framework\Indexer\CacheContext
223
+ * @return array
224
224
*/
225
- private function getCategoryIdsFromIndex (array $ productIds )
225
+ private function getCategoryIdsFromIndex (array $ productIds ): array
226
226
{
227
227
$ categoryIds = [];
228
228
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 ()
237
234
);
235
+ $ categoryIds [] = $ storeCategories ;
238
236
}
239
- $ parentCategories = $ categoryIds ;
237
+ $ categoryIds = array_merge (...$ categoryIds );
238
+
239
+ $ parentCategories = [$ categoryIds ];
240
240
foreach ($ categoryIds as $ categoryId ) {
241
241
$ parentIds = explode ('/ ' , $ this ->getPathFromCategoryId ($ categoryId ));
242
- $ parentCategories = array_merge ( $ parentCategories , $ parentIds) ;
242
+ $ parentCategories[] = $ parentIds ;
243
243
}
244
- $ categoryIds = array_unique ($ parentCategories );
244
+ $ categoryIds = array_unique (array_merge (... $ parentCategories) );
245
245
246
246
return $ categoryIds ;
247
247
}
0 commit comments