Skip to main content
Skip to main content
You're viewing the documentation for v1, which isn't the latest Medusa version.Latest documentation

updateVariants - Product Module Reference

Beta

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

updateVariants(id, data, sharedContext?): Promise<ProductVariantDTO>​

This method is used to update a variant.

Example​

const variant = await productModuleService.updateVariants(
"variant_123",
{
title: "Blue Shirt",
}
)

Parameters​

idstringRequired
The ID of the variant to be updated.
The attributes of the variant to be updated
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns​

PromisePromise<ProductVariantDTO>Required
The updated variant.

updateVariants(selector, data, sharedContext?): Promise<ProductVariantDTO[]>​

This method is used to update a list of variants matching the specified filters.

Example​

const variants = await productModuleService.updateVariants(
{
id: ["variant_123", "variant_321"],
},
{
title: "Blue Shirt",
}
)

Parameters​

The filters specifying which variants to update.
The attributes to be updated on the selected variants
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns​

PromisePromise<ProductVariantDTO[]>Required
The updated variants.
Was this section helpful?