I am using the sales_order_grid_collection_load_before event in order to append a filter to the collection.
However, in my case, I need to JOIN sales_flat_order table.
The problem is that the ordering is of the form ORDER BY created_at, and both sales_flat_order_grid and sales_flat_order have this column name..

How can I change/modify it to main_table.created_at, for instance?
I'm looking for a systematic method to prepend the table aliases to ORDER statements regardless of the specific column used, and, maybe to GROUP statements to.

How can I achieve this?

1 Answer 1


Are you looking for this solution?

$select = $collection->getSelect();
  • It Appends an additional order by. Additionally, what if the user orders by a different column?
    – user76568
    Jan 27, 2014 at 15:00
  • Than you need to check post data to know which filter customer selected. Jan 27, 2014 at 15:02
  • Yes correct. But how do I remove the original order by? Your solution adds another order by
    – user76568
    Jan 27, 2014 at 15:04
  • Answer updated. Jan 27, 2014 at 15:08
  • Nope, The reset does not remove the original order by.
    – user76568
    Jan 27, 2014 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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