diff --git a/vendor/magento/module-catalog-graph-ql/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor/CatalogProcessor.php b/vendor/magento/module-catalog-graph-ql/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor/CatalogProcessor.php index c8f9ad5de008..b0df8fddff08 100644 --- a/vendor/magento/module-catalog-graph-ql/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor/CatalogProcessor.php +++ b/vendor/magento/module-catalog-graph-ql/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor/CatalogProcessor.php @@ -49,7 +49,27 @@ public function process( ContextInterface $context = null ): Collection { $this->collectionProcessor->process($searchCriteria, $collection); + $store = $context->getExtensionAttributes()->getStore(); + $this->addRootCategoryFilterForStore($collection, (string) $store->getRootCategoryId()); return $collection; } + + /** + * Add filtration based on the store root category id + * + * @param Collection $collection + * @param string $rootCategoryId + */ + private function addRootCategoryFilterForStore(Collection $collection, string $rootCategoryId) : void + { + $select = $collection->getSelect(); + $connection = $collection->getConnection(); + $select->where( + $connection->quoteInto( + 'e.path LIKE ? OR e.entity_id=' . $connection->quote($rootCategoryId, 'int'), + '%/' . $rootCategoryId . '/%' + ) + ); + } }