---
displayed_sidebar: productReference
badge:
  variant: orange
  text: Beta
slug: /references/product/updateVariants
sidebar_label: updateVariants
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# updateVariants - Product Module Reference

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

This method is used to update a product's variants.

## Example

```ts
import {
  initialize as initializeProductModule,
} from "@medusajs/product"
import { 
  UpdateProductVariantDTO
} from "@medusajs/product/dist/types/services/product-variant"

async function updateProductVariants (items: UpdateProductVariantDTO[]) {
  const productModule = await initializeProductModule()

  const productVariants = await productModule.updateVariants(items)

  // do something with the product variants or return them
}
```

## Parameters

<ParameterTypes parameters={[
  {
    "name": "data",
    "type": "[UpdateProductVariantDTO](../../product/interfaces/product.UpdateProductVariantDTO.mdx)[]",
    "description": "The product variants to update.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "allow_backorder",
        "type": "`boolean`",
        "description": "Whether the product variant can be ordered when it's out of stock.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "barcode",
        "type": "`string`",
        "description": "The barcode of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "ean",
        "type": "`string`",
        "description": "The EAN of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "height",
        "type": "`number`",
        "description": "The height of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "hs_code",
        "type": "`string`",
        "description": "The HS Code of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "id",
        "type": "`string`",
        "description": "The ID of the product variant to update.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "inventory_quantity",
        "type": "`number`",
        "description": "The inventory quantiy of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "length",
        "type": "`number`",
        "description": "The length of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "manage_inventory",
        "type": "`boolean`",
        "description": "Whether the product variant's inventory should be managed by the core system.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "material",
        "type": "`string`",
        "description": "The material of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "metadata",
        "type": "`Record<string, unknown>`",
        "description": "Holds custom data in key-value pairs.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "mid_code",
        "type": "`string`",
        "description": "The MID Code of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "options",
        "type": "[CreateProductVariantOptionDTO](../../product/interfaces/product.CreateProductVariantOptionDTO.mdx)[]",
        "description": "The product variant options to create and associate with the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "option_id",
            "type": "`string`",
            "description": "",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "value",
            "type": "`string`",
            "description": "The value of a product variant option.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      },
      {
        "name": "origin_country",
        "type": "`string`",
        "description": "The origin country of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "sku",
        "type": "`string`",
        "description": "The SKU of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "title",
        "type": "`string`",
        "description": "The tile of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "upc",
        "type": "`string`",
        "description": "The UPC of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "weight",
        "type": "`number`",
        "description": "The weight of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "width",
        "type": "`number`",
        "description": "The width of the product variant.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "sharedContext",
    "type": "[Context](../../product/interfaces/product.Context.mdx)",
    "description": "A context used to share resources, such as transaction manager, between the application and the module.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "enableNestedTransactions",
        "type": "`boolean`",
        "description": "A boolean value indicating whether nested transactions are enabled.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "isolationLevel",
        "type": "`string`",
        "description": "A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "manager",
        "type": "`TManager`",
        "description": "An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionId",
        "type": "`string`",
        "description": "A string indicating the ID of the current transaction.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionManager",
        "type": "`TManager`",
        "description": "An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />

## Returns

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ProductVariantDTO](../../product/interfaces/product.ProductVariantDTO.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "The updated product variants's details.",
    "expandable": false,
    "children": [
      {
        "name": "ProductVariantDTO[]",
        "type": "[ProductVariantDTO](../../product/interfaces/product.ProductVariantDTO.mdx)[]",
        "optional": false,
        "defaultValue": "",
        "description": "",
        "expandable": false,
        "children": [
          {
            "name": "ProductVariantDTO",
            "type": "`object`",
            "description": "A product variant's data.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      }
    ]
  }
]} />
