Search code examples
sap-commerce-cloud

How to deal with publishing promotion issues Hybris 2105?


We have migrated our SAP Hybris from 2011 to 2105.

There are some issues coming while publishing new promotions, which seem to work fine in the lower version.When we publish a promotion(even OOB promotion like in Conditions CMS Site and in Action 10% discount on cart) and when I publish the promotion, I get an error like:

   ruleOrderEntryFixedDiscountAction.executeAction(new 
   DefaultDroolsRuleActionContext(variables, kcontext), 
   ["value_uuid":"6e732228-89fe-4f4e-8dea-5235dee2ccd7", 
    "bundleSize":new Integer(4), "bundleSize_uuid":"49803399- 
     53a8-44b6-85cd-35c1b83235d7", "bundleLimit_uuid":"778299c6- 
     75bd-414e-97bb-3e5fe1aa0bf9", "bundleLimit":new Integer(2), 
     "value":new BigDecimal("50")]);
     $groupExecution.trackRuleGroupExecution($config);:
     [Error: unable to resolve method using strict-mode: 
     org.drools.core.spi.KnowledgeHelper.$groupExecution()]

Solution

  • This is due to some changes in the drools rule engine. This causes an exception during the parsing of older Drools Rule.

    To solve this, you can

    • Make the content of all drools rules blank, and republish all rules to have correct and active drools rules for all your promotions. Example of a script: You need to disable the interceptors as they might prevent you from changing the rule content

        import de.hybris.platform.commerceservices.search.pagedata.PageableData
        import de.hybris.platform.servicelayer.search.FlexibleSearchQuery
        import com.google.common.collect.ImmutableMap;
        import de.hybris.platform.servicelayer.interceptor.impl.InterceptorExecutionPolicy;
        import de.hybris.platform.servicelayer.session.SessionExecutionBody;
        import de.hybris.platform.servicelayer.session.SessionService;
        import com.google.common.collect.ImmutableSet;
      
      
        int start = 0
        int pageSize = 1000
        int total = pageSize
      
        final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery("select {PK} from {DroolsRule} ORDER BY {PK}")
      
        searchQuery.setCount(pageSize)
        searchQuery.setNeedTotal(true)
      
        while (start < total) {
            searchQuery.setStart(start)
            def searchResult = flexibleSearchService.search(searchQuery)
      
            searchResult.getResult().each {
                final Map<String, Object> params = ImmutableMap.of(InterceptorExecutionPolicy.DISABLED_INTERCEPTOR_TYPES,
                    ImmutableSet.of(InterceptorExecutionPolicy.InterceptorType.PREPARE,InterceptorExecutionPolicy.InterceptorType.VALIDATE));
      
                sessionService.executeInLocalViewWithParams(params, new SessionExecutionBody() {
                    @Override
                    public void executeWithoutResult() {
                        it.setRuleContent("");
                        modelService.save(it);
                    }
                });
            }
      
            total = searchResult.getTotalCount()
            start += pageSize
        }
      
        println "Script has been completed."
      

    OR

    • Remove all DroolsRule objects if you no longer need them. Do note that removing these old rules might have impact on existing orders tied to that Drools rule. The promotion results will still be attached, but it will be hard to tell what promotion triggered that result.

    I would advise going for the first option as to not lose any data

    Don't forget to republish your rules after performing either of the steps