Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Display Products - Possible to order by custom meta value?

Matt Apr 14, 2017 11:09AM PDT

We are assigning simple numerical meta values to our products like (3,2,1) and some products will not have a meta value at all. On search and category pages we would like to display the products in order of the custom meta value. (i.e. 3,3,2,2,2,1,1,1,1,0,0,0,0,0,0) We have tried to display the products using:

{% assign products = collection.products | sort:
'item.metafields.important.important' %}
{% for product in products %}
{{ product.title }}
{% endfor %}

But nothing I try seems to work. Any help you can give me would be much appreciated.

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found