Populators, Converters and WsDTO concept in SAP Commerce(Hybris)

Why we need them?

Let’s say we have product table(ProductModel) in the database with 50 fields but we need 10 of them to return to Front end(UI). We call our model source which has all the data from the database and we call target(DTO) the data structure which is subset of the model source and will be passed to UI. We use converters and populators to create a target DTO by converting a source Model object using Populators to populate the DTO.

Steps for defining Converters and Populators(Example with ProductData):

1. Defining data transfer object(DTO).

WsDTO concept

WsDTO is data layer used by version 2 of the REST API in OCC.

  • DEFAULT — medium set of fields defined on the most common use cases.
  • FULL — all fields are returned.
<bean parent="fieldSetLevelMapping" id="productWsDTOFieldSetLevelMapping">
<property name="dtoClass"
value="de.hybris.platform.commercewebservicescommons.dto.product.ProductWsDTO"/>
<property name="levelMapping">
<map>
<entry key="BASIC"
value="purchasable,codeShort,stock,name,baseProduct,availableForPickup,code,url,price,description,images(DEFAULT),availableUnits,potentialPromotions(DEFAULT),summary"/>
<entry key="DEFAULT"
value="code,codeShort,name,url,description,summary,favourite,baseProduct,availableUnits,baseUnit,price(DEFAULT),images(DEFAULT),potentialPromotions(DEFAULT),classifications(DEFAULT),breadcrumbs,crmProductInformations,promotion"/>
<entry key="FULL"
value="code,summary,productReferences(FULL),classifications(FULL),averageRating,purchasable,volumePrices(FULL),variantType,stock(FULL),description,variantMatrix(FULL),codeShort,name,favourite,availableUnits,baseUnit,breadcrumbs,crmProductInformations,baseOptions(FULL),baseProduct,availableForPickup,variantOptions(FULL),reviews(FULL),code,url,price(FULL),numberOfReviews,manufacturer,volumePricesFlag,futureStocks(FULL),images(FULL),categories(FULL),potentialPromotions(FULL),priceRange,multidimensional"/>
</map>
</property>

</bean>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store