0

Since upgrading to Magento 2.4x and having to use ElasticSearch as default, I am unable to find a way to sort category products by newest (created_at). I have tried enabling used_in_sort_by for created_at but it does not order products corretly. I am using the following to sort products -

                case 'new_arrivals':
                $this->_collection
                ->getSelect()
                ->order('e.entity_id '. $this->getCurrentDirection());
                break;

I can get price and name sorting to work fine but sort by created_at does not. I've also tried sort by entity_id which does not work also.

0

Sometimes magento has strange behavior with some types. Like one time I had a filter not displaying in front cause his type was text instead of varchar or the opposite can't remember.

Learning that ordering by date isn't working wouldn't surprise me anymore from that framework^^

So you can still hack it by doing the sort by yourself I guess. Iterate on your collection and sort it using the date like that.

But you shoudl also show us what you tried to order your list cause ordering by date seems to be something done a lot, you might proceed the wrong way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.