ProductVariantService
constructor
Parameters
__namedParameters
ObjectRequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "product-variant.created"
Events.DELETED
stringRequiredDefault: "product-variant.deleted"
Events.UPDATED
stringRequiredDefault: "product-variant.updated"
Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
addOptionValue
Adds option value to a variant. Fails when product with variant does not exist or if that product does not have an option with the given option id. Fails if given variant is not found. Option value must be of type string or number.
Parameters
variantId
stringRequiredoptionId
stringRequiredoptionValue
stringRequiredReturns
atomicPhase_
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>Requiredcreate
Creates an unpublished product variant. Will validate against parent product to ensure that the variant can in fact be created.
Type Parameters
TVariants
CreateProductVariantInput | CreateProductVariantInput[]RequiredTOutput
objectRequiredParameters
variants
CreateProductVariantInput | CreateProductVariantInput[]RequiredReturns
Promise
Promise<TOutput>Requireddelete
Deletes variant or variants. Will never fail due to delete being idempotent.
Parameters
variantIds
string | string[]RequiredReturns
Promise
Promise<void>RequireddeleteOptionValue
Deletes option value from given variant. Will never fail due to delete being idempotent.
Parameters
variantId
stringRequiredoptionId
stringRequiredReturns
Promise
Promise<void>RequiredgetFreeTextQueryBuilder_
Lists variants based on the provided parameters and includes the count of variants that match the query.
Parameters
query
FindWithRelationsOptionsRequiredq
stringReturns
getRegionPrice
Gets the price specific to a region. If no region specific money amount exists the function will try to use a currency price. If no default currency price exists the function will throw an error.
Parameters
variantId
stringRequiredcontext
GetRegionPriceContextRequiredReturns
Promise
Promise<null | number>RequiredisVariantInSalesChannels
Check if the variant is assigned to at least one of the provided sales channels.
Parameters
id
stringRequiredsalesChannelIds
string[]RequiredReturns
Promise
Promise<boolean>Requiredlist
Parameters
Returns
listAndCount
Parameters
Returns
retrieve
Gets a product variant by id.
Parameters
variantId
stringRequiredReturns
retrieveBySKU
Gets a product variant by id.
Parameters
sku
stringRequiredReturns
setCurrencyPrice
Parameters
variantId
stringRequiredprice
ProductVariantPriceRequiredReturns
Deprecated
use addOrUpdateCurrencyPrices instead Sets the default price for the given currency.
setRegionPrice
Parameters
variantId
stringRequiredprice
ProductVariantPriceRequiredReturns
Deprecated
use addOrUpdateRegionPrices instead Sets the default price of a specific region
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanupdate
**update**(variantData): Promise<[ProductVariant](/references/entities/classes/ProductVariant)[]>
Updates a collection of variant.
Parameters
variantData
object[]RequiredReturns
**update**(variantOrVariantId, update): Promise<[ProductVariant](/references/entities/classes/ProductVariant)>
Updates a variant. Price updates should use dedicated methods. The function will throw, if price updates are attempted.
Parameters
update
UpdateProductVariantInputRequiredReturns
**update**(variantOrVariantId, update): Promise<[ProductVariant](/references/entities/classes/ProductVariant)>
Parameters
update
UpdateProductVariantInputRequiredReturns
updateBatch
Parameters
variantData
UpdateProductVariantData[]RequiredReturns
updateOptionValue
Updates variant's option value. Option value must be of type string or number.
Parameters
variantId
stringRequiredoptionId
stringRequiredoptionValue
stringRequiredReturns
updateVariantPrices
**updateVariantPrices**(data): Promise<void>
Updates variant/prices collection. Deletes any prices that are not in the update object, and is not associated with a price list.
Parameters
data
UpdateVariantPricesData[]RequiredReturns
Promise
Promise<void>Required**updateVariantPrices**(variantId, prices): Promise<void>
Updates a variant's prices. Deletes any prices that are not in the update object, and is not associated with a price list.