0

I have a controller which replaces an existing controller. Under certain conditions my controller should run the implementation from the existing controller; however it should be transparent (it should behave like a URL rewrite with a non-redirect behavior).

So far I haven't been able to find out how I can either pass the request on to the second controller, or execute the second controller's action and return the result as though it were from my controller.

asked Oct 23, 2014 at 13:17

2 Answers 2

2

Take a look at the _forward method

abstract class Mage_Core_Controller_Varien_Action
 ...
 /**
 * Throw control to different action (control and module if was specified).
 *
 * @param string $action
 * @param string|null $controller
 * @param string|null $module
 * @param array|null $params
 */
 protected function _forward($action, $controller = null, $module = null, array $params = null)
{
 ....

E.g see newAction() in /app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php

/**
 * Create new CMS page
 */
public function newAction()
{
 // the same form is used to create and edit
 $this->_forward('edit');
}
/**
 * Edit CMS page
 */
public function editAction()
{
 ...
answered Oct 23, 2014 at 13:37
1

Yes, just use \Mage_Core_Controller_Varien_Action::_forward

answered Oct 23, 2014 at 13:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.