ProductSet and existing global metafield

The metafields key title_tag and description_tag are used to set the SEO meta title tag and description.

To update these metafields, please use the product update query:

mutation {
  productUpdate(
    input: {
      id: "gid://shopify/Product/5591484858390"
      metafields: [
        {
          id: "gid://shopify/Metafield/21111411048611",
          value: "Matte black sunglasses"
        }
      ]
    }
  ) {
    product {
      metafields(first: 10) {
        edges {
          node {
            key
            value
          }
        }
      }
    }
  }
}

Alternatively, if you want to create/update using the product set query, use the seo field in the product set query:

mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
  productSet(synchronous: $synchronous, input: $productSet) {
    product {
      id
    }
    productSetOperation {
      id
      status
      userErrors {
        code
        field
        message
      }
    }
    userErrors {
      code
      field
      message
    }
  }
}

Variables:

{
  "productSet": {
    "id": "gid://shopify/Product/7851971248188",
    "seo": {
      "title": "The Demo product",
      "description": "The product is a test product"
    },
    "metafields": [
      {
        "key": "brand",
        "namespace": "custome",
        "type": "single_line_text_field",
        "value": "My Brand"
      }
    ]
  },
  "synchronous": true
}

Could you please try this query?

1 Like