Requires write_products
access scope. Also: The user must have a permission to update product variants.
Updates multiple product variants for a single product in one operation. You can run this mutation directly or as part of a bulk operation for large-scale catalog updates.
Use the productVariantsBulkUpdate
mutation to efficiently modify product variants—such as different sizes, colors, or materials—associated with an existing product. The mutation is helpful if you need to update a product's variants in bulk, such as importing from an external system.
The mutation supports:
After creating variants, you can make additional changes using the productSet
mutation, which is used to perform multiple operations on products, such as creating or modifying product options and variants.
You can also specifically manage product options through related mutations:
Learn more about the product model and adding product data.
When partial updates are allowed, valid variant changes may be persisted even if some of the variants updated have invalid data and cannot be persisted. When partial updates are not allowed, any error will prevent all variants from updating.
List of new media to be added to the product.
The ID of the product associated with the variants to update.
An array of product variants to update.
The updated product object.
The list of errors that occurred from executing the mutation.
mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants) { product { id } productVariants { id metafields(first: 2) { edges { node { namespace key value } } } } userErrors { field message } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants) { product { id } productVariants { id metafields(first: 2) { edges { node { namespace key value } } } } userErrors { field message } } }", "variables": { "productId": "gid://shopify/Product/20995642", "variants": [ { "id": "gid://shopify/ProductVariant/1070325197", "metafields": [ { "id": "gid://shopify/Metafield/1069229095", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "RUBBER", "type": "single_line_text_field" } ] }, { "id": "gid://shopify/ProductVariant/1070325198", "metafields": [ { "id": "gid://shopify/Metafield/1069229096", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "CREPE", "type": "single_line_text_field" } ] } ] } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants) { product { id } productVariants { id metafields(first: 2) { edges { node { namespace key value } } } } userErrors { field message } } }`, { variables: { "productId": "gid://shopify/Product/20995642", "variants": [ { "id": "gid://shopify/ProductVariant/1070325197", "metafields": [ { "id": "gid://shopify/Metafield/1069229095", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "RUBBER", "type": "single_line_text_field" } ] }, { "id": "gid://shopify/ProductVariant/1070325198", "metafields": [ { "id": "gid://shopify/Metafield/1069229096", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "CREPE", "type": "single_line_text_field" } ] } ] }, }, ); const data = await response.json();
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants) { product { id } productVariants { id metafields(first: 2) { edges { node { namespace key value } } } } userErrors { field message } } }`, "variables": { "productId": "gid://shopify/Product/20995642", "variants": [ { "id": "gid://shopify/ProductVariant/1070325197", "metafields": [ { "id": "gid://shopify/Metafield/1069229095", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "RUBBER", "type": "single_line_text_field" } ] }, { "id": "gid://shopify/ProductVariant/1070325198", "metafields": [ { "id": "gid://shopify/Metafield/1069229096", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "CREPE", "type": "single_line_text_field" } ] } ] }, }, });
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkUpdate(productId: $productId, variants: $variants) { product { id } productVariants { id metafields(first: 2) { edges { node { namespace key value } } } } userErrors { field message } } } QUERY variables = { "productId": "gid://shopify/Product/20995642", "variants": [ { "id": "gid://shopify/ProductVariant/1070325197", "metafields": [ { "id": "gid://shopify/Metafield/1069229095", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "RUBBER", "type": "single_line_text_field" } ] }, { "id": "gid://shopify/ProductVariant/1070325198", "metafields": [ { "id": "gid://shopify/Metafield/1069229096", "value": "SYNTHETIC LEATHER" }, { "namespace": "my_fields", "key": "sole_material", "value": "CREPE", "type": "single_line_text_field" } ] } ] } response = client.query(query: query, variables: variables)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4