Delete item cart error magento

The tutorial show to fix delete cart item error in magento . When removing an item from the magento checkout cart page it redirect to the home page. The error is due the redirect function in the cartcontroller.php file

The error can be fix by rewriting the core files. In magento for editing the core files we need to create a module. Please click here for step by step explanation.

require_once 'Mage/Checkout/controllers/CartController.php';


class Core_Cart_CartController extends Mage_Checkout_CartController {


    /**
     * Delete shoping cart item action
     */
    public function deleteAction()
    {
        if ($this->_validateFormKey()) {
            $id = (int)$this->getRequest()->getParam('id');
            if ($id) {
                try {
                    $this->_getCart()->removeItem($id)
                        ->save();
                } catch (Exception $e) {
                    $this->_getSession()->addError($this->__('Cannot remove the item.'));
                    Mage::logException($e);
                }
            }
        } else {
            $this->_getSession()->addError($this->__('Cannot remove the item.'));
        }

        $this->_redirect('checkout/cart');
    }

}

Share this Tutorial