I used many update methods for update values in sales_flat_order and sales_flat_order_grid tables, but no method didn't work.

I don't know why the update is not done.

Method 1:-

$coreResource = Mage::getSingleton('core/resource');
$write = $coreResource->getConnection('core_write');
        $_field_flat_order =array();
        $_field_flat_order['grand_total']          = $order_gt;
        $_field_flat_order['base_grand_total']     = $order_gt;
        $_field_flat_order['discount_amount']      = $order_discount;
        $_field_flat_order['base_discount_amount'] = $order_discount;
        $_field_flat_order['discount_description'] = "1%";
        $write->update($coreResource->getTableName('sales_flat_order'),$_field_flat_order,array('entity_id = ?' => $order_id,));

Method 2:-


Method 3 :-

$sql_order = "UPDATE sales_flat_order SET grand_total='".$order_gt."',base_grand_total='".$order_gt."',discount_amount='".$order_discount."',base_discount_amount='".$order_discount."',discount_description='1%' WHERE entity_id ='".$order_id."'";

No method didn't work, but all other tables are updating perfectly.

Anyone know the reason.?

2 Answers 2



<?php $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?>


$write->query("UPDATE sales_flat_order SET grand_total = '$order_gt', base_grand_total = '$order_gt', discount_amount = '$order_discount', base_discount_amount = '$order_discount', discount_description ='1%' WHERE entity_id = '$order_id'");
  • This is also not working @Marcel,I think there is a connection problem. But thank you. Feb 15, 2018 at 9:19
  • Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?
    – Marcel
    Feb 15, 2018 at 10:50
  • I am using update query in observer(sales_order_invoice_save_after) file. Feb 15, 2018 at 11:25
  • If execute query directly in phpmyadmin,update is working. Feb 15, 2018 at 11:26
  • Maybe this could help you: magento.stackexchange.com/questions/60288/…
    – Marcel
    Feb 16, 2018 at 13:26

Having in mind that "While creating invoice to particular order, We can't update sales order tables for that particular order.", you can update that order getting it from the observer Example:

config.xml ...




class Module_SalesOrder_Model_Observer
   public function updateDeliveryDate(Varien_Event_Observer $observer) {
      $_event             = $observer->getEvent();
      $_invoice           = $_event->getInvoice();
      $_order             = $_invoice->getOrder();

      $_order->setDeliveryAt('2018-03-26 00:00:00');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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