cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable multiple promotion groups for a site in Hybris?

chetanks3005
Discoverer
0 Kudos
654

I have a requirement where I want 2 promotion groups to be assigned to a BaseSite. Since OOTB allows only one promo group per site, How do I achieve it? Thanks in advance.

View Entire Topic
mansurarisoy
Contributor
0 Kudos

This is not possible by default, but luckily PromotionsService's updatePromotions method takes a collection of PromotionGroupModel as its parameter, so I believe this method should work for multiple promotion groups. I did not test it so you need to test it to see whether it works or not.

If it works, what you can do to achieve multiple promotion groups to be assigned to a BaseSite is as follows:

1. Create a many-to-many relation between BaseSite and PromotionGroup

2. Extend DefaultCommerceCartCalculationStrategy with CustomCommerceCalculationStrategy

3. Override getPromotionGroups() method according to your need, it's up to you, some possible scenarios I can think of

  • you can use both defaultPromotionGroup and promotionGroups you defined and merge them in the collection
  • you can only use promotionGroups
  • you can use promotionGroups but defaultPromotion as fallback if no promotionGroups define

4. Define spring bean for your custom strategy and alias for commerceCartCalculationStrategy

<alias alias="commerceCartCalculationStrategy" name="customCommerceCartCalculationStrategy"/>
<bean id="customCommerceCartCalculationStrategy" parent="defaultCommerceCartCalculationStrategy"
class="com.customextension.order.impl.CustomCommerceCartCalculationStrategy">
</bean>

Hope this helps,