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 Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionRelatedVariantsProductContextContributor
(VariantService<Variant> variantService, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescription<T extends ProductDetailsContext>
Collection<T>contribute
(@NonNull Collection<T> productDetailsContexts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Contributes to the suppliedProductDetailsContext
.protected <T extends ProductDetailsContext>
Map<String,Set<String>> contributeOtherVariantIds
(@NonNull Collection<T> productDetailsContexts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extension point for contributing other variant IDs to the set.int
getOrder()
protected com.broadleafcommerce.common.extension.TypeFactory
protected VariantService<Variant>
-
Field Details
-
DEFAULT_ORDER
public static final int DEFAULT_ORDER- See Also:
-
-
Constructor Details
-
RelatedVariantsProductContextContributor
public RelatedVariantsProductContextContributor(VariantService<Variant> variantService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.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 suppliedProductDetailsContext
. This should not mutate the inputted context, but return a new one with the new contributions.- Specified by:
contribute
in interfaceProductDetailsContextContributor
- Parameters:
productDetailsContexts
- The contexts to which to contributecontextInfo
- 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 contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- A set of variant IDs related to the
resolved product
.
-
getVariantService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-