Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-10370

Migrate promotion condition and action rule

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Implemented
    • Trunk
    • 18.12.01
    • product
    • None

    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

        1. OFBIZ-10370.patch
          199 kB
          Nicolas Malin

        Issue Links

          Activity

            People

              nmalin Nicolas Malin
              nmalin Nicolas Malin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: