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 77
88namespace Magento \CatalogGraphQl \Model \Resolver \Category ;
99
10+ use Magento \Catalog \Model \Category ;
1011use Magento \Framework \GraphQl \Query \Resolver \IdentityInterface ;
1112
1213/**
1516class CategoriesIdentity implements IdentityInterface
1617{
1718 /** @var string */
18- private $ cacheTag = \ Magento \ Catalog \ Model \ Category::CACHE_TAG ;
19+ private $ cacheTag = Category::CACHE_TAG ;
1920
2021 /**
2122 * Get category IDs from resolved data
@@ -26,8 +27,9 @@ class CategoriesIdentity implements IdentityInterface
2627 public function getIdentities (array $ resolvedData ): array
2728 {
2829 $ ids = [];
29- if (!empty ($ resolvedData )) {
30- foreach ($ resolvedData as $ category ) {
30+ $ resolvedCategories = $ resolvedData ['items ' ] ?? $ resolvedData ;
31+ if (!empty ($ resolvedCategories )) {
32+ foreach ($ resolvedCategories as $ category ) {
3133 $ ids [] = sprintf ('%s_%s ' , $ this ->cacheTag , $ category ['id ' ]);
3234 }
3335 if (!empty ($ ids )) {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ type Query {
2121 filters : CategoryFilterInput @doc (description : " Identifies which Category filter inputs to search for and return." )
2222 pageSize : Int = 20 @doc (description : " Specifies the maximum number of results to return at once. This attribute is optional." )
2323 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 " )
2525}
2626
2727type 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
138138 children : [CategoryTree ] @doc (description : " Child categories tree." ) @resolver (class : " Magento\\ CatalogGraphQl\\ Model\\ Resolver\\ CategoryTree" )
139139}
140140
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." )
143143 page_info : SearchResultPageInfo @doc (description : " An object that includes the page_info and currentPage values specified in the query." )
144144 total_count : Int @doc (description : " The total number of categories that match the criteria." )
145145}
You can’t perform that action at this time.
0 commit comments