Skip to content
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

Fetch the products of a category or a virtual category by a slug property instead of the id #642

Open
tupac-rocher opened this issue Dec 11, 2024 · 0 comments

Comments

@tupac-rocher
Copy link
Collaborator

tupac-rocher commented Dec 11, 2024

Description

In the case I have to retrieve the products of a given category where I only know the url_key (defined as an additional attribute for my categories), I need to make two requests. One that filters the categories according to my url_key.
The concrete call is:
query getCategory { documents(entityType: "category", localizedCatalog: "com_fr", filter: {equalFilter: {field: "url", eq: "weekends-by-the-river"}}) { collection { data } } }
And then from the response, I get the category id to make the second request which retrieve the products:
query getProducts($requestType: ProductRequestTypeEnum!, $localizedCatalog: String!, $currentPage: Int, $currentCategoryId: String, $pageSize: Int, $search: String, $sort: ProductSortInput) { products: products( requestType: $requestType localizedCatalog: $localizedCatalog currentPage: $currentPage currentCategoryId: $currentCategoryId pageSize: $pageSize search: $search sort: $sort ) {...})
with the variables as is:
{ "currentCategoryId": "my_category_id", "currentPage": 1, "localizedCatalog": "19", "pageSize": 10, "requestType": "product_catalog" }

It would be easier if the categories would be fetchable by slug or url_key, because from a frontend perspective, it's important for the SEO score to have an explicit url.

@tupac-rocher tupac-rocher changed the title Fetch a category or a virtual category via a slug property instead of the id Fetch the products of a category or a virtual category by a slug property instead of the id Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant