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?
1 Like
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"
]
}
]
}
Thank you for your reply. I am using API version 2024-04. product->options
and product->variants
are deprecated.
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
2 Likes
This worked perfectly, thank you for posting your solution!
Specifically using strategy: REMOVE_STANDALONE_VARIANT
variable with productVariantsBulkCreate seemed to do the trick.