How to achieve the below getParams() in Magento2?

$params = Mage::app()->getRequest()->getParams();

You can directly call inside phtml file like below,

$blockObject= $block->getLayout()->createBlock('Namespace\Vendor\Block\YourBlock');

$params = $blockObject->getRequest()->getParams(); 

In controllers and blocks you have direct access to the request object:


Anywhere else, you have to add \Magento\Framework\App\RequestInterface as constructor parameter if it is not there yet, and assign it to $this->request. Then you can use


Fetch All Posted data on a controller in a variable

$data = $this->getRequest()->getParams();

Use a helper on phtml


You can achieve this


will get you the post data

If you want to get specific param


Responsible class is \Magento\Backend\App\Action

If you want get the values into phtml, one possibility is Use registry. for example.

public function __construct(
    \Magento\Framework\Registry $registry,
    $this->registry     = $registry;


$this->registry->register('test_var', 'this is a test!');

echo $this->registry->registry('test_var');

Register the values in controller and create a function in your block(PHTML file using) by using the block ($block) pass the data into template.

  • ok..and how to call the $helper = Mage::helper("myhelperclass"); in my phtml – Sushivam Sep 14 '16 at 6:18

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.