on 2018 Jun 28 4:26 PM
Hello, I have a lot of promotion, we have been creating promotions rules (and, consequently, drools rules) for 2 years without a stop. So, the system is overloaded. I am thinking about creating a Impex, to eliminate a lot of promotions that make no sense anymore. So the header I was thinking is: REMOVE PromotionSourceRule; code[unique=true] -> to eliminate Promotion Rules
and the header to eliminate the DroolsRules is not ready, because the code is not unique. I am thinking about using the PK.
Has anyone tried this before?
Request clarification before answering.
I tried it but it didn't work very well from memory. I ended writing a groovy script that archives all rules that have expired. I suppose you could modify this to delete after archiving. This will run on a cron every night.
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.ruleengine.RuleEngineActionResult;
import de.hybris.platform.ruleengine.RuleEngineService;
import de.hybris.platform.ruleengine.model.AbstractRuleEngineRuleModel;
import de.hybris.platform.ruleengine.model.DroolsKIEModuleModel;
import de.hybris.platform.ruleengineservices.RuleEngineServiceException;
import de.hybris.platform.ruleengineservices.compiler.RuleCompilerException;
import de.hybris.platform.ruleengineservices.compiler.RuleCompilerProblem.Severity;
import de.hybris.platform.ruleengineservices.compiler.RuleCompilerResult;
import de.hybris.platform.ruleengineservices.compiler.RuleCompilerService;
import de.hybris.platform.ruleengineservices.compiler.impl.DefaultRuleCompilerProblem;
import de.hybris.platform.ruleengineservices.compiler.impl.DefaultRuleCompilerResult;
import de.hybris.platform.ruleengineservices.enums.RuleStatus;
import de.hybris.platform.ruleengineservices.maintenance.RuleCompilerPublisherResult;
import de.hybris.platform.ruleengineservices.maintenance.RuleCompilerPublisherResult.Result;
import de.hybris.platform.ruleengineservices.model.AbstractRuleModel;
import de.hybris.platform.servicelayer.model.ModelService;
import de.hybris.platform.ruleengine.*;
$promotionSourceRulesQuery="select {pk},{code},{enddate} from {promotionsourcerule} where ({enddate} < NOW() - INTERVAL 1 DAY and {status}<>'8796153643099')"
ruleCompilerService = spring.getBean('ruleCompilerService');
platformRuleEngineService = spring.getBean('platformRuleEngineService');
flexibleSearchService = spring.getBean('flexibleSearchService');
ruleMaintenanceService=spring.getBean("ruleMaintenanceService")
List sourceRules = flexibleSearchService.search($promotionSourceRulesQuery).getResult();
for (sourceRule in sourceRules) {
//ruleCompilerService.compile(sourceRule);
ruleMaintenanceService.archiveRule(sourceRule);
}
platformRuleEngineService.initializeAllRulesModules();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
there are out of the box cron jobs in the latest versions to remove the drools rules. its called droolsrulemaintainence job. also there are lot of recommendations given to take care of the promotions under Cx works area of sap.com. please do validate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.