I am trying to redirect to a different controller from one controller . I also want to set an Url parameter along with the redirect. But this is throwing me an error

Uncaught Error: Call to undefined method Magento\Backend\Model\View\Result\Redirect\Interceptor::setParam()

Here is my code.

public function execute()

    $resultRedirect = $this->resultRedirectFactory->create();
    $resultRedirect->setParam('myname', 'Nuno Sousa');
    return $resultRedirect;

What is wrong with the above code? or is there any other way?

  • What will be your result url? Commented Oct 8, 2018 at 13:34
  • it will go to create new customer page
    – Melvin
    Commented Oct 8, 2018 at 13:35
  • customer/index/new This is your custom page? Commented Oct 8, 2018 at 13:37

2 Answers 2


You can pass param like this :

$params = array('myname' => 'Nuno Sousa');
$resultRedirect->setPath('customer/index/new', ['params' => $params]);

You can retrive using this :

  • @RohanHapani, how to link to controller from phtml with params? Commented Jan 29, 2019 at 7:09

I am using Magento 2.3.4

$params = array('myname' => 'Nuno Sousa');

Somehow this did not work for me.

$resultRedirect->setPath('[modulename]/[controllername]/[actionname]', ['params' => $params]);

This worked.

$resultRedirect->setPath('[modulename]/[controllername]/[actionname]', $params);

Just in case if anyone having this same issue

  • I experienced the same thing in 2.3.4.
    – Geat
    Commented Jul 13, 2020 at 19:35
  • This should be the right solution in recent versions instead. it works in 2.4 too
    – Capitaine
    Commented May 27, 2022 at 16:18

Your Answer

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

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