I add an alias to collection for priority sort product with price first.
$collection->getSelect()
->columns(["IF((price_index.price && price_index.price > 0),1,0) as have_price"])
->order('have_price DESC');
It worked well on magnento 2.3 but after upgrade to 2.4, the query return no order have_price
, only order FIELD(e.entity_id,1,2,3,4)
Is there any way to sort category product collection by custom sort like that?