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:
- From your Shopify admin, go toSettings>Custom data.
- Select the part of your store that you want to create the reference for. For example,Products.
- ClickAdd definition.
- In theNamefield, enter a name for your definition.
- ClickSelect type>Metaobject.你可能want to name this metafield with the same 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.
- Do one of the following:
- ChooseOne value, if you only need to display one entry per product.
- ChooseList of values, if you want to display more than one entry in a product.
- SelectStorefrontsto allow your metafield content to be accessible by your storefront.
- 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:
- 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 fromProducts.
- 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.
- ClickSelect 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.
- Repeat the steps above to link entries to other products, as needed.
You can also create entries from a referenced source. You can clickCreate newto 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 thecreating a referencesteps.
A mixed reference can only be connected to your storefront through Liquid or through Storefront API for Custom Storefronts and Hydrogen.