Class RelatedCategoriesProductContextContributor
java.lang.Object
com.broadleafcommerce.catalog.service.product.commerce.context.contributor.RelatedCategoriesProductContextContributor
- All Implemented Interfaces:
ProductDetailsContextContributor
,org.springframework.core.Ordered
public class RelatedCategoriesProductContextContributor
extends Object
implements ProductDetailsContextContributor
Contributes all of the related
Categories
to the ProductDetailsContext
.
This will look through all of the ItemChoices
and find all parent categories
for the resolved product.
Extend contributeOtherCategoryIds(java.util.Collection<T>, com.broadleafcommerce.data.tracking.core.context.ContextInfo)
to contribute other category IDs before fetching all
of the related category.
- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionRelatedCategoriesProductContextContributor
(CategoryService<Category> categoryService, CategoryProductService<CategoryProduct> categoryProductService, 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>
Set<String>contributeOtherCategoryIds
(@NonNull Collection<T> productDetailsContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extension point for contributing other category IDs to the set.protected CategoryProductService<CategoryProduct>
protected CategoryService<Category>
int
getOrder()
protected com.broadleafcommerce.common.extension.TypeFactory
-
Field Details
-
DEFAULT_ORDER
public static final int DEFAULT_ORDER- See Also:
-
-
Constructor Details
-
RelatedCategoriesProductContextContributor
public RelatedCategoriesProductContextContributor(CategoryService<Category> categoryService, CategoryProductService<CategoryProduct> categoryProductService, 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.
-
contributeOtherCategoryIds
protected <T extends ProductDetailsContext> Set<String> contributeOtherCategoryIds(@NonNull @NonNull Collection<T> productDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extension point for contributing other category IDs to the set.- Parameters:
productDetailsContext
- The context to which to contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- A set of category IDs related to the
resolved product
.
-
getCategoryService
-
getCategoryProductService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-