Is there a Magento function to get the value of "id" from this url:
http://example.com/path/action/id/123
I know I can split the url on "/" to get the value, but I'd prefer a single function.
This doesn't work:
$id = $this->getRequest()->getParam('id');
It only works if I use http://example.com/path/action?id=123
If your url is the following structure:
http://yoursiteurl.com/index.php/admin/sales_order_invoice/save/order_id/1795/key/b62f67bcaa908cdf54f0d4260d4fa847/
then use:
If you want to get All Url Value or Parameter value than use below code.
If your url is like this:
http://magentoo.blogspot.com/magentooo/userId=21
then use this to get the value of url
If you want more info about this click here.
If it's a Magento module, you can use the Varien Object getter. If it's for your own module controller, you may want to use the register method.
Source: http://www.vjtemplates.com/blog/magento/register-and-registry
Magento's default routing algorithm uses three part URLs.
So when you call
The word
path
is your front name,action
is your controller name, andid
is your action method. After these three methods, you can usegetParam
to grab a key/value pairYou may also use the
getParams
method to grab an array of parameters