Skip to main content
Skip to main content

upsertVariants - Product Module Reference

This documentation provides a reference to the upsertVariants method. This belongs to the Product Module.

upsertVariants(data, sharedContext?): Promise<ProductVariantDTO[]>

This method updates existing variants, or creates new ones if they don't exist.

Example

const variants = await productModuleService.upsertVariants([
{
id: "variant_123",
title: "Green Shirt",
},
{
title: "Blue Shirt",
options: {
Color: "Blue",
},
},
])

Parameters

The attributes to update or create for each variant.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<ProductVariantDTO[]>Required
The updated and created variants.

upsertVariants(data, sharedContext?): Promise<ProductVariantDTO>

This method updates an existing variant, or creates a new one if it doesn't exist.

Example

const variant = await productModuleService.upsertVariants({
id: "variant_123",
title: "Green Shirt",
})

Parameters

The attributes to update or create for the variant.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<ProductVariantDTO>Required
The updated or created variant.
Was this section helpful?