Class DefaultBundleCommerceRuleService

  • All Implemented Interfaces:
    BundleRuleService
    Direct Known Subclasses:
    DefaultBundleRuleService

    public class DefaultBundleCommerceRuleService
    extends java.lang.Object
    implements BundleRuleService
    Default implementation of the bundle rule service BundleRuleService. It searches for the the lowest price (based on bundle price rules) for a product that is a part of a bundle.
    • Constructor Detail

      • DefaultBundleCommerceRuleService

        public DefaultBundleCommerceRuleService()
    • Method Detail

      • getChangePriceBundleRule

        @Nullable
        public ChangeProductPriceBundleRuleModel getChangePriceBundleRule​(@Nonnull
                                                                          BundleTemplateModel targetComponent,
                                                                          @Nonnull
                                                                          ProductModel targetProduct,
                                                                          @Nonnull
                                                                          ProductModel conditionalProduct,
                                                                          @Nonnull
                                                                          CurrencyModel currency)
        Description copied from interface: BundleRuleService
        Returns a ChangeProductPriceBundleRuleModel valid for the given targetProduct. The method calculates (forecasts) the lowest product price for the given targetProduct which shall be added to a bundle based on the given bundle template (targetComponent) in combination with the given conditionalProduct. The bundle or a cart to which the given products should be added may or may not yet exist. The method just forecasts the possible price for the given combination of input parameters.
        Specified by:
        getChangePriceBundleRule in interface BundleRuleService
        Parameters:
        targetComponent - bundle template based on which the given targetProduct is or shall be added to a bundle
        targetProduct - product that is added to a bundle and for which the product price is calculated
        conditionalProduct - second product that is added to the same bundle as the given targetProduct and that is the condition for a ChangeProductPriceBundleRuleModel to be selected
        currency - the currency the ChangeProductPriceBundleRuleModel must match to be selected
        Returns:
        a ChangeProductPriceBundleRuleModel if existing or null
      • evaluateBundleRules

        protected AbstractBundleRuleModel evaluateBundleRules​(java.util.List<AbstractBundleRuleModel> bundleRules,
                                                              ProductModel product,
                                                              java.util.Set<ProductModel> otherProductsInSameBundle)
        Evaluates if any of the given bundleRules is applicable for the given product in the context of the list of other products that are already in the same bundle. Depending on whether the given product is a target or a conditional product of the bundleRule the check itself is done either in method checkBundleRuleForTargetProduct or method checkBundleRuleForConditionalProduct.
      • getCartProductsInSameBundle

        protected java.util.Set<ProductModel> getCartProductsInSameBundle​(AbstractOrderModel order,
                                                                          ProductModel product,
                                                                          EntryGroup bundleEntryGroup)
        Returns a list of of products that belong to the same bundle entry group in the given multi-cart as the given product
      • checkBundleRuleForTargetProduct

        protected boolean checkBundleRuleForTargetProduct​(AbstractBundleRuleModel rule,
                                                          java.util.Set<ProductModel> otherProductsInSameBundle)
        Applies the rules for conditional products to check if the given rule meets the requirements. Returns true if the given list of products otherProductsInSameBundle matches the list of conditional products of the given rule, otherwise false.
      • checkBundleRuleForConditionalProduct

        protected boolean checkBundleRuleForConditionalProduct​(AbstractBundleRuleModel bundleRule,
                                                               java.util.Set<ProductModel> otherProductsInSameBundle,
                                                               ProductModel product)
        Applies the check logic for disable product rules to test if the given bundleRule meets the requirements. Returns true if the given bundleRule is of type "ALL" and the given product is listed as a conditional product, all other conditional products and at least one of the target products are already added to the bundle in the cart. It also returns true if the given bundleRule is of type "ANY" and the given product is listed as a conditional product and at least one of the target products is already added to the bundle in the cart. In all other cases it returns false. It is assumed that the given product is in the list of conditional products of the given bundleRule.
      • unrestricted

        protected <A extends ItemModel,​R> R unrestricted​(A model,
                                                               java.util.function.Function<A,​R> getter)
        Executes getter in search-restrictions-off context.
        Type Parameters:
        A - type of the object
        R - type of the data
        Parameters:
        model - persistent object to get data from
        getter - data obtaining logic
        Returns:
        data collected in restriction-free content
      • setBundleTemplateService

        public void setBundleTemplateService​(BundleTemplateService bundleTemplateService)
      • getDisableProductBundleRuleDao

        protected BundleRuleDao getDisableProductBundleRuleDao()
      • setDisableProductBundleRuleDao

        public void setDisableProductBundleRuleDao​(BundleRuleDao disableProductBundleRuleDao)
      • setSearchRestrictionService

        public void setSearchRestrictionService​(SearchRestrictionService searchRestrictionService)
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • setSessionService

        public void setSessionService​(SessionService sessionService)
      • setEntryGroupService

        public void setEntryGroupService​(EntryGroupService entryGroupService)
      • getL10NService

        protected L10NService getL10NService()
      • setL10NService

        public void setL10NService​(L10NService l10nService)