Skip to content

Instantly share code, notes, and snippets.

@mklooss
Created November 13, 2013 09:09
Show Gist options
  • Save mklooss/7446005 to your computer and use it in GitHub Desktop.
Save mklooss/7446005 to your computer and use it in GitHub Desktop.
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