Unable to sort Express list by date attribute

Permalink
V 8.4.2

$calendar = Express::getObjectByHandle('dblsession');
        $list = new \Concrete\Core\Express\EntryList($calendar);
        if($datesort !== 'desc') { // todo this doesnt work
            $list->sortBySessionDate(); // asc
        } else {
            $list->sortBySessionDate('desc');
        }


The date order of the list appears to neither by asc or desc, just in unsorted order. What am I missing or is this a bug? About 700 Express entries in the list in case that makes any difference.

surefyre
 
Myq replied on at Permalink Reply
Myq
Does it work if you use
$list->sortBy('SessionDate',  'desc')

https://documentation.concrete5.org/api/8.3.0/Concrete/Core/Express/...
surefyre replied on at Permalink Reply 1 Attachment
surefyre
That actually throws an error during getResults() for SessionDate or session_date (the actual attribute handle), which seems wrong?

"An exception occurred while executing 'SELECT e.exEntryID, session_date FROM ExpressEntityEntries e LEFT JOIN DblsessionExpressSearchIndexAttributes ea ON e.exEntryID = ea.exEntryID WHERE e.exEntryEntityID = ? ORDER BY session_date desc' with params ["75615924-9963-11e8-8a1a-083e8ebfcaa9"]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'session_date' in 'field list'"

Yet session_date clearly is the attrib handle (see attached)
A3020 replied on at Permalink Reply
A3020
Try
$list->sortBy('ea.ak_session_date', 'desc');
surefyre replied on at Permalink Reply
surefyre
Nope, same unordered output :/
A3020 replied on at Permalink Reply
A3020
Some ideas:
- Inspect the contents of the DblsessionExpressSearchIndexAttributes table.
- Get the query from the $list object an try to run it manually.

If the search index attribute table is empty, or not up to date, it's because entries need to be 'indexed'.
surefyre replied on at Permalink Best Answer Reply
surefyre
I think if it's got us THIS stumped it needs a bug report ;)

I'll sort in PHP after the fact, during output
Myq replied on at Permalink Reply
Myq
Yes, please! If you can describe an MCVE (https://stackoverflow.com/help/mcve), that would be great to document on GitHub:https://github.com/concrete5/concrete5/issues...