77
88namespace Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider ;
99
10+ use Exception ;
1011use GraphQL \Language \AST \FieldNode ;
11- use GraphQL \Language \AST \NodeKind ;
1212
13- use Magento \Store \Api \Data \StoreInterface ;
13+ use GraphQL \Language \AST \NodeKind ;
14+ use Iterator ;
1415use Magento \Catalog \Api \Data \CategoryInterface ;
1516use Magento \Catalog \Model \Category ;
1617use Magento \Catalog \Model \ResourceModel \Category \Collection ;
1718use Magento \Catalog \Model \ResourceModel \Category \CollectionFactory ;
18- use Magento \GraphQl \Model \Query \ContextInterface ;
1919use Magento \CatalogGraphQl \Model \AttributesJoiner ;
2020use Magento \CatalogGraphQl \Model \Category \DepthCalculator ;
21+ use Magento \CatalogGraphQl \Model \Category \Filter \SearchCriteria ;
2122use Magento \CatalogGraphQl \Model \Category \LevelCalculator ;
2223use Magento \CatalogGraphQl \Model \Resolver \Categories \DataProvider \Category \CollectionProcessorInterface ;
23- use Magento \CatalogGraphQl \Model \Category \Filter \SearchCriteria ;
2424use Magento \Framework \EntityManager \MetadataPool ;
25- use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
2625use Magento \Framework \Exception \LocalizedException ;
27- use \Exception ;
28- use \Iterator ;
26+ use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
27+ use Magento \GraphQl \Model \Query \ContextInterface ;
28+ use Magento \Store \Api \Data \StoreInterface ;
2929
3030/**
3131 * Category tree data provider
@@ -125,7 +125,8 @@ public function getTree(ResolveInfo $resolveInfo, int $rootCategoryId, int $stor
125125 * @throws LocalizedException
126126 * @throws Exception
127127 */
128- private function getCollection (ResolveInfo $ resolveInfo , int $ rootCategoryId ) : Collection {
128+ private function getCollection (ResolveInfo $ resolveInfo , int $ rootCategoryId ) : Collection
129+ {
129130 $ categoryQuery = $ resolveInfo ->fieldNodes [0 ];
130131 $ collection = $ this ->collectionFactory ->create ();
131132 $ this ->joinAttributesRecursively ($ collection , $ categoryQuery , $ resolveInfo );
@@ -138,6 +139,8 @@ private function getCollection(ResolveInfo $resolveInfo, int $rootCategoryId) :
138139 } else {
139140 $ regExpPathFilter = sprintf ('.*/%s/[/0-9]*$ ' , $ rootCategoryId );
140141 }
142+
143+ //Add `is_anchor` attribute to selected field
141144 $ collection ->addAttributeToSelect ('is_anchor ' );
142145
143146 //Search for desired part of category tree
0 commit comments