Migrating metafields to a definition

If you want to add validation rules to an existing set of metafields, then you can migrate your metafields to a definition. When you create a custom definition for existing sets of metafields, the validation rules that you specify prevent you or your apps from adding invalid values.

You migrate your metafields by creating a custom definition for a set of metafields with a particular namespace and key. After you create a definition, if any values for your existing metafields don’t match your definition, then you need to fix your metafield values.

You can only add definitions for sets of metafields that have a namespace and key with the correct format. If your namespace and key contains special characters, then you can't migrate that set of metafields to a definition.

Create a definition for sets of metafields that don't yet have a definition

  1. From your Shopify admin, go to Settings > Metafields.
  2. In the Manage metafields section, select the category that contains the metafield that you want to edit.
  3. On the Metafield definitions page, select the namespace and key that you want to create a definition for.
  4. Enter the following information for your metafield definition:
    1. In the Name field, enter a name for your definition.
    2. Optional: In the Description field, enter a description for your metafield.
  5. Click Select content type, and then select the content type that best matches your metafield values from the dropdown menu.
  6. Configure the content type and validation information:
    1. If the content type has additional configuration options, then select the correct option for your metafield. For example, type of measurement.
    2. In the Validation section, configure the Addional rules for your definition.
    3. If the content type has a Defaults section, then select a default unit.
  7. Click Save.
  8. Review the validation results, and then click Save and continue.

If any metafield values don’t match your new definition, then you need to fix your metafield values. After you save your definition, you're automatically redirected to the bulk editor to review and fix any validation errors.

Next steps

After you add definitions for your metafields, you can do the following:

Ready to start selling with Shopify?

Try it free