must list all of variants when update a variants?

Solved
zhagan
Excursionist
16 1 0

Do I have to list all variants in request when I just want to  update one of them ?

Update a product and one of its variants

PUT /admin/api/2021-04/products/632910392.json

 

{
  "product": {
    "id": 632910392,
    "title": "Updated Product Title",
    "variants": [
      {
        "id": 808950810,
        "price": "2000.00",
        "sku": "Updating the Product SKU"
      },
      {
        "id": 49148385
      },
      {
        "id": 39072856
      },
      {
        "id": 457924702
      }
    ]
  }
}

 

 

0 Likes
awwdam
Shopify Staff
Shopify Staff
55 4 1

This is an accepted solution.

Hey @zhagan,

Listing the variants of a product would be required when updating a product and variant(s) via the REST Admin API. Alternatively you can update a product and just a single variant with independent requests. Feel free to look into the following resource, which has steps for updating single product variants (see our REST Product Variant Doc here).

Product Variant - modify an existing variant |PUT /admin/api/2021-04/variants/{variant_id}.json 

 

{ 
  "variant": {
    "id": [ENTER VARIANT ID], 
    "option1": "Not Pink", 
    "price": "99.00" 
  } 
}

 

 

 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
zhagan
Excursionist
16 1 0

@awwdam Thank you for your answer, that is good idea to update a variant in this way.

 

0 Likes