enter image description here

I am developing custom module, in which i'm adding custom block sales->order edit page with field price that update total paid price (Order Totals) block. But while refreshing

block, i got an error

Fatal error: Call to a member function getOrder() on a non-object \app\code\core\Mage\Sales\Block\Order\Totals.php on line 67

After clicking to "Add button", It call saveAction() controller

public function saveAction() 
    $modelOrder = Mage::getModel('sales/order')->load(100015)->setGrandTotal(300)->save(); 
    return $this->_forward('successajax'); 


and $this->_forward('successajax'); call to below controller

public function successajaxAction()

On ajax response, We replace Order Totals block will showing me bellow error.

enter image description here

Please help me to resolve this error.

  • please provide full details about your custom module., like block, controllers, config etc Commented Aug 1, 2015 at 7:44
  • I have custom form in admin->sales->order that submit price field to saveAction() controller. public function saveAction() { $modelOrder = Mage::getModel('sales/order') ->setGrandTotal(500)->save(); return $this->_forward('successajax'); } 'public function successajaxAction() { $this->loadLayout(); $this->getResponse()->setBody( Mage::app()->getLayout()->createBlock('adminhtml/sales_order_totals')->setTemplate('sales/order/totals.phtml')->toHtml() ); }' Commented Aug 1, 2015 at 7:51
  • We need to get that error, which is coming, so for that need full code and file description, after examine which we can go forward for solution, so please edit your question and add your code description on it Commented Aug 1, 2015 at 8:20

1 Answer 1


With lots of crazy research and after spending full day on this, I found solution of my question.

I have to override OrderController.php file in config.xml

        <!-- Override OrderController -->
                    <NameSpace_ModuleName before="Mage_Adminhtml">NameSpace_ModuleName</NameSpace_ModuleName>

and override file in NameSpace/ModuleName/controllers/Adminhtml/OrderController.php

require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
class NameSpace_ModuleName_Adminhtml_OrderController extends Mage_Adminhtml_Sales_OrderController
    public function saveAction() {  
        if ($data = $this->getRequest()->getPost()) { 

            try {
                $modelOrder = Mage::getModel('sales/order')->load($data['order_id'])

                /** Initialize order **/
                $order = $this->_initOrder(true);                               

                $response = $this->getLayout()->createBlock('adminhtml/sales_order_totals')->setTemplate('sales/order/totals.phtml')->toHtml();

            } catch (Exception $e) {
                $response = array(
                'error'     => true,
                'message'   => $this->__('Cannot update price. Please refresh page.')
                $response = Mage::helper('core')->jsonEncode($response);
} ?>

I think this may help other people that facing issue like this.

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.