Package de.hybris.platform.promotions
Interface PromotionsService
-
- All Known Implementing Classes:
DefaultPromotionEngineService,DefaultPromotionsService,DefaultSapPromotionEngineService
public interface PromotionsServiceThe service for the Promotions extension. Manages applying promotions to carts and orders.- Use the
updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)methods to evaluate the promotions that can be applied to a cart or order. - Use the
getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel)methods to retrieve the promotions calculated for an order. - Use the
getProductPromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.product.ProductModel)methods to retrieve the promotions that aProductModelcan be part of. - The promotions extension stores additional database items for the cart and order items. When a cart is removed
from the system it is necessary to call the
cleanupCart(de.hybris.platform.core.model.order.CartModel)method to removed these items.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcleanupCart(CartModel cart)Delete the the stored promotion results for a Cart.java.util.List<? extends AbstractPromotionModel>getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.java.util.List<? extends AbstractPromotionModel>getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.PromotionGroupModelgetDefaultPromotionGroup()Lookup the default promotion group created by the promotions extension.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<ProductPromotionModel>getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.java.util.List<ProductPromotionModel>getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.java.lang.StringgetPromotionDescription(AbstractPromotionModel promotion)Get the description of given promotion.PromotionGroupModelgetPromotionGroup(java.lang.String identifier)Lookup a promotion group with the given identifier.PromotionOrderResultsgetPromotionResults(AbstractOrderModel order)Get the promotion results for the specified order.PromotionOrderResultsgetPromotionResults(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)Get the promotion results for the specified order.java.util.Collection<AbstractPromotionRestrictionModel>getRestrictions(AbstractPromotionModel promotion)Get the collection ofAbstractPromotionRestrictionModelinstances.voidtransferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)Transfer the promotions applied to a cart to a new order.PromotionOrderResultsupdatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)Update the promotions on the specifiedAbstractOrderobject.PromotionOrderResultsupdatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)Update the promotions on the specifiedAbstractOrderModelobject.
-
-
-
Method Detail
-
getProductPromotions
java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related to- Returns:
- The list of
ProductPromotionrelated to theProductModelspecified
-
getProductPromotions
java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related toevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.date- The date to check for promotions, typically the current date- Returns:
- The list of
ProductPromotionrelated to theProductModelspecified
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluate- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluatedate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product to pass to restrictions- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, java.util.Date date)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product to pass to restrictionsdate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.date- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.product- The product to pass to restrictions if evaluateRestrictions is true- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, java.util.Date date)
Get the ordered list ofOrderPromotioninstances.- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.product- The product to pass to restrictions if evaluateRestrictions is truedate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getAbstractProductPromotions
java.util.List<? extends AbstractPromotionModel> getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related to- Returns:
- The list of
AbstractPromotionModelrelated to theProductModelspecified
-
getAbstractProductPromotions
java.util.List<? extends AbstractPromotionModel> getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related toevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.date- The date to check for promotions, typically the current date- Returns:
- The list of
AbstractPromotionModelrelated to theProductModelspecified
-
updatePromotions
PromotionOrderResults updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
Update the promotions on the specifiedAbstractOrderobject. This method will automatically apply all possible product promotional updates to the cart, but not apply order level promotions. Any previously applied order level promotions will remain applied. Promotions are evaluated at the current system time. The promotion results are stored in the database and the samePromotionOrderResultscan be obtained later by callinggetPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel).- Parameters:
promotionGroups- The promotion groups to evaluateorder- The order object to update with the results of the promotions- Returns:
- The promotion results
-
updatePromotions
PromotionOrderResults updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
Update the promotions on the specifiedAbstractOrderModelobject. The resulting promotions can be retrieved later by callinggetPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel). The order must be calculated before calling this method.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)must be called after callingAbstractOrder.recalculate()on theAbstractOrderModel. Where thePromotionsManager.AutoApplyModeis set toPromotionsManager.AutoApplyMode.KEEP_APPLIEDthe state of any previously appliedPromotionResultis recorded and if it is still in the fired state (PromotionResult.isApplied()) after reevaluating the promotions it will be automatically reapplied. The promotion results are stored in the database and the samePromotionOrderResultscan be obtained later by callinggetPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel). After this method is called, please call getModelService().refresh(order) or getModelService().save(order).- Parameters:
promotionGroups- The promotion groups to evaluateorder- The AbstractOrder object to update the promotions forevaluateRestrictions- If true any promotion restrictions will be observed, if false all promotion restrictions are ignoredproductPromotionMode- The auto apply mode. This determines whether this method applies any product promotional changes to line items or discounts to the overall amountorderPromotionMode- The auto apply mode. This determines whether this method applies any order promotional changes to line items or discounts to the overall amountdate- The effective date for the promotions to check. Use this to to see the effects of promotions in the past or future.- Returns:
- The promotion results
-
getPromotionResults
PromotionOrderResults getPromotionResults(AbstractOrderModel order)
Get the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toupdatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)for the same order. If any of the promotion results are invalid then they will be ignored.- Parameters:
order- The order to get the promotion results for- Returns:
- The promotion results
-
getPromotionResults
PromotionOrderResults getPromotionResults(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
Get the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toupdatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)for the same order. If any of the promotion results are invalid then this method will recalculate the promotions by callingupdatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel).- Parameters:
promotionGroups- The promotion groups to evaluateorder- The AbstractOrder object to get the promotions forevaluateRestrictions- If true any promotion restrictions will be observed, if false all promotion restrictions are ignoredproductPromotionMode- The auto apply mode. This determines whether this method applies any product promotional changes to line items or discounts to the overall amountorderPromotionMode- The auto apply mode. This determines whether this method applies any order promotional changes to line items or discounts to the overall amountdate- The effective date for the promotions to check. Use this to to see the effects of promotions in the past or future.- Returns:
- The promotion results
-
cleanupCart
void cleanupCart(CartModel cart)
Delete the the stored promotion results for a Cart.- Parameters:
cart- TheCartto delete the results for
-
transferPromotionsToOrder
void transferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)
Transfer the promotions applied to a cart to a new order. This is used when an order is created from a cart.- Parameters:
source- The cart that has promotionstarget- The order that promotions should be applied toonlyTransferAppliedPromotions- Flag to indicate that only applied promotions should be transfered. If false all promotion results will be transfered
-
getDefaultPromotionGroup
PromotionGroupModel getDefaultPromotionGroup()
Lookup the default promotion group created by the promotions extension.- Returns:
- the default promotion group
-
getPromotionGroup
PromotionGroupModel getPromotionGroup(java.lang.String identifier)
Lookup a promotion group with the given identifier.- Parameters:
identifier- identifier of the promotion group to look for- Returns:
- the promotion group or null if no group with the given identifier is found
- Throws:
java.lang.IllegalArgumentException- if identifier is null
-
getRestrictions
java.util.Collection<AbstractPromotionRestrictionModel> getRestrictions(AbstractPromotionModel promotion)
Get the collection ofAbstractPromotionRestrictionModelinstances.- Parameters:
promotion- the promotion which restrictions should be returned- Returns:
- A collection of
AbstractPromotionRestrictionModelinstances attached to this promotion.
-
getPromotionDescription
java.lang.String getPromotionDescription(AbstractPromotionModel promotion)
Get the description of given promotion.- Parameters:
promotion- the promotion to get the description for- Returns:
- String representing promotion description
-
-