Class RelatedVariantsProductContextContributor

java.lang.Object
com.broadleafcommerce.catalog.service.product.commerce.context.contributor.RelatedVariantsProductContextContributor
All Implemented Interfaces:
ProductDetailsContextContributor, org.springframework.core.Ordered

public class RelatedVariantsProductContextContributor extends Object implements ProductDetailsContextContributor
Contributes all of the related Variants to the ProductDetailsContext. This will look through all of the IncludedProducts, ItemChoices, and related products.

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

Extend contributeOtherVariantIds(java.util.Collection<T>, 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

    • RelatedVariantsProductContextContributor

      public RelatedVariantsProductContextContributor(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 <T extends ProductDetailsContext> Collection<T> contribute(@NonNull @NonNull Collection<T> productDetailsContexts, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductDetailsContextContributor
      Contributes to the supplied ProductDetailsContext. This should not mutate the inputted context, but return a new one with the new contributions.
      Specified by:
      contribute in interface ProductDetailsContextContributor
      Parameters:
      productDetailsContexts - The contexts to which to contribute
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      A version of the supplied ProductDetailsContext with the new contributions.
    • contributeOtherVariantIds

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

      protected VariantService<Variant> getVariantService()
    • getTypeFactory

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