Copying prefixed tags to metafields in Shopify
It is common practice to use prefixed tags, like brand=Ablestar to store additional product data in Shopify. With Shopify's focus on metafields, and the new Search & Discovery app, you may need to move the data from these prefixed tags into metafields. For example, you may need to set a 'Brand' metafield to be the value of whatever comes after the 'brand=' part of a tag.
In this article we will show you how to set these metafields in a couple steps.
Creating a new metafield definition
If you haven't already, you'll need to create a new metafield definition in the Shopify admin. This is the name of the metafield where you'll store the value from the prefixed tags. To create a new metafield definition:
- Open up the settings section of the Shopify Admin and click on Custom Data
- Click on Products to view your product metafield definitions
- Click on Add definition to create a new definition
- Fill out the name for the new definition (eg, 'Brand') and set the type to 'Single Line Text'
- Click on Save to create your new metafield definition
Refresh the metafield definitions in the Bulk Product Editor
- Go to Settings -> Metafields in the menu on the left
- Click on the Refresh button in the 'Shopify Metafield Definitions' section of the page
- Wait a second until the new metafield definitions appear
Edit the metafield using a prefixed tag
Now we are ready to run the actual edit. Go to the Home section of the app and search for the products you want to edit. Once you have them selected:
- Click on Edit Products at the top right of the screen
- Click on the button underneath 'Field to Edit' and choose the metafield that you want to set
- To add a dynamic value, click on Add placeholder and select Tag Suffix from the dropdown
- A window will open up asking for the tag prefix, enter the part of the tag like 'brand=' that you want to look for and click on Add placeholder
- Verify that the products look accurate in the preview and click on Run Edit