Sorting Based on Date Added

I have a client that is asking if we can sort by most recent recipes added. My only thought is we can sort based on date but I’m not positive if that’s functionality that’s currently supported or the best way to accomplish this.

Open to work around solutions as well. I’ve thought about assigning number values but run into issues with November/December being 11/12 or trying to figure out a solution for years being factored in since this client has been with us for over a year almost.

Hi @Khari_Williams ,

I had bookmarked your post because I was keen to see any suggestions. None so far, unfortunately.
I have tried adding Entity ID as a searchable/sortable field (as recipes added at a later date would have entity ids with a higher number than those added previously), but this does not seem to be supported.
How about adding a custom date field (“Date added”) that needs to be populated when a new recipe is added? You would then sort by this date in descending order.
Would that work for your client?

Best,
Stefan

Hi Khari,

@Stefan_Heidbrink’s suggestion would be the best approach here. You can add a custom date field that shows when the recipe was added and then sort in descending order. You can see a live example on the Hitchhikers blog page here. In the search config, make sure to set the date field as sortable and include how you want to sort the field, such as below:

"blog": {
  "searchableFields": {
    "c_blogDateFull": {
      "sortable": true
    }
  },
  "sortBys": [
    {
      "direction": "DESC",
      "field": "c_blogDateFull",
      "type": "FIELD"
    }
  ]
}

Hey Kristy,

Just checking back in but is this still the best approach to a problem like this or is there anything else we can do?

Hey Khari,

Yes, the best approach is still to sort on a custom date field. However, we’ve since launched the Ideas board and I would suggest adding an idea for functionality to sort on the built-in date added field from entity metadata.