【问题标题】:Not able to publish Hybris Promotion无法发布 Hybris 促销
【发布时间】:2019-04-23 12:40:07
【问题描述】:

我在 hybris 1808 中创建了一个促销,但是当我尝试发布该促销时它失败了。 1808 Vanilla Hybris 也有同样的促销活动

我在 localextension.xml 中添加了以下属性并尝试过,但仍然遇到同样的问题

  1. promotionenginesamplesaddon
  2. promotionengineatddtests

我预计促销状态为发布,但发布时失败并显示以下错误日志:

19.04.23 17:54:40:527   INFO    *************************************
19.04.23 17:54:40:535   INFO    Starting RuleEngineCompilePublishJob
19.04.23 17:54:40:535   INFO    *************************************
19.04.23 17:54:44:903   ERROR   The rule compilation finished with errors
19.04.23 17:54:44:910   ERROR   Exception caught - de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.droolsruleengineservices.interceptors.DroolsRuleValidateInterceptor@3d9f547f]:rule(code:testPromotion) The drl content does not contain the matching rule declaration with the value of your hybris rule's uuid attribute. Please adjust the uuid of your hybris rule and/or add: rule "2e0e0ac2-7475-44c1-9114-07a0d7174534" (i.e. putting the rule uuid in double-quotes) in your drl content.
19.04.23 17:54:44:915   INFO    *************************************
19.04.23 17:54:44:915   INFO    RuleEngineCompilePublishJob finished with errors
19.04.23 17:54:44:915   INFO    *************************************

【问题讨论】:

  • 如果需要任何其他信息,请告诉我

标签: hybris promotions


【解决方案1】:

您使用的是哪个版本的 hybris?

因为我在发布促销活动时从 6.3 升级到 6.7 时遇到了这个问题。

我在 6.3 的自定义类中重写了该方法,如下所示:

@Override
    protected String generateRuleContentRule(final DroolsRuleGeneratorContext context, final String actions, final String metadata)
    {
        final AbstractRuleModel rule = context.getRuleCompilerContext().getRule();
        final Map variables = context.getVariables();
        final StringBuilder buffer = new StringBuilder(4096);
        buffer.append("rule \"").append(rule.getUuid()).append("\"\n");
        buffer.append("@ruleCode(\"").append(rule.getCode()).append("\")\n");
        buffer.append(metadata);
        buffer.append("dialect \"mvel\" \n");
        buffer.append("salience ").append(rule.getPriority()).append('\n');

...

必须将 DefaultDroolsRuleTargetCodeGenerator 类中的这个覆盖方法更改为包含 droolRule uuid 而不是规则 uuid,这是 6.7 中 OOTB DefaultDroolsRuleTargetCodeGenerator 类中合并的更改

     protected String generateRuleContentRule(DroolsRuleGeneratorContext context, String actions, String metadata) {
    AbstractRuleModel rule = context.getRuleCompilerContext().getRule();
    DroolsRuleModel droolsRule = context.getDroolsRule();
    StringBuilder buffer = new StringBuilder(4096);
    buffer.append("rule \"").append(droolsRule.getUuid()).append("\"\n");
    buffer.append("@ruleCode(\"").append(rule.getCode()).append("\")\n");
    buffer.append("@moduleName(\"").append(context.getRuleCompilerContext().getModuleName()).append("\")\n");
    buffer.append(metadata);
    buffer.append("dialect \"mvel\" \n");

这解决了上面的错误。

希望这会有所帮助。 快乐编码。

【讨论】:

    猜你喜欢
    • 2018-06-26
    • 1970-01-01
    • 2018-06-28
    • 1970-01-01
    • 2019-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多