Solved

mutation productOptionsCreate only creates one option value per option

jjjjjj7787
Shopify Partner
3 1 1

Given the input:

 

 

{
  "productId": "gid://shopify/Product/XXXXX",
  "options": [
    {
      "name": "Size",
      "values": [
        {
          "name": "Small"
        },
        {
          "name": "Medium"
        },
        {
          "name": "Large"
        }
      ]
    }
  ]
}

 

 

The product option "Size" is created with only the first value "Small".

Any Idea why this is happening?

Accepted Solution (1)

jjjjjj7787
Shopify Partner
3 1 1

This is an accepted solution.

I found the solution so I'm posting it here in case anyone else faces the same issue.


First, create a standalone variant using the productCreate mutation, then overwrite it using the productVariantsBulkCreate mutation as explained in this doc. https://shopify.dev/docs/api/admin/migrate/new-product-model/add-data

View solution in original post

Replies 3 (3)

Notified
Shopify Partner
11 1 0

product->options .. refers to the name of the option and not its values.

product->variants->options refers to actual values . beware though product->variants will be deprecated in next release [2024-04]

 

 

May be try the following 



{
"title": " Title ..... ",
"published": true,
"options": [
"Size"
],
"handle": "handle....",
"variants": [
{
"options": [
"Small"
]
},
{
"options": [
"Large"
]
}
]
}

 

 

jjjjjj7787
Shopify Partner
3 1 1

Thank you for your reply. I am using API version 2024-04. `product->options` and `product->variants` are deprecated.

jjjjjj7787
Shopify Partner
3 1 1

This is an accepted solution.

I found the solution so I'm posting it here in case anyone else faces the same issue.


First, create a standalone variant using the productCreate mutation, then overwrite it using the productVariantsBulkCreate mutation as explained in this doc. https://shopify.dev/docs/api/admin/migrate/new-product-model/add-data