I am trying to create a list of products filtered by their metafields.
For example:
{% assign products = collection.products | where: “metafields.my_fields.product_in_stock”, “1” %}
is something like this possible?
Or is there an alternative way to achieve the same thing? (a list of products filtered by the respective product metafields)?
The purpose of this is to allow me to not display certain objects in a collection with more control than is offered in the current “collection” UI.
Hi @ohreallyhmmmm ,
This is not possible, filter 2.0 does not support it. You can only do this with the app, Refer app: https://apps.shopify.com/product-filter-search
Hope it helps!
In order to filter products by metafields correctly, you can use this app https://apps.shopify.com/ultimate-search-and-filter-1. You can add metafields to filter in this app by following the steps below:
-
Go to App Settings => Search Index in the app
-
Add a product or variant metafield with namespace and key
-
Hit Sync button
-
Go to Filter groups => choose a filter group => add a new filter and select your metafield from the dropdown