Use metafield capabilities
Capabilities provide a way to mix in behaviors and logic with your metafields. When you create a metafield definition, you can enable capabilities
that provide additional behavior. You can enable the following capabilities:
- Smart collection: Create an automated collection based on metafield values for a given definition.
- Admin filterable: Filter products based on metafield values for a definition.
Smart collection
Anchor link to section titled "Smart collection"An automated collection, also known as a smart collection, is a grouping of products that's defined by a set of rules. Shopify automatically changes the contents of an automated collection based on the configured rules. You can create rules with metafield definitions to automatically update the contents of an automated collection based on product or variant metafields.
Smart collections are available for the following metafield types:
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 |
- To create a smart collection, you can use the
collectionCreate
mutation. - To update an existing collection, you can use the
collectionUpdate
mutation. - To enable this capability, you can use the
metafieldDefinitionUpdate
mutation.
The following example shows how to create a metafield definition with the smartCollectionCondition
set to true
to enable the smart collection capability:
Admin filterable
Anchor link to section titled "Admin filterable"The admin filterable capability allows you to use a metafield definition and its values to filter resource lists in the Shopify admin. This capability makes it easier for merchants to find and manage resources such as products based on their specific metafield values. The capability is available for the following metafield types:
- Single line text or Single line text (list)
- Product reference or Product reference (list)
- True or false
- Collection reference or Collection reference (list)
- Page reference or Page reference (list)
- Metaobject reference or Metaobject reference (list)
To enable this capability, you can use the metafieldDefinitionUpdate
mutation.
The following example shows how to create a metafield definition with adminFilterable
set to true
to enable the admin filterable capability: