cancel
Showing results for 
Search instead for 
Did you mean: 

Add recursive product counter for categories endpoints

former_member826667
Discoverer
0 Kudos

I am new to hybris and I got a technical task that I want to understand and implement.

Add recursive product counter for categories endpoints.

a. bean.xml -> extend DTOs of CategoryHierarchyData and CategoryHierarchyWsDTO

b. extend DefaultCategoryHierarchyPopulator

c. spring.xml -> define bean of extended DefaultCategoryHierarchyPopulator

d. web-spring.xml -> define bean fieldSetLevelMapping for DataMapper

BUT I don't understand what I should achieve and where to start. could anybody help?

adiputera
Active Participant
0 Kudos

Why did you put my name on the assigned tag?

Your points look like good steps, what have you tried?

And what exactly are you trying to achieve? Category A has xx number of products? Category B has yy number of products?

former_member826667
Discoverer
0 Kudos

I am trying to achive thise

I thought you will help me, Sir

I changed my bean.xml and added the necessary param, also I wrote custom populator and change fieldSetLevelMapping. the problem is that it uses the default populator instead of mine .

this is my bean.xml of facadeextension

<bean class="de.hybris.platform.commercefacades.catalog.data.CategoryHierarchyData"
extends="de.hybris.platform.commercefacades.catalog.data.AbstractCatalogItemData">
<property name="productCount" type="Integer"/>
</bean>


<bean class="de.hybris.platform.commercewebservicescommons.dto.catalog.CategoryHierarchyWsDTO"
extends="de.hybris.platform.commercewebservicescommons.dto.catalog.AbstractCatalogItemWsDTO">
<property name="productCount" type="Integer"/>
</bean>

and this is bean definations of spring.xml .

I can't recognize why my alias didn't work and when I am using a controller which populates my CategoryDTO it uses the default populator instead of mine even if I override it with the alias

<alias  name="customCategoryHierarchyPopulator" alias="categoryHierarchyPopulator"/>
<bean id="customCategoryHierarchyPopulator"
class="com.org.training.facades.populators.CustomCategoryHierarchyPopulator"
parent="defaultCategoryHierarchyPopulator"/>



public class CustomCategoryHierarchyPopulator extends CategoryHierarchyPopulator {
@Override
public void populate(CategoryModel source, CategoryHierarchyData target, Collection<? extends CatalogOption> options, PageOption page) throws ConversionException {
target.setProductCount(source.getProducts().size());
super.populate(source, target, options, page);
}
}
adiputera
Active Participant
0 Kudos

that's seems ok, so when you debug it's not coming to your custom populator at all?

can you try overriding the defaultCategoryHierarchyPopulator instead? But you also have to put all property from defaultCategoryHierarchyPopulator to your populator in spring.xml

Accepted Solutions (0)

Answers (0)