cancel
Showing results for 
Search instead for 
Did you mean: 

How to customize Europe1PriceFactory and put your custom logic in it?

kundan1986
Explorer
0 Kudos

Hi Experts,

In our project a single product can have a multiple price row with a valid stnd end date and we wanted that the price row should be returned based on the price row creation time i.e the most recently created price row. So we thought of overriding the Europe1PriceFactory class and its method - matchPriceRowForPrice() in this method we want to put our custom logic. But although we created a custom price factory but still the OOTB price factory class is called only. Below are the steps that i followed for overriding the price factory. 1. Crated a new class that extends Europe1PriceFacotory public class EtradeEurope1PriceFactory extends Europe1PriceFactory { public PriceRow matchPriceRowForPrice() {

} }

This class i have created in CustomeB2BCoreExtension.

  1. Then injected the bean into customb2bcore-spring.xml

Any help is highly appreciated here.

Thanks,

rohit31_raj92
Active Participant
0 Kudos

Hi Yes its possible to override the Europe1PriceFactory into your project, did you changed the property file for Europe1PriceFactory so your new price factory can be picked ? if not then please try it.may be because of it you are not able to override

former_member620692
Active Contributor
0 Kudos

- check https://answers.sap.com/questions/12758578/view.html if it fulfils your requirement. By the way, customeeurope1 in default.pricefactory=customeeurope1 corresponds to the name of your extension; not the bean id.

kundan1986
Explorer
0 Kudos

Hello Arvind Sir,

I just have to override few methods of PriceFactory, so i don't want to create a new extension and here following POJO approach. I think in this case overriding "default.pricefactory" in properties file is not required.

Thanks,

former_member620692
Active Contributor
0 Kudos

Good that you have figured out the approach to proceed with. I just wanted to let you know that the value for the key, default.pricefactory should be the name of the extension and not the bean id.

Wish you good luck!

kundan1986
Explorer
0 Kudos

Hello Sir,

I am still not able to figure out why my customEuropeFactory is not getting called, I have posted the class definition as well as the spring bean definition here in the post, is any thing wrong with the class and bean definition. Since i have not created any new extension here the value for the key default.pricefactory is still europe1.

Thanks,

former_member620692
Active Contributor
0 Kudos

Hello Kundan - I would still try the approach mentioned in https://answers.sap.com/questions/12758578/view.html and see if it works.

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Simply add bean in the spring xml file with your price factory class (I've adde in the CompanyCore extention)

<bean id="europe1.manager" class="com.company.core.price.CompanyCatalogAwareEurope1PriceFactory"
     init-method="init" destroy-method="destroy">
   <property name="retrieveChannelStrategy" ref="retrieveChannelStrategy"/>
</bean>

Class file:

public class CompanyCatalogAwareEurope1PriceFactory extends CatalogAwareEurope1PriceFactory {

    @Override
    public PriceValue getBasePrice(AbstractOrderEntry entry) throws JaloPriceFactoryException {
        super.getBasePrice(entry);
    }
}
rohit31_raj92
Active Participant
0 Kudos

Hi @kundan

Please override the below property to make your new custom price factory changes being reflected.

Name of an extension used as the default PriceFactory from the list of installed extensions

default.pricefactory=europe1

Please let me know if this helps you.

kundan1986
Explorer
0 Kudos

So in my case i need to add below key-value in local.proerties right?

default.pricefactory=customeeurope1

Below is the bean definition in spring.xml file

 <bean id="customeeurope1.manager"
     class="com.custom.b2b.core.jalo.CustomeEurope1PriceFactory"
       init-method="init" destroy-method="destroy">
     <property name="retrieveChannelStrategy" ref="retrieveChannelStrategy"/>
 </bean> 
rohit31_raj92
Active Participant
0 Kudos

Yes, you need to override this with your new price factory value..Go ahead and try. Let me know if this helps you

kundan1986
Explorer
0 Kudos

Still not working

Thanks,