File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
app/code/Magento/CatalogGraphQl Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \CatalogGraphQl \Model \Resolver \Category ;
9
9
10
+ use Magento \Catalog \Model \Category ;
10
11
use Magento \Framework \GraphQl \Query \Resolver \IdentityInterface ;
11
12
12
13
/**
15
16
class CategoriesIdentity implements IdentityInterface
16
17
{
17
18
/** @var string */
18
- private $ cacheTag = \ Magento \ Catalog \ Model \ Category::CACHE_TAG ;
19
+ private $ cacheTag = Category::CACHE_TAG ;
19
20
20
21
/**
21
22
* Get category IDs from resolved data
@@ -26,8 +27,9 @@ class CategoriesIdentity implements IdentityInterface
26
27
public function getIdentities (array $ resolvedData ): array
27
28
{
28
29
$ ids = [];
29
- if (!empty ($ resolvedData )) {
30
- foreach ($ resolvedData as $ category ) {
30
+ $ resolvedCategories = $ resolvedData ['items ' ] ?? $ resolvedData ;
31
+ if (!empty ($ resolvedCategories )) {
32
+ foreach ($ resolvedCategories as $ category ) {
31
33
$ ids [] = sprintf ('%s_%s ' , $ this ->cacheTag , $ category ['id ' ]);
32
34
}
33
35
if (!empty ($ ids )) {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ type Query {
21
21
filters : CategoryFilterInput @doc (description : " Identifies which Category filter inputs to search for and return." )
22
22
pageSize : Int = 20 @doc (description : " Specifies the maximum number of results to return at once. This attribute is optional." )
23
23
currentPage : Int = 1 @doc (description : " Specifies which page of results to return. The default value is 1." )
24
- ): CategoryResult @resolver (class : " Magento\\ CatalogGraphQl\\ Model\\ Resolver\\ CategoriesQuery" )
24
+ ): CategoryResult @resolver (class : " Magento\\ CatalogGraphQl\\ Model\\ Resolver\\ CategoriesQuery" ) @cache ( cacheIdentity : " Magento \\ CatalogGraphQl \\ Model \\ Resolver \\ Category \\ CategoriesIdentity " )
25
25
}
26
26
27
27
type Price @doc (description : " Price is deprecated, replaced by ProductPrice. The Price object defines the price of a product as well as any tax-related adjustments." ) {
@@ -138,8 +138,8 @@ type CategoryTree implements CategoryInterface @doc(description: "Category Tree
138
138
children : [CategoryTree ] @doc (description : " Child categories tree." ) @resolver (class : " Magento\\ CatalogGraphQl\\ Model\\ Resolver\\ CategoryTree" )
139
139
}
140
140
141
- type CategoryResult @doc (description : " Collection of CategoryTree object and pagination information." ) {
142
- items : [CategoryTree ] @doc (description : " List of categories that match filter criteria." )
141
+ type CategoryResult @doc (description : " A collection of CategoryTree objects and pagination information." ) {
142
+ items : [CategoryTree ] @doc (description : " A list of categories that match the filter criteria." )
143
143
page_info : SearchResultPageInfo @doc (description : " An object that includes the page_info and currentPage values specified in the query." )
144
144
total_count : Int @doc (description : " The total number of categories that match the criteria." )
145
145
}
You can’t perform that action at this time.
0 commit comments