How to Customize Price Factory

if we want to make changes in the priceRow model and europe1PriceFactory consequently.

There are three methods for changing the pricefactory:

  1. The first method is to create a new extension, change the manager to implement the PriceFactory interface.
  2. The second method is Extending Europe1 extension.
  3. last is POJO only.

Create New Extension:

If we want to create a new extension, change the manager(generated) in order to implement the PriceFactory interface and then set your extension name as default price factory in your local.properties.

Extend Europe1 extension:

This extension is a default extension present in the hybris platform. which will be help to calculate price, tax, and discount services.

steps are given below in order to Extend Europe1 extension:

  1. In first step we need to create an extension myPriceFactory, and the managersuperclass as Europe1PriceFactory,
<extension name="myPriceFactory"
abstractclassprefix="Generated"
classprefix="MyPriceFactory"
managername="MyPriceFactory"
name="myPriceFactory"
managersuperclass="de.hybris.platform.europe1.jalo.Europe1PriceFactory">

2. Now in MyPriceFactory class, override the related methods from Europe1PriceFactory.

3. add default.pricefactory=myPriceFactory in the local.properties.

POJO only:

if we want to override one or two methods from Europe1PriceFactory then the easiest method would be to inject own POJO class that extends the Europe1PriceFactory

catalog-spring.xml

<bean id="europe1.manager" class="de.hybris.platform.catalog.jalo.CatalogAwareEurope1PriceFactory"
 init-method="init" destroy-method="destroy">
 <property name="retrieveChannelStrategy" ref="retrieveChannelStrategy"/>
</bean>

By declaring as europe1.manager, the CatalogAwareEurope1PriceFactory replaces the default Europe1PriceFactory. And therefore you can change it accordingly to your own PriceFactory class.

Leave a comment