无法发布Hybris促销

无法发布Hybris促销,hybris,promotions,Hybris,Promotions,我在hybris 1808创建了一个促销,但当我试图发布促销时,它失败了。1808年香草海布里斯也有同样的促销活动 我在localextension.xml中添加了以下属性,并尝试过,但仍然面临相同的问题 促销引擎示例 升级引擎测试 我希望升级状态为发布,但发布时失败,出现以下错误日志: 19.04.23 17:54:40:527 INFO ************************************* 19.04.23 17:54:40:535 INFO Sta

我在hybris 1808创建了一个促销,但当我试图发布促销时,它失败了。1808年香草海布里斯也有同样的促销活动

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

促销引擎示例 升级引擎测试 我希望升级状态为发布,但发布时失败,出现以下错误日志:

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

因为我在发布促销时从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');

必须更改DefaultDroolRuleTargetCodeGenerator类中被重写的方法,以包括droolRule uuid,而不是规则uuid,这是6.7中包含在OOTB DefaultDroolRuleTargetCodeGenerator类中的更改

     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");
这解决了上述错误

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

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