Class DefaultAddProductToCartActionStrategy
- java.lang.Object
-
- de.hybris.platform.promotionengineservices.action.impl.AbstractRuleActionStrategy<RuleBasedOrderAddProductActionModel>
-
- de.hybris.platform.promotionengineservices.action.impl.DefaultAddProductToCartActionStrategy
-
- All Implemented Interfaces:
RuleActionStrategy,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware
public class DefaultAddProductToCartActionStrategy extends AbstractRuleActionStrategy<RuleBasedOrderAddProductActionModel>
Encapsulates logic of adding new order entry and give a 100% discount for it.
-
-
Constructor Summary
Constructors Constructor Description DefaultAddProductToCartActionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected AbstractOrderEntryModeladdNewEntry(AbstractOrderModel order, ProductModel product, int quantityToAdd)java.util.List<PromotionResultModel>apply(AbstractRuleActionRAO action)If the parameter action is of typeDiscountRAOand is applied to Order Entry the discount is added to corresponding Order Entry model.protected RuleBasedOrderAddProductActionModelcreateOrderAddProductAction(AbstractRuleActionRAO action, int quantity, ProductModel product, PromotionResultModel promoResult)protected AbstractOrderEntryModelfindMatchingGiveAwayEntry(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action)Deprecated, for removal: This API element is subject to removal in a future version.protected AbstractOrderEntryModelfindMatchingGiveAwayEntry(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action, java.util.function.BiPredicate<RuleBasedOrderAddProductActionModel,AbstractOrderEntryModel> matchingCondition)protected AbstractOrderEntryModelfindOrderEntryForUndo(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action)tries to find an order entry usable for theundo(ItemModel)method based on matching product, quantity andgiveAwayflag: First tries to match an order entry that is marked asgiveAwaywith the same product and quantity.protected CartServicegetCartService()protected AbstractOrderEntryModelgetEntryWithMatchingProductAndQuantity(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action)Deprecated, for removal: This API element is subject to removal in a future version.since 1905protected java.util.Optional<AbstractOrderEntryModel>getExistingGiveAwayEntry(AbstractOrderModel order, ProductModel product)protected OrderServicegetOrderService()protected OrderUtilsgetOrderUtils()protected ProductServicegetProductService()protected RuleEngineCalculationServicegetRuleEngineCalculationService()protected voidnormalizeEntryNumbers(AbstractOrderModel order)normalizes the givenorder's entries by assigning them increasing entry numbers starting from 0.voidsetCartService(CartService cartService)voidsetOrderService(OrderService orderService)voidsetOrderUtils(OrderUtils orderUtils)voidsetProductService(ProductService productService)voidsetRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService)voidundo(ItemModel item)Revokes the Promotion Action that was applied.-
Methods inherited from class de.hybris.platform.promotionengineservices.action.impl.AbstractRuleActionStrategy
createPromotionAction, getActionUtils, getCalculationService, getExtendedOrderDao, getForceImmediateRecalculation, getMetadataHandlers, getModelService, getPromotionAction, getPromotionActionService, getPromotionResultUtils, getRuleActionMetadataHandlers, getStrategyId, handleActionMetadata, handleUndoActionMetadata, recalculateIfNeeded, setActionUtils, setBeanName, setCalculationService, setExtendedOrderDao, setForceImmediateRecalculation, setModelService, setPromotionAction, setPromotionActionService, setPromotionResultUtils, setRuleActionMetadataHandlers, undoInternal
-
-
-
-
Method Detail
-
apply
public java.util.List<PromotionResultModel> apply(AbstractRuleActionRAO action)
If the parameter action is of typeDiscountRAOand is applied to Order Entry the discount is added to corresponding Order Entry model.- Parameters:
action- the action to apply- Returns:
- list of
PromotionResultModelas a result of theDiscountRAOapplication.
-
addNewEntry
protected AbstractOrderEntryModel addNewEntry(AbstractOrderModel order, ProductModel product, int quantityToAdd)
-
getExistingGiveAwayEntry
protected java.util.Optional<AbstractOrderEntryModel> getExistingGiveAwayEntry(AbstractOrderModel order, ProductModel product)
-
createOrderAddProductAction
protected RuleBasedOrderAddProductActionModel createOrderAddProductAction(AbstractRuleActionRAO action, int quantity, ProductModel product, PromotionResultModel promoResult)
-
undo
public void undo(ItemModel item)
Description copied from interface:RuleActionStrategyRevokes the Promotion Action that was applied.- Parameters:
item- the action to be undone
-
normalizeEntryNumbers
protected void normalizeEntryNumbers(AbstractOrderModel order)
normalizes the givenorder's entries by assigning them increasing entry numbers starting from 0. This method is called during theundo(ItemModel)call of this action if the undo removes an order entry completely.- Parameters:
order- the order to normalize
-
findOrderEntryForUndo
protected AbstractOrderEntryModel findOrderEntryForUndo(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action)
tries to find an order entry usable for theundo(ItemModel)method based on matching product, quantity andgiveAwayflag: First tries to match an order entry that is marked asgiveAwaywith the same product and quantity. If none is found, tries to find an entry with just matching product and quantity. If still none is found, tries to find an entry for the given product with higher quantity.- Parameters:
order- the order to look for an order entry foraction- the action- Returns:
- an order entry or null if no matching one is found
-
getEntryWithMatchingProductAndQuantity
@Deprecated(since="1905", forRemoval=true) protected AbstractOrderEntryModel getEntryWithMatchingProductAndQuantity(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action)Deprecated, for removal: This API element is subject to removal in a future version.since 1905- Returns:
- if exists, an order entry with matching product and quantity, null otherwise
-
findMatchingGiveAwayEntry
@Deprecated(since="1905", forRemoval=true) protected AbstractOrderEntryModel findMatchingGiveAwayEntry(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action)Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- if exists give-away order entry with matching product and quantity , null otherwise
-
findMatchingGiveAwayEntry
protected AbstractOrderEntryModel findMatchingGiveAwayEntry(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action, java.util.function.BiPredicate<RuleBasedOrderAddProductActionModel,AbstractOrderEntryModel> matchingCondition)
- Returns:
- if exists give-away order entry with matching product and quantity , null otherwise
-
getCartService
protected CartService getCartService()
-
setCartService
public void setCartService(CartService cartService)
-
getProductService
protected ProductService getProductService()
-
setProductService
public void setProductService(ProductService productService)
-
getRuleEngineCalculationService
protected RuleEngineCalculationService getRuleEngineCalculationService()
-
setRuleEngineCalculationService
public void setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService)
-
getOrderService
protected OrderService getOrderService()
-
setOrderService
public void setOrderService(OrderService orderService)
-
getOrderUtils
protected OrderUtils getOrderUtils()
-
setOrderUtils
public void setOrderUtils(OrderUtils orderUtils)
-
-