Calling getParams() in Magento2
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:
$this->getRequest()->getParams()
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
$this->request->getParams()
Fetch All Posted data on a controller in a variable
$data = $this->getRequest()->getParams();
Use a helper on phtml
$this->helper('\Helloworld\CustomModule\Helper\Data')->getCustomdata($data);