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
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
| Name | Type |
|---|---|
T | extends PriceListPriceUpdateInput | PriceListPriceCreateInput |
Parameters
| Name | Type | Description |
|---|---|---|
prices | T[] | 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
| 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
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
| 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
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
| Name | Type | Description |
|---|---|---|
id | string | id 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
| Name | Type | Description |
|---|---|---|
priceListObject | CreatePriceListInput | the 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
| Name | Type | Description |
|---|---|---|
id | string | id 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
| 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
medusa/src/services/price-list.ts:237
deleteProductPrices
▸ deleteProductPrices(priceListId, productIds): Promise<[string[], number]>
Parameters
| Name | Type |
|---|---|
priceListId | string |
productIds | string[] |
Returns
Promise<[string[], number]>
Defined in
medusa/src/services/price-list.ts:419
deleteVariantPrices
▸ deleteVariantPrices(priceListId, variantIds): Promise<[string[], number]>
Parameters
| Name | Type |
|---|---|
priceListId | string |
variantIds | string[] |
Returns
Promise<[string[], number]>
Defined in
medusa/src/services/price-list.ts:456
list
▸ list(selector?, config?): Promise<PriceList[]>
Lists Price Lists
Parameters
| Name | Type | Description |
|---|---|---|
selector | FilterablePriceListProps | the query object for find |
config | FindConfig<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
| Name | Type | Description |
|---|---|---|
selector | FilterablePriceListProps | the query object for find |
config | FindConfig<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
| Name | Type | Default value |
|---|---|---|
priceListId | string | undefined |
selector | FilterableProductProps | Selector<Product> | {} |
config | FindConfig<Product> | undefined |
requiresPriceList | boolean | false |
Returns
Promise<[Product[], number]>
Defined in
medusa/src/services/price-list.ts:337
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
medusa/src/services/price-list.ts:385
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
medusa/src/services/price-list.ts:80
shouldRetryTransaction_
▸ Protected shouldRetryTransaction_(err): boolean
Parameters
| Name | Type |
|---|---|
err | Record<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
| 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
medusa/src/services/price-list.ts:161
upsertCustomerGroups_
▸ Protected upsertCustomerGroups_(priceListId, customerGroups): Promise<void>
Parameters
| Name | Type |
|---|---|
priceListId | string |
customerGroups | { id: string }[] |
Returns
Promise<void>
Defined in
medusa/src/services/price-list.ts:316
withTransaction
▸ withTransaction(transactionManager?): PriceListService
Parameters
| Name | Type |
|---|---|
transactionManager? | EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction