【问题标题】:Get product info in promotions applied in Hybris在 Hybris 中应用的促销活动中获取产品信息
【发布时间】:2018-08-15 22:00:42
【问题描述】:

我想了解促销引擎上的哪些产品应用了哪些促销,以便在它们之间分配产品价格并将它们发送到 ERP。

当我们查看 Hybris 中的promotionService 时,有一个方法叫做getPromotionResults(order)。它返回 PromotionOrderResults 对象。在这个对象中,有两个方法与我的案例相关,getAppliedProductPromotions() 和 getAppliedOrderPromotions()。 如果我没有错过它,我无法在这些方法的结果中看到促销的产品信息。此外,我通过 promotion.getAppliedOrderPromotions().get(0).getAllAttributes() 查看了所有属性,但我无法拥有它们。

我如何知道促销中的产品信息和折扣金额?

【问题讨论】:

  • 您还在使用旧版促销活动吗?还是新的基于规则的推广引擎?
  • 我已经在上面作为促销引擎告诉过它。我的意思是,它是基于流口水的推广引擎

标签: java hybris promotions


【解决方案1】:

你要找的方法是

PromotionOrderResults#getAppliedProductPromotions()

这将返回应用于订单条目/产品的所有促销活动,您可以通过PromotionOrderEntryConsumed PromotionResult#getConsumedEntries()导航到产品

【讨论】:

  • 我有一个目标捆绑促销,并描述了 4 个容器,它们在条件下拥有自己的产品。除此之外,我描述了一个操作,其中包含订单的特定价格,包括每个容器中的一个产品。我无法访问计算服务中的已消费条目。为了给出一个例子,“order.getAllPromotionResults().iterator().next().getConsumedEntries()”导致空列表。我使用 Hybris v6.4。
  • 我看到了一个链接 elision.eu/the-new-features-in-sap-hybris-commerce-6-7 。当您查看它时,您会看到“用于促销的订单条目项目的消耗和可用性”。是否有任何选项可以在下订单期间在计算服务中获取受促销影响的产品?
【解决方案2】:

我有办法获得在促销活动中作为免费礼物添加的产品...通常是这样的

Set promotionResultModels = cart.getAllPromotionResults();
 
  if (!Objects.isNull(promotionResultModels))
  {
     Iterator resultsIterator = promotionResultModels.iterator();

     while (resultsIterator.hasNext())
     {
        PromotionResultModel promoResultModel = (PromotionResultModel) resultsIterator.next();
        Iterator var6 = promoResultModel.getActions().iterator();

        while (var6.hasNext())
        {
           AbstractPromotionActionModel action = (AbstractPromotionActionModel) var6.next();
           if (action instanceof RuleBasedOrderAddProductActionModel)
           {
              String freeGiftProductCode = ((RuleBasedOrderAddProductActionModel) action).getProduct().getCode();

           }
        }
     }
  }

但在我的情况下,这是免费礼品促销,不确定基于捆绑的促销是否可能具有类似的属性。根据实际触发促销的产品,我仍在寻找获得它的方法。我最接近的是这个:

((RuleBasedOrderAddProductActionModel) action).getRule().getRuleContent()

但是,这是具有 RAO 的 Hybris 生成代码,并且产品代码隐藏在该字符串中。所以我需要编写一个丑陋的脚本解析器来查找代码。

如果您找到第二部分,即触发促销的产品,请告诉我,我也在寻找它。

【讨论】:

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