I am unable to delete the updated product from the mini cart. this is the code: path : app/code/core/Mage/Checkout/controllers/CartController.php
public function ajaxUpdateAction()
{
if (!$this->_validateFormKey()) {
Mage::throwException('Invalid form key');
}
$id = (int)$this->getRequest()->getParam('id');
$qty = $this->getRequest()->getParam('qty');
$result = array();
if ($id) {
try {
$cart = $this->_getCart();
if (isset($qty)) {
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$qty = $filter->filter($qty);
}
$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem) {
Mage::throwException($this->__('Quote item is not found.'));
}
if ($qty == 0) {
$cart->removeItem($id);
} else {
$quoteItem->setQty($qty)->save();
}
$this->_getCart()->save();
$this->loadLayout();
$result['content'] = $this->getLayout()->getBlock('minicart_content')->toHtml();
$result['qty'] = $this->_getCart()->getSummaryQty();
if (!$quoteItem->getHasError()) {
$result['message'] = $this->__('Item was updated successfully.');
} else {
$result['notice'] = $quoteItem->getMessage();
}
$result['success'] = 1;
} catch (Exception $e) {
$result['success'] = 0;
$result['error'] = $this->__('Can not save item.');
}
}
$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
Getting below error:
There has been an error processing your request
Invalid form key
Trace:
#0 app/code/core/Mage/Checkout/controllers/CartController.php(636): Mage::throwException('Invalid form ke...')
#1 app/code/local/Mage/Core/Controller/Varien/Action.php(418): Mage_Checkout_CartController->ajaxUpdateAction()
#2 app/code/local/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('ajaxUpdate')
#3 app/code/local/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#4 app/code/local/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#5 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#6 index.php(86): Mage::run('', 'store')
#7 {main}
Can I know what was the problem