A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm Trying To Create A Product With Multiple Product Option Here Is The JSON I'm Using.
API URL : https://xyz.myshopify.com/admin/api/2020-07/products.json
JSON :
{
"product": {
"title": "New Product Json",
"body_html": "XYZ",
"vendor": "MySHOP",
"product_type": "",
"published": true,
"tags": "test, test new",
"images": [{
"src": "https://www.w3schools.com/w3css/img_lights.jpg"
}],
"variants": [{
"title": "26\" x 36\" \/ Horizontal",
"option1": "26\" x 36\"",
"option2": "Horizontal",
"sku": "16127874501899",
"price": 29.95
}, {
"title": "51\" x 60\" \/ Horizontal",
"option1": "51\" x 60\"",
"option2": "Horizontal",
"sku": "16127874501937",
"price": 39.95
}, {
"title": "68\" x 80\" \/ Horizontal",
"option1": "68\" x 80\"",
"option2": "Horizontal",
"sku": "16127874501039",
"price": 49.95
}, {
"title": "88\" x 104\" \/ Horizontal",
"option1": "88\" x 104\"",
"option2": "Horizontal",
"sku": "16127874501145",
"price": 59.95
}, {
"title": "26\" x 36\" \/ Vertical",
"option1": "26\" x 36\"",
"option2": "Vertical",
"sku": "161278745052",
"price": 29.95
}, {
"title": "51\" x 60\" \/ Vertical",
"option1": "51\" x 60\"",
"option2": "Vertical",
"sku": "16127874501494",
"price": 39.95
}, {
"title": "68\" x 80\" \/ Vertical",
"option1": "68\" x 80\"",
"option2": "Vertical",
"sku": "16127874501720",
"price": 49.95
}, {
"title": "88\" x 104\" \/ Vertical",
"option1": "88\" x 104\"",
"option2": "Vertical",
"sku": "16127874501733",
"price": 59.95
}]
},
"options": [{
"name": "Size",
"values": ["26\" x 36\"", "51\" x 60\"", "68\" x 80\"", "88\" x 104\""]
}, {
"name": "Alignment",
"values": ["Horizontal", "Vertical"]
}]
}
Error:
{
"errors": {
"base": [
"The variant '26\" x 36\"' already exists."
]
}
}
Please Anybody Can Help Me Out To Solve The Error. I'm Confused Where I'm Going Wrong
Solved! Go to the solution
This is an accepted solution.
Happy to help you out with this.
From the code sample provided your options definition falls outside of the product object definition. Move the options definition into the product definition as illustrated below and everything should be fine.
Hope this helps, if you have any questions please don't hesitate to reach out.
Regards,
John
John C | Developer 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
This is an accepted solution.
This is an accepted solution.
Happy to help you out with this.
From the code sample provided your options definition falls outside of the product object definition. Move the options definition into the product definition as illustrated below and everything should be fine.
Hope this helps, if you have any questions please don't hesitate to reach out.
Regards,
John
John C | Developer 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