Hi Team,
I am aware of creating the custom category retriver class in my project.
com.adobe.cq.commerce.core.components.internal.models.v1.categorylist.CategoriesRetriever
com.adobe.cq.commerce.core.components.models.productlist.CategoryRetriever
com.adobe.cq.commerce.core.components.models.retriever.AbstractCategoryRetriever
com.adobe.cq.commerce.core.components.models.retriever.AbstractCategoriesRetriever
com.adobe.cq.commerce.core.components.internal.models.v1.breadcrumb.BreadcrumbRetriever
But, I cannot call these classes direclty from my sling model class.
cc @AmitVishwakarma @AMANATH_ULLAH @sarav_prakash @arunpatidar @mk_aem21
Thanks
Views
Replies
Total Likes
Yes, you can use the out-of-the-box CIF category retriever. The relevant class is CategoriesRetriever.
To use it:
1. Inject the CategoriesRetriever into your Sling model using @reference.
2. Use CategoryFilterInput to set filters and CategoryTreeQueryDefinition to define your query.
3. Call categoriesRetriever.getCategories(queryDefinition) to retrieve the categories.
Here's a quick example:
@reference
private CategoriesRetriever categoriesRetriever;
public void getCategories() {
CategoryFilterInput filterInput = new CategoryFilterInput();
CategoryTreeQueryDefinition query = new CategoryTreeQueryDefinition(filterInput);
List<CategoryModel> categories = categoriesRetriever.getCategories(query);
}
This way, you don’t need a custom retriever class.
Are you sure about this solution? I mean have you used in your project like this?
Why I am asking is: "com.adobe.cq.commerce.core.components.internal.models.v1.categorylist.CategoriesRetriever" As this suggests, this is internal one. So, is it possible to use as
@Reference
private CategoriesRetriever categoriesRetriever;
Views
Replies
Total Likes
I am getting this error, while building the project
Bundle abc.core:1.0.0-SNAPSHOT is importing package(s)
com.adobe.cq.commerce.core.components.internal.models.v1.categorylist in start level 20 but no bundle is exporting these for that start level. (com.abc:abcd.all:1.0.0-SNAPSHOT)