Skip to content

Instantly share code, notes, and snippets.

@mklooss

mklooss/Observer.php

Created Nov 13, 2013
Embed
What would you like to do?
Magento form_key validation failed in 1.8 after upgrade from 1.7
<controller_action_predispatch_checkout_cart_add>
<observers>
<mymodul_fromkey>
<type>singleton</type>
<class>mymodul/observer</class>
<method>addDisableValidatFromKey</method>
</mymodul_fromkey>
</observers>
</controller_action_predispatch_checkout_cart_add>
<?php
class MyCompany_MyModul_Model_Observer
{
/**
*
*
*/
public function addDisableValidatFromKey(Varien_Event_Observer $observer)
{
$controller = $observer->getControllerAction();
$formKey = $controller->getRequest()->getParam('form_key', null);
if(!is_null($formKey) && $formKey != Mage::getSingleton('core/session')->getFormKey())
{
$controller->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