In the cart screen, I've included a block that is calling a controller, where I modify the items of the cart, and after this, I want to reload the cart screen again, so I can see the changes in the quantities and prices.

But the redirect method is doing nothing.

This is my controller:

class MyModule_IndexController extends Mage_Core_Controller_Front_Action
    public function indexAction() {
        if ($this->getRequest()->isPost()) {
            try {
                $cart = Mage::getModel('checkout/cart')->getQuote();
                foreach ($cart->getAllItems() as $item) {
                    array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
            } catch (Mage_Core_Exception $e) {
            } catch (Exception $e) {
                $this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));

    protected function _getSession()
        return Mage::getSingleton('customer/session');

The line:


doesn't seem to be working...

  • use return $this->_redirect('checkout/cart'); Commented Jul 22, 2016 at 10:57
  • the same... I've also added return $this; at the end, but same thing... no redirecting
    – nano
    Commented Jul 22, 2016 at 11:02
  • Can you debug that it executes _redirect function ? Also your controller name MyModule_IndexController seems wrong, it should be MyCompany_MyModule_IndexController Commented Jul 22, 2016 at 11:16
  • The module name was changed on purpose, don't worry. That controller is called from an Ajax method, sgo I'm oing to return something like this echo json_encode(array('reload' => $reload_url, ...)); and handle the redirection through JS code.
    – nano
    Commented Jul 22, 2016 at 11:21
  • 1
    ahh!!. If you are calling this method by AJAX (not mentioned in question), then echo return url and use window.location.href to redirect by javascript Commented Jul 22, 2016 at 11:25

1 Answer 1


First of all - you'll need to put redirect code right before last closing "}". Because if your request is not POST type - you'll have no redirect at all.

And instead of


You can try to use these constructions:



$redirectUrl = $this->getUrl('checkout/cart');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.