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.

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()
{
   ...
| improve this answer | |
1

Yes, just use \Mage_Core_Controller_Varien_Action::_forward

| improve this answer | |

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.