I have a product collection that use a addAttributeToSort
.
Now there exists a sort filter in the frontend to sort products e.g. for price or date.
When I click that filter in the frontend I have to reset my first order by.
But now the problem is I can only reset the order after the frontend runs his new order.
So my question is there a possibility to reset only specific order by columns or can I only reset all order at once?
Best Answer
The available sorting methods are
Only
setOrder($field, $dir)
is available regardless of collection type and system settings. I suggest you get used to usingsetOrder()
.If you need to enforce an order, but an order is already set on the collection, use
unshiftOrder($field
,$dir)
for flat table collections.For EAV collections you need to do
Resource: http://tweetorials.tumblr.com/post/11137227678/magento-collection-ordering-or-sorting