我已经实施了BXGY定制推广。为了简化我的情况,比方说,在您的购物车中有X产品之后,您将得到Y免费产品。
如果我有2*X合格产品在购物车预期行为是得到2*Y免费产品。
我的问题是那次晋升的多次解雇。如果我将多次射击的最大次数设置为4,则动作(获得免费产品)被激活4次,尽管我在购物车中有2*X产品。
因此,我的结论是,我需要消费合格的产品(与该产品的条目),就像用户获得的免费产品被消费,这样他们就不能参加另一次促销活动的资格认证。
我的研究结论是,我需要在(YFreeGift)RAOAction中使用条目,但是我需要检索所有的条件产品,而且我不认为这是一种正确的方法(条件在工作中)。
有人知道如何使用符合条件的条目吗?
BXGY的条件转换器(我也有强制性的合格产品,但这对这个问题并不重要)
public class RuleHeinekenBXGYFQualifyingProductsConditionTranslator implements RuleConditionTranslator
{
@Override
public RuleIrCondition translate(RuleCompilerContext context, RuleConditionData ruleCondition, RuleConditionDefinitionData conditionDefinition) throws RuleCompilerException
{
List<String> mandatoryProducts = (List) getConditionParameterValue(ruleCondition, "mandatoryQualifyingProducts");
List<String> alternativeProducts = (List) getConditionParameterValue(ruleCondition, "alternativeQualifyingProducts");
Integer qualifyingCount = (Integer) getConditionParameterValue(ruleCondition, "qualifyingCount");
if(isEmpty(mandatoryProducts) && isEmpty(alternativeProducts) || qualifyingCount == null || qualifyingCount <= 0)
throw new PromotionConditionParametersValidationException();
String cartRAO = context.generateVariable(CartRAO.class);
List<RuleIrCondition> mandatoryProductsConditions = getMandatoryProductsConditions(context, mandatoryProducts, cartRAO);
List<RuleIrCondition> qualifyingCountCondition = getQualifyingCountCondition(context, qualifyingCount, cartRAO);
RuleIrGroupCondition qualifyingConditions = new RuleIrGroupCondition();
qualifyingConditions.setOperator(RuleIrGroupOperator.AND);
qualifyingConditions.setChildren(listUnion(mandatoryProductsConditions, qualifyingCountCondition));
return qualifyingConditions;
}
private List<RuleIrCondition> getQualifyingCountCondition(RuleCompilerContext context, Integer qualifyingCount, String cartRAO)
{
String qualifyingCountRAO = context.generateVariable(QualifyingCountRAO.class);
String promotionCode = context.getRule().getCode();
return getListOfRuleConditions(
aRuleCondition()
.withModelRAO(qualifyingCountRAO)
.withAttribute("promotionCode")
.withOperator(EQUAL)
.withValue(promotionCode)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(qualifyingCountRAO)
.withAttribute("qualifyingCount")
.withOperator(GREATER_THAN_OR_EQUAL)
.withValue(qualifyingCount)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(cartRAO)
.withAttribute("qualifyingCounts")
.withOperator(CONTAINS)
.withTargetVariable(qualifyingCountRAO)
.buildAttributeRelationCondition());
}
private List<RuleIrCondition> getMandatoryProductsConditions(RuleCompilerContext context, List<String> mandatoryProducts, String cartRAO)
{
if(isEmpty(mandatoryProducts))
return emptyList();
return getMapOfQualifyingProductsWithQuantities(mandatoryProducts)
.entrySet().stream()
.map(entry -> getMandatoryProductCondition(context, cartRAO, entry.getKey(), entry.getValue()))
.collect(toList());
}
private RuleIrExistsCondition getMandatoryProductCondition(RuleCompilerContext context, String cartRAO, String product, int qualifyingCount)
{
RuleIrLocalVariablesContainer variablesContainer = context.createLocalContainer();
String containsProductRAO = context.generateLocalVariable(variablesContainer, ProductRAO.class);
String containsOrderEntryRAO = context.generateLocalVariable(variablesContainer, OrderEntryRAO.class);
List<RuleIrCondition> listOfConditions = getListOfRuleConditions(
aRuleCondition()
.withModelRAO(containsProductRAO)
.withAttribute("code")
.withOperator(EQUAL)
.withValue(product)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(containsOrderEntryRAO)
.withAttribute("product")
.withOperator(EQUAL)
.withTargetVariable(containsProductRAO)
.buildAttributeRelationCondition(),
aRuleCondition()
.withModelRAO(containsOrderEntryRAO)
.withAttribute("quantity")
.withOperator(GREATER_THAN_OR_EQUAL)
.withValue(qualifyingCount)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(cartRAO)
.withAttribute("entries")
.withOperator(CONTAINS)
.withTargetVariable(containsOrderEntryRAO)
.buildAttributeRelationCondition());
RuleIrExistsCondition mandatoryProductsExistCondition = new RuleIrExistsCondition();
mandatoryProductsExistCondition.setVariablesContainer(variablesContainer);
mandatoryProductsExistCondition.setChildren(listOfConditions);
return mandatoryProductsExistCondition;
}
}发布于 2017-05-29 23:41:25
规则引擎提供了一种机制,用于对规则触发操作项的次数进行限制。 最大的规则执行允许您控制规则的操作可以执行的最大次数,只要满足条件。对于所有开箱即用的促销操作,此属性的值应设置为1。
查看RuleConfigurationRRD属性。
取自help.hybris.com。
发布于 2017-05-31 15:02:46
你用的是什么版本?在6.4或6.3 AFAIK之前的免费赠与行动中有一个错误。该免费礼品行动是由2个行动内部(添加产品到购物车,并给予100%折扣的附加产品)。由于这个错误,您可能需要增加最大规则执行量,以使原来的数量翻一番(因为每个操作“添加到购物车”和“折扣产品”将算作一次执行)。
要回答有关订单输入消耗的突出显示的问题:促销引擎现在不支持订单输入消耗OOTB。这是传统促销活动的一部分,但已被放弃,而倾向于堆叠。
但更广泛地说,你似乎采取的方法并不是狂妄自大打算如何使用免费赠与行动。如果您想要BOGOF (或BXGYF),您通常会定义一个促销,检查您的合格产品X和待打折产品Y在购物车中的数量是否足够。然后,该操作只需对Y产品进行折扣。您还可以添加一个潜在的促销检查,只检查产品X,它将触发一条消息,比如将n个产品Y添加到您的购物车中,以免费获得它们,以便提醒客户s/他有资格获得促销。
如果您查看promotionenginesamplesaddon扩展/addon,您会发现这两个促销活动应该做到我上面的意思:
potential_product_buy_x_get_y_free
product_buy_x_get_y_free希望这能帮上忙
塞巴斯蒂安
https://stackoverflow.com/questions/44238254
复制相似问题