Skip to main content

Class: PriceListService

Provides layer to manipulate product tags.

Hierarchy

  • TransactionBaseService

    PriceListService

Constructors

constructor

new PriceListService(__namedParameters)

Parameters

NameType
__namedParametersPriceListConstructorProps

Overrides

TransactionBaseService.constructor

Defined in

packages/medusa/src/services/price-list.ts:57

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


customerGroupService_

Protected Readonly customerGroupService_: CustomerGroupService

Defined in

packages/medusa/src/services/price-list.ts:48


featureFlagRouter_

Protected Readonly featureFlagRouter_: FlagRouter

Defined in

packages/medusa/src/services/price-list.ts:55


manager_

Protected manager_: EntityManager

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/price-list.ts:45


moneyAmountRepo_

Protected Readonly moneyAmountRepo_: typeof MoneyAmountRepository

Defined in

packages/medusa/src/services/price-list.ts:53


priceListRepo_

Protected Readonly priceListRepo_: typeof PriceListRepository

Defined in

packages/medusa/src/services/price-list.ts:52


productService_

Protected Readonly productService_: ProductService

Defined in

packages/medusa/src/services/price-list.ts:50


productVariantRepo_

Protected Readonly productVariantRepo_: typeof ProductVariantRepository

Defined in

packages/medusa/src/services/price-list.ts:54


regionService_

Protected Readonly regionService_: RegionService

Defined in

packages/medusa/src/services/price-list.ts:49


transactionManager_

Protected transactionManager_: undefined | EntityManager

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/price-list.ts:46


variantService_

Protected Readonly variantService_: ProductVariantService

Defined in

packages/medusa/src/services/price-list.ts:51

Methods

addCurrencyFromRegion

Protected addCurrencyFromRegion<T>(prices): Promise<T[]>

Add currency_code to an MA record if region_idis passed.

Type parameters

NameType
Textends PriceListPriceCreateInput | PriceListPriceUpdateInput

Parameters

NameTypeDescription
pricesT[]a list of PriceListPrice(Create/Update)Input records

Returns

Promise<T[]>

updated prices list

Defined in

packages/medusa/src/services/price-list.ts:519


addPrices

addPrices(id, prices, replace?): Promise<PriceList>

Adds prices to a price list in bulk, optionally replacing all existing prices

Parameters

NameTypeDefault valueDescription
idstringundefinedid of the price list
pricesPriceListPriceCreateInput[]undefinedprices to add
replacebooleanfalsewhether to replace existing prices

Returns

Promise<PriceList>

updated Price List

Defined in

packages/medusa/src/services/price-list.ts:218


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

NameTypeDescription
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


clearPrices

clearPrices(id): Promise<void>

Removes all prices from a price list and deletes the removed prices in bulk

Parameters

NameTypeDescription
idstringid of the price list

Returns

Promise<void>

updated Price List

Defined in

packages/medusa/src/services/price-list.ts:258


create

create(priceListObject): Promise<PriceList>

Creates a Price List

Parameters

NameTypeDescription
priceListObjectCreatePriceListInputthe Price List to create

Returns

Promise<PriceList>

created Price List

Defined in

packages/medusa/src/services/price-list.ts:119


delete

delete(id): Promise<void>

Deletes a Price List Will never fail due to delete being idempotent.

Parameters

NameTypeDescription
idstringid of the price list

Returns

Promise<void>

empty promise

Defined in

packages/medusa/src/services/price-list.ts:272


deletePrices

deletePrices(id, priceIds): Promise<void>

Removes prices from a price list and deletes the removed prices in bulk

Parameters

NameTypeDescription
idstringid of the price list
priceIdsstring[]ids of the prices to delete

Returns

Promise<void>

updated Price List

Defined in

packages/medusa/src/services/price-list.ts:243


deleteProductPrices

deleteProductPrices(priceListId, productIds): Promise<[string[], number]>

Parameters

NameType
priceListIdstring
productIdsstring[]

Returns

Promise<[string[], number]>

Defined in

packages/medusa/src/services/price-list.ts:446


deleteVariantPrices

deleteVariantPrices(priceListId, variantIds): Promise<[string[], number]>

Parameters

NameType
priceListIdstring
variantIdsstring[]

Returns

Promise<[string[], number]>

Defined in

packages/medusa/src/services/price-list.ts:483


list

list(selector?, config?): Promise<PriceList[]>

Lists Price Lists

Parameters

NameTypeDescription
selectorFilterablePriceListPropsthe query object for find
configFindConfig<FilterablePriceListProps>the config to be used for find

Returns

Promise<PriceList[]>

the result of the find operation

Defined in

packages/medusa/src/services/price-list.ts:292


listAndCount

listAndCount(selector?, config?): Promise<[PriceList[], number]>

Lists Price Lists and adds count

Parameters

NameTypeDescription
selectorFilterablePriceListPropsthe query object for find
configFindConfig<FilterablePriceListProps>the config to be used for find

Returns

Promise<[PriceList[], number]>

the result of the find operation

Defined in

packages/medusa/src/services/price-list.ts:316


listProducts

listProducts(priceListId, selector?, config?, requiresPriceList?): Promise<[Product[], number]>

Parameters

NameTypeDefault value
priceListIdstringundefined
selectorSelector<Product> | FilterableProductProps{}
configFindConfig<Product>undefined
requiresPriceListbooleanfalse

Returns

Promise<[Product[], number]>

Defined in

packages/medusa/src/services/price-list.ts:364


listVariants

listVariants(priceListId, selector?, config?, requiresPriceList?): Promise<[ProductVariant[], number]>

Parameters

NameTypeDefault value
priceListIdstringundefined
selectorFilterableProductVariantProps{}
configFindConfig<ProductVariant>undefined
requiresPriceListbooleanfalse

Returns

Promise<[ProductVariant[], number]>

Defined in

packages/medusa/src/services/price-list.ts:412


retrieve

retrieve(priceListId, config?): Promise<PriceList>

Retrieves a product tag by id.

Parameters

NameTypeDescription
priceListIdstringthe id of the product tag to retrieve
configFindConfig<PriceList>the config to retrieve the tag by

Returns

Promise<PriceList>

the collection.

Defined in

packages/medusa/src/services/price-list.ts:88


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

NameType
errRecord<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:31


update

update(id, update): Promise<PriceList>

Updates a Price List

Parameters

NameTypeDescription
idstringthe id of the Product List to update
updateUpdatePriceListInputthe update to apply

Returns

Promise<PriceList>

updated Price List

Defined in

packages/medusa/src/services/price-list.ts:167


upsertCustomerGroups_

Protected upsertCustomerGroups_(priceListId, customerGroups): Promise<void>

Parameters

NameType
priceListIdstring
customerGroups{ id: string }[]

Returns

Promise<void>

Defined in

packages/medusa/src/services/price-list.ts:345


withTransaction

withTransaction(transactionManager?): PriceListService

Parameters

NameType
transactionManager?EntityManager

Returns

PriceListService

Inherited from

TransactionBaseService.withTransaction

Defined in

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