Change defualt Sort Order

Hej.

I’m making a shop where i want my collections sorted by “Newest First”. But in my app on Shopify, the default sort order is set to Relevance, and i can’t move it down.´

I have tried doing it in JS with helper and setIndex, but that didn’t work, cause when i go back, in the browser history, it is again set to Relevant. (This is properly because it is not reloading, but just showing popup previews)

How do i move it down, so the site always open on “newest first”?

Hi @peter5,

Thanks for reaching us!

The Sorting Orders only applies to the InstantSearch widget that is used on the shop search results page.
The active Sorting Orders have no impact on the results orders of the Autocomplete.

When talking about collections, are you talking about:

  • product orders on a specific collection page?
  • collections results in the Autocomplete results?

Regards,

Hey Charly.

It is also the InstantSearch i’m talking about. It is the product orders on all our collections. Not only a specific page.
I’m not sure what Autocomplete results are.
You can see the settings i am talking about here:
https://imgur.com/a/aXkS0WH

Is there a way to remove the Relevant as the default?

I also have this issue - any update?

We ended up redirecting the site to it self, but with the sort order changed.

My college made the change, so not sure prissily who it was done.

Hi @peter5, @trevor,

In order to have “Newest Order” as primary sorting on collection and search results pages, you will have to make changes to the algolia_instant_search.js.liquid file as it follows:

Around the line 66 (depending on your existing modifications) you’ll have to make this update:

Before

sortOrders: algolia.sortOrders,

After

sortOrders: _.sortBy(algolia.sortOrders, (so) => so.label === ‘Newest first’ ? -1 : 1),

Remember to enable the “Newest first” Sort Order from the Algolia Plugin before applying this change.


Please do test this modification on a development store before using it in production.

1 Like