get the value of url in magento


If you want to get the value of url in magento or if you want to get parameters id in magento. for front end or backend it works for both conditions.

Get url param vaule for Admin/Backend

This is my dummy url:-
http://magentoo.blogspot.com/index.php/admin/sales_order_invoice/save/order_id/1795/key/b62f67bcaa908cdf54f0d4260d4fa847/
Now if i want fetch the value of url. than i use this method to get the value.
echo $this->getRequest()->getParam('order_id'); // output is 1795


Get url param vaule for Front End

This is my dummy url:-
http://magentoo.blogspot.com/path/action/id/productId/105
echo $this->getRequest()->getParam('productId'); // output is 105

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

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


1 comment: