Referencing metaobjects

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.

Create a reference to a metaobject

Steps:

  1. From your Shopify admin, go to Settings > Custom data.

  2. Select the part of your store that you want to create the reference for. For example, Products.

  3. Click Add definition.

  4. In the Name field, enter a name for your definition.

  5. 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.

  6. Do one of the following:

    • Choose One value if you only need to display one entry per product.
    • Choose List of values if you want to display more than one entry in a product.
  7. Select Storefronts to allow your metafield content to be accessible by your storefront.

  8. 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.

Connect entries

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.

Steps:

  1. In your Shopify admin, navigate to the part of your store that you want your content entries to display on. For example, you can go to a product page in your admin from Products.
  2. In the Metafields section, locate the custom definition that you created previously and click the definition name. If the metafield definition that you created isn't listed, then click Show all.
  3. Click Select entry. The drop-down menu only displays all matching entries of that type. If you set up the definition to accept a list of values, then you can select multiple entries.
  4. Repeat the steps above to link entries to other products, as needed.

You can also create entries from a referenced source. You can click Create new to create a new 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.

A mixed reference can only be connected to your storefront through Liquid or through Storefront API for Custom Storefronts and Hydrogen.

Learn more about custom data for developers.

Can’t find the answers you’re looking for? We’re here to help.