cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend DefaultCommercePlaceOrderStrategy

Former Member
0 Kudos

Hi Experts,

We are using hybris 6.2.0, DefaultCommercePlaceOrderStrategy bean resides in commerceservices extension. I need to create a new CustomDefaultCommercePlaceOrderStragey class which extends DefaultCommercePlaceOrderStrategy and override the placeOrder() method .How could i achieve this. Please explain step by step.

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

I faced the same issue and after spending some time in looking at how DefaultCommerceCheckoutService 's bean is configured I found that it has explicitly specified the dependency for Place order strategy as follows

 <property name="commercePlaceOrderStrategy" ref="b2bCommercePlaceOrderStrategy"/>

So for extending a the DefaultCommercePlaceOrderStrategy in B2B store you should always give alias as b2bCommercePlaceOrderStrategy as given in following example:

 <alias name="customDefaultCommercePlaceOrderStrategy" alias="b2bCommercePlaceOrderStrategy"/>

Cheers!! 🙂

bhavirisetty
Active Participant
0 Kudos

Hi,

Write your own class and extend the DefaultCommercePlaceOrderStrategy and override required method then follow the below spring configuration in your extension spring.xml

 <alias alias="commercePlaceOrderStrategy" name="newCommercePlaceOrderStrategy"/>
     <bean id="newCommercePlaceOrderStrategy"
             class="your.new.fully.qualified.classpath" parent="defaultCommercePlaceOrderStrategy"/>


Thanks

Former Member
0 Kudos

Hi Phani,

Thank you for the quick reply, I have followed the same steps you have explained but instead of calling my overridden method which is calling original method.Below are my bean definitions. Here RgcCommercePlaceOrderStrategy extends DefaultCommercePlaceOrderStrategy


 <bean id="rgcCommercePlaceOrderStrategy"
         class="de.hybris.rgc.extend.commerceservice.RgcCommercePlaceOrderStrategy" parent="defaultCommercePlaceOrderStrategy">
     <property name="calculationService" ref="rgcCalculationService"/>
 </bean>**
bhavirisetty
Active Participant
0 Kudos

Hi,

You didn't specify the alias for your bean definition,

 <alias alias="commercePlaceOrderStrategy" name="rgcCommercePlaceOrderStrategy"/>

This alias is matters here.

Thanks

Former Member
0 Kudos

I forgot to mention alias bean definition in my earlier comment.It was there in spring configuration file like below

Still it is not calling custom overridden method.

bhavirisetty
Active Participant
0 Kudos

I believe there might be another bean strategy which is overriding your definition, search your work space with alias="commercePlaceOrderStrategy", may be you can find a clue.

Former Member
0 Kudos

Below bean exists in yacceleratorfractusfulfilmentprocess extension

bhavirisetty
Active Participant
0 Kudos

This should not cause anything, Would you mind put debug point on class which is getting called now and see who is the caller for that class then you can get to know how this class being called instead your custom class.

0 Kudos

Hi Gopi,

I am facing the same problem, were you able to resolve this. Please let me know how if you were able resolve this.