cancel
Showing results for 
Search instead for 
Did you mean: 

Product count per category

Former Member
0 Kudos

On the category page we display the subcategories (one level down in the hierarchy) of the current category. But I also need to show the product count (of visible products) of these subcategories. What would be a good way to find the number of visible products but not always calculate in real time?

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Use the following method from ProductService to give you the count

/** Counts all products of the specific {@link CategoryModel} excluding double linked products. This includes all its own products and products belonging to any sub category. @param category the {@link CategoryModel} @return amount of all products of the category @throws IllegalArgumentException if parameter category is null. */ Integer getAllProductsCountForCategory(CategoryModel category);

Former Member
0 Kudos

Hi Ravi, i am trying to get products count of all categories i want to display in the occ v2 web service catalog response.how can i do that.i am using this service for getting catalogs http://localhost:9301/rest/v2/apparel-uk/catalogs?fields=FULL in this service response i need products count.please suggest me on this.