Filtering products by Metafield value
As a Shopify merchant, you know how powerful Metafields are. Shopify Metafields allows you to save specialized information that is not provided by Shopify admin by default, add custom fields to any page or object in your store, and track your customers more efficiently. For instance, you are selling second-hand jackets and you want to display their condition in percentage values on the storefront. Metafields can help you with that.
From August 2021, Shopify allows you to create and manage Metafields in the Shopify admin. You can still use other Metafield apps from the Shopify App Store as they come with more advanced features.
In the example of selling second-hand jackets, you might want to set up a filter that contains percentage values on the collection page like the following image, and you can do that with our app. As the app allows you to offer thematic filters by creating a “tag” or a “multi-level tag” filter option, it also lets you create a filter for your Metafields’ values.
On this page
Step 1: Add product Metafields to the app’s admin
To create a filter for your Metafield values on your storefront, the Metafield, which contains all those values, needs to first be added to the app's admin successfully. The app can sync values of product Metafields which are created either directly from Shopify or by using an app from the Shopify App Store.
Note: The app lets you add up to 5 Metafields to apply to your site search and filtering solutions. To add more than 5 Metafields to the app, you can send your request to firstname.lastname@example.org for further assistance.
- From our app’s admin, go to Tool > Metafields.
- Click Add metafield and fill in the namespace and the key of the specific Metafield that you want the app to sync its values. In the example of selling second-hand jackets, you have created a product Metafield from Shopify admin as product_field.product_condition, then you fill in the namespace as product_field and the key as product_condition.
- In the Applies to section:
- The Display option is checked by default, meaning that the Metafield data will be added to all products.
- Select Search if you want the added Metafield to be searchable in Instant Search results.
- Select Filter option if you want to create a filter option by Metafield.
- Select Sort by option if you want to sort out potential products based on appropriate Metafield data.
- Click Save and wait about 3 minutes to let the sync process complete.
- [Optional] When you encounter an error message that says “Invalid metafields found” or “Incorrect information or metafield not found in products”:
- You might have filled in the wrong Metafield's namespace and key.
- The products with the corresponding Metafields might have been deleted.
- When you are certain that you have filled in the correct namespace and key, you can try to connect that Metafield to your theme to display specialized information on your storefront. Then you refresh the Metafields page from our app’s admin to check if the error message disappears.
Create a filter for Metafield values
Now you can create a filter for values of the Metafield you have added successfully to Product Filter & Search database.
- From the app’s admin, go to Filter > Manage filter trees.
- Click the filter tree that you want to set up a filter for the Metafield values.
- Click Add filter option.
- In the drop-down of Option Type, select the phrase that starts with “Metafield-” and shows the namespace and the key of the Metafield you want to use its values. In the example of selling second-hand jackets, the phrase that you must select in the drop-down of Option Type looks like the following:
Note: When you cannot find the Metafield you have added to the app's admin in the drop-down of Option Type:
- You might have not added the Metafield successfully to the app's admin due to “Invalid metafields found” or “Incorrect information or metafield not found in products” errors.
- You might have not selected the Filter option in the Applies to section when adding the Metafield to the app's admin.