Skip to content

Instantly share code, notes, and snippets.

@nhp
Forked from bastianccm/Observer.php
Last active December 15, 2016 17:27
Show Gist options
  • Save nhp/42b553e00c3366bedeeb to your computer and use it in GitHub Desktop.
Save nhp/42b553e00c3366bedeeb to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<config>
<frontend>
<events>
<controller_action_predispatch_checkout_cart_add>
<observers>
<extra_static>
<type>singleton</type>
<class>extra_static/observer</class>
<method>controllerActionPredispatchForceValidFormKey</method>
</extra_static>
</observers>
</controller_action_predispatch_checkout_cart_add>
<controller_action_predispatch_wishlist_index_add>
<observers>
<extra_static>
<type>singleton</type>
<class>extra_static/observer</class>
<method>controllerActionPredispatchForceValidFormKey</method>
</extra_static>
</observers>
</controller_action_predispatch_wishlist_index_add>
</events>
</frontend>
</config>
<?php
/**
* Class Extra_Static_Model_Observer
*
* @category Model
* @package Extra_Static
* @author AOE Magento Team <[email protected]>
* @license none none
* @link www.aoe.com
*/
class Extra_Static_Model_Observer
{
/**
* forces the correct form_key
*
* @param Varien_Event_Observer $observer The varien event observer
* @return void
*/
public function controllerActionPredispatchForceValidFormKey(Varien_Event_Observer $observer)
{
$observer->getControllerAction()->getRequest()->setParam('form_key', Mage::getSingleton('core/session')->getFormKey());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment