Anyone know how to sort collections by any non-standard means?

Highlighted
Tourist
4 0 2

Hi. There are a lot of threads about this, and they all seem to just be shut down by the admins, so I'd like to try again:

Sorting Collections by anything other than the standard methods seems impossible. I want to sort my collections by dates — dates of my choosing. So I assign the product a date and the collection sorts that way. I thought the publish date would be a good place to start, but....

  1. Nope. Collections are sorted by creation date. A date I can't see or edit once I made it. I don't even know what those dates are anymore. 
  2. Liquid will not address the issue. No known solutions there.
  3. Javascript attempts on the front end to re-sort the page using wrappers with objects, metafields, or tags doesn't seem to work. Shopify looks like it resists all attempts we've thrown at it.

SO! Anyone got an idea how I can automatically resort the front end of my collections by dates that I assign to the products?

Help! :)

 

 

2 Likes
Highlighted
Tourist
4 0 2

BTW — I want to add. We're using a pretty stripped down TIMBER theme. So it's pretty basic on the front end.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
370 0 32

Hello Ben, Ben here - your Shopify Guru!

 You could always manually sort your collection listings using a link list. There is a guide here on how to do that:

https://docs.shopify.com/manual/configuration/store-customization/page-specific/collections/taking-c...

If you reorder the links in the list it will reflect on the front end. 

If that does not work for you then you would need to program some sort of custom sort. LIquid on it's own cannot do this, you can't set a publish date with collections either. I would suggest you use metafields to add your post date to the collection. Set up a namespace like:

date => posted : value

That is where the easy part of this ends. You then would need to build a json string to hold all your collection objects. But by default liquid will not return your metafields with the collection object. So you would need to manually open the json object text string. Then insert your metafield as part of the object. Do this for each collection you have attached your metafield too. This could be within an alternative list-collections.liquid template. Something like the code I have here:

https://github.com/bczegeny/Collection_Sort_Metafield_Date/blob/master/list-collections.liquid

I hope this helps! Feel free to reach out if you have any further questions :)

Cheers,
Ben C - Shopify Guru
Support@Shopify.com

 

0 Likes
Highlighted
Tourist
4 0 2

Hey Ben! Thanks! Okay, going to give this a try. We already were appending the metafields for the sort, so that's great. Will attempt the rest and let you know!

Cheers.

0 Likes
Highlighted
Shopify Partner
24 0 2

Any luck with this?

0 Likes
Shopify Partner
34 0 3

Hello there, We just added a feature to sort your existing collections by either updated or publish date to our app Advanced Collections -  https://apps.shopify.com/advanced-custom-collections

 

For this issue, you can try sorting by publish date as you can edit the publish date on Shopify admin itself. There is a 7 day free trial so do try it out. Thanks!

0 Likes