You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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.
The text was updated successfully, but these errors were encountered: