@@ -172,14 +172,36 @@ protected function reindex()
172
172
{
173
173
foreach ($ this ->storeManager ->getStores () as $ store ) {
174
174
if ($ this ->getPathFromCategoryId ($ store ->getRootCategoryId ())) {
175
- $ this ->currentStore = $ store ;
175
+ $ this ->setCurrentStore ( $ store) ;
176
176
$ this ->reindexRootCategory ($ store );
177
177
$ this ->reindexAnchorCategories ($ store );
178
178
$ this ->reindexNonAnchorCategories ($ store );
179
179
}
180
180
}
181
181
}
182
182
183
+ /**
184
+ * Set current store
185
+ *
186
+ * @param StoreInterface $store
187
+ * @return $this
188
+ */
189
+ private function setCurrentStore (StoreInterface $ store ): self
190
+ {
191
+ $ this ->currentStore = $ store ;
192
+ return $ this ;
193
+ }
194
+
195
+ /**
196
+ * Get current store
197
+ *
198
+ * @return StoreInterface
199
+ */
200
+ private function getCurrentStore (): StoreInterface
201
+ {
202
+ return $ this ->currentStore ;
203
+ }
204
+
183
205
/**
184
206
* Return validated table name
185
207
*
@@ -485,6 +507,7 @@ protected function hasAnchorSelect(Store $store)
485
507
*/
486
508
protected function createAnchorSelect (Store $ store )
487
509
{
510
+ $ this ->setCurrentStore ($ store );
488
511
$ isAnchorAttributeId = $ this ->config ->getAttribute (
489
512
\Magento \Catalog \Model \Category::ENTITY ,
490
513
'is_anchor '
@@ -494,7 +517,6 @@ protected function createAnchorSelect(Store $store)
494
517
$ rootCatIds = explode ('/ ' , $ this ->getPathFromCategoryId ($ store ->getRootCategoryId ()));
495
518
array_pop ($ rootCatIds );
496
519
497
- $ this ->currentStore = $ store ;
498
520
$ temporaryTreeTable = $ this ->makeTempCategoryTreeIndex ();
499
521
500
522
$ productMetadata = $ this ->metadataPool ->getMetadata (ProductInterface::class);
@@ -692,7 +714,7 @@ protected function fillTempCategoryTreeIndex($temporaryName)
692
714
['ccacs ' => $ this ->getTable ('catalog_category_entity_int ' )],
693
715
'ccacs. ' . $ categoryLinkField . ' = c. ' . $ categoryLinkField
694
716
. ' AND ccacs.attribute_id = ccacd.attribute_id AND ccacs.store_id = ' .
695
- $ this ->currentStore ->getId (),
717
+ $ this ->getCurrentStore () ->getId (),
696
718
[]
697
719
)->where (
698
720
$ this ->connection ->getIfNullSql ('ccacs.value ' , 'ccacd.value ' ) . ' = ? ' ,
@@ -708,7 +730,7 @@ protected function fillTempCategoryTreeIndex($temporaryName)
708
730
foreach ($ categories as $ category ) {
709
731
$ categoriesTree = explode ('/ ' , $ category ['path ' ]);
710
732
foreach ($ categoriesTree as $ parentId ) {
711
- if (!in_array ($ this ->currentStore ->getRootCategoryId (), $ categoriesTree , true )) {
733
+ if (!in_array ($ this ->getCurrentStore () ->getRootCategoryId (), $ categoriesTree , true )) {
712
734
break ;
713
735
}
714
736
0 commit comments