I have two modules
1)Paypalrec with action fornt - Index/Index
2) unsubscribe with action admin/Index/UnsubscribeFinal
I want to redirect Index/Index controller to admin/Index/UnsubscribeFinal here.
Can anyone help?
I have two modules
1)Paypalrec with action fornt - Index/Index
2) unsubscribe with action admin/Index/UnsubscribeFinal
I want to redirect Index/Index controller to admin/Index/UnsubscribeFinal here.
Can anyone help?
To do the following in Magento 2, you must do the following in your execute
method:
public function execute()
{
/* Do your controller action stuff here */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('adminRouteFrontName/controllerFolder/actionClass');
return $resultRedirect;
}
You don't need to add the \Magento\Framework\Controller\Result\RedirectFactory
to your constructor as it is already declared in the abstract class Magento\Framework\App\Action\AbstractAction
so you have already access to the $this->resultRedirectFactory
variable.
The parameters in my example are:
adminhtml/routes.xml
Controller/Adminhtml
Index.php
it would be index
, for Grid.php
it would be grid
and so on.