Class DefaultCartItemMergingService<I extends com.broadleafcommerce.cart.client.domain.CartItem>

All Implemented Interfaces:
CartItemMergingService<I>, ItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I>

public class DefaultCartItemMergingService<I extends com.broadleafcommerce.cart.client.domain.CartItem> extends AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I> implements CartItemMergingService<I>
The default implementation of a cart item merging service.
Skye Pekerti
  • Constructor Details

  • Method Details

    • getItemsFromContainer

      protected Collection<I> getItemsFromContainer(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart container, @Nullable context)
      Description copied from class: AbstractItemMergingService
      Gets the from the item container.
      Specified by:
      getItemsFromContainer in class AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>
      container - the container to fetch the items from
      context - the context of the request
      the items from the container
    • isSameItem

      protected boolean isSameItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item1, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item2)
      Description copied from class: AbstractItemMergingService
      Tells if two item instances are actually the same instance. This would typically be determined by something like the item ID. Note that this does NOT indicate that "these items are the same so they should be merged". This is used to prevent creating an item match with itself during an update scenario.
      Specified by:
      isSameItem in class AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>
      item1 - an item to compare
      item2 - another item to compare
      true if the two items are referring to the same instance
    • hashMatchingCriteria

      protected String hashMatchingCriteria(@NonNull I item)
      Generates a hash for any information on the item that should be used to determine if they represent the same item configuration. This implementation uses the following criteria:
      - attribute choices, which are product options of type CART_ITEM_ATTRIBUTE or VARIANT_DISTINGUISHING
      - sku, which uniquely identifies products and their variations
      - merchandising context, which identifies selector products
      - pricing key
      Specified by:
      hashMatchingCriteria in class AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>
      item - the item to generate a hash for
      a hashed string of some subset of the items attributes
    • resolveMergeTypes

      protected void resolveMergeTypes(@NonNull @NonNull List<MergeItemPair<I>> mergeItemPairs, @Nullable context)
      Description copied from class: AbstractItemMergingService
      Determines what merge types should be used for the items and applies it to the merge item pairs.
      Specified by:
      resolveMergeTypes in class AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>
      mergeItemPairs - the item pairs to resolve the merge types for
    • buildCatalogItemRequestsForMergeItem

      protected Collection<CatalogItemRequest> buildCatalogItemRequestsForMergeItem(@NonNull @NonNull List<MergeItemPair<I>> mergeItemPairs, @Nullable context)
    • buildCatalogItemRequest

      protected CatalogItemRequest buildCatalogItemRequest(@NonNull @NonNull MergeItemPair<I> mergeItemPair, @Nullable context)
      Hook point to build the CatalogItemRequest and populate any additional attributes that should be passed to the CatalogProvider when fetching the catalog representation for merging the cart item.
      mergeItemPair - the MergeItemPair containing the details for the item merge
      context - context information around sandbox and multitenant state
      the populated CatalogItemRequest for the MergeItemPair
    • identifyCatalogItemKey

      protected String identifyCatalogItemKey(@NonNull @NonNull MergeItemPair<I> mergeItemPair, @Nullable context)
    • doMergeCombine

      protected void doMergeCombine(@NonNull @NonNull MergeItemPair<I> itemPair)
      Description copied from class: AbstractItemMergingService
      Perform the actual combination of two items (quantity change) for the combination merge type.
      Specified by:
      doMergeCombine in class AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>
      itemPair - the item pair to combine
    • getProviders

      protected CartOperationServiceProviders getProviders()
    • getProperties

      protected CartOperationServiceProperties getProperties()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getTypeFactory

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

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)