diff --git a/src/module-elasticsuite-virtual-category/Model/Rule.php b/src/module-elasticsuite-virtual-category/Model/Rule.php index 1dc3845cc..49197d404 100644 --- a/src/module-elasticsuite-virtual-category/Model/Rule.php +++ b/src/module-elasticsuite-virtual-category/Model/Rule.php @@ -330,7 +330,7 @@ private function buildCategorySearchQuery($category, $excludedCategories = []): private function getVirtualRootCategory(CategoryInterface $category): ?CategoryInterface { $storeId = $this->getStoreId(); - $rootCategory = $this->categoryFactory->create()->setStoreId($storeId); + $rootCategory = null; if ($category->getVirtualCategoryRoot() !== null && !empty($category->getVirtualCategoryRoot())) { $rootCategoryId = $category->getVirtualCategoryRoot(); @@ -433,7 +433,7 @@ private function getVirtualCategoryQuery( // - - Category C (virtual with category B as root) // When you compute the rule of the category A you do not need to compute the rule of the category C // as all the product will be there. - if ($rootCategory && array_intersect(explode('/', $rootCategory->getPath()), $excludedCategories)) { + if ($rootCategory && $rootCategory->getPath() && array_intersect(explode('/', (string) $rootCategory->getPath()), $excludedCategories)) { return null; }