Currently promotion rule engine works with :
- entities ProductPromoCond et ProductPromoAction
- java linear function ProductPromoWorker.checkCondition() (ProductPromoWorker:910) and ProductPromoWorker.performAction (ProductPromoWorker:1423)
- Enumeration list to indicate on java function what piece of code to activate the control or action
The problem with this structure is when you want to create a new case of condition or action, you need to modify the framework code base.
We propose an other way with convert the 2 big java leaner function to service representation with one service by case.
To realize it we introduce a relation with CustomMethod :
ProductPromoRule --> ProductPromoCond -> CustomMethod
-> ProductPromoAction -> CustomMethod
Each functions's case are converted to service with a related CustomMethod.
With this pattern now you can write your own condition rule and action rule on your plugin and link it on the promo engine
When it's possible we associate a unit test to the service
For backware compatibility current enumeration receive on enumCode the customMethodId to ensure that old data work fine with the new engine
Related dev discussion