ProductVariantService
constructor
Parameters
__namedParameters
objectRequired__namedParameters.productVariantRepository
anyRequired__namedParameters.productRepository
anyRequired__namedParameters.eventBusService
anyRequired__namedParameters.regionService
anyRequired__namedParameters.moneyAmountRepository
anyRequired__namedParameters.productOptionValueRepository
anyRequired__namedParameters.cartRepository
anyRequired__namedParameters.priceSelectionStrategy
anyRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.UPDATED
stringRequiredDefault: "product-variant.updated"
Events.CREATED
stringRequiredDefault: "product-variant.created"
Events.DELETED
stringRequiredDefault: "product-variant.deleted"
__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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>Requiredretrieve
Gets a product variant by id.
Parameters
variantId
stringRequiredReturns
retrieveBySKU
Gets a product variant by id.
Parameters
sku
stringRequiredReturns
create
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>Requiredupdate
**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
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.
Parameters
variantId
stringRequiredprices
ProductVariantPrice[]RequiredReturns
Promise
Promise<void>RequiredupdateVariantPricesBatch
Parameters
data
UpdateVariantPricesData[]RequiredReturns
Promise
Promise<void>RequiredupsertRegionPrices
Parameters
data
UpdateVariantRegionPriceData[]RequiredReturns
Promise
Promise<void>RequiredupsertCurrencyPrices
Parameters
data
object[]RequiredReturns
Promise
Promise<void>RequiredgetRegionPrice
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>RequiredsetRegionPrice
Parameters
variantId
stringRequiredprice
ProductVariantPriceRequiredReturns
Deprecated
use addOrUpdateRegionPrices instead Sets the default price of a specific region
setCurrencyPrice
Parameters
variantId
stringRequiredprice
ProductVariantPriceRequired