Class DefaultCartItemCatalogInformationService<P extends Product>
java.lang.Object
com.broadleafcommerce.cartoperation.service.mapping.DefaultCartItemCatalogInformationService<P>
- All Implemented Interfaces:
CartItemCatalogInformationService<P>
public class DefaultCartItemCatalogInformationService<P extends Product>
extends Object
implements CartItemCatalogInformationService<P>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCartItemCatalogInformationService(CartItemConfigurationService<Product> cartItemConfigurationService, List<CartItemProductMapper> cartItemProductMappers, CartOperationServiceProperties properties) DefaultCartItemCatalogInformationService(List<CartItemProductMapper> cartItemProductMappers) -
Method Summary
Modifier and TypeMethodDescriptionbuildItemAttributeChoices(@NonNull Map<String, String> requestItemAttributeChoices) protected com.broadleafcommerce.pricing.client.domain.PriceInfocleanPriceInfo(@NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) ExcludePriceableTargetinformation from thePriceInfoas it's unnecessary to calculate pricing.protected BroadleafProductService<Product>protected CartItemConfigurationService<Product>protected List<CartItemProductMapper>protected CartItemProductServicePropertiesgetCategoryIdsForProduct(P product) protected StringgetDataDrivenEnumId(DataDrivenEnum dataDrivenEnum) protected com.broadleafcommerce.cart.client.domain.ImageAssetRefgetImageAssetForProduct(P product) protected com.broadleafcommerce.cart.client.domain.ImageAssetRefgetImageAssetForVariant(@NonNull Variant variant, P product) protected IncludedProductConfigurationServiceprotected ItemChoiceConfigurationServicegetPriceableCharacteristics(P product) Gets the list ofCharacteristic field namesthat can be targeted for pricing.protected StringgetPricingKey(P product, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Returns the product price key, if specified, otherwise retrieves it from the cart item or generates a new one.protected CartOperationServicePropertiesgetTargetableCharacteristics(P product) Gets the list ofproduct characteristic valuesmapped by theirfield namesthat can be targeted in rule builders.protected voidhydrateIncludedProductDependentItems(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, P product, boolean isAdd) PopulateIncludedProductinformation onCartItem.getDependentCartItems()based on the product configuration.protected voidhydrateItemChoiceDependentItems(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, P product) PopulateItemChoiceinformation onCartItem.getDependentCartItems()based on the product configuration.identifyProductForCartItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList) Finds the catalog item that was added to the cart represented by the given cart item.protected booleanmatchesPreferredAssetTag(@NonNull com.broadleafcommerce.cart.client.domain.ImageAssetRef asset) Whether the given asset matches thepreferredAssetTagto help determine which product asset to show in the cart for the item.protected booleanmatchesVariantOption(@NonNull com.broadleafcommerce.cart.client.domain.ImageAssetRef asset, @NonNull String optionKey, @NonNull String optionValue) Whether the asset matches the given product option values belonging to a variant.protected voidpopulateAttributeChoiceLabelsFromOptions(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product) protected voidpopulateBasicInfo(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product) Hydrates basic product information onto a cart item.com.broadleafcommerce.cart.client.domain.CartItempopulateCatalogItemInformation(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, boolean isAdd, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populate catalog information within theCartItembased on the providedCatalogItemand the merchandising contextcom.broadleafcommerce.cart.client.domain.CartItempopulateCatalogItemInformation(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, @NonNull List<P> catalogItemList, boolean isAdd, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populate catalog information within theCartItembased on the providedCatalogItemand the merchandising contextprotected voidpopulateDependentItemInformation(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, @NonNull List<P> products, boolean isAdd) Deprecated.protected voidpopulateDependentItemInformation(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, @NonNull List<P> products, boolean isAdd, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidpopulateInternalAttributes(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product) Hydrates the internal attributes onto a cart item.populatePricingInfo(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, Variant variant) Handles setting catalog pricing info onto a cart item.protected voidpopulateVariantInfo(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, @NonNull Map<String, com.broadleafcommerce.pricing.client.domain.PriceInfo> skuPriceInfos, Variant variant) Hydrates variant info onto the cart item if a variant was added to cart.protected voidpopulateVariantInformation(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Variant variant, @NonNull Map<String, com.broadleafcommerce.pricing.client.domain.PriceInfo> skuPriceInfos) voidsetBroadleafProductService(BroadleafProductService<Product> broadleafProductService) voidsetCartItemProductServiceProperties(CartItemProductServiceProperties cartItemProductServiceProperties) voidsetIncludedProductService(IncludedProductConfigurationService includedProductService) voidsetItemChoiceService(ItemChoiceConfigurationService itemChoiceService)
-
Constructor Details
-
DefaultCartItemCatalogInformationService
-
DefaultCartItemCatalogInformationService
public DefaultCartItemCatalogInformationService(CartItemConfigurationService<Product> cartItemConfigurationService, List<CartItemProductMapper> cartItemProductMappers, CartOperationServiceProperties properties)
-
-
Method Details
-
populateCatalogItemInformation
public com.broadleafcommerce.cart.client.domain.CartItem populateCatalogItemInformation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, boolean isAdd, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemCatalogInformationServicePopulate catalog information within theCartItembased on the providedCatalogItemand the merchandising context- Specified by:
populateCatalogItemInformationin interfaceCartItemCatalogInformationService<P extends Product>- Parameters:
cartItem- The CartItem that is to be updated with catalog item datacatalogItemList- The catalog items that were retrieved for the add-to-cart, including dependent catalog itemsisAdd- Whether we are in an add-to-cart flowcontextInfo- Context information around sandbox and multitenant state- Returns:
- the updated CartItem that now contains CatalogItem data
-
populateCatalogItemInformation
public com.broadleafcommerce.cart.client.domain.CartItem populateCatalogItemInformation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product, @NonNull @NonNull List<P> catalogItemList, boolean isAdd, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemCatalogInformationServicePopulate catalog information within theCartItembased on the providedCatalogItemand the merchandising context- Specified by:
populateCatalogItemInformationin interfaceCartItemCatalogInformationService<P extends Product>- Parameters:
cartItem- The CartItem that is to be updated with catalog item dataproduct- The CatalogItem that this CartItem is intended to representcatalogItemList- The catalog items that were retrieved for the add-to-cart, including dependent catalog itemsisAdd- Whether we are in an add-to-cart flowcontextInfo- Context information around sandbox and multitenant state- Returns:
- the updated CartItem that now contains CatalogItem data
-
identifyProductForCartItem
protected Optional<P> identifyProductForCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList) Finds the catalog item that was added to the cart represented by the given cart item.- Parameters:
cartItem- Cart item to be hydrated with Catalog infocatalogItemList- The list of Catalog Items that match one of the cart items in the cart- Returns:
- The catalog item that matches the specific cart item.
-
populateBasicInfo
protected void populateBasicInfo(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product) Hydrates basic product information onto a cart item.- Parameters:
cartItem- The cart item to hydrateproduct- The product or parent product of a variant added to the cart- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
populateInternalAttributes
protected void populateInternalAttributes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product) Hydrates the internal attributes onto a cart item.- Parameters:
cartItem- The cart item to hydrateproduct- The product or parent product of a variant added to the cart- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
getPriceableCharacteristics
Gets the list ofCharacteristic field namesthat can be targeted for pricing.- Parameters:
product- Product to get characteristics from- Returns:
- The list of
Characteristic field namesthat can be targeted for pricing. - Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
getTargetableCharacteristics
Gets the list ofproduct characteristic valuesmapped by theirfield namesthat can be targeted in rule builders.- Parameters:
product- Product to get characteristics from- Returns:
- The list of
product characteristic valuesmapped by theirfield namesthat can be targeted in rule builders. - Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
populatePricingInfo
protected Map<String,com.broadleafcommerce.pricing.client.domain.PriceInfo> populatePricingInfo(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product, @Nullable Variant variant) Handles setting catalog pricing info onto a cart item. Returns the sku price info found as a map where the key is the sku and the value is the price info.- Parameters:
cartItem- The cart item to set catalog pricing info ontoproduct- The selected product to add to cartvariant- The selected variant to add to cart if any- Returns:
- The skue price infos
- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
populateVariantInfo
protected void populateVariantInfo(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product, @NonNull @NonNull Map<String, com.broadleafcommerce.pricing.client.domain.PriceInfo> skuPriceInfos, @Nullable Variant variant) Hydrates variant info onto the cart item if a variant was added to cart.- Parameters:
cartItem- The cart item to be hydratedproduct- The parent product of the variantskuPriceInfos- The price info discovered for the variantvariant- The variant to use for hydration- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
getDataDrivenEnumId
-
cleanPriceInfo
protected com.broadleafcommerce.pricing.client.domain.PriceInfo cleanPriceInfo(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) ExcludePriceableTargetinformation from thePriceInfoas it's unnecessary to calculate pricing.- Parameters:
priceInfo- The price info to clean up for addition to CartItem attributes- Returns:
- The price info with target information excluded
-
getPricingKey
protected String getPricingKey(@NonNull P product, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Returns the product price key, if specified, otherwise retrieves it from the cart item or generates a new one. This in general only needed for theDefaultProductType.MERCHANDISING_PRODUCTas it doesn't have the SKU and pricing key.- Parameters:
product- the product to get the pricing key fromcartItem- the cart item to get the pricing key from- Returns:
- the pricing key
-
getImageAssetForProduct
@Nullable protected com.broadleafcommerce.cart.client.domain.ImageAssetRef getImageAssetForProduct(@NonNull P product) -
getImageAssetForVariant
-
matchesPreferredAssetTag
protected boolean matchesPreferredAssetTag(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.ImageAssetRef asset) Whether the given asset matches thepreferredAssetTagto help determine which product asset to show in the cart for the item. This only checks for a matching asset tag.- Parameters:
asset- The asset to check for a match- Returns:
- Whether the asset matches the preferred tag.
- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
matchesVariantOption
protected boolean matchesVariantOption(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.ImageAssetRef asset, @NonNull @NonNull String optionKey, @NonNull @NonNull String optionValue) Whether the asset matches the given product option values belonging to a variant. By default, this matches against the asset's tags, converting theoptionKeyandoptionValueto upper and lower case as well to avoid case-sensitivity.- Parameters:
asset- The asset to check for a matchoptionKey- The variant's option key, e.g., coloroptionValue- The variant's option value, e.g., red- Returns:
- Whether the asset matches the variant's option.
- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
getCategoryIdsForProduct
-
populateVariantInformation
-
buildItemAttributeChoices
-
populateAttributeChoiceLabelsFromOptions
protected void populateAttributeChoiceLabelsFromOptions(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product) -
populateDependentItemInformation
@Deprecated protected void populateDependentItemInformation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product, @NonNull @NonNull List<P> products, boolean isAdd) Deprecated. -
populateDependentItemInformation
-
hydrateIncludedProductDependentItems
protected void hydrateIncludedProductDependentItems(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, @NonNull P product, boolean isAdd) PopulateIncludedProductinformation onCartItem.getDependentCartItems()based on the product configuration.- Parameters:
cartItem- The cart item on which to populate dependent item product configuration information.potentialDependentItems- The list ofCartItem.getDependentCartItems()to pick from to find a match for anIncludedProduct.product- The product with configuration to be used for hydration.isAdd- Whether we are in an add-to-cart flow
-
hydrateItemChoiceDependentItems
protected void hydrateItemChoiceDependentItems(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, @NonNull P product) PopulateItemChoiceinformation onCartItem.getDependentCartItems()based on the product configuration.- Parameters:
cartItem- The cart item on which to populate dependent item product configuration information.potentialDependentItems- The list ofCartItem.getDependentCartItems()to pick from to find a match for anItemChoice.product- The product with configuration to be used for hydration.
-
getCartItemConfigurationService
-
getCartItemProductMappers
-
getProperties
-
getBroadleafProductService
-
setBroadleafProductService
@Autowired public void setBroadleafProductService(BroadleafProductService<Product> broadleafProductService) -
getIncludedProductService
-
setIncludedProductService
@Autowired public void setIncludedProductService(IncludedProductConfigurationService includedProductService) -
getItemChoiceService
-
setItemChoiceService
-
getCartItemProductServiceProperties
-
setCartItemProductServiceProperties
@Autowired public void setCartItemProductServiceProperties(CartItemProductServiceProperties cartItemProductServiceProperties)
-