Interface SkuInventoryAvailabilityStrategy<I extends SkuInventory>

  • All Known Implementing Classes:
    DefaultSkuInventoryAvailabilityStrategy

    public interface SkuInventoryAvailabilityStrategy<I extends SkuInventory>
    Implementors of this interface provide logic to retrieve inventory availability for browsing and for decrementing SkuInventory associated with Soft and Hard inventory reservations. This component is not intended to handle changes or 'writes' (insert, update, delete) to SkuInventory. It is also not intended to handle queries for back-office functions. Rather, it's meant to provide a strategy to allow customers to find the appropriate inventory availability for browsing, and the the appropriate SkuInventory records for reservation by the customer (reservation is handled by another component). Implementors may wish to ensure that inventory records are available at a single location; or that inventory records are available at the closest location to a physical address; or a combination. In other words, the decision of where to source inventory, especially for shipping to the customer, can be quite different from one company to another. This allows for pluggable heuristics, providing different implementors the option to use different algorithms for determining availability and for determining from which InventoryLocation(s) SkuInventory should be retrieved and, eventually, decremented and reserved.
    Author:
    Kelly Tisdell (ktisdell)
    See Also:
    InventoryTransactionType, DefaultInventoryTransactionType.SOFT_RESERVED, DefaultInventoryTransactionType.HARD_RESERVED, SkuInventoryService, SkuInventoryAdjustmentService
    • Method Detail

      • readAvailableInventory

        List<I> readAvailableInventory​(@NonNull
                                       String skuRefFieldTpe,
                                       @NonNull
                                       Map<String,​Integer> skuReferences,
                                       Optional<Boolean> forShip,
                                       Optional<Boolean> forPickup,
                                       Optional<Boolean> inStore,
                                       @Nullable
                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        This reads inventory that is generally available (has at least 1 item at the time of the query) that are available in InventoryLocations that allow pickup, shipping, or in-store shopping. This method does not necessarily discriminate about which InventoryLocation, except that whether that location satisfies the pickup, shipping, or in-store shopping allowance. This is best used for general browsing (e.g. product list pages - PLP), when general availability is required and specific inventory reservations are not required. This should NOT be used for finding SkuInventory for inventory reservation.
        Parameters:
        skuRefFieldTpe - - the type of sku reference (see DefaultSkuReferenceFieldType).
        skuReferences - - the values with which to look up SkuInventory based on the skuRefFieldTpe
        forShip - - informs whether inventory should be searched in InventoryLocations that allow shipping
        forPickup - - informs whether inventory should be searched in InventoryLocations that allow pickup
        inStore - - informs whether inventory should be searched in InventoryLocations that allow in-store shopping
        contextInfo -
        Returns:
      • readAvailableInventory

        List<I> readAvailableInventory​(@NonNull
                                       String skuRefFieldTpe,
                                       @NonNull
                                       Map<String,​Integer> skuReferences,
                                       @Nullable
                                       String inventoryLocationId,
                                       @Nullable
                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        This method is used to find SkuInventory at a specific InventoryLocation. This can be useful for determining if a Store or a Pickup location have inventory available. This method MAY be used for determining which inventory is should be reserved when the InventoryLocation is known. This method returns inventory with at least the provided quantity available item at the time of the query.
        Parameters:
        skuRefFieldTpe - - the type of sku reference (see DefaultSkuReferenceFieldType).
        skuReferences - - map of SKU Reference to quantity requested
        inventoryLocationId - - the inventory location id
        contextInfo -
        Returns:
      • readAvailableInventoryForShip

        List<I> readAvailableInventoryForShip​(@NonNull
                                              String skuRefFieldTpe,
                                              @NonNull
                                              Map<String,​Integer> skuReferenceQuantities,
                                              @NonNull
                                              Optional<String> inventoryLocationId,
                                              @NonNull
                                              Optional<Address> address,
                                              @Nullable
                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        This method is generally used to determine which inventory should be reserved in a ship-to scenario, where the customer does not select the ship-from location. Implementors may wish to use the Address argument, if provided, to find the closest InventoryLocations, or they may wish to use the provided inventoryLocationId, which must be a Shipping location. Implementors may choose to override this method to a provide an algorithm-based approach, such as geographically closest locations or locations with the highest amount of inventory, or locations that can fulfill the most items. The decision on the best approach to inventory reservation and fulfillment may be different for each company, and so this is expected to be overridden and customized. Either inventoryLocationId or address is required.
        Parameters:
        skuRefFieldTpe -
        skuReferenceQuantities - - map of SKU Reference to quantity requested
        inventoryLocationId - - specifies the location, in lieu of an address, from which to check inventory. This is required if address is not present.
        address - - optional information to assist in choosing the InventoryLocations. This is required if inventoryLocationId is not present.
        contextInfo -
        Returns: