Can someone please tell me when a record is pushed into the "sales_flat_order_grid" table?

How can I switch first name and last name in "billing_name" column of this table?

  • where exactly do u want to use it.? Jun 9, 2015 at 5:14
  • are this only create issue in Order grid?
    – Amit Bera
    Jun 9, 2015 at 7:37
  • I just want to change the name format to Last name + First name (instead of First name + Last name). Why don't they separate the billing_name column into 2 columns (billing_firstname and billing_lastname)? Jun 9, 2015 at 10:40

3 Answers 3


I think you want to customer_firstname and customer_lastname different column in sales_flat_order_grid,,,,for that just create two column in sales_flat_order_grid and clear your magento cache..

and try to place new order and see database you can see both column are poupluate with this value because resource model detects the same name of columns in grid and main table and fulfill it automatically,


Not clear with your requirement. sales_flat_order_grid table will be filled when order is created.Both sales_flat_order_grid and sales_flat_order will have same information.Do not directly edit in sales_flat_order_grid as this may change in the Grid but not in the order view page.I would suggest to listen an observer and write you logic. You can find evens in here https://www.nicksays.co.uk/magento-events-cheat-sheet-1-7/ Let me know if that helps


The name column of the grid table is populated by Mage_Sales_Model_Resource_Order::_initVirtualGridColumns().

You can rewrite this method to manipulate the format as I decribed here: Magento table "sales_flat_order_grid" contains extra space in customer's name value (just switch $ifNullFirst and $ifNullLast to exchange their position)

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.