2

I have a controller which is configured to handle requests prior to the core controller using a config.xml similar to this;

<frontend>
  <routers>
    <catalogsearch>
      <args>
        <modules>
          <myextension before="Mage_CatalogSearch">My_Extension</myextension>
        </modules>
      </args>
    </catalogsearch>
  </routers>
</frontend>

The action it overrides should occasionally pass-through to the next (CatalogSearch) controller, and other times should execute it's own action and return--without running the CatalogSearch action.

class My_Controller extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        if ($this->shouldRun())
        {
            $this->loadLayout();
            $this->renderLayout();
            // Stop further processing
        }

        // Continue to next controller
    }
}

In my controller action how can I prevent the next controller from being called?

2

You want to use

parent::actionName();

if im not mistaken.

  • In this case I'm not actually inheriting from the controller, just intercepting a request to it. Although I may just switch to inheritance as it's not a big issue in my current scenario. – STW Oct 23 '14 at 18:12
  • I think that is the best approach. – mbalparda Oct 23 '14 at 18:56
1

I don't really understand the main goal of it, but like you described it in the second code listing, there should be just an else path because you state, that you want to stop further processing?

If I am wrong, can you please be a little bit more precise on what you want to achieve.

It would also not hurt to inherit the Mage_CatalogSearch_*Controller you want to rewrite.

  • In my code example I would like the response to return at the // Stop comment--however using a return there still seems to execute the next controller action. My question is how do I stop the next controller from running when using the before="" attribute to intercept a request/route? – STW Oct 23 '14 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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