How to get a URL parameter in the Magento controller?

If your URL is the following structure: http://yoursiteurl.com/index.php/admin/sales_order_invoice/save/order_id/1795/

then use:

echo $this->getRequest()->getParam('order_id'); // output is 1795

If you want to get All Url Value or Parameter value then use the below code.

var_dump($this->getRequest()->getParams());

If your URL is like this: http://magentoo.blogspot.com/magentooo/userId=21

then use this to get the value of the URL

echo $_GET['userId'];

Leave a comment

Your email address will not be published. Required fields are marked *