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:
-
Method Summary
Modifier and TypeMethodDescriptionreadAvailableInventory
(String skuRefFieldTpe, Map<String, Integer> skuReferences, String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method is used to findSkuInventory
at a specificInventoryLocation
.readAvailableInventory
(String skuRefFieldTpe, Map<String, Integer> skuReferences, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, 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 inInventoryLocation
s that allow pickup, shipping, or in-store shopping.readAvailableInventoryForShip
(String skuRefFieldTpe, Map<String, Integer> skuReferenceQuantities, Optional<String> inventoryLocationId, Optional<Address> address, 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.
-
Method Details
-
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 inInventoryLocation
s that allow pickup, shipping, or in-store shopping. This method does not necessarily discriminate about whichInventoryLocation
, 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 findingSkuInventory
for inventory reservation.- Parameters:
skuRefFieldTpe
- - the type of sku reference (see DefaultSkuReferenceFieldType).skuReferences
- - the values with which to look upSkuInventory
based on the skuRefFieldTpeforShip
- - informs whether inventory should be searched inInventoryLocation
s that allow shippingforPickup
- - informs whether inventory should be searched inInventoryLocation
s that allow pickupinStore
- - informs whether inventory should be searched inInventoryLocation
s that allow in-store shoppingcontextInfo
-- 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 findSkuInventory
at a specificInventoryLocation
. 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 theInventoryLocation
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 requestedinventoryLocationId
- - the inventory location idcontextInfo
-- 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 theAddress
argument, if provided, to find the closestInventoryLocation
s, 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 requestedinventoryLocationId
- - 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 theInventoryLocation
s. This is required if inventoryLocationId is not present.contextInfo
-- Returns:
-