Class DefaultMarketingMessageUtils

java.lang.Object
com.broadleafcommerce.catalogbrowse.service.DefaultMarketingMessageUtils
All Implemented Interfaces:
MarketingMessageUtils

public class DefaultMarketingMessageUtils extends Object implements MarketingMessageUtils
Utilities to aid in the retrieval of MarketingMessages
Author:
Jon Fleschler (jfleschler)
  • Constructor Details

    • DefaultMarketingMessageUtils

      public DefaultMarketingMessageUtils(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • Method Details

    • buildLineItems

      public List<LineItemDTO> buildLineItems(@NonNull @NonNull ProductList productDetails, boolean buildForAllTermsAndFrequencies, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: MarketingMessageUtils
      Build LineItemDTOs from hydrated product details.
      Specified by:
      buildLineItems in interface MarketingMessageUtils
      Parameters:
      productDetails - the hydrated product details
      buildForAllTermsAndFrequencies - whether to build LineItemDTOs for all available terms and frequencies for each product. If true, all available frequencies will be fetched based on Product.getTerms() and LineItemDTOs are built for each term and frequency combination.
      priceContext - the PriceContext containing details about the currency
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      list of LineItemDTOs
    • populateProductsWithAllTermsAndFrequencies

      protected <T extends Product> List<T> populateProductsWithAllTermsAndFrequencies(@NonNull @NonNull List<T> products, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Populates a new list of Products for each available term and frequency combination for each product in the input list.

      This method will fetch the PriceInfos for all available term and frequency combinations for each product, and clone the product (and variants if it has them) and set the corresponding PriceInfo for each combination.

      This is to ensure that MarketingMessages for Offers that are targeting a specific term or frequency will be properly fetched.

      Parameters:
      products - the list of products to populate
      priceContext - the PriceContext containing details about the currency
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a new list of Products with each available term and frequency combination
      Since:
      Catalog Browse Service 2.2.0, Release Train 2.3.0
    • fetchPriceInfosWithAllAvailableTermAndFrequencies

      protected <T extends Product> List<com.broadleafcommerce.pricing.client.domain.PriceInfo> fetchPriceInfosWithAllAvailableTermAndFrequencies(@NonNull @NonNull List<T> products, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Fetches the PriceInfos for all available term and frequency combinations for the given products.

      This will build a PriceableTarget for each Product.getTerms() and SKUs.

      Parameters:
      products - the list of products to fetch the PriceInfos for
      priceContext - the PriceContext containing details about the currency
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a list of PriceInfos for all available term and frequency combinations for the given products
      Since:
      Catalog Browse Service 2.2.0, Release Train 2.3.0
    • addTargetsForProduct

      protected void addTargetsForProduct(@NonNull @NonNull Map<Object,Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>> targetsMap, @NonNull @NonNull Product product)
      Adds the PriceableTargets for the given Product to the given map.

      This will add a target for the product's SKU and each variant SKU, then duplicated for each Product.getTerms() if it has any.

      Parameters:
      targetsMap - a map of SKU to PriceableTargets
      product - the Product to add the targets for
      Since:
      Catalog Browse Service 2.2.0, Release Train 2.3.0
    • buildLineItemFromVariant

      protected LineItemDTO buildLineItemFromVariant(@NonNull @NonNull Product product, @NonNull @NonNull Variant variant)
    • populateLineItemPricing

      protected void populateLineItemPricing(@NonNull @NonNull LineItemDTO item, @NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
    • populateLineItemRecurringPricing

      protected void populateLineItemRecurringPricing(@NonNull @NonNull LineItemDTO item, @NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
      Populates the recurring pricing for the given LineItemDTO based on the given PriceInfo.
      Parameters:
      item - the LineItemDTO to populate
      priceInfo - the PriceInfo to get the recurring pricing from
      Since:
      Catalog Browse Service 2.2.0, Release Train 2.3.0
    • getCategoryIds

      protected List<String> getCategoryIds(Map<String,Object> attributes)
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getBrowsePricingProvider

      protected PricingProvider getBrowsePricingProvider()
    • setBrowsePricingProvider

      @Autowired public void setBrowsePricingProvider(PricingProvider browsePricingProvider)