Sorting search results alphabetically

Shopify Partner
4 0 0

Hi there,

 

So my store has several hundred different colors of paint, and when you search the site the results seem to just show in random order. I have done some investigation into this and from what I can tell Shopify has no way of displaying these results in alphabetical order. 

 

That by itself seems pretty ridiculous.

 

Anyways, I have done some more looking and it seems like it might be possible to add all the products that I want included in search results to a collection and then sort the collection a-z. 

 

Does this seem like a reasonable way to accomplish the objective of sorting search results a-z? I understand that this will require some customization, but I don't want to go out and try to get this done if it will not work the way i am thinking it could.

0 Likes
Tourist
4 0 1

You should be able to write some form of

 

{% assign sorted_results = search.results | sort: "value" %}

 

and then {% for item in sorted_results %}

 ~~~~~~~~~~~~~

{% endfor%}

0 Likes
Shopify Partner
4 0 0

Does this solution take into account the pagination issue?

 

From what I am understanding, search results can only be sorted page by page - so page 1 can be a-z, but page 2 will be a completely different set of results that will also be in a-z order. I want the complete set of results to sort a-z across all pages of results.

 

Is putting the products into a collection and then sorting the collection a valid solution to this issue?

0 Likes
Tourist
4 0 1

You can try paginating the sorted results, instead of the search results themselves.

 

However a collection with those products would also work.


@pickeringmt wrote:

Does this solution take into account the pagination issue?

 

From what I am understanding, search results can only be sorted page by page - so page 1 can be a-z, but page 2 will be a completely different set of results that will also be in a-z order. I want the complete set of results to sort a-z across all pages of results.

 

Is putting the products into a collection and then sorting the collection a valid solution to this issue?


 

0 Likes
Shopify Expert
6 0 0

I am facing same problem, How can I sort the entire result set? 

Help me Json

0 Likes