Class PromotionEvaluationContext

java.lang.Object
de.hybris.platform.promotions.result.PromotionEvaluationContext

public class PromotionEvaluationContext extends Object
PromotionEvaluationContext.
  • Constructor Details

    • PromotionEvaluationContext

      public PromotionEvaluationContext(AbstractOrder order, boolean observeRestrictions, Date date)
      Create an context for evaluating promotions on the given order.
      Parameters:
      order - The order the context is evaluating
      observeRestrictions - Whether restrictions should be observed during evaluation
      date - The effective date to use when evaluating promotions
  • Method Details

    • startLoggingConsumed

      public void startLoggingConsumed(AbstractPromotion promo)
      Start recording all of the consumed items in any view. This will remember any items consumed from any view that currently exist, and any view created.
      Parameters:
      promo - The promotion requesting the recording
    • finishLoggingAndGetConsumed

      public List<PromotionOrderEntryConsumed> finishLoggingAndGetConsumed(AbstractPromotion promo, boolean removeFromOrder)
      Complete the logging operation and return a list of all order entry consumptions since logging began. This operation moves the current set of operations to the LOG of all operations since the context was created.
      Parameters:
      promo - The promotion requesting to complete the logging operation
      removeFromOrder - Consume all the entries marked such that they cannot be used in another promotion
      Returns:
      A List of all consumption operations made to any view since logged was started
    • abandonLogging

      public void abandonLogging(AbstractPromotion promo)
      Abandon the current logging operation and throw away all of the consumption objects.
      Parameters:
      promo - the promotion
    • getLogger

      Get the consumption logger for this context. Only used internally by the view system.
      Returns:
      The logger
    • getOrder

      public AbstractOrder getOrder()
      Get the order that this context is working on.
      Returns:
      The current order
    • getObserveRestrictions

      public boolean getObserveRestrictions()
      Should restrictions be observed when evaluating promotions.
      Returns:
      true if restrictions should be observed, false otherwise.
    • createView

      public PromotionOrderView createView(SessionContext ctx, AbstractPromotion promotion, List<Product> validProducts)
      Create a filtered view of the order containing only the products specified in validProducts. This view shows the live remaining quantities of items, and is able to determine how many items remain. The view removes consumed items and as such always shows the current available state. The products in the cart and their base products (if variant or composite) are matched against the validProducts list. This allows a variant product in the cart to be matched against its base product in the list of valid products. Variant products extend VariantProduct and composite products implement the CompositeProduct interface.
      Parameters:
      ctx - The hybris session context
      promotion - The promotion creating the view
      validProducts - The products that should be included in the view
      Returns:
      A filtered view of the order showing only products from the list of valid products
    • getDate

      public Date getDate()
      Get the effective date from the evaluation context. The date exists so that the effect of promotions can be seen on dates other than the current system time.
      Returns:
      The date that the promotions are being evaluated using
    • createPriceComparator

      public static Comparator<PromotionOrderEntry> createPriceComparator(SessionContext ctx)
      Create a comparator for the current context that orders by price in natural order (lowest to highest). The head of a list sorted by this comparator will have the lowest price at index 0 and the highest at index length-1
      Parameters:
      ctx - The current hybris session context
      Returns:
      A comparator to sort PromotionOrderEntry objects by price