Magento 2 get Parameters in the URL
First, you need to inject \Magento\Framework\App\Request\Http
at _construct function then using
Magento2 how to getRequest
$this->request->getParam('id'
),you can your data
protected $request;
public function __construct(
\Magento\Framework\App\Request\Http $request,
....//rest of parameters here
) {
$this->request = $request;
...//rest of constructor here
}
public function getIddata()
{
// use
$this->request->getParams(); // all params
return $this->request->getParam('id');
}
You are trying in correct way.
$custId = $this->getRequest()->getParam('id');
You can try with below code also
$params = $this->request->getParams();
$custId = $params['id'];