Class RelatedVariantsCategoryContextContributor

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

public class RelatedVariantsCategoryContextContributor extends Object implements CategoryDetailsContextContributor
Contributes all of the related Variants to the CategoryDetailsContext. This will look for direct variants of the related products.

This should be run after RelatedProductsCategoryContextContributor to allow us to gather all the variants at once.

Extend contributeOtherVariantIds(com.broadleafcommerce.catalog.domain.category.commerce.CategoryDetailsContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo) to contribute other variant IDs before fetching all of the related variants.

Author:
Nathan Moore (nathandmoore)
  • Field Details

  • Constructor Details

    • RelatedVariantsCategoryContextContributor

      public RelatedVariantsCategoryContextContributor(VariantService<Variant> variantService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • 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.
    • contributeOtherVariantIds

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

      protected VariantService<Variant> getVariantService()
    • getTypeFactory

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