1

I want to track that I am editing an order at backend in magento, so I want to track that Edit button has been clicked at backend in order section. See below image for more help-

enter image description here

How can I track an order is being edited at backend. I also Googled for an observer for this event but could not found. Please anybody can help me here. Anyone can ask question if he has.

EDITED:- Now I have added following code in config.xml file-

<controller_action_predispatch_adminhtml_sales_order_edit_index>
                <observers>
                    <kartparadigm_storecredit>
                        <class>kartparadigm_storecredit/observer</class>
                        <method>editOrder</method>
                    </kartparadigm_storecredit>
                </observers>
</controller_action_predispatch_adminhtml_sales_order_edit_index>

and in my observer.php file-

public function editOrder(Varien_Event_Observer $observer)
{
    Mage::log("I am bad boy");
    $order = $observer->getEvent()->getOrder();
    Mage::log('order-id- '.$order->getIncrementId());
    Mage::log('order-status- '.$order->getStatus());

}

Only "I am a bad boy" is printed in log file and it shows 500 Server Error on edit page. I think its because of second line in observer method but not sure why?

2 Answers 2

1

From event controller_action_predispatch_adminhtml_sales_order_edit_index you can not get the order object itself (nothing is loaded yet because it is triggered before the action.

But at this event you can get the order id, by

$orderId=Mage::app()->getRequest()->getParam('order_id');

Then load it:

$order = Mage::getModel('sales/order')->load($orderId);

To get the currently loggedin admin user, try this code

$admin = Mage::getSingleton('admin/session')->getUser()

source https://magento.stackexchange.com/a/4758/4564

0

You can add an observer at the predispatch action for this specific controller with the node controller_action_predispatch_adminhtml_sales_order_edit_index
Example :
<controller_action_predispatch_adminhtml_sales_order_edit_index> <observers> <your_unique_observer_key_here> <class>module/observer</class> <method>yourFunctionHere</method> </your_unique_observer_key_here> </observers> </controller_action_predispatch_adminhtml_sales_order_edit_index>

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.