It looks like we should be able to create products with linkedMetafields now, but the documentation on shopify.dev seems out of date and the examples don’t work.
For example, this GraphQL productCreate (2024-07) mutation raises error “Cannot specify ‘values’ for an option linked to a metafield.” It’s unclear what goes in productOptions.values.linkedMetafieldValue and what goes in productOptions.linkedMetafield.values. The documentation’s explanation doesn’t clarify anything. Anyone got linkedMetafield to work?
This input below raises “Cannot specify ‘values’ for an option linked to a metafield.”
{
title: "Product Test",
status: "ACTIVE",
category: "gid://shopify/TaxonomyCategory/hg-13-9",
productOptions: [
{
name: "Color",
position: 1,
values:
{ name: "Green", linkedMetafieldValue: "gid://shopify/Metaobject/65800667298" }
{ name: "Clear", linkedMetafieldValue: "gid://shopify/Metaobject/65800339618" },
{ name: "Brown", linkedMetafieldValue: "gid://shopify/Metaobject/65800700066" }
],
linkedMetafield: {
namespace: "shopify",
key: "color-pattern",
values: ["gid://shopify/Metaobject/65800667298", "gid://shopify/Metaobject/65800339618", "gid://shopify/Metaobject/65800700066"]
}
}
]
}
This input below raises “At least one value for the option linked to the ‘shopify.color-pattern’ metafield is invalid”
{
title: "Product Test",
status: "ACTIVE",
category: "gid://shopify/TaxonomyCategory/hg-13-9",
productOptions: [
{
name: "Color",
position: 1,
values:
linkedMetafield: {
namespace: "shopify",
key: "color-pattern",
values: ["gid://shopify/Metaobject/65800667298", "gid://shopify/Metaobject/65800339618", "gid://shopify/Metaobject/65800700066"]
}
}
]
}
Here’s the pretty obtuse explanation on how to use linkedMetafields.
