Save Time With Metaobjects in Shopify
You can create metaobjects in a few simple steps, even without coding experience.
The release of Shopify 2.0 introduced metafields and metaobjects, two helpful features every store owner can use without knowing how to write code as long as they use a Shopify 2.0 Theme.
Metafields and metaobjects are related but not identical.
Metafields are custom fields that extend an existing Shopify object, such as products, variants, collections, customers, orders, blog posts, and other areas of your Shopify store.
Metaobjects are custom objects that are entirely separate from an existing Shopify object. Metaobjects also have fields. These fields use the same content type classifications as metafields, which can initially be a bit confusing.
What makes metaobjects unique and a tremendous time safer is that a metafield can refer to a metaobject.
Suppose your Shopify store sells designer goods, and you want to display the designer's bio below the product description. You could add a metafield to the product object and copy the designer's bio to each product. But that would be redundant. If you had to tweak the bio, you would need to copy the new text to each product. Updating an extensive catalog can take a long time.
But there is a faster way by using a metaobject instead of a metafield.
How to Create a Metaobject
Following my example, instead of adding a metafield to the product object, you create an independent metaobject called Designer with four fields:
Designer-Name with the content type single-line text;
Designer-Headline with the content type single-line text;
Designer-Bio with the content type multi-line text and
Designer-Picture with the content type file.
Here are the steps in Shopify:
Go to Shopify Admin > Content > Metaobjects.
Click Add Definitions.
Enter a Name and a Description.
Add the Fields and select each field's Content Type.
Save.
How to Add Data to a Metaobject
Adding data to an existing metaobject is straightforward, like filling out a form.
Go to Shopify Admin > Content > Metaobjects.
Click the metaobject to which you want to add a record. In my example, it would be the metaobject Designer.
Click Add Entry.
Fill out the form.
Click Save.
Add as many entries as you need.
How to Reference a Metaobject
To use the data you have entered in the metaobject with one of the built-in Shopify objects, you need to create a metafield that points to it.
In my example, if you want to add the designer's name to each product, add a metafield Product Designer to the product object and point it to the metaobject Designer.
Go to Shopify Admin > Content > Metaobjects.
Click Manage Definitions.
Under Metafield Definitions, select Products.
Click Assigned to all Products.
Click Add Definition.
Enter a Name and a Description. In my example, under Name, type in Product Designer. Enter a description.
Select a Metafield Content Type. From the list of content types, choose Metaobject.
Select a metaobject from the dropdown list. In my example, select the metaobject Designer.
Save
The last step is to add the designer's name to each product.
Go to Shopify Admin > Products.
Select a product.
Scroll down to Product Metafields.
Click the metafield Product Designer.
Select the Entry.
Save.
Repeat for each product.
How to Connect a Field in a Metaobject to a Theme Using the Theme Editor
If you use a Shopify 2.0 theme, you can use the built-in Theme Editor to connect a field in a metaobject to your theme without needing to write code.
Go to Shopify Admin > Online Store.
Under your current theme, click Customize.
Select the page template at the top of the Theme Editor, for example, Home Page or Products > Default Product.
Add a new section or add a new block within an existing section.
Choose the section or block type, such as Collapsible Tab.
Click the Collapsible Tab you just created.
Under content, click the icon Connect Dynamic Source.
Click Products from the menu.
Select a metaobject from the list.
Select a field from the list. Please note that only fields with a compatible content type will be displayed. If your field doesn't show up, the content type is likely incompatible. In this case, go back to the definition of this metaobject and change the content type of this field.
Save your template.
Metaobjects โ The Time Saver
Metaobjects can save you a lot of time when you need to make changes to your online store.
Suppose the bio of one of the designers in my example needs to be updated. Instead of updating each product, you simply update the entry in the metaobject. That's it.
Go to Shopify Admin > Content > Metaobjects.
Click the metaobject to be updated. In my example, it would be the metaobject Designer.
Click the Entry to be updated.
Update the form.
Click Save.
Since the reference to the metaobject has not changed, the update will automatically display the next time a website visitor clicks on the product.