If you want to use your metaobject in a specific part of Shopify, such as products, orders, or customers, then create a metafield reference. For example, if you built a "Product features" metaobject and you want to use it on your product pages, then you can create a product metafield that references this specific metaobject. The reference allows you to display unique "Product features" on specific products. For example, you can reference an entry called "Sustainability" on Product A, and an entry called "Materials" on Product B.
Creating a reference to a metaobject
- From your Shopify admin, go to Settings > Custom data.
- Select the part of your store that you want to create the reference for. For example, Products.
- Click Add definition.
- In the Name field, enter a name for your definition.
- Click Select type > Metaobject. You might want to name this metafield with the same name as your metaobject so it's easy for you to find later. You can also select Mixed reference and that will allow you to select more than one metaobject type.
- Do one of the following:
- Choose One value, if you only need to display one entry for product features per product.
- Choose List of values, if you want to display more than one entry in a product.
- Select Storefronts to allow your metafield content to be accessible by your storefront.
- Click Save.
Now that you have established a relationship between a resource and a metaobject, you'll connect the specific entries to the specific products you want to display the metaobjects on.
After you've set up your metaobject, added a few entries, and created the metaobject reference definition, you can now link the individual entries to other parts of your store.
- In your Shopify admin, navigate to the part of your store that you want your content entries to appear on. For example, you can go to a product page in your admin from Products.
- In the Metafields section, locate the custom definition that you created previously and click on the definition name. If you don't see the metafield definition you created, then click Show all.
- Click Select entry. The drop-down menu only shows all matching entries of that type. If you set up the definition to accept a list of values, then you can select multiple entries.
- Repeat the steps above to link entries to other products, as needed.
If you do not see what you are looking for, then you can also create entries from a referenced source. You can click on Create new to create a new product features entry, which is then automatically referenced by Product A and also available to reference on other products as well.
Creating a mixed reference
You can create a mixed reference using the creating a reference steps above.
A mixed reference can only be connected to your storefront through Liquid or through Storefront API for Custom Storefronts and Hydrogen.