From 7a8e203470741a1f64e9e3ccf02e73c1ba8960da Mon Sep 17 00:00:00 2001 From: "ivan.hrytsai" Date: Tue, 27 May 2025 15:38:22 +0300 Subject: [PATCH] Fix issues in Blog --- Model/Resolver/Categories.php | 2 +- Model/Resolver/Posts.php | 2 +- Model/Resolver/Tags.php | 2 +- etc/schema.graphqls | 9 +++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Model/Resolver/Categories.php b/Model/Resolver/Categories.php index e658414..c5585b7 100644 --- a/Model/Resolver/Categories.php +++ b/Model/Resolver/Categories.php @@ -97,7 +97,7 @@ public function resolve( $scopeFilter = $this->filterBuilder ->setField('store_id') - ->setValue($scope) + ->setValue($args['storeId'] ?? $scope) ->setConditionType('eq') ->create(); $filterGroups[] = $this->filterGroupBuilder->addFilter($scopeFilter)->create(); diff --git a/Model/Resolver/Posts.php b/Model/Resolver/Posts.php index 9720850..ad3f6b1 100755 --- a/Model/Resolver/Posts.php +++ b/Model/Resolver/Posts.php @@ -108,7 +108,7 @@ public function resolve( $scopeFilter = $this->filterBuilder ->setField('store_id') - ->setValue($scope) + ->setValue($args['storeId'] ?? $scope) ->setConditionType('eq') ->create(); $filterGroups[] = $this->filterGroupBuilder->addFilter($scopeFilter)->create(); diff --git a/Model/Resolver/Tags.php b/Model/Resolver/Tags.php index 837459f..d8185ed 100644 --- a/Model/Resolver/Tags.php +++ b/Model/Resolver/Tags.php @@ -97,7 +97,7 @@ public function resolve( $scopeFilter = $this->filterBuilder ->setField('store_id') - ->setValue($scope) + ->setValue($args['storeId'] ?? $scope) ->setConditionType('eq') ->create(); $filterGroups[] = $this->filterGroupBuilder->addFilter($scopeFilter)->create(); diff --git a/etc/schema.graphqls b/etc/schema.graphqls index 403f773..d60ab6a 100644 --- a/etc/schema.graphqls +++ b/etc/schema.graphqls @@ -21,14 +21,19 @@ type Query { sort: [String] @doc(description: "Specifies which attribute to sort on, and whether to return the results in ascending or descending order.") sortFiled: String = "publish_time" @doc(description: "Specifies what field to sort posts by. The default value is publish_time.") allPosts: Boolean @doc(description: "If true get all posts.") + storeId: Int = 0 @doc(description: "Specifies the store view ID to filter the results. The default value is 0, meaning no specific store filter applied.") ): blogPostsOutput @resolver(class: "\\Magefan\\BlogGraphQl\\Model\\Resolver\\Posts") @doc(description: "The posts query searches for posts that match the criteria specified in the search and filter attributes") blogComments( filter: BlogCommentsFilterInput @doc(description: "Identifies which comment attributes to search for and return."), pageSize: Int = 5 @doc(description: "Specifies the maximum number of results to return at once. This attribute is optional."), currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1."), ):blogCommentsOutput @resolver(class: "\\Magefan\\BlogGraphQl\\Model\\Resolver\\Comments") @doc(description: "The comments query searches for posts that match the criteria specified in the search and filter attributes") - blogTags: blogTagsOutput @resolver(class: "\\Magefan\\BlogGraphQl\\Model\\Resolver\\Tags") @doc(description: "") - blogCategories: blogCategoriesOutput @resolver(class: "\\Magefan\\BlogGraphQl\\Model\\Resolver\\Categories") @doc(description: "") + blogTags( + storeId: Int = 0 @doc(description: "Specifies the store view ID to filter the results. The default value is 0, meaning no specific store filter applied.") + ): blogTagsOutput @resolver(class: "\\Magefan\\BlogGraphQl\\Model\\Resolver\\Tags") @doc(description: "") + blogCategories( + storeId: Int = 0 @doc(description: "Specifies the store view ID to filter the results. The default value is 0, meaning no specific store filter applied.") + ): blogCategoriesOutput @resolver(class: "\\Magefan\\BlogGraphQl\\Model\\Resolver\\Categories") @doc(description: "") } type Mutation {