ProductVariantService
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>cartRepository_Repository<Cart> & { findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations }Requiredmanager_EntityManagerRequiredmoneyAmountRepository_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 }RequiredproductRepository_Repository<Product> & { _applyCategoriesQuery: Method _applyCategoriesQuery ; _findWithRelations: Method _findWithRelations ; bulkAddToCollection: Method bulkAddToCollection ; bulkRemoveFromCollection: Method bulkRemoveFromCollection ; findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations ; findWithRelationsAndCount: Method findWithRelationsAndCount ; getCategoryIdsFromInput: Method getCategoryIdsFromInput ; getCategoryIdsRecursively: Method getCategoryIdsRecursively ; getFreeTextSearchResultsAndCount: Method getFreeTextSearchResultsAndCount ; isProductInSalesChannels: Method isProductInSalesChannels ; queryProducts: Method queryProducts ; queryProductsWithIds: Method queryProductsWithIds }RequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredEvents.DELETEDstringRequiredEvents.UPDATEDstringRequiredAccessors
activeManager_
Returns
EntityManagerEntityManagerRequiredMethods
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
variantIdstringRequiredoptionIdstringRequiredoptionValuestringRequiredReturns
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.
Parameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
PromisePromise<TResult>Requiredcreate
Creates an unpublished product variant. Will validate against parent product to ensure that the variant can in fact be created.
Parameters
Returns
PromisePromise<TOutput>Requireddelete
Deletes variant or variants. Will never fail due to delete being idempotent.
Parameters
variantIdsstring | string[]RequiredReturns
PromisePromise<void>RequireddeleteOptionValue
Deletes option value from given variant. Will never fail due to delete being idempotent.
Parameters
variantIdstringRequiredoptionIdstringRequiredReturns
PromisePromise<void>RequiredgetFreeTextQueryBuilder_
Lists variants based on the provided parameters and includes the count of variants that match the query.
Parameters
qstringReturns
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
variantIdstringRequiredReturns
PromisePromise<null | number>RequiredisVariantInSalesChannels
Check if the variant is assigned to at least one of the provided sales channels.
Parameters
idstringRequiredsalesChannelIdsstring[]RequiredReturns
PromisePromise<boolean>Requiredlist
Parameters
Returns
listAndCount
Parameters
Returns
retrieve
Gets a product variant by id.
Parameters
variantIdstringRequiredReturns
retrieveBySKU
Gets a product variant by id.
Parameters
skustringRequiredReturns
setCurrencyPrice
Parameters
variantIdstringRequiredReturns
Deprecated
use addOrUpdateCurrencyPrices instead Sets the default price for the given currency.
setRegionPrice
Parameters
variantIdstringRequiredReturns
Deprecated
use addOrUpdateRegionPrices instead Sets the default price of a specific region
shouldRetryTransaction_
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
booleanbooleanupdate
**update**(variantData): Promise<[ProductVariant](/references/js-client/internal/classes/internal.internal.ProductVariant)[]>
Updates a collection of variant.
Parameters
variantData{ updateData: [UpdateProductVariantInput](/references/js-client/internal/types/internal.UpdateProductVariantInput) ; variant: [ProductVariant](/references/js-client/internal/classes/internal.internal.ProductVariant) }[]RequiredReturns
**update**(variantOrVariantId, update): Promise<[ProductVariant](/references/js-client/internal/classes/internal.internal.ProductVariant)>
Updates a variant. Price updates should use dedicated methods. The function will throw, if price updates are attempted.
Parameters
Returns
**update**(variantOrVariantId, update): Promise<[ProductVariant](/references/js-client/internal/classes/internal.internal.ProductVariant)>
Parameters
Returns
updateBatch
Parameters
Returns
updateOptionValue
Updates variant's option value. Option value must be of type string or number.
Parameters
variantIdstringRequiredoptionIdstringRequiredoptionValuestringRequiredReturns
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
Returns
PromisePromise<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
variantIdstringRequiredReturns
PromisePromise<void>RequiredupdateVariantPricesBatch
Parameters
Returns
PromisePromise<void>RequiredupsertCurrencyPrices
Parameters
data{ price: [WithRequiredProperty](/references/js-client/internal/types/internal.internal.WithRequiredProperty)<[ProductVariantPrice](/references/js-client/internal/types/internal.ProductVariantPrice), "currency_code"> ; variantId: string }[]RequiredReturns
PromisePromise<void>RequiredupsertRegionPrices
Parameters
Returns
PromisePromise<void>RequiredvalidateVariantsToCreate_
Parameters
Returns
voidvoidwithTransaction
Parameters
transactionManagerEntityManager