Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

mutation productOptionsCreate only creates one option value per option

Solved

mutation productOptionsCreate only creates one option value per option

jjjjjj7787
Shopify Partner
3 1 3

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 3

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 4 (4)

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 3

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

jjjjjj7787
Shopify Partner
3 1 3

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

vydiadev
Shopify Partner
1 0 0

This worked perfectly, thank you for posting your solution!

 

Specifically using `strategy: REMOVE_STANDALONE_VARIANT` variable with productVariantsBulkCreate seemed to do the trick.