A space to discuss online store customization, theme development, and Liquid templating.
In Dawn, when showing lists of products, the alphabetical sort order uses the default language for sorting rather than the currently active language. Looking at the liquid code it appears that it iterates over the collection without using translation strings. Just referencing the translated title would not change the sort order.
This happens in all product collections.
So, any idea how I would go about doing that?
To test the behaviour, I tried this...
assign products = collection.products | sort: 'title'
assign products = collection.products | sort: 'title' | reverse
They both return a collection which is properly sorted in the current language, whereas this returns a wrongly sorted collection...
assign products = collection.products
...although this is supposed to use the sort_by property of the targeted collection. Elements are here all sorted by their default language title.
I can use the first example as a workaround, but it is not exactly elegant.
Hi Thniels,
Thanks for highlighting this - I'll connect with our internal team to see if this feature could be added to future versions of Dawn.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Awesome! But, is this an issue that stems from the underlying collection object or is it the theme that has a problem? My personal guess would have been the former, which is why I was reluctant to use the mentioned workaround, because that may cause an unwanted degree of [schema] coupling, e.g., in case the sort options on the collection object change.