Register Login

How to Customize Price Factory

Updated May 18, 2018

Change Price Row model and europe1PriceFactory

Hello SAP Experts,

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

How can I use my own price factory?

Please help me.


Comments

  • 31 Aug 2017 5:54 pm Rohit Mahajan Helpful Answer

    Inside the OrderManager.class the pricefactory is loaded from ExtensionManager against the property "default.pricefactory". This property is defined in the project.properties file. The default value is project.properties file.

    Now the extension manager for europe1 is Europe1PriceFactory which helps to calculate price, tax and discount.

    public AbstractPriceFactory getDefaultPriceFactory() {  if (pricefactory == null)  {   final String pfName = Config.getParameter("default.pricefactory");   ......    // get pricefactory from ExtensionManager    pricefactory = (AbstractPriceFactory) ExtensionManager.getInstance().getExtension(pfName);   }   ......return pricefactory; }
  • 31 Aug 2017 5:56 pm Abhijeet Mudgal Helpful Answer

    There are three method 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. And last is POJO Only

    Create a New Extension

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

    Extend Europe1 extension

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

    Please follow the steps below in order to Extend Europe1 extension

    1) First create an extension myPriceFactory, and then set 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, please override the related methods from Europe1PriceFactory .

    3) Now at last in the local.properties, add default.pricefactory=myPriceFactory.

    POJO Only

    If you just want to override one or two methods from Europe1PriceFactory, injecting your own POJO class that extends the Europe1PriceFactory is the easiest option.

    In case you only 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.


×