Skip to main content
Skip to main content

PriceListService

Provides layer to manipulate product tags.

Constructors

constructor

**new PriceListService**(«destructured»)

Parameters
__namedParametersPriceListConstructorPropsRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
customerGroupService_CustomerGroupServiceRequired
featureFlagRouter_FlagRouterRequired
manager_EntityManagerRequired
moneyAmountRepo_Repository<MoneyAmount> & { addPriceListPrices: Method addPriceListPrices ; createProductVariantMoneyAmounts: Method createProductVariantMoneyAmounts ; deletePriceListPrices: Method deletePriceListPrices ; deleteVariantPricesNotIn: Method deleteVariantPricesNotIn ; findCurrencyMoneyAmounts: Method findCurrencyMoneyAmounts ; findManyForVariantInPriceList: Method findManyForVariantInPriceList ; findManyForVariantInRegion: Method findManyForVariantInRegion ; findManyForVariantsInRegion: Method findManyForVariantsInRegion ; findRegionMoneyAmounts: Method findRegionMoneyAmounts ; findVariantPricesNotIn: Method findVariantPricesNotIn ; getPricesForVariantInRegion: Method getPricesForVariantInRegion ; insertBulk: Method insertBulk ; updatePriceListPrices: Method updatePriceListPrices ; upsertVariantCurrencyPrice: Method upsertVariantCurrencyPrice }Required
priceListRepo_Repository<PriceList> & { listAndCount: Method listAndCount ; listPriceListsVariantIdsMap: Method listPriceListsVariantIdsMap }Required
productService_ProductServiceRequired
productVariantRepo_Repository<ProductVariant>Required
regionService_RegionServiceRequired
transactionManager_undefined | EntityManagerRequired
variantService_ProductVariantServiceRequired

Accessors

activeManager_

Protected activeManager_: [object Object]

Methods

addCurrencyFromRegion

Protected **addCurrencyFromRegion**<TypeParameter T>(prices): Promise&#60;T[]&#62;

Add currency_code to an MA record if region_idis passed.

Type Parameters
Parameters
pricesT[]Required
a list of PriceListPrice(Create/Update)Input records
Returns

Promise<T[]>

PromisePromise<T[]>Required
updated prices list

addPrices

**addPrices**(id, prices, replace?): Promise&#60;[PriceList](/references/services/classes/PriceList)&#62;

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

Parameters
idstringRequired
id of the price list
prices to add
replacebooleanRequired
whether to replace existing prices

Default: false

Returns

Promise<PriceList>

PromisePromise<PriceList>Required
updated Price List

atomicPhase_

Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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
TResultobjectRequired
TErrorobjectRequired
Parameters
work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (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>

PromisePromise<TResult>Required
the result of the transactional work

clearPrices

**clearPrices**(id): Promise&#60;void&#62;

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

Parameters
idstringRequired
id of the price list
Returns

Promise<void>

PromisePromise<void>Required
updated Price List

create

**create**(priceListObject): Promise&#60;[PriceList](/references/services/classes/PriceList)&#62;

Creates a Price List

Parameters
priceListObjectCreatePriceListInputRequired
the Price List to create
Returns

Promise<PriceList>

PromisePromise<PriceList>Required
created Price List

delete

**delete**(id): Promise&#60;void&#62;

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

Parameters
idstringRequired
id of the price list
Returns

Promise<void>

PromisePromise<void>Required
empty promise

deletePrices

**deletePrices**(id, priceIds): Promise&#60;void&#62;

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

Parameters
idstringRequired
id of the price list
priceIdsstring[]Required
ids of the prices to delete
Returns

Promise<void>

PromisePromise<void>Required
updated Price List

deleteProductPrices

**deleteProductPrices**(priceListId, productIds): Promise&#60;[string[], number]&#62;

Parameters
priceListIdstringRequired
productIdsstring[]Required
Returns

Promise<[string[], number]>

PromisePromise<[string[], number]>Required

deleteVariantPrices

**deleteVariantPrices**(priceListId, variantIds): Promise&#60;[string[], number]&#62;

Parameters
priceListIdstringRequired
variantIdsstring[]Required
Returns

Promise<[string[], number]>

PromisePromise<[string[], number]>Required

list

**list**(selector?, config?): Promise&#60;[PriceList](/references/services/classes/PriceList)[]&#62;

Lists Price Lists

Parameters
selectorFilterablePriceListPropsRequired
the query object for find

Default: {}

configFindConfig<PriceList>Required
the config to be used for find
Returns

Promise<PriceList[]>

PromisePromise<PriceList[]>Required
the result of the find operation

listAndCount

**listAndCount**(selector?, config?): Promise&#60;[[PriceList](/references/services/classes/PriceList)[], number]&#62;

Lists Price Lists and adds count

Parameters
selectorFilterablePriceListPropsRequired
the query object for find

Default: {}

configFindConfig<PriceList>Required
the config to be used for find
Returns

Promise<[PriceList[], number]>

PromisePromise<[PriceList[], number]>Required
the result of the find operation

listPriceListsVariantIdsMap

**listPriceListsVariantIdsMap**(priceListIds): Promise&#60;&#123; [priceListId: string]: string[]; &#125;&#62;

Parameters
priceListIdsstring | string[]Required
Returns

Promise<{ [priceListId: string]: string[]; }>

PromisePromise<{ [priceListId: string]: string[]; }>Required

listProducts

**listProducts**(priceListId, selector?, config?, requiresPriceList?): Promise&#60;[[Product](/references/services/classes/Product)[], number]&#62;

Parameters
priceListIdstringRequired

Default: {}

configFindConfig<Product>Required
requiresPriceListbooleanRequired

Default: false

Returns

Promise<[Product[], number]>

PromisePromise<[Product[], number]>Required

listVariants

**listVariants**(priceListId, selector?, config?, requiresPriceList?): Promise&#60;[[ProductVariant](/references/services/classes/ProductVariant)[], number]&#62;

Parameters
priceListIdstringRequired

Default: {}

configFindConfig<ProductVariant>Required
requiresPriceListbooleanRequired

Default: false

Returns

Promise<[ProductVariant[], number]>

PromisePromise<[ProductVariant[], number]>Required

retrieve

**retrieve**(priceListId, config?): Promise&#60;[PriceList](/references/services/classes/PriceList)&#62;

Retrieves a product tag by id.

Parameters
priceListIdstringRequired
the id of the product tag to retrieve
configFindConfig<PriceList>Required
the config to retrieve the tag by

Default: {}

Returns

Promise<PriceList>

PromisePromise<PriceList>Required
the collection.

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters
errRecord<string, unknown> | { code: string }Required
Returns

boolean

booleanboolean

update

**update**(id, update): Promise&#60;[PriceList](/references/services/classes/PriceList)&#62;

Updates a Price List

Parameters
idstringRequired
the id of the Product List to update
updateUpdatePriceListInputRequired
the update to apply
Returns

Promise<PriceList>

PromisePromise<PriceList>Required
updated Price List

upsertCustomerGroups_

Protected **upsertCustomerGroups_**(priceListId, customerGroups): Promise&#60;void&#62;

Parameters
priceListIdstringRequired
customerGroups{ id: string }[]Required
Returns

Promise<void>

PromisePromise<void>Required

withTransaction

**withTransaction**(transactionManager?): [PriceListService](/references/services/classes/PriceListService)

Parameters
transactionManagerEntityManager
Returns

PriceListService

PriceListServicePriceListServiceRequired
Was this section helpful?