Long M K Nguyễn
Long M K Nguyễn

Reputation: 817

How to reindex sales_flat_order_grid in Magento 1.9

There was an error when processing the order on our production environment and records were not inserted for sales_flat_order_grid table, is there any command or function from Magento that can be run to fix the missing record? Thanks

Upvotes: 3

Views: 1162

Answers (1)

Long M K Nguyễn
Long M K Nguyễn

Reputation: 817

Eventually i had to write a shell script to fix this. I'm sharing this small script that will reindex the table in case anyone has the same problem and need to have the right data in the grid again

    try {
        Mage::getModel('sales/order')->getResource()->updateGridRecords(
            Mage::getResourceModel('sales/order_collection')->getAllIds()
        );
    } catch (Exception $e) {
        echo $e->getMessage() . "\n";
    }

Upvotes: 4

Related Questions