Suppose I like to add an event on payment save
do not add code in core file add it in overwrite file this is just an example
then i will add this code
magento\app\code\core\Mage\Checkout\controllers\OnepageController.php"
on savePaymentAction function
Mage::dispatchEvent('on_payment_methode_save', array('data' => $data));
public function savePaymentAction()
{
if ($this->_expireAjax()) {
return;
}
try {
if (!$this->getRequest()->isPost()) {
$this->_ajaxRedirectResponse();
return;
}
$data = $this->getRequest()->getPost('payment', array());
$result = $this->getOnepage()->savePayment($data);
Mage::dispatchEvent('on_payment_methode_save', array('data' => $data));
// get section and redirect data
$redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
if (empty($result['error']) && !$redirectUrl) {
$this->loadLayout('checkout_onepage_review');
$result['goto_section'] = 'review';
$result['update_section'] = array(
'name' => 'review',
'html' => $this->_getReviewHtml()
);
}
if ($redirectUrl) {
$result['redirect'] = $redirectUrl;
}
} catch (Mage_Payment_Exception $e) {
if ($e->getFields()) {
$result['fields'] = $e->getFields();
}
$result['error'] = $e->getMessage();
} catch (Mage_Core_Exception $e) {
$result['error'] = $e->getMessage();
} catch (Exception $e) {
Mage::logException($e);
$result['error'] = $this->__('Unable to set Payment Method.');
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
now add an event in your config XML file
<events>
<on_payment_methode_save>
<observers>
<Company_Module_Model_Observer>
<class>Company_Module_Model_Observer</class>
<method>onPaymentSave</method>
</Company_Module_Model_Observer>
</observers>
</on_payment_methode_save>
</events>
and further in your Model/observer.php file
public function orderGridLodBefore(Varien_Event_Observer $observer){
$event = $observer->getEvent()->getData();
}
No comments:
Post a Comment