Description
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
<CustomMethod customMethodId="PPC_PRODUCT_AMOUNT" customMethodTypeId="PRODUCT_PROMO_COND" customMethodName="productPromoCondProductAmount" description="Product amount"/> <Enumeration enumId="PPIP_PRODUCT_AMOUNT" enumCode="PPC_PRODUCT_AMOUNT"/><!--link enumeration with customMethod for backware compatibility-->
//for backware compatibility resolve customMethodId from enumCode GenericValue condEnum = EntityQuery.use(delegator).from("Enumeration").where("enumId", inputParamEnumId).cache().queryOne(); if (condEnum != null) { customMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", condEnum.get("enumCode")).cache().queryOne(); serviceName = customMethod.getString("customMethodName"); }
Related dev discussion
Attachments
Attachments
Issue Links
- causes
-
OFBIZ-10794 Promotion condition/action type of few promotion not showing
-
- Closed
-
-
OFBIZ-11105 Add backward compatibility for inputParamEnumId in promotion management
-
- Closed
-