Class: ProductVariantInventoryService
Hierarchy
TransactionBaseService↳
ProductVariantInventoryService
Constructors
constructor
• new ProductVariantInventoryService(__namedParameters)
Parameters
| Name | Type |
|---|---|
__namedParameters | InjectedDependencies |
Overrides
TransactionBaseService.constructor
Defined in
packages/medusa/src/services/product-variant-inventory.ts:43
Properties
__configModule__
• Protected Optional Readonly __configModule__: Record<string, unknown>
Inherited from
TransactionBaseService.__configModule__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:10
__container__
• Protected Readonly __container__: any
Inherited from
TransactionBaseService.__container__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:9
__moduleDeclaration__
• Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:11
cacheService_
• Protected Readonly cacheService_: CacheService
Defined in
packages/medusa/src/services/product-variant-inventory.ts:41
inventoryService_
• Protected Readonly inventoryService_: IInventoryService
Defined in
packages/medusa/src/services/product-variant-inventory.ts:40
manager_
• Protected manager_: EntityManager
Overrides
TransactionBaseService.manager_
Defined in
packages/medusa/src/services/product-variant-inventory.ts:33
productVariantService_
• Protected Readonly productVariantService_: ProductVariantService
Defined in
packages/medusa/src/services/product-variant-inventory.ts:38
salesChannelInventoryService_
• Protected Readonly salesChannelInventoryService_: SalesChannelInventoryService
Defined in
packages/medusa/src/services/product-variant-inventory.ts:37
salesChannelLocationService_
• Protected Readonly salesChannelLocationService_: SalesChannelLocationService
Defined in
packages/medusa/src/services/product-variant-inventory.ts:36
stockLocationService_
• Protected Readonly stockLocationService_: IStockLocationService
Defined in
packages/medusa/src/services/product-variant-inventory.ts:39
transactionManager_
• Protected transactionManager_: undefined | EntityManager
Overrides
TransactionBaseService.transactionManager_
Defined in
packages/medusa/src/services/product-variant-inventory.ts:34
Methods
adjustInventory
▸ adjustInventory(variantId, locationId, quantity): Promise<void>
Adjusts inventory of a variant on a location
Parameters
| Name | Type | Description |
|---|---|---|
variantId | string | variant id |
locationId | string | location id |
quantity | number | quantity to adjust |
Returns
Promise<void>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:573
adjustReservationsQuantityByLineItem
▸ adjustReservationsQuantityByLineItem(lineItemId, variantId, locationId, quantity): Promise<void>
Adjusts the quantity of reservations for a line item by a given amount.
Parameters
| Name | Type | Description |
|---|---|---|
lineItemId | string | The ID of the line item |
variantId | string | The ID of the variant |
locationId | string | The ID of the location to prefer adjusting quantities at |
quantity | number | The amount to adjust the quantity by |
Returns
Promise<void>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:419
atomicPhase_
▸ Protected atomicPhase_<TResult, 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.
Type parameters
| Name |
|---|
TResult |
TError |
Parameters
| Name | Type | Description |
|---|---|---|
work | (transactionManager: EntityManager) => Promise<TResult> | the transactional work to be done |
isolationOrErrorHandler? | IsolationLevel | (error: TError) => Promise<void | TResult> | the isolation level to be used for the work. |
maybeErrorHandlerOrDontFail? | (error: TError) => Promise<void | TResult> | Potential error handler |
Returns
Promise<TResult>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:50
attachInventoryItem
▸ attachInventoryItem(variantId, inventoryItemId, requiredQuantity?): Promise<ProductVariantInventoryItem>
Attach a variant to an inventory item
Parameters
| Name | Type | Description |
|---|---|---|
variantId | string | variant id |
inventoryItemId | string | inventory item id |
requiredQuantity? | number | quantity of variant to attach |
Returns
Promise<ProductVariantInventoryItem>
the variant inventory item
Defined in
packages/medusa/src/services/product-variant-inventory.ts:255
confirmInventory
▸ confirmInventory(variantId, quantity, context?): Promise<Boolean>
confirms if requested inventory is available
Parameters
| Name | Type | Description |
|---|---|---|
variantId | string | id of the variant to confirm inventory for |
quantity | number | quantity of inventory to confirm is available |
context | Object | optionally include a sales channel if applicable |
context.salesChannelId? | null | string | - |
Returns
Promise<Boolean>
boolean indicating if inventory is available
Defined in
packages/medusa/src/services/product-variant-inventory.ts:69
deleteReservationsByLineItem
▸ deleteReservationsByLineItem(lineItemId, variantId, quantity): Promise<void>
delete a reservation of variant quantity
Parameters
| Name | Type | Description |
|---|---|---|
lineItemId | string | line item id |
variantId | string | variant id |
quantity | number | quantity to release |
Returns
Promise<void>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:538
detachInventoryItem
▸ detachInventoryItem(inventoryItemId, variantId?): Promise<void>
Remove a variant from an inventory item
Parameters
| Name | Type | Description |
|---|---|---|
inventoryItemId | string | inventory item id |
variantId? | string | variant id or undefined if all the variants will be affected |
Returns
Promise<void>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:317
listByItem
▸ listByItem(itemIds): Promise<ProductVariantInventoryItem[]>
list registered inventory items
Parameters
| Name | Type | Description |
|---|---|---|
itemIds | string[] | list inventory item ids |
Returns
Promise<ProductVariantInventoryItem[]>
list of inventory items
Defined in
packages/medusa/src/services/product-variant-inventory.ts:173
listByVariant
▸ Private listByVariant(variantId): Promise<ProductVariantInventoryItem[]>
List inventory items for a specific variant
Parameters
| Name | Type | Description |
|---|---|---|
variantId | string | string[] | variant id |
Returns
Promise<ProductVariantInventoryItem[]>
variant inventory items for the variant id
Defined in
packages/medusa/src/services/product-variant-inventory.ts:192
listInventoryItemsByVariant
▸ listInventoryItemsByVariant(variantId): Promise<InventoryItemDTO[]>
lists inventory items for a given variant
Parameters
| Name | Type | Description |
|---|---|---|
variantId | string | variant id |
Returns
Promise<InventoryItemDTO[]>
lidt of inventory items for the variant
Defined in
packages/medusa/src/services/product-variant-inventory.ts:233
listVariantsByItem
▸ listVariantsByItem(itemId): Promise<ProductVariant[]>
lists variant by inventory item id
Parameters
| Name | Type | Description |
|---|---|---|
itemId | string | item id |
Returns
Promise<ProductVariant[]>
a list of product variants that are associated with the item id
Defined in
packages/medusa/src/services/product-variant-inventory.ts:215
reserveQuantity
▸ reserveQuantity(variantId, quantity, context?): Promise<void | ReservationItemDTO[]>
Reserves a quantity of a variant
Parameters
| Name | Type | Description |
|---|---|---|
variantId | string | variant id |
quantity | number | quantity to reserve |
context | ReserveQuantityContext | optional parameters |
Returns
Promise<void | ReservationItemDTO[]>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:349
retrieve
▸ retrieve(inventoryItemId, variantId): Promise<ProductVariantInventoryItem>
Retrieves a product variant inventory item by its inventory item ID and variant ID.
Parameters
| Name | Type | Description |
|---|---|---|
inventoryItemId | string | The ID of the inventory item to retrieve. |
variantId | string | The ID of the variant to retrieve. |
Returns
Promise<ProductVariantInventoryItem>
A promise that resolves with the product variant inventory item.
Defined in
packages/medusa/src/services/product-variant-inventory.ts:144
setProductAvailability
▸ setProductAvailability(products, salesChannelId): Promise<(Product | PricedProduct)[]>
Parameters
| Name | Type |
|---|---|
products | (Product | PricedProduct)[] |
salesChannelId | undefined | string |
Returns
Promise<(Product | PricedProduct)[]>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:665
setVariantAvailability
▸ setVariantAvailability(variants, salesChannelId): Promise<ProductVariant[] | PricedVariant[]>
Parameters
| Name | Type |
|---|---|
variants | ProductVariant[] | PricedVariant[] |
salesChannelId | undefined | string |
Returns
Promise<ProductVariant[] | PricedVariant[]>
Defined in
packages/medusa/src/services/product-variant-inventory.ts:617
shouldRetryTransaction_
▸ Protected shouldRetryTransaction_(err): boolean
Parameters
| Name | Type |
|---|---|
err | Record<string, unknown> | { code: string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:31
validateInventoryAtLocation
▸ validateInventoryAtLocation(items, locationId): Promise<void>
Validate stock at a location for fulfillment items
Parameters
| Name | Type | Description |
|---|---|---|
items | Omit<LineItem, "beforeInsert">[] | Fulfillment Line items to validate quantities for |
locationId | string | Location to validate stock at |
Returns
Promise<void>
nothing if successful, throws error if not
Defined in
packages/medusa/src/services/product-variant-inventory.ts:492
withTransaction
▸ withTransaction(transactionManager?): ProductVariantInventoryService
Parameters
| Name | Type |
|---|---|
transactionManager? | EntityManager |
Returns
ProductVariantInventoryService
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:14