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](../../entities/classes/entities.ProductVariant.mdx)[]>
Updates a collection of variant.
Parameters
variantData
object[]RequiredReturns
**update**(variantOrVariantId, update): Promise<[ProductVariant](../../entities/classes/entities.ProductVariant.mdx)>
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](../../entities/classes/entities.ProductVariant.mdx)>
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
ProductVariantPriceRequiredReturns
Deprecated
use addOrUpdateCurrencyPrices instead Sets the default price for the given currency.
updateOptionValue
Updates variant's option value. Option value must be of type string or number.
Parameters
variantId
stringRequiredoptionId
stringRequiredoptionValue
stringRequiredReturns
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
deleteOptionValue
Deletes option value from given variant. Will never fail due to delete being idempotent.
Parameters
variantId
stringRequiredoptionId
stringRequiredReturns
Promise
Promise<void>RequiredlistAndCount
Parameters
Returns
list
Parameters
Returns
delete
Deletes variant or variants. Will never fail due to delete being idempotent.
Parameters
variantIds
string | string[]RequiredReturns
Promise
Promise<void>RequiredisVariantInSalesChannels
Check if the variant is assigned to at least one of the provided sales channels.
Parameters
id
stringRequiredsalesChannelIds
string[]RequiredReturns
Promise
Promise<boolean>RequiredgetFreeTextQueryBuilder_
Lists variants based on the provided parameters and includes the count of variants that match the query.
Parameters
query
FindWithRelationsOptionsRequiredq
stringReturns
validateVariantsToCreate_
Parameters
variants
CreateProductVariantInput[]RequiredReturns
void
voidRequired