Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Product lists not adhering to localised titles when sorting alphabetically

Product lists not adhering to localised titles when sorting alphabetically

thniels
Shopify Partner
3 0 0

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?

Replies 3 (3)

thniels
Shopify Partner
3 0 0

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.

Liam
Community Manager
3108 344 899

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

thniels
Shopify Partner
3 0 0

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.