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 | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredEvents.DELETED
stringRequiredEvents.UPDATED
stringRequiredAccessors
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.
Parameters
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.
Parameters
Returns
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
q
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
stringRequiredReturns
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
stringRequiredReturns
Deprecated
use addOrUpdateCurrencyPrices instead Sets the default price for the given currency.
setRegionPrice
Parameters
variantId
stringRequiredReturns
Deprecated
use addOrUpdateRegionPrices instead Sets the default price of a specific region
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
booleanupdate
**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
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
Returns
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
stringRequiredReturns
Promise
Promise<void>RequiredupdateVariantPricesBatch
Parameters
Returns
Promise
Promise<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
Promise
Promise<void>RequiredupsertRegionPrices
Parameters
Returns
Promise
Promise<void>RequiredvalidateVariantsToCreate_
Parameters
Returns
void
voidwithTransaction
Parameters
transactionManager
EntityManager