A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hey,
I was working with creating a product with variants which had unique prices and inventory quantities and found that the 'REMOVE_STANDALONE_VARIANT' wasn't working. When I try to request productVariantsBulkCreate using that param, I am hit with the error:
"userErrors": [
{
"field": ["variants", "0"],
"message": "The variant '11 / 2323' already exists. Please change at least one option value."
}
]
Don;t mind the weird option names, they were typed in haste.
The 11/ 2323 variant is created when I add options to the product in my 'productOptionsCreate' which returns this as the variant.
"variants": {
"nodes": [
{
"id": "gid://shopify/ProductVariant/49370552041756",
"title": "11 / 2323",
"selectedOptions": [
{ "name": "test", "value": "11" },
{ "name": "test_2", "value": "2323" }
]
}
]
},
I believe this is an bug, but just in case I will include my full query:
{
"query": "mutation productVariantsBulkCreate($productId: ID!, $variantsInput: [ProductVariantsBulkInput!]!) {\n productVariantsBulkCreate(productId: $productId, variants: $variantsInput) {\n product {\n id\n }\n productVariants {\n id\n metafields(first: 1) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}",
"variables": {
"productId": "gid://shopify/Product/9530321109276",
"strategy": "REMOVE_STANDALONE_VARIANT",
"variantsInput": [
{
"price": 2323,
"inventoryQuantities": [
{
"availableQuantity": 23,
"locationId": "gid://shopify/Location/98154283292"
}
],
"optionValues": [
{ "name": "11", "optionName": "test" },
{ "name": "2323", "optionName": "test_2" }
]
},
{
"price": 3,
"inventoryQuantities": [
{
"availableQuantity": 43,
"locationId": "gid://shopify/Location/98154283292"
}
],
"optionValues": [
{ "name": "11", "optionName": "test" },
{ "name": "232", "optionName": "test_2" }
]
}
]
}
}
Thanks for all the help!
Solved! Go to the solution
This is an accepted solution.
Found out I was being silly - for anyone stumbling across this in the future the solution is adding the ProductVariantsBulkCreateStrategy variable to the GQL request.
This is an accepted solution.
Found out I was being silly - for anyone stumbling across this in the future the solution is adding the ProductVariantsBulkCreateStrategy variable to the GQL request.