↓ Skip to main content
← Back to blog

How to copy metafield and metaobject definitions to another Shopify store

Shopify has no button that copies definitions between stores. How to export metafield and metaobject definitions to a spreadsheet and import them into another store.

How to copy metafield and metaobject definitions to another Shopify store

Shopify has no button that copies metafield or metaobject definitions from one store to another. You can create them again one by one in the admin, or a developer can copy them through the Admin API. To copy them without rebuilding each one, use an import app such as Altera: export the definitions from the first store to a spreadsheet, and import the file into the second store.

Altera exports metafield definitions and metaobject definitions in one file. The import creates the metaobject definitions first, so the metafield definitions that reference them work, and it updates definitions that already exist instead of making duplicates.

What Shopify offers
#

MethodWho it is forCopies to another store
Shopify adminAnyone, one definition at a timeNo
Shopify CLIApp developers, for the app’s own definitionsOnly to stores with the app installed
Admin APIDevelopers who write a scriptYes, with code
Spreadsheet import appMerchants and agenciesYes

The admin. You add metafield definitions in Settings > Metafields and metaobjects, and metaobject definitions in Content > Metaobjects or Settings > Custom data. Shopify’s Help Center articles on metafield definitions and metaobjects describe how to create them in the admin. They do not describe an export, an import, or a copy to another store.

Shopify CLI. The command shopify app import custom-data-definitions is for app developers. It reads the definitions that your app owns (namespace $app, or metaobject types such as $app:author) from a development store or a Shopify Plus sandbox store, and converts them to TOML for shopify.app.toml. When you run shopify app deploy, Shopify creates those definitions on every store that has the app installed. See the announcement on the developer changelog. It does not copy the definitions that a merchant made in the admin, which are usually in the custom namespace.

The Admin API. A developer can read the definitions with the metafieldDefinitions and metaobjectDefinitions queries, and create them on the other store with metafieldDefinitionCreate and metaobjectDefinitionCreate. The script must create the metaobject definitions first, and it must change the IDs in the reference validations, because each store gives its definitions different IDs.

A spreadsheet import app does the same work without code. The rest of this guide uses Altera.

Copy the definitions with a spreadsheet
#

Install Altera on both stores. You export on the source store and import on the destination store.

1. Export from the source store
#

In Altera on the source store, click New export. Select Metafield definitions and Metaobject definitions, and click Start export. When the job is done, click Download output.

Altera export page with Metafield definitions and Metaobject definitions selected. The metafield definitions have a filter Namespace is not equal to shopify, and the file format is Excel
Both definition types in one export. The namespace filter is added for you.

The export adds the filter Namespace is not equal to shopify to the metafield definitions. Definitions in that namespace belong to Shopify, and apps can’t create them on another store.

The Excel file has a sheet for each data type: Metafield Definitions and Metaobject Definitions.

2. Check the file
#

The Metafield Definitions sheet has one row per definition:

OwnerHandleNameType
Productscustom.designerDesignermetaobject_reference
Productscustom.care_instructionsCare instructionsmulti_line_text_field
Variantscustom.fitFitsingle_line_text_field

Handle is the namespace and the key, joined by a period. The file also has the columns Description, Pinned Position, the Option: columns for access and capabilities, and a Validation: column for each rule. For example, custom.fit has Slim, Regular, Relaxed in Validation: Choices.

custom.designer has designer in Validation: Metaobject Definitions. A reference to a metaobject definition uses its type, not its ID, so the file works on any store.

The Metaobject Definitions sheet has one row per field of a definition:

TypeNameField: KeyField: NameField: TypeField: Required
designerDesignernameNamesingle_line_text_fieldTRUE
designerDesignerbioBiomulti_line_text_fieldFALSE
designerDesignerportraitPortraitfile_referenceFALSE

The settings of the definition, such as Description and the Option: columns, are on the first row of each definition.

You can delete the rows of definitions that you don’t want to copy. You can leave the ID column in the file. The IDs of the source store don’t match on the destination store, so Altera looks for each metafield definition by owner and handle, and for each metaobject definition by type. For all columns, see Metafield definition fields and Metaobject definition fields.

3. Import into the destination store
#

In Altera on the destination store, click Upload file on the home page and select the file. Altera recognizes both sheets and shows the columns that it found.

Altera import screen for definitions.xlsx. The Metaobject Definitions sheet and the Metafield Definitions sheet are both ready, with their recognized columns
Both sheets are ready. The metaobject definitions are imported first.

The Command column is MERGE in an export. With MERGE, Altera creates the definitions that are missing and updates the ones that exist. You can import the same file again, and it does not create duplicates. Click Start import.

4. Check the results
#

When the job is done, download the results file and check the Import Comment column for messages about each row. Then open Settings > Metafields and metaobjects on the destination store and check a few definitions.

Test with a few definitions first if the destination store already has definitions of its own. Export them as a backup before you import.

Metaobject definitions come first
#

A metafield definition of the type metaobject_reference, list.metaobject_reference, mixed_reference, or list.mixed_reference names the metaobject definitions that it can point to. Shopify only accepts the metafield definition when those metaobject definitions exist on the store.

When both sheets are in one Excel file, Altera imports the Metaobject Definitions sheet before the Metafield Definitions sheet. A metaobject definition can also reference another metaobject definition in the same file. If you use separate files, import the metaobject definitions first.

If a referenced definition is not on the store and not in the file, the metafield definition fails with MOBD006, and a metaobject definition fails with MOBD011.

Copy only some definitions
#

Add filters to the export to copy part of the definitions:

  • Metafield definitions: Owner type (for example only products and variants), Namespace, Key, and Created at.
  • Metaobject definitions: Type and Is managed by Shopify.

Definitions that Shopify manages have a type that starts with shopify--. They are in the export by default. Product category definitions, such as shopify--color-pattern, are enabled on the destination store during the import. Other definitions that Shopify manages can’t be imported and fail with MOBD005. If you don’t need them, filter them out or delete their rows.

See Understanding filters for how filters work.

Copy the values too
#

Definitions are only the structure. The values are on the products, variants, collections, and other objects, and in the metaobject entries. After the definitions are on the destination store:

Update definitions later
#

To change many definitions at once, export them, edit the file, and import it on the same store. You can change the name, the description, the pinned position, the options, and most validations. To copy new definitions to the other store later, run the same export and import again.

Some values can’t change after a definition is created. For a metafield definition, these are the owner, the namespace, the key, and the type. For a metaobject definition, these are the type, the field keys, and the field types. Shopify also can’t change which metaobject definitions an existing reference definition points to.

Common errors and fixes
#

MDEF003: the namespace belongs to Shopify. Apps can’t create or edit definitions in the shopify namespace. Keep the default export filter, or delete these rows. For product category metafields, import the shopify-- category metaobject definitions, which Altera enables on the store.

MDEF014: the type can’t be changed. The destination store already has a definition with the same owner and handle, but with another type. Change the definition on one of the stores, or give one of them another key.

MOBD006 or MOBD011: a referenced metaobject definition is not found. Add the metaobject definition to the file, or import it first.

MOBD005: the definition is managed by Shopify. Apps can’t create these definitions, for example the definitions of the Shopify Knowledge Base app. Install that app on the destination store so that it creates its own definitions, and remove the rows from the file.

The limit of the store. Shopify allows up to 256 metafield definitions for each owner type, such as products or customers (Help Center).

The limit of the plan. On the free Starter plan, Altera imports up to 10 items of each data type per import, and each definition is one item. Altera Pro has no item limit.

FAQ
#

Can I copy metafield definitions to another Shopify store?

Yes, but not with a button in the Shopify admin. Install an import app such as Altera on both stores, export the metafield definitions from the first store, and import the file into the second store. The definitions keep their namespace, key, type, name, description, validations, and access settings.

How do I export metafield definitions?

In Altera, click New export, select Metafield definitions, and click Start export. The file has one row per definition with the owner, handle (namespace and key), name, type, description, options, and validations. You can export metaobject definitions in the same file.

Do I need to copy metaobject definitions first?

Yes, when a metafield definition references a metaobject, for example a product metafield of the type metaobject_reference. Shopify needs the metaobject definition before it can create the metafield definition. If both are sheets in one Excel file, Altera imports the metaobject definitions first.

Does Shopify CLI copy definitions between stores?

Not the definitions that you made in the admin. The shopify app import custom-data-definitions command is for app developers. It reads the definitions that an app owns from a development store and turns them into TOML for the app’s configuration file.

Does copying the definitions also copy the metafield values?

No. A definition is only the structure. To copy the values, export the products, collections, or other objects with their metafield columns, and export the metaobject entries with the Metaobjects data type. Import the definitions first.

Copy your definitions to another store.

Export metafield and metaobject definitions to one file, and import it into the other store.

Try Altera free