Converter
SAP Commerce (Hybris) uses converters to changing models to data object. Data object is kind of DTO. It stores value in the memory, unlike models. Model has a proxy connection with DB, it loads data to memory when it is required. In the facade layer, a model is converted to a data object. View/Controller layer uses the data objects.
Best approach is never using model objects in the controller layer. Always fetch data by facade layer and get a converted data object.
A converter may have different populators. Each populator has different purpose. You can add custom populators for your custom fields or override a populator easily. This architecture gives you a flexible solution for converting operations.
You can find detailed information in the official guide.
How to print all populators of a converter?
I will share a small groovy script to get list of populators of a converter.
Run following groovy script in HAC -> Console -> Scripting Languages. Don’t forget to changing orderConverter part of the script by your converter’s bean name.
import de.hybris.platform.converters.Populator converter = spring.getBean("orderConverter"); for(Populator populator : converter.getPopulators()){ println(populator.getClass()) }
Result of getting list of populators of a converter will be as following
class de.hybris.platform.commercefacades.voucher.converters.populator.OrderAppliedVouchersPopulator class de.hybris.platform.commercefacades.order.converters.populator.PickupOrderEntryGroupPopulator class de.hybris.platform.commercefacades.order.converters.populator.DeliveryOrderEntryGroupPopulator class de.hybris.platform.acceleratorfacades.order.populators.AcceleratorGroupOrderEntryPopulator class de.hybris.platform.commercefacades.order.converters.populator.OrderConsignmentPopulator class de.hybris.platform.commercefacades.order.converters.populator.GroupOrderConsignmentEntryPopulator class de.hybris.platform.ordermanagementfacades.order.converters.populator.OrderCancelPopulator class de.hybris.platform.ordermanagementfacades.order.converters.populator.OrderReturnPopulator class de.hybris.platform.configurablebundlefacades.order.converters.populator.BundleOrderPopulator
Hybris will run populators in the giving order. So, you can analyze which populators have an effect while model to data conversion.