Hello,
I want to link existing product options to a metafield.
Manually it would look like this:
-
Select “connect metafield” in the color option
-
Choose “color”
It would then look like this:
It pulled the data from my pre-defined color product category metafield:
I’m currently trying to reproduce the linking of the color metafield to the option but I cant get it to work.
What I tried so far:
Use an admin API request > productOptionUpdate
Mutation input:
{
“productId”: “gid://shopify/Product/8582628278424”,
“option”:
{
“linkedMetafield”: {
“key”: “color-pattern”,
“namespace”: “shopify”
},
“id”: “gid://shopify/ProductOption/10830831321240”,
“name”: “Color”,
“position”: 1
},
“optionValuesToUpdate”: [
{
“id”: “gid://shopify/ProductOptionValue/4298614374552”,
“name”: “Charcoal”,
“linkedMetafieldValue”: “gid://shopify/Metaobject/73278357656”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614243480”,
“name”: “White”,
“linkedMetafieldValue”: “gid://shopify/Metaobject/73278259352”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614276248”,
“name”: “Black”,
“linkedMetafieldValue”: “gid://shopify/Metaobject/73278226584”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614341784”,
“name”: “Military Green”,
“linkedMetafieldValue”: “gid://shopify/Metaobject/73278324888”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614407320”,
“name”: “Heather Red”,
“linkedMetafieldValue”: “gid://shopify/Metaobject/73278292120”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614309016”,
“name”: “Natural”,
“linkedMetafieldValue”: “gid://shopify/Metaobject/73278193816”
}
]
}
What is wrong with this input? There is currently no metafield linked, but I get this error message in flow:
“Mutation had user errors: “An option cannot have both metafield linked and nonlinked option values.””
This is how it looks right now:
“options”: [
{
“linkedMetafield”: null,
“id”: “gid://shopify/ProductOption/10830831321240”,
“name”: “Color”,
“optionValues”: [
{
“id”: “gid://shopify/ProductOptionValue/4298614374552”,
“linkedMetafieldValue”: null,
“name”: “Charcoal”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614243480”,
“linkedMetafieldValue”: null,
“name”: “White”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614276248”,
“linkedMetafieldValue”: null,
“name”: “Black”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614341784”,
“linkedMetafieldValue”: null,
“name”: “Military Green”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614407320”,
“linkedMetafieldValue”: null,
“name”: “Heather Red”
},
{
“id”: “gid://shopify/ProductOptionValue/4298614309016”,
“linkedMetafieldValue”: null,
“name”: “Natural”
}
]
}


