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.

Creating a reference to a metaobject

Steps:

  1. From your Shopify admin, go toSettings>Custom data
  2. Select the part of your store that you want to create the reference for. For example,Products
  3. ClickAdd definition
  4. In theNamefield, enter a name for your definition.
  5. ClickSelect type>Metaobject.你可能想要的名字这metafield年代ame name as your metaobject so it's easy for you to find later. You can also selectMixed referenceand that will allow you to select more than one metaobject type.
  6. Do one of the following:
    • ChooseOne value, if you only need to display one entry for product features per product.
    • ChooseList of values, if you want to display more than one entry in a product.
  7. SelectStorefrontsto allow your metafield content to be accessible by your storefront.
  8. ClickSave

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.

Connecting 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 appear on. For example, you can go to a product page in your admin fromProducts
  2. In theMetafieldssection, locate the custom definition that you created previously and click the definition name. If the metafield definition that you created isn't listed, then clickShow all
  3. ClickSelect 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.
  4. Repeat the steps above to link entries to other products, as needed.

If what you want isn't available, then you can also create entries from a referenced source. You can clickCreate newto 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 thecreating a referencesteps above.

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

Ready to start selling with Shopify?

Try it free