@jacco: There is a way around this, the productVariantsBulkCreate
mutation will work for meta-linked options - but you need to do some prep work…
-
Create the
MetaObject
(already needed to do this) and capture its ID
Repeat as needed for multiple option values being added. -
New step: using the
productOptionUpdate
mutation, add the newMetaObject
IDs to theOption
on the affected product.
Make sure you provide"variantStrategy": "LEAVE_AS_IS"
so that Shopify doesn’t automatically create variants for the new option value(s):
{
"productId": "gid://shopify/Product/7549509795926",
"variantStrategy": "LEAVE_AS_IS",
"option": {
"id": "gid://shopify/ProductOption/9701258756182"
},
"optionValuesToAdd": [
{
"linkedMetafieldValue": "gid://shopify/Metaobject/102586810454"
}
]
}
- Using the
productVariantBulkCreate
mutation, create the new variant(s) using the linked option value(s) as was attempted before.
Here is where the “must provide name or ID” error comes in… If you provide thename
for the option value in addition to the metaobject ID the mutation now works - the variant(s) are created properly with the linked option values, now that they exist on the product as valid values for the option.
So it may or may not be a validation error in the mutation. It may instead be that the productVariantsBulkCreate
mutation can’t add linked options to the product and needs help with that part of the process, and the error message it returns totally obscures that fact.