Class RelatedProductsCategoryContextContributor

java.lang.Object
com.broadleafcommerce.catalog.service.category.commerce.context.contributor.RelatedProductsCategoryContextContributor
All Implemented Interfaces:
CategoryDetailsContextContributor, org.springframework.core.Ordered

public class RelatedProductsCategoryContextContributor extends Object implements CategoryDetailsContextContributor
Contributes all of the related Products to the CategoryDetailsContext.
Author:
Nathan Moore (nathandmoore)
  • Field Details

  • Constructor Details

  • Method Details

    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • contribute

      public CategoryDetailsContext contribute(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CategoryDetailsContextContributor
      Contributes to the supplied CategoryDetailsContext. This should not mutate the inputted context, but return a new one with the new contributions.
      Specified by:
      contribute in interface CategoryDetailsContextContributor
      Parameters:
      categoryDetailsContext - The context to which to contribute
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      A version of the supplied CategoryDetailsContext with the new contributions.
    • getPromotionalProductsToContribute

      protected List<PromotionalCategoryProduct> getPromotionalProductsToContribute(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Collects all of the PromotionalCategoryProducts related to the resolved category.
      Parameters:
      categoryDetailsContext - The context to which to contribute
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      all of the PromotionalCategoryProducts related to the resolved category.
    • getCategoryProductIdsToContribute

      protected Map<String,org.springframework.data.domain.Page<String>> getCategoryProductIdsToContribute(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Collects the IDs of all the products related to the resolved category through related CategoryProducts. Returns a map Category IDs to a page of product IDs.

      Note that only the product IDs are hydrated onto the CategoryProduct so there's no point in saving the entire product ref here.

      Parameters:
      categoryDetailsContext - The context to which to contribute
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      a map of the product IDs to the IDs of their Categories.
    • contributeOtherProductIds

      protected Set<String> contributeOtherProductIds(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Extension point for contributing other product IDs to the set.
      Parameters:
      categoryDetailsContext - The context to which to contribute
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      A set of product IDs related to the resolved category.
    • contributeRelatedProducts

      @Deprecated protected final CategoryDetailsContext contributeRelatedProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Set<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • contributeRelatedProducts

      protected final CategoryDetailsContext contributeRelatedProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Set<String> productIds, @NonNull @NonNull Map<String,org.springframework.data.domain.Page<String>> categoryProductIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Fetches and contributes the related products to the CategoryDetailsContext.
      Parameters:
      categoryDetailsContext - The context to which to contribute
      productIds - Ids of the Products to fetch and contribute
      categoryProductIds - Mapping of Category Ids to a page of Products
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      A version of the supplied CategoryDetailsContext with the new contributions.
    • contributeRelatedCategoryProducts

      protected final CategoryDetailsContext contributeRelatedCategoryProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Map<String,org.springframework.data.domain.Page<String>> categoryProductsMap)
      Contributes the related category products to the CategoryDetailsContext.
      Parameters:
      categoryDetailsContext - The context to which to contribute
      categoryProductsMap - Map of category IDs to Product IDs for the CategoryProducts to contribute.
      Returns:
      A version of the supplied CategoryDetailsContext with the new contributions.
    • contributeRelatedPromoProducts

      protected final CategoryDetailsContext contributeRelatedPromoProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Collection<PromotionalCategoryProduct> promotionalProducts)
      Parameters:
      categoryDetailsContext - The context to which to contribute
      promotionalProducts - PromotionalCategoryProducts related to the category
      Returns:
      the CategoryDetailsContext with CategoryDetailsContext.getRelatedPromotionalProducts().
    • getRuleBaseProducts

      protected Map<String,ProductSummary> getRuleBaseProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Map<String,org.springframework.data.domain.Page<String>> categoryProductIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      If the resolved Category is CategoryProductMembershipType.RULE_BASED, then this method fetches all the Products that match the rule.
      Parameters:
      categoryDetailsContext - The contexts to which to contribute
      contextInfo - Additional sandbox and tenancy info
      Returns:
      A mapping of the related products by their ids.
    • getCategoryProductService

      protected CategoryProductService<CategoryProduct> getCategoryProductService()
    • getPromoCategoryProductService

      protected PromotionalCategoryProductService<PromotionalCategoryProduct> getPromoCategoryProductService()
    • getProductService

      protected ProductService<Product> getProductService()
    • getTypeFactory

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

      @Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager()
    • setRsqlFilterParser

      @Autowired public void setRsqlFilterParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser rsqlFilterParser)
    • getRsqlFilterParser

      protected com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser getRsqlFilterParser()
    • setCacheByProductContributionKeyGen

      @Autowired @Qualifier("catalogCacheByProductContribution") public void setCacheByProductContributionKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByProductContributionKeyGen)
      See Also:
    • getCacheByProductContributionKeyGen

      @Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByProductContributionKeyGen()
      See Also:
    • setCacheByRuleProductContributionKeyGen

      @Autowired @Qualifier("catalogCacheByRuleProductContribution") public void setCacheByRuleProductContributionKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByRuleProductContributionKeyGen)
      See Also:
    • getCacheByRuleProductContributionKeyGen

      @Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByRuleProductContributionKeyGen()
      See Also: