How do I get data of post variables ? Like if I post form with post method then I can get itt with $_REQUEST or with $_POST. How I can do this in mgento ?
You can go through this way:
replace 'ship-note' with your custom field.
$delivery_instruction_note = Mage::app()->getRequest()->getParam('ship-note');
Just to mention for everyone looking into this thread..
$this->getRequest()->getParams('value_here');
is just wrong... The only available method to retrieve a special param with or without default value is without s
$this->getRequest()->getParam('param','defaultValue');
All other comments are just wrong
You can get all variables using $this->getRequest()->getParams();
. This will return all variables. For any particular name like id
you can use $this->getRequest()->getParam('id');
without the "s". Hope this will help.
You can read the values with
$this->getRequest()->getParam('field_name');
The code above will get you values from GET
and POST
.
But if you want to check if something was sent specifically through POST
you can get it like this.
$this->getRequest()->getPost('field_name');
You can even specify a default value.
$somevar = $this->getRequest()->getParam('some_var', 7);
this means that if $_POST['some_var']
is not set, the variable $somevar
will have the value 7
.
Return array with params post/get
Mage::app()->getRequest()->getParams();
Return value by field name
Mage::app()->getRequest()->getParam('field');