How do you create an automatic Shopify collection based on metafields?
by Alfredo Pantoja
Create more accurate and flexible collections using metafields instead of tags
Metafields provide more accuracy, flexibility and structure than tags. Use the power of metafields to create endless automatic "smart" collections.
Create your metafield and enable smart collections
To create your metafield:
- Go to "Content" in your admin dashboard
- Click on "Manage" on the top right
- Smart collections can be enabled with either product or variant metafields. Click on whichever you prefer.
- Click on "Add definition" on the top right
- Fill out the "Name" field with whatever name you feel makes sense for this metafield - something descriptive that will remind you of what it does.
- It's also a good idea to fill out the "Description" field with more info that will remind you of what this metafield does
- Click on the "Select type" button
- Select the data type of your metafield. The "Single line text", "True or false", "Integer", "Decimal", and "Rating" data types work really well for this.
- Finally, scroll down and toggle on the "Smart collections" option. This enables the feature.
Set the values for your new metafields
You can now go to the admin view of any product or variant - depending on which type of metafield you created - and set the appropriate values for your metafield.
Metafield definitions and supported conditions
Only certain metafield product and variant definitions are supported with specific conditions.
In the admin page for your product or variant, scroll all the way down to the "metafields" section.
Here you can adjust the values for your new metafield.
Metafield definition type | Supported conditions |
---|---|
True or false | equals |
Integer | equals greater than less than |
Decimal | equals greater than less than |
Rating | equals greater than less than |
Single line text (one value and list of values) | equals |
Create a smart collection using a Metafield
Keep the table above as a reference for which conditions you can use.
Last step - to create your automatic "smart" collection:
- Go to "Collections" page in your admin
- Click on "Create collection"
- Under "Collection type" select the "Smart" option
- In the "Conditions" section you can create as many conditions as necessary, and select whether your collection should meet "all conditions" or just "any condition".
Have fun with it. That's all there is to it!