首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过Impex发布PromotionSourceRule?

如何通过Impex发布PromotionSourceRule?
EN

Stack Overflow用户
提问于 2018-03-26 20:20:26
回答 2查看 1K关注 0票数 0

我已经使用下面的impEx创建了基于优惠券的促销规则。成功创建了规则,但没有将提升模块部署到其中。

代码语言:javascript
复制
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}}}]";;;
EN

回答 2

Stack Overflow用户

发布于 2018-03-27 16:27:10

您是通过hac还是作为系统初始化/更新的一部分进行导入?

RuleEngineSystemSetup中的逻辑仅在系统初始化或系统更新的上下文中起作用。如果您查看默认实现,您将看到:

代码语言:javascript
复制
public class DefaultRuleEngineSystemSetup extends AbstractEventListener<AfterInitializationEndEvent>

因此,在impex和对registerSourceRuleForDeployment的调用期间,仅注册规则以供发布,一旦触发AfterInitializationEndEvent (由平台在初始化/更新之后),收集的规则将被发布。

如果你在hac的上下文中运行这个脚本,你可以使用beanshell代码来调用一个常规的RuleEngineService方法来初始化你的模块,或者你可以尝试调用DefaultRuleEngineSystemSetup.onEvent(final AfterInitializationEndEvent event)方法,传入一个“假的”非空事件来触发system setup类内部的逻辑(我相信它需要一个非空事件来记录传入的事件,但除了这个事件没有被使用之外)我还没有尝试过的最后一件事,都需要在你的impex脚本中编写更多的脚本。

希望这能帮上忙,塞巴斯蒂安

票数 0
EN

Stack Overflow用户

发布于 2019-11-14 13:35:26

下面的impex将用于编译和发布促销规则

代码语言:javascript
复制
$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);
";
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49491367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档