Question

I'd like to add a hook to a Magento core action (in this specific case Mage_Adminhtml_Sales_Order_CreateController::saveAction() but I hope there's a general solution).

Just a hunch, but it seems to me that there should be a way to add a hook to an action using Magento's XML, without having to override a class just to add a one-line Mage::dispatchEvent(). Perhaps this is wishful thinking.

Is there any way to do this using XML? Or no? If so, how?

Was it helpful?

Solution

Good news: you don't need to rewrite controllers to listen for it to be called. Magento has dynamic eventing that are called both before and after a controller action is fired.

In your case all you would have to listen for is controller_action_predispatch_adminhtml_sales_order_create_save.

In the case that you would want to listen for after the action has completed and just prior to the request completion, you would change predispatch to postdispatch.

More reading: https://magento.stackexchange.com/a/5614/336

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top