@@ -50,6 +50,7 @@ class CategoryHelper
50
50
protected $ categoryRepository ;
51
51
52
52
protected $ isCategoryVisibleInMenuCache ;
53
+ protected $ coreCategories ;
53
54
protected $ idColumn ;
54
55
protected $ categoryAttributes ;
55
56
protected $ rootCategoryId = -1 ;
@@ -548,7 +549,12 @@ public function isCategoryVisibleInMenu($categoryId, $storeId)
548
549
*/
549
550
public function getCoreCategories ($ filterNotIncludedCategories = true , $ storeId = null )
550
551
{
551
- $ key = $ filterNotIncludedCategories ? 'filtered ' : 'non_filtered ' ;
552
+ // Cache category look up by store scope
553
+ $ key = ($ filterNotIncludedCategories ? 'filtered ' : 'non_filtered ' ) . "- $ storeId " ;
554
+
555
+ if (isset ($ this ->coreCategories [$ key ])) {
556
+ return $ this ->coreCategories [$ key ];
557
+ }
552
558
553
559
$ collection = $ this ->categoryCollectionFactory ->create ()
554
560
->distinct (true )
@@ -562,14 +568,14 @@ public function getCoreCategories($filterNotIncludedCategories = true, $storeId
562
568
$ collection ->addAttributeToFilter ('include_in_menu ' , '1 ' );
563
569
}
564
570
565
- $ coreCategories [$ key ] = [];
571
+ $ this -> coreCategories [$ key ] = [];
566
572
567
573
/** @var \Magento\Catalog\Model\Category $category */
568
574
foreach ($ collection as $ category ) {
569
- $ coreCategories [$ key ][$ category ->getId ()] = $ category ;
575
+ $ this -> coreCategories [$ key ][$ category ->getId ()] = $ category ;
570
576
}
571
577
572
- return $ coreCategories [$ key ];
578
+ return $ this -> coreCategories [$ key ];
573
579
}
574
580
575
581
/**
0 commit comments