@@ -172,14 +172,36 @@ protected function reindex()
172172 {
173173 foreach ($ this ->storeManager ->getStores () as $ store ) {
174174 if ($ this ->getPathFromCategoryId ($ store ->getRootCategoryId ())) {
175- $ this ->currentStore = $ store ;
175+ $ this ->setCurrentStore ( $ store) ;
176176 $ this ->reindexRootCategory ($ store );
177177 $ this ->reindexAnchorCategories ($ store );
178178 $ this ->reindexNonAnchorCategories ($ store );
179179 }
180180 }
181181 }
182182
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+
183205 /**
184206 * Return validated table name
185207 *
@@ -485,6 +507,7 @@ protected function hasAnchorSelect(Store $store)
485507 */
486508 protected function createAnchorSelect (Store $ store )
487509 {
510+ $ this ->setCurrentStore ($ store );
488511 $ isAnchorAttributeId = $ this ->config ->getAttribute (
489512 \Magento \Catalog \Model \Category::ENTITY ,
490513 'is_anchor '
@@ -494,7 +517,6 @@ protected function createAnchorSelect(Store $store)
494517 $ rootCatIds = explode ('/ ' , $ this ->getPathFromCategoryId ($ store ->getRootCategoryId ()));
495518 array_pop ($ rootCatIds );
496519
497- $ this ->currentStore = $ store ;
498520 $ temporaryTreeTable = $ this ->makeTempCategoryTreeIndex ();
499521
500522 $ productMetadata = $ this ->metadataPool ->getMetadata (ProductInterface::class);
@@ -692,7 +714,7 @@ protected function fillTempCategoryTreeIndex($temporaryName)
692714 ['ccacs ' => $ this ->getTable ('catalog_category_entity_int ' )],
693715 'ccacs. ' . $ categoryLinkField . ' = c. ' . $ categoryLinkField
694716 . ' AND ccacs.attribute_id = ccacd.attribute_id AND ccacs.store_id = ' .
695- $ this ->currentStore ->getId (),
717+ $ this ->getCurrentStore () ->getId (),
696718 []
697719 )->where (
698720 $ this ->connection ->getIfNullSql ('ccacs.value ' , 'ccacd.value ' ) . ' = ? ' ,
@@ -708,7 +730,7 @@ protected function fillTempCategoryTreeIndex($temporaryName)
708730 foreach ($ categories as $ category ) {
709731 $ categoriesTree = explode ('/ ' , $ category ['path ' ]);
710732 foreach ($ categoriesTree as $ parentId ) {
711- if (!in_array ($ this ->currentStore ->getRootCategoryId (), $ categoriesTree , true )) {
733+ if (!in_array ($ this ->getCurrentStore () ->getRootCategoryId (), $ categoriesTree , true )) {
712734 break ;
713735 }
714736
0 commit comments