【问题标题】:Publish or undeploy promotion via a cronjob in Hybris通过 Hybris 中的 cronjob 发布或取消部署促销
【发布时间】:2018-09-09 16:21:36
【问题描述】:

我想根据在后台确定为具有促销代码、开始日期和结束日期的单独模型的日期,通过 cronjob 通过 cronjob 发布或取消部署基于新促销引擎(规则库)的促销。

我在帮助 hybris 中找不到促销 api,无法像在后台执行发布和取消部署操作。而且我在项目中也找不到相关的推广服务。

任何帮助将不胜感激。

【问题讨论】:

    标签: java hybris promotions


    【解决方案1】:

    以下是在 Groovy 中发布促销活动的示例:

    import de.hybris.platform.core.Registry
    def activateAllPromotions()
    {
        def maintenanceService = Registry.getApplicationContext().getBean("ruleMaintenanceService")
        def ruleService = Registry.getApplicationContext().getBean("ruleService")
        def rules = ruleService.getAllRules()
        def res = maintenanceService.compileAndPublishRules(rules,"promotions-module",true)
    }
    activateAllPromotions()
    

    您可以使用maintenanceService#archiveRule(AbstractRuleModel)取消发布

    【讨论】:

    • 仅供参考,hac 中的 groovy 控制台通过变量 spring 提供 spring 上下文。因此,您可以使用 spring.getBean('...') 而不是 Registry...
    【解决方案2】:

    对于发布促销活动,您可以使用:

    ruleMaintenanceService.compileAndPublishRules(promotions,"promotions-module",true);
    

    对于取消发布促销,您可以使用:

    ruleMaintenanceService.undeployRules(promotions,site);
    

    【讨论】:

    • compileAndPublishRules 对我不起作用。这会编译规则,但不会发布它。在 BO 中,我看到已编译的规则版本增加,状态为 inactive。我怎样才能让它工作?谢谢! UPD:我是个笨蛋。保存规则后,会自动创建它的新版本。它应该被发布。
    猜你喜欢
    • 1970-01-01
    • 2018-06-26
    • 1970-01-01
    • 2018-06-28
    • 2015-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-14
    相关资源
    最近更新 更多