Skip to main content
Skip to main content

ProductVariantInventoryService

Hierarchy

  • TransactionBaseService

    ProductVariantInventoryService

Constructors

constructor

new ProductVariantInventoryService(«destructured»)

Parameters

Name
«destructured»

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/product-variant-inventory.ts:50

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.__configModule__

Defined in

medusa/src/interfaces/transaction-base-service.ts:14


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

medusa/src/interfaces/transaction-base-service.ts:15


cacheService_

Protected Readonly cacheService_: ICacheService

Defined in

medusa/src/services/product-variant-inventory.ts:48


eventBusService_

Protected Readonly eventBusService_: IEventBusService

Defined in

medusa/src/services/product-variant-inventory.ts:47


inventoryService_

Protected Readonly inventoryService_: IInventoryService

Defined in

medusa/src/services/product-variant-inventory.ts:46


manager_

Protected manager_: EntityManager

Overrides

TransactionBaseService.manager_

Defined in

medusa/src/services/product-variant-inventory.ts:39


productVariantService_

Protected Readonly productVariantService_: ProductVariantService

Defined in

medusa/src/services/product-variant-inventory.ts:44


salesChannelInventoryService_

Protected Readonly salesChannelInventoryService_: SalesChannelInventoryService

Defined in

medusa/src/services/product-variant-inventory.ts:43


salesChannelLocationService_

Protected Readonly salesChannelLocationService_: SalesChannelLocationService

Defined in

medusa/src/services/product-variant-inventory.ts:42


stockLocationService_

Protected Readonly stockLocationService_: IStockLocationService

Defined in

medusa/src/services/product-variant-inventory.ts:45


transactionManager_

Protected transactionManager_: undefined | EntityManager

Overrides

TransactionBaseService.transactionManager_

Defined in

medusa/src/services/product-variant-inventory.ts:40

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

-EntityManager:

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

Methods

adjustInventory

adjustInventory(variantId, locationId, quantity): Promise<void>

Adjusts inventory of a variant on a location

Parameters

NameDescription
variantIdstring
locationIdstring
quantitynumber

Returns

Promise<void>

-Promise:

Defined in

medusa/src/services/product-variant-inventory.ts:740


adjustReservationsQuantityByLineItem

adjustReservationsQuantityByLineItem(lineItemId, variantId, locationId, quantity): Promise<void>

Adjusts the quantity of reservations for a line item by a given amount.

Parameters

NameDescription
lineItemIdstring
variantIdstring
locationIdstring
quantitynumber

Returns

Promise<void>

-Promise:

Defined in

medusa/src/services/product-variant-inventory.ts:530


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.

Name
TResult
TError

Parameters

NameDescription
work(transactionManager: EntityManager) => Promise<TResult>
isolationOrErrorHandler?IsolationLevel | (error: TError) => Promise<void | TResult>
maybeErrorHandlerOrDontFail?(error: TError) => Promise<void | TResult>

Returns

Promise<TResult>

-Promise: the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

medusa/src/interfaces/transaction-base-service.ts:56


attachInventoryItem

attachInventoryItem(attachments): Promise<ProductVariantInventoryItem[]>

Attach a variant to an inventory item

Parameters

Name
attachments

Returns

Promise<ProductVariantInventoryItem[]>

-Promise: the variant inventory item -ProductVariantInventoryItem[]: -ProductVariantInventoryItem:

Defined in

medusa/src/services/product-variant-inventory.ts:257

attachInventoryItem(variantId, inventoryItemId, requiredQuantity?): Promise<ProductVariantInventoryItem[]>

Parameters

Name
variantId
inventoryItemId
requiredQuantity?

Returns

Promise<ProductVariantInventoryItem[]>

-Promise: -ProductVariantInventoryItem[]: -ProductVariantInventoryItem:

Defined in

medusa/src/services/product-variant-inventory.ts:264


confirmInventory

confirmInventory(variantId, quantity, context?): Promise<Boolean>

confirms if requested inventory is available

Parameters

NameDescription
variantIdstring
quantitynumber
contextobject
context.salesChannelId?null | string

Returns

Promise<Boolean>

-Promise: boolean indicating if inventory is available

Defined in

medusa/src/services/product-variant-inventory.ts:76


deleteReservationsByLineItem

deleteReservationsByLineItem(lineItemId, variantId, quantity): Promise<void>

delete a reservation of variant quantity

Parameters

NameDescription
lineItemIdstring | string[]
variantIdstring
quantitynumber

Returns

Promise<void>

-Promise:

Defined in

medusa/src/services/product-variant-inventory.ts:705


detachInventoryItem

detachInventoryItem(inventoryItemId, variantId?): Promise<void>

Remove a variant from an inventory item

Parameters

NameDescription
inventoryItemIdstring
variantId?string

Returns

Promise<void>

-Promise:

Defined in

medusa/src/services/product-variant-inventory.ts:409


getAvailabilityContext

Private getAvailabilityContext(variants, salesChannelId, existingContext?): Promise<Required<AvailabilityContext>>

Parameters

Name
variants
salesChannelId
existingContext

Returns

Promise<Required<AvailabilityContext>>

-Promise: -Required:

Defined in

medusa/src/services/product-variant-inventory.ts:843


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

NameDescription
variantInventoryItemsProductVariantInventoryItem[]
channelIdstring

Returns

Promise<number>

-Promise: The available quantity of the variant from the inventoryItems -number: (optional)

Defined in

medusa/src/services/product-variant-inventory.ts:954


listByItem

listByItem(itemIds): Promise<ProductVariantInventoryItem[]>

list registered inventory items

Parameters

NameDescription
itemIdsstring[]

Returns

Promise<ProductVariantInventoryItem[]>

-Promise: list of inventory items -ProductVariantInventoryItem[]: -ProductVariantInventoryItem:

Defined in

medusa/src/services/product-variant-inventory.ts:179


listByVariant

listByVariant(variantId): Promise<ProductVariantInventoryItem[]>

List inventory items for a specific variant

Parameters

NameDescription
variantIdstring | string[]

Returns

Promise<ProductVariantInventoryItem[]>

-Promise: variant inventory items for the variant id -ProductVariantInventoryItem[]: -ProductVariantInventoryItem:

Defined in

medusa/src/services/product-variant-inventory.ts:196


listInventoryItemsByVariant

listInventoryItemsByVariant(variantId): Promise<InventoryItemDTO[]>

lists inventory items for a given variant

Parameters

NameDescription
variantIdstring

Returns

Promise<InventoryItemDTO[]>

-Promise: lidt of inventory items for the variant -InventoryItemDTO[]:

Defined in

medusa/src/services/product-variant-inventory.ts:235


listVariantsByItem

listVariantsByItem(itemId): Promise<ProductVariant[]>

lists variant by inventory item id

Parameters

NameDescription
itemIdstring

Returns

Promise<ProductVariant[]>

-Promise: a list of product variants that are associated with the item id -ProductVariant[]: -ProductVariant:

Defined in

medusa/src/services/product-variant-inventory.ts:217


reserveQuantity

reserveQuantity(variantId, quantity, context?): Promise<void | ReservationItemDTO[]>

Reserves a quantity of a variant

Parameters

NameDescription
variantIdstring
quantitynumber
contextReserveQuantityContext

Returns

Promise<void | ReservationItemDTO[]>

-Promise: -void \| ReservationItemDTO[]: (optional)

Defined in

medusa/src/services/product-variant-inventory.ts:439


retrieve

retrieve(inventoryItemId, variantId): Promise<ProductVariantInventoryItem>

Retrieves a product variant inventory item by its inventory item ID and variant ID.

Parameters

NameDescription
inventoryItemIdstring
variantIdstring

Returns

Promise<ProductVariantInventoryItem>

-Promise: A promise that resolves with the product variant inventory item. -ProductVariantInventoryItem:

Defined in

medusa/src/services/product-variant-inventory.ts:152


setProductAvailability

setProductAvailability(products, salesChannelId): Promise<(Product | PricedProduct)[]>

Parameters

Name
products
salesChannelId

Returns

Promise<(Product | PricedProduct)[]>

-Promise: -(Product \| PricedProduct)[]: -Product \| PricedProduct: (optional)

Defined in

medusa/src/services/product-variant-inventory.ts:910


setVariantAvailability

setVariantAvailability(variants, salesChannelId, availabilityContext?): Promise<ProductVariant[] | PricedVariant[]>

Parameters

Name
variants
salesChannelId
availabilityContext

Returns

Promise<ProductVariant[] | PricedVariant[]>

-Promise: -ProductVariant[] \| PricedVariant[]: (optional)

Defined in

medusa/src/services/product-variant-inventory.ts:784


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name
err

Returns

boolean

-boolean: (optional)

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

medusa/src/interfaces/transaction-base-service.ts:37


validateInventoryAtLocation

validateInventoryAtLocation(items, locationId): Promise<void>

Validate stock at a location for fulfillment items

Parameters

NameDescription
itemsOmit<LineItem, "beforeInsert">[]
locationIdstring

Returns

Promise<void>

-Promise: nothing if successful, throws error if not

Defined in

medusa/src/services/product-variant-inventory.ts:640


withTransaction

withTransaction(transactionManager?): ProductVariantInventoryService

Parameters

Name
transactionManager?

Returns

ProductVariantInventoryService

-ProductVariantInventoryService:

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20

Was this section helpful?