7
7
8
8
namespace Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider ;
9
9
10
+ use Exception ;
10
11
use GraphQL \Language \AST \FieldNode ;
11
- use GraphQL \Language \AST \NodeKind ;
12
12
13
- use Magento \Store \Api \Data \StoreInterface ;
13
+ use GraphQL \Language \AST \NodeKind ;
14
+ use Iterator ;
14
15
use Magento \Catalog \Api \Data \CategoryInterface ;
15
16
use Magento \Catalog \Model \Category ;
16
17
use Magento \Catalog \Model \ResourceModel \Category \Collection ;
17
18
use Magento \Catalog \Model \ResourceModel \Category \CollectionFactory ;
18
- use Magento \GraphQl \Model \Query \ContextInterface ;
19
19
use Magento \CatalogGraphQl \Model \AttributesJoiner ;
20
20
use Magento \CatalogGraphQl \Model \Category \DepthCalculator ;
21
+ use Magento \CatalogGraphQl \Model \Category \Filter \SearchCriteria ;
21
22
use Magento \CatalogGraphQl \Model \Category \LevelCalculator ;
22
23
use Magento \CatalogGraphQl \Model \Resolver \Categories \DataProvider \Category \CollectionProcessorInterface ;
23
- use Magento \CatalogGraphQl \Model \Category \Filter \SearchCriteria ;
24
24
use Magento \Framework \EntityManager \MetadataPool ;
25
- use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
26
25
use 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 ;
29
29
30
30
/**
31
31
* Category tree data provider
@@ -125,7 +125,8 @@ public function getTree(ResolveInfo $resolveInfo, int $rootCategoryId, int $stor
125
125
* @throws LocalizedException
126
126
* @throws Exception
127
127
*/
128
- private function getCollection (ResolveInfo $ resolveInfo , int $ rootCategoryId ) : Collection {
128
+ private function getCollection (ResolveInfo $ resolveInfo , int $ rootCategoryId ) : Collection
129
+ {
129
130
$ categoryQuery = $ resolveInfo ->fieldNodes [0 ];
130
131
$ collection = $ this ->collectionFactory ->create ();
131
132
$ this ->joinAttributesRecursively ($ collection , $ categoryQuery , $ resolveInfo );
@@ -138,6 +139,8 @@ private function getCollection(ResolveInfo $resolveInfo, int $rootCategoryId) :
138
139
} else {
139
140
$ regExpPathFilter = sprintf ('.*/%s/[/0-9]*$ ' , $ rootCategoryId );
140
141
}
142
+
143
+ //Add `is_anchor` attribute to selected field
141
144
$ collection ->addAttributeToSelect ('is_anchor ' );
142
145
143
146
//Search for desired part of category tree
0 commit comments