Files
medusa-store/docs/content/references/services/classes/PriceListService.md
2023-03-16 14:20:25 +02:00

15 KiB

Class: PriceListService

Provides layer to manipulate product tags.

Hierarchy

  • TransactionBaseService

    PriceListService

Constructors

constructor

new PriceListService(__namedParameters)

Parameters

Name Type
__namedParameters PriceListConstructorProps

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

Name Type
T extends PriceListPriceCreateInput | PriceListPriceUpdateInput

Parameters

Name Type Description
prices T[] 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

Name Type Default value Description
id string undefined id of the price list
prices PriceListPriceCreateInput[] undefined prices to add
replace boolean false whether 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

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


clearPrices

clearPrices(id): Promise<void>

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

Parameters

Name Type Description
id string id 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

Name Type Description
priceListObject CreatePriceListInput the 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

Name Type Description
id string id 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

Name Type Description
id string id of the price list
priceIds string[] 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

Name Type
priceListId string
productIds string[]

Returns

Promise<[string[], number]>

Defined in

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


deleteVariantPrices

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

Parameters

Name Type
priceListId string
variantIds string[]

Returns

Promise<[string[], number]>

Defined in

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


list

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

Lists Price Lists

Parameters

Name Type Description
selector FilterablePriceListProps the query object for find
config FindConfig<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

Name Type Description
selector FilterablePriceListProps the query object for find
config FindConfig<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

Name Type Default value
priceListId string undefined
selector Selector<Product> | FilterableProductProps {}
config FindConfig<Product> undefined
requiresPriceList boolean false

Returns

Promise<[Product[], number]>

Defined in

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


listVariants

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

Parameters

Name Type Default value
priceListId string undefined
selector FilterableProductVariantProps {}
config FindConfig<ProductVariant> undefined
requiresPriceList boolean false

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

Name Type Description
priceListId string the id of the product tag to retrieve
config FindConfig<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

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


update

update(id, update): Promise<PriceList>

Updates a Price List

Parameters

Name Type Description
id string the id of the Product List to update
update UpdatePriceListInput the 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

Name Type
priceListId string
customerGroups { id: string }[]

Returns

Promise<void>

Defined in

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


withTransaction

withTransaction(transactionManager?): PriceListService

Parameters

Name Type
transactionManager? EntityManager

Returns

PriceListService

Inherited from

TransactionBaseService.withTransaction

Defined in

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