Refresh order grid table in Magento 1

Recently, we’ve faced a data inconsistency in the Magento sales_flat_order_grid db table. Some of the values in custom columns look like they were shifted. This issue may occur if the order grid has multiple custom fields and when a user archives orders in the Enterprise Edition.

Thanks to this thread, we’ve developed a shell-script, which will refresh the sales_flat_order_grid table to correspond exactly to the sales_flat_order table:

 * @author Atwix Team
 * @copyright Copyright (c) 2016 Atwix (
 * @package Atwix_Shell
require_once 'abstract.php';

class Atwix_Shell_Free_Order_Grid_Update extends Mage_Shell_Abstract
    public function run()
        try {
            echo 'Done!' . PHP_EOL;
        } catch (Exception $e) {
            echo $e->getMessage() . PHP_EOL;

$shell = new Atwix_Shell_Free_Order_Grid_Update();

You can run this script from your Magento installation root directory in the following way:

php shell/orders_grid_update.php

Pretty simple and really efficient. I hope, this little blog post will save you some time.

Thanks for reading!

You may also want to read:

  • Adding custom product attribute to quote and order items in Magento
  • Case Studies

    Meet our clients

    From startups backed by Mark Cuban and Sir Richard Branson, to some of the biggest eCommerce operations in the world, Atwix helps our clients deliver unparalleled eСommerce experiences. We’re proud to work with the following companies: