无法发布Hybris促销活动

问题描述 投票:0回答:1

我已经在hybris 1808中创建了一个促销活动但是当我试图发布促销活动时它就失败了。同样的促销活动在1808年香草Hybris工作

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

  1. promotionenginesamplesaddon
  2. promotionengineatddtests

我希望促销状态为Publish,但在发布时出现以下错误日志时失败:

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个回答
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");

这解决了上面的错误。

希望这可以帮助。快乐的编码。

© www.soinside.com 2019 - 2024. All rights reserved.