Skip to content

Commit 0a40bdb

Browse files
author
Oleksandr Iegorov
committed
ACP2E-363: Graphql categoryList does not filter based on Store header
1 parent 548ac72 commit 0a40bdb

File tree

1 file changed

+20
-0
lines changed
  • app/code/Magento/CatalogGraphQl/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor

1 file changed

+20
-0
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Categories/DataProvider/Category/CollectionProcessor/CatalogProcessor.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,27 @@ public function process(
4949
ContextInterface $context = null
5050
): Collection {
5151
$this->collectionProcessor->process($searchCriteria, $collection);
52+
$store = $context->getExtensionAttributes()->getStore();
53+
$this->addRootCategoryFilterForStore($collection, (string) $store->getRootCategoryId());
5254

5355
return $collection;
5456
}
57+
58+
/**
59+
* Add filtration based on the store root category id
60+
*
61+
* @param Collection $collection
62+
* @param string $rootCategoryId
63+
*/
64+
private function addRootCategoryFilterForStore(Collection $collection, string $rootCategoryId) : void
65+
{
66+
$select = $collection->getSelect();
67+
$connection = $collection->getConnection();
68+
$select->where(
69+
$connection->quoteInto(
70+
'e.path LIKE ? OR e.entity_id=' . $connection->quote($rootCategoryId, 'int'),
71+
'%/' . $rootCategoryId . '/%'
72+
)
73+
);
74+
}
5575
}

0 commit comments

Comments
 (0)