ProductVariantInventoryService
Constructors
constructor
**new ProductVariantInventoryService**(«destructured»)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredinventoryService_
Protected get**inventoryService_**(): [IInventoryService](/references/services/interfaces/IInventoryService)
Returns
adjustInventory
(inventoryItemId: string, locationId: string, adjustment: number, context?: SharedContext) => Promise<InventoryLevelDTO>RequiredconfirmInventory
(inventoryItemId: string, locationIds: string[], quantity: number, context?: SharedContext) => Promise<boolean>RequiredcreateInventoryItem
(input: CreateInventoryItemInput, context?: SharedContext) => Promise<InventoryItemDTO>RequiredcreateInventoryItems
(input: CreateInventoryItemInput[], context?: SharedContext) => Promise<InventoryItemDTO[]>RequiredcreateInventoryLevel
(data: CreateInventoryLevelInput, context?: SharedContext) => Promise<InventoryLevelDTO>RequiredcreateInventoryLevels
(data: CreateInventoryLevelInput[], context?: SharedContext) => Promise<InventoryLevelDTO[]>RequiredcreateReservationItem
(input: CreateReservationItemInput, context?: SharedContext) => Promise<ReservationItemDTO>RequiredcreateReservationItems
(input: CreateReservationItemInput[], context?: SharedContext) => Promise<ReservationItemDTO[]>RequireddeleteInventoryItem
(inventoryItemId: string | string[], context?: SharedContext) => Promise<void>RequireddeleteInventoryItemLevelByLocationId
(locationId: string | string[], context?: SharedContext) => Promise<void>RequireddeleteInventoryLevel
(inventoryItemId: string, locationId: string, context?: SharedContext) => Promise<void>RequireddeleteReservationItem
(reservationItemId: string | string[], context?: SharedContext) => Promise<void>RequireddeleteReservationItemByLocationId
(locationId: string | string[], context?: SharedContext) => Promise<void>RequireddeleteReservationItemsByLineItem
(lineItemId: string | string[], context?: SharedContext) => Promise<void>RequiredlistInventoryItems
(selector: FilterableInventoryItemProps, config?: FindConfig<InventoryItemDTO>, context?: SharedContext) => Promise<[InventoryItemDTO[], number]>RequiredlistInventoryLevels
(selector: FilterableInventoryLevelProps, config?: FindConfig<InventoryLevelDTO>, context?: SharedContext) => Promise<[InventoryLevelDTO[], number]>RequiredlistReservationItems
(selector: FilterableReservationItemProps, config?: FindConfig<ReservationItemDTO>, context?: SharedContext) => Promise<[ReservationItemDTO[], number]>RequiredrestoreInventoryItem
(inventoryItemId: string | string[], context?: SharedContext) => Promise<void>RequiredretrieveAvailableQuantity
(inventoryItemId: string, locationIds: string[], context?: SharedContext) => Promise<number>RequiredretrieveInventoryItem
(inventoryItemId: string, config?: FindConfig<InventoryItemDTO>, context?: SharedContext) => Promise<InventoryItemDTO>RequiredretrieveInventoryLevel
(inventoryItemId: string, locationId: string, context?: SharedContext) => Promise<InventoryLevelDTO>RequiredretrieveReservationItem
(reservationId: string, context?: SharedContext) => Promise<ReservationItemDTO>RequiredretrieveReservedQuantity
(inventoryItemId: string, locationIds: string[], context?: SharedContext) => Promise<number>RequiredretrieveStockedQuantity
(inventoryItemId: string, locationIds: string[], context?: SharedContext) => Promise<number>RequiredupdateInventoryItem
(inventoryItemId: string, input: Partial<CreateInventoryItemInput>, context?: SharedContext) => Promise<InventoryItemDTO>RequiredupdateInventoryLevel
(inventoryItemId: string, locationId: string, update: UpdateInventoryLevelInput, context?: SharedContext) => Promise<InventoryLevelDTO>RequiredupdateInventoryLevels
(updates: BulkUpdateInventoryLevelInput[], context?: SharedContext) => Promise<InventoryLevelDTO[]>RequiredupdateReservationItem
(reservationItemId: string, input: UpdateReservationItemInput, context?: SharedContext) => Promise<ReservationItemDTO>RequiredstockLocationService_
Protected get**stockLocationService_**(): [IStockLocationService](/references/services/interfaces/IStockLocationService)
Returns
create
(input: CreateStockLocationInput, context?: SharedContext) => Promise<StockLocationDTO>Requiredlist
(selector: FilterableStockLocationProps, config?: FindConfig<StockLocationDTO>, context?: SharedContext) => Promise<StockLocationDTO[]>RequiredlistAndCount
(selector: FilterableStockLocationProps, config?: FindConfig<StockLocationDTO>, context?: SharedContext) => Promise<[StockLocationDTO[], number]>Requiredretrieve
(id: string, config?: FindConfig<StockLocationDTO>, context?: SharedContext) => Promise<StockLocationDTO>Requiredupdate
(id: string, input: UpdateStockLocationInput, context?: SharedContext) => Promise<StockLocationDTO>RequiredMethods
adjustInventory
**adjustInventory**(variantId, locationId, quantity): Promise<void>
Adjusts inventory of a variant on a location
Parameters
variantId
stringRequiredlocationId
stringRequiredquantity
numberRequiredReturns
Promise<void>
Promise
Promise<void>RequiredadjustReservationsQuantityByLineItem
**adjustReservationsQuantityByLineItem**(lineItemId, variantId, locationId, quantity): Promise<void>
Adjusts the quantity of reservations for a line item by a given amount.
Parameters
lineItemId
stringRequiredvariantId
stringRequiredlocationId
stringRequiredquantity
numberRequiredReturns
Promise<void>
Promise
Promise<void>RequiredatomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>RequiredattachInventoryItem
**attachInventoryItem**(attachments): Promise<[ProductVariantInventoryItem](/references/services/classes/ProductVariantInventoryItem)[]>
Attach a variant to an inventory item
Parameters
attachments
{ inventoryItemId: string ; requiredQuantity?: number ; variantId: string }[]RequiredReturns
Promise<ProductVariantInventoryItem[]>
**attachInventoryItem**(variantId, inventoryItemId, requiredQuantity?): Promise<[ProductVariantInventoryItem](/references/services/classes/ProductVariantInventoryItem)[]>
Parameters
variantId
stringRequiredinventoryItemId
stringRequiredrequiredQuantity
numberReturns
Promise<ProductVariantInventoryItem[]>
confirmInventory
**confirmInventory**(variantId, quantity, context?): Promise<[Boolean](/references/services/#boolean)>
confirms if requested inventory is available
Parameters
variantId
stringRequiredquantity
numberRequiredcontext
objectRequiredDefault: {}
context.salesChannelId
null | stringReturns
Promise<Boolean>
deleteReservationsByLineItem
**deleteReservationsByLineItem**(lineItemId, variantId, quantity): Promise<void>
delete a reservation of variant quantity
Parameters
lineItemId
string | string[]RequiredvariantId
stringRequiredquantity
numberRequiredReturns
Promise<void>
Promise
Promise<void>RequireddetachInventoryItem
**detachInventoryItem**(inventoryItemId, variantId?): Promise<void>
Remove a variant from an inventory item
Parameters
inventoryItemId
stringRequiredvariantId
stringReturns
Promise<void>
Promise
Promise<void>RequiredgetAvailabilityContext
Private **getAvailabilityContext**(variants, salesChannelId, existingContext?): Promise<[Required](/references/services/types/Required)<[AvailabilityContext](/references/services/types/AvailabilityContext)>>
Parameters
variants
string[]RequiredsalesChannelId
undefined | string | string[]RequiredDefault: {}
Returns
Promise<Required<AvailabilityContext>>
getVariantQuantityFromVariantInventoryItems
**getVariantQuantityFromVariantInventoryItems**(variantInventoryItems, channelId): Promise<number>
Get the quantity of a variant from a list of variantInventoryItems The inventory quantity of the variant should be equal to the inventory item with the smallest stock, adjusted for quantity required to fulfill the given variant.
Parameters
channelId
stringRequiredReturns
Promise<number>
Promise
Promise<number>RequiredlistByItem
**listByItem**(itemIds): Promise<[ProductVariantInventoryItem](/references/services/classes/ProductVariantInventoryItem)[]>
list registered inventory items
Parameters
itemIds
string[]RequiredReturns
Promise<ProductVariantInventoryItem[]>
listByVariant
**listByVariant**(variantId): Promise<[ProductVariantInventoryItem](/references/services/classes/ProductVariantInventoryItem)[]>
List inventory items for a specific variant
Parameters
variantId
string | string[]RequiredReturns
Promise<ProductVariantInventoryItem[]>
listInventoryItemsByVariant
**listInventoryItemsByVariant**(variantId): Promise<[InventoryItemDTO](/references/services/types/InventoryItemDTO)[]>
lists inventory items for a given variant
Parameters
variantId
stringRequiredReturns
Promise<InventoryItemDTO[]>
listVariantsByItem
**listVariantsByItem**(itemId): Promise<[ProductVariant](/references/services/classes/ProductVariant)[]>
lists variant by inventory item id
Parameters
itemId
stringRequiredReturns
Promise<ProductVariant[]>
reserveQuantity
**reserveQuantity**(variantId, quantity, context?): Promise<void \| [ReservationItemDTO](/references/services/types/ReservationItemDTO)[]>
Reserves a quantity of a variant
Parameters
variantId
stringRequiredquantity
numberRequiredDefault: {}
Returns
Promise<void | ReservationItemDTO[]>
retrieve
**retrieve**(inventoryItemId, variantId): Promise<[ProductVariantInventoryItem](/references/services/classes/ProductVariantInventoryItem)>
Retrieves a product variant inventory item by its inventory item ID and variant ID.
Parameters
inventoryItemId
stringRequiredvariantId
stringRequiredReturns
Promise<ProductVariantInventoryItem>
setProductAvailability
**setProductAvailability**(products, salesChannelId): Promise<([Product](/references/services/classes/Product) \| [PricedProduct](/references/services/types/PricedProduct))[]>
Parameters
salesChannelId
undefined | string | string[]RequiredReturns
Promise<(Product | PricedProduct)[]>
setVariantAvailability
**setVariantAvailability**(variants, salesChannelId, availabilityContext?): Promise<[ProductVariant](/references/services/classes/ProductVariant)[] \| [PricedVariant](/references/services/types/PricedVariant)[]>
Parameters
salesChannelId
undefined | string | string[]RequiredDefault: {}
Returns
Promise<ProductVariant[] | PricedVariant[]>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanvalidateInventoryAtLocation
**validateInventoryAtLocation**(items, locationId): Promise<void>
Validate stock at a location for fulfillment items
Parameters
Returns
Promise<void>
Promise
Promise<void>RequiredwithTransaction
**withTransaction**(transactionManager?): [ProductVariantInventoryService](/references/services/classes/ProductVariantInventoryService)
Parameters
transactionManager
EntityManagerReturns
ProductVariantInventoryService