Package de.hybris.platform.promotions
Interface PromotionsService
-
- All Known Implementing Classes:
DefaultPromotionEngineService
,DefaultPromotionsService
,DefaultSapPromotionEngineService
public interface PromotionsService
The 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 aProductModel
can 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 void
cleanupCart(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 ofAbstractPromotionModel
instances that are related to theProductModel
specified.java.util.List<? extends AbstractPromotionModel>
getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofAbstractPromotionModel
instances that are related to theProductModel
specified.PromotionGroupModel
getDefaultPromotionGroup()
Lookup the default promotion group created by the promotions extension.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<ProductPromotionModel>
getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.java.util.List<ProductPromotionModel>
getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.java.lang.String
getPromotionDescription(AbstractPromotionModel promotion)
Get the description of given promotion.PromotionGroupModel
getPromotionGroup(java.lang.String identifier)
Lookup a promotion group with the given identifier.PromotionOrderResults
getPromotionResults(AbstractOrderModel order)
Get the promotion results for the specified order.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.java.util.Collection<AbstractPromotionRestrictionModel>
getRestrictions(AbstractPromotionModel promotion)
Get the collection ofAbstractPromotionRestrictionModel
instances.void
transferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)
Transfer the promotions applied to a cart to a new order.PromotionOrderResults
updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
Update the promotions on the specifiedAbstractOrder
object.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 specifiedAbstractOrderModel
object.
-
-
-
Method Detail
-
getProductPromotions
java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.- Parameters:
promotionGroups
- The promotion groups to evaluateproduct
- The product that the promotions are related to- Returns:
- The list of
ProductPromotion
related to theProductModel
specified
-
getProductPromotions
java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.- 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
ProductPromotion
related to theProductModel
specified
-
getOrderPromotions
java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)
Get the ordered list ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofOrderPromotion
instances.- 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 ofAbstractPromotionModel
instances that are related to theProductModel
specified.- Parameters:
promotionGroups
- The promotion groups to evaluateproduct
- The product that the promotions are related to- Returns:
- The list of
AbstractPromotionModel
related to theProductModel
specified
-
getAbstractProductPromotions
java.util.List<? extends AbstractPromotionModel> getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofAbstractPromotionModel
instances that are related to theProductModel
specified.- 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
AbstractPromotionModel
related to theProductModel
specified
-
updatePromotions
PromotionOrderResults updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
Update the promotions on the specifiedAbstractOrder
object. 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 samePromotionOrderResults
can 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 specifiedAbstractOrderModel
object. 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.AutoApplyMode
is set toPromotionsManager.AutoApplyMode.KEEP_APPLIED
the state of any previously appliedPromotionResult
is 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 samePromotionOrderResults
can 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
- TheCart
to 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 ofAbstractPromotionRestrictionModel
instances.- Parameters:
promotion
- the promotion which restrictions should be returned- Returns:
- A collection of
AbstractPromotionRestrictionModel
instances 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
-
-