我已经使用下面的impEx创建了基于优惠券的促销规则。成功创建了规则,但没有将提升模块部署到其中。
INSERT_UPDATE PromotionSourceRule;code[unique=true];priority;maxAllowedRuns;stackable[default=false];ruleGroup(code);conditions;actions;website(Identifier)[default=$defaultPromoGrp];status(code)[default=$defaultRuleStatus];excludeFromStorefrontDisplay[default=false]
"#% beforeEach:
if(de.hybris.platform.personalizationsampledataaddon.util.CxAddOnSampleDataUtils.isPromotionSourceRuleUnmodifiable(line.get(new Integer(1)))){
line.clear();
}";
"#% afterEach: de.hybris.platform.core.Registry.getApplicationContext().getBean(""ruleEngineSystemSetup"").registerSourceRuleForDeployment(impex.getLastImportedItem(), new String[]{$promotionModule, $promotionPreviewModule});"
;coupon_code_20_percentage_cart_discount;25;1;true;couponPromotionRuleGroup;"[{""definitionId"":""y_qualifying_coupons"",""parameters"":{""coupons"":{""uuid"":""COUPON20"",""type"":""List(ItemType(AbstractCoupon))"",""value"":[""COUPON20""]}},""children"":[]}]";"[{""definitionId"":""y_order_percentage_discount"",""parameters"":{""value"":{""uuid"":""20"",""type"":""java.math.BigDecimal"",""value"":20}}}]";;;发布于 2018-03-27 16:27:10
您是通过hac还是作为系统初始化/更新的一部分进行导入?
RuleEngineSystemSetup中的逻辑仅在系统初始化或系统更新的上下文中起作用。如果您查看默认实现,您将看到:
public class DefaultRuleEngineSystemSetup extends AbstractEventListener<AfterInitializationEndEvent>因此,在impex和对registerSourceRuleForDeployment的调用期间,仅注册规则以供发布,一旦触发AfterInitializationEndEvent (由平台在初始化/更新之后),收集的规则将被发布。
如果你在hac的上下文中运行这个脚本,你可以使用beanshell代码来调用一个常规的RuleEngineService方法来初始化你的模块,或者你可以尝试调用DefaultRuleEngineSystemSetup.onEvent(final AfterInitializationEndEvent event)方法,传入一个“假的”非空事件来触发system setup类内部的逻辑(我相信它需要一个非空事件来记录传入的事件,但除了这个事件没有被使用之外)我还没有尝试过的最后一件事,都需要在你的impex脚本中编写更多的脚本。
希望这能帮上忙,塞巴斯蒂安
发布于 2019-11-14 13:35:26
下面的impex将用于编译和发布促销规则
$defaultPromoGrp = <promo-group>
$promotionSourceRulesQuery="select {psr.pk} from {PromotionSourceRule as psr},{PromotionGroup as pg} where {psr.code} in ('<Promotion Code with comma separated>') and {pg.Identifier}='$defaultPromoGrp' and {psr.website}={pg.pk}"
"#%groovy% ruleCompilerService = spring.getBean('ruleCompilerService');
platformRuleEngineService = spring.getBean('platformRuleEngineService');
flexibleSearchService = spring.getBean('flexibleSearchService');
List sourceRules = flexibleSearchService.search($promotionSourceRulesQuery).getResult();
spring.getBean('ruleMaintenanceService').compileAndPublishRules(sourceRules, ""promotions-module"", false);
";https://stackoverflow.com/questions/49491367
复制相似问题