How to build metaobjects
Metaobjects allow to create and store a custom data with the following displaying this new structured information in the storefront.
To organize and display the additional structured information in your store, follow the next main steps:
Step 1. Build a Metaobject.
To create and store additional information in your store, create a Metaobject definition with the list of entries. Each entry will include as many fields as you form while adding the Metaobject definition. The entries can be used to display in different theme sections and blocks.
- Add Metafaobject definition. Go to Shopify Admin -> Settings -> Custom data -> Metaobjects and press the “Add definition” button:
Then, type the name of the metaobject definition and change the “Type” if needed:
In the “Fields” drop-down, choose the type of the field:
Edit the popup to create a new field:
Add as many fields as needed:
Hit the “Save” button to store settings.
- Edit Metaobject fields. To edit fields, you are going to create metaobject entries.
Navigate to Content -> Metaobjects in your Shopify admin and press the “Add entry” button. Next, choose the Metaobject definition in the drop-down for which the entry will be used:
Then, edit fields with the content. And save the changes.
Add as many entries as you need:
Step 2. Create a Metafield.
Create a Metafield definition to connect Metaobject entries with a product. Thus, you will be able to assign each entry to a Metafield in the desired sequence and for each individual product.
- Add a Metafafield definition. Go to Shopify Admin -> Settings -> Custom data -> Metafields and choose the part of a store to create metafields definitions. In our case, it will be “Products”.
Then, press the “Add definition” button:
Create a metafield with the format:
- Name = e.g. Feature 1
- Namespace and key = custom.feature_1
- Description = Your text (optional)
- Select content type -> Metaobject
- Reference = your Metaobject definition
Save the changes.
Add numerous metafields:
- Connect Metafields with the entries for a product. Navigate to Products and select a product.
Use each Metafield to connect with different entries:
Save the settings.
Step 3. Connect the Metaobject with the theme.
To link metaobjects to the theme blocks or sections, go to the theme Editor and select a part of a store to work on it, for example, “Products”. Then, decide what section or block to use on a page:
Press the source icon next to each field in the block/section to connect the Metaobject reference with the field:
In the Metaobject reference, select an entry to use for each field:
Use different Metaobject references to connect with different sections in the block:
Save the settings.