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 of the product IDs to the IDs of their Categories.

      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

      protected final CategoryDetailsContext contributeRelatedProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Set<String> productIds, @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
      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().
    • 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()
    • 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: