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

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

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


customerGroupService_

Protected Readonly customerGroupService_: CustomerGroupService

Defined in

medusa/src/services/price-list.ts:42


featureFlagRouter_

Protected Readonly featureFlagRouter_: FlagRouter

Defined in

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


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

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


moneyAmountRepo_

Protected Readonly moneyAmountRepo_: Repository<MoneyAmount> & { addPriceListPrices: (priceListId: string, prices: PriceListPriceCreateInput[], overrideExisting: boolean) => Promise<MoneyAmount[]> ; deletePriceListPrices: (priceListId: string, moneyAmountIds: string[]) => Promise<void> ; deleteVariantPricesNotIn: (variantIdOrData: string | { prices: ProductVariantPrice[] ; variantId: string }[], prices?: Price[]) => Promise<void> ; findManyForVariantInPriceList: (variant_id: string, price_list_id: string, requiresPriceList: boolean) => Promise<[MoneyAmount[], number]> ; findManyForVariantInRegion: (variant_id: string, region_id?: string, currency_code?: string, customer_id?: string, include_discount_prices?: boolean, include_tax_inclusive_pricing: boolean) => Promise<[MoneyAmount[], number]> ; findManyForVariantsInRegion: (variant_ids: string | string[], region_id?: string, currency_code?: string, customer_id?: string, include_discount_prices?: boolean, include_tax_inclusive_pricing: boolean) => Promise<[Record<string, MoneyAmount[]>, number]> ; findVariantPricesNotIn: (variantId: string, prices: Price[]) => Promise<MoneyAmount[]> ; insertBulk: (data: _QueryDeepPartialEntity<MoneyAmount>[]) => Promise<MoneyAmount[]> ; updatePriceListPrices: (priceListId: string, updates: PriceListPriceUpdateInput[]) => Promise<MoneyAmount[]> ; upsertVariantCurrencyPrice: (variantId: string, price: Price) => Promise<MoneyAmount> }

Defined in

medusa/src/services/price-list.ts:47


priceListRepo_

Protected Readonly priceListRepo_: Repository<PriceList> & { listAndCount: (query: ExtendedFindConfig<PriceList>, q?: string) => Promise<[PriceList[], number]> }

Defined in

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


productService_

Protected Readonly productService_: ProductService

Defined in

medusa/src/services/price-list.ts:44


productVariantRepo_

Protected Readonly productVariantRepo_: Repository<ProductVariant>

Defined in

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


regionService_

Protected Readonly regionService_: RegionService

Defined in

medusa/src/services/price-list.ts:43


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

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


variantService_

Protected Readonly variantService_: ProductVariantService

Defined in

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

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

Inherited from

TransactionBaseService.activeManager_

Defined in

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

Methods

addCurrencyFromRegion

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

Add currency_code to an MA record if region_idis passed.

Type parameters

NameType
Textends PriceListPriceUpdateInput | PriceListPriceCreateInput

Parameters

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

Returns

Promise<T[]>

updated prices list

Defined in

medusa/src/services/price-list.ts:492


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

medusa/src/services/price-list.ts:212


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

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


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

medusa/src/services/price-list.ts:252


create

create(priceListObject): Promise<PriceList>

Creates a Price List

Parameters

NameTypeDescription
priceListObjectCreatePriceListInputthe Price List to create

Returns

Promise<PriceList>

created Price List

Defined in

medusa/src/services/price-list.ts:113


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

medusa/src/services/price-list.ts:266


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

medusa/src/services/price-list.ts:237


deleteProductPrices

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

Parameters

NameType
priceListIdstring
productIdsstring[]

Returns

Promise<[string[], number]>

Defined in

medusa/src/services/price-list.ts:419


deleteVariantPrices

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

Parameters

NameType
priceListIdstring
variantIdsstring[]

Returns

Promise<[string[], number]>

Defined in

medusa/src/services/price-list.ts:456


list

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

Lists Price Lists

Parameters

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

Returns

Promise<PriceList[]>

the result of the find operation

Defined in

medusa/src/services/price-list.ts:286


listAndCount

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

Lists Price Lists and adds count

Parameters

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

Returns

Promise<[PriceList[], number]>

the result of the find operation

Defined in

medusa/src/services/price-list.ts:300


listProducts

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

Parameters

NameTypeDefault value
priceListIdstringundefined
selectorFilterableProductProps | Selector<Product>{}
configFindConfig<Product>undefined
requiresPriceListbooleanfalse

Returns

Promise<[Product[], number]>

Defined in

medusa/src/services/price-list.ts:337


listVariants

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

Parameters

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

Returns

Promise<[ProductVariant[], number]>

Defined in

medusa/src/services/price-list.ts:385


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

medusa/src/services/price-list.ts:80


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

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


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

medusa/src/services/price-list.ts:161


upsertCustomerGroups_

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

Parameters

NameType
priceListIdstring
customerGroups{ id: string }[]

Returns

Promise<void>

Defined in

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


withTransaction

withTransaction(transactionManager?): PriceListService

Parameters

NameType
transactionManager?EntityManager

Returns

PriceListService

Inherited from

TransactionBaseService.withTransaction

Defined in

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

Was this page helpful?