How to manage Shopify Metafields?


Here we will take a look at how to create, update and delete your Shopify metafields. As well as we will have a small insight on how to display your metafields in your storefront. We will take a look at the metafields for Products, but you can also manage your metafields with the Excelify for:

Creating Metafields

1. Export your Products with the Excelify app.

Export Products in Shopify

2. To create and manage our Metafields we will only need basic columns from exported file to identify the Product, so from exported file delete all columns except:

  • ID
  • Handle
Product identification columns Excelify

3. How to construct Metafield column.

Metafields are constructed by principle – Metafield: Namespace.Key [Metafield type], so let’s break it down:

  • Metafield: – This part allows our app to understand that this column will contain Metafield.
  • Namespace – This is a category or, how I like to say, a folder that contains your Metafields, so you can group different Metafields into these imaginary “folders”.
  • Key – The name of Metafield.
  • Metafield Type – There are 3 types of Metafields in Shopify – integer, string and json_string. Today we will be looking at string Metafields as they are the most popular.

4. Create your own Metafield column.

We will assume that we wish to display some custom product specification on our storefront so our Metafield column name will be ‘Metafield: specs.material [string].

Metafield column Excelify Shopify

5. Fill your Metafield column with values that you wish to be displayed.

Create metafield Shopify

6. Save & Import.

7. Check your new Metafields.

Sadly we cannot really see Metafields anywhere in Shopify so at the moment we can export our Products with Metafields to see in the exported file if they have stored correctly.

Updating Metafields

1. Export your Products with Metafields.

2. Delete unnecessary columns.

To update metafields we will only need Product identification columns and Metafield columns, so delete all columns except:

  • Id
  • Handle
  • Metafield: … (all your metafields columns)

3. Edit values for the Metafields you wish to update.

4. Save & Import your updated file.

5. Check your updated Metafields. 

To see updated Metafields you can export your Products with Metafields just as in the #8 step.

Deleting Metafields

1. Export your Products with the Metafields.

2. Delete unnecessary columns.

To delete metafields we will only need Product identification columns and Metafield columns you wish to delete, so delete all columns except:

  • Id
  • Handle
  • Metafield: … (Metafield columns you wish to delete)

3. Delete values from Metafield column.

To delete a metafield we do need to just delete all values within its column and import this metafield empty.

4. Save & Import.

The app now deleted metafields for the products that had empty value for those metafields.

Displaying metafields

Metafields are custom fields that you can use in various places, for example if you need to store some custom information that you will use in your exported reports, but one of main metafield usage is to display this custom stored information in your store, so we will now take a quick look on how to acheive this.

1. Create your metafields.

For this please follow list points #1 – #7.

2. Go to your Themes code in your Shopify Admin.

You can locate your themes code going in your Shopify Admin -> Online Store -> Themes -> Actions -> Edit Code

Edit themes code in Shopify

3. Locate product.liquid

product.liquid contains the code for the page that displays your products.

Liquid product Code file

4. Add code to display your Metafield

Now we will add just one line of code to display this new Metafields we created in the ‘Create Metafield’ section.

Material: {{ product.metafields.specs.material }}

Shopify liquid code Metafield

5. Save and go check any product in your store.

Custom text in storepage

Good to know!

Export Metafields to CSV

Export Shopify Metafields to CSV

Do you remember the time when you had to export only to Excel format if you wanted to export Metafields? And when you asked us to export Metafields to CSV format, we said it’s technically very challenging.

Know what? We did it! You can export your Metafields now also to the “Excelify: CSV” format as well.

It means that now you can make the large backups of your whole store, including the Metafields, and restore it easily on the same or on a different store. Using this CSV format for very large files will be faster, and less demanding on our server resources.

Also, you can import Metafields columns from CSV.

Read more about Metafields here.

Import Shopify Metafields as json_string

Shopify import Metafields as json_string

To import the Metafields to Shopify as json_string type, import the Metafield column with the “[json_string]” suffix.

For example, your Metafield import column can be:

Metafield: custom.json [json_string]

Then you can use this field in your Shopify Liquid theme as the JSON object.

Read more about importing Metafields to Shopify using Excelify.

Product Variant Metafields

Shopify variant metafields

The same way as you have “Metafield:” columns, you now have the “Variant Metafield:” columns for Products where you can export and import variant metafields.

For example:

  • The variant metafield with name “buy_price” in the global namespace should be called “Variant Metafield: buy_price”.
  • The variant metafield with name “description” in the “details” namespace should be called “Variant Metafield: details.description”.

Note that exporting and importing Variant Metafields will significantly increase the time it takes to process the items because each variant metafield needs separate request to the Shopify API. Therefore, be mindful and export/import variant metafields only when you really need them.

To start using variant metafields, refresh the app page.

Metafields import

Speed: Metafields import speed doesn’t depend on Metafield count anymore. Even for 100 Metafields per item, it will import as quickly as with no Metafields.

Delete: You can delete Metafields for items just by clearing values in that Metafield column, and importing.

Set type: Metafield can have “string” or “integer” type, which is now auto-detected from Excel cell type, and set correctly when you do the import.

Read more: Metafields template documentation