Skip to content

[GraphQL] Add possibility to filter categories by parent_id #30630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/code/Magento/CatalogGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ input ProductAttributeFilterInput @doc(description: "ProductAttributeFilterInput
input CategoryFilterInput @doc(description: "CategoryFilterInput defines the filters to be used in the search. A filter contains at least one attribute, a comparison operator, and the value that is being searched for.")
{
ids: FilterEqualTypeInput @doc(description: "Filter by category ID that uniquely identifies the category.")
parent_id: FilterEqualTypeInput @doc(description: "Filter by parent category ID")
url_key: FilterEqualTypeInput @doc(description: "Filter by the part of the URL that identifies the category.")
name: FilterMatchTypeInput @doc(description: "Filter by the display name of the category.")
url_path: FilterEqualTypeInput @doc(description: "Filter by the URL path for the category.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,20 @@ public function filterSingleCategoryDataProvider(): array
'position' => '1'
]
],
[
'parent_id',
'eq',
'4',
[
'id' => '5',
'name' => 'Category 1.1.1',
'url_key' => 'category-1-1-1',
'url_path' => 'category-1/category-1-1/category-1-1-1',
'children_count' => '0',
'path' => '1/2/3/4/5',
'position' => '1'
]
],
[
'name',
'match',
Expand Down Expand Up @@ -642,6 +656,41 @@ public function filterMultipleCategoriesDataProvider(): array
]
]
],
// Filter by multiple parent IDs
[
'parent_id',
'in',
'["3", "4"]',
[
[
'id' => '4',
'name' => 'Category 1.1',
'url_key' => 'category-1-1',
'url_path' => 'category-1/category-1-1',
'children_count' => '0',
'path' => '1/2/3/4',
'position' => '1'
],
[
'id' => '5',
'name' => 'Category 1.1.1',
'url_key' => 'category-1-1-1',
'url_path' => 'category-1/category-1-1/category-1-1-1',
'children_count' => '0',
'path' => '1/2/3/4/5',
'position' => '1'
],
[
'id' => '13',
'name' => 'Category 1.2',
'url_key' => 'category-1-2',
'url_path' => 'category-1/category-1-2',
'children_count' => '0',
'path' => '1/2/3/13',
'position' => '2'
]
]
],
//Filter by multiple url keys
[
'url_key',
Expand Down