Can we redirect controller to another controller in another custom function rather execute function?

magento.stackexchange https://magento.stackexchange.com/questions/272803

Вопрос

Can we redirect controller to another controller in such a way that previous controller continue its working in its execute method and next controller works render the layout at a same time? and after executing it returns the next controller

e.g

public function execute()
{
       //do what ever we want

    return $resultRedirect->setPath('abc/def/jklmno');
}
public function abc()
{
       $resultRedirect->setPath('abc/def/ghi');
}

is this possible?

Это было полезно?

Решение

Re-direction to another controller is fine and no code will be executed if it not called or included inside the execute()

So, basically you should call that function on your execute() which has re-direction function and so.

For Example :

public function execute()
{
   //do what ever we want
  return $this->abc(); // call internal function then next line won't execute
  return $resultRedirect->setPath('abc/def/jklmno');
}
public function abc()
{
   $resultRedirect->setPath('abc/def/ghi');
}

I could partially understood your requirement and may be I would say re-direction based on certain conditions would help you as far as I guess.

NOTE : Each page have a separate controller.

Hope this helps.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top