1

I want to get my all the details of a sale order in my controller and then update the status of that order.

Plus how can I pass order ID in URL string and than get it as Magento1.9 doesn't allow $_GET[] and $_POST[]

  • On admin or frontend? – Sukumar Gorai Jul 6 '18 at 7:26
  • i want to get the details on the frontend – Subhan Sunny Jul 6 '18 at 7:35
1

If you have entity id then use below code to get order details:

$order = Mage::getModel('sales/order')->load($entity_id);

If you have order increment id then use below code to get order details:

$order = Mage::getModel('sales/order')->loadByIncrementId('10000001');

If you want to get data from post or get action then you can use the following code:

$order_id = $this->getRequest()->getParam('order_id'); //This will return only order id

And if you are posting multiple value from form or multiple parameters through url or get method then you need to use below code:

$params = $this->getRequest()->getParams();

Use below code for your form action:

Mage::getUrl('frontname/controller/action', array('id' => 1));//If you want to pass only one parameter

Output URL for above code: http://www.example.com/frontname/controller/action/id/1

And if you have multiple parameters then use below code:

Mage::getUrl('frontname/controller/action', array('id'=>1', '_query'=>array('parm1'=>'value1', 'parm2'=>'value2'))); //If you want to pass multiple parameters

Output URL for above code: http://www.example.com/frontname/controller/action/id/1/?parm1=value1&parm2=value2

  • $order_id = '100000003'; $order = Mage::getModel('sales/order')->loadByIncrementId('10000001'); print_r($order->getData()); and this is returning me empty array, like this Array ( ) – Subhan Sunny Jul 6 '18 at 7:44
  • Put your order id instead of 10000001 like this $order = Mage::getModel('sales/order')->loadByIncrementId($order_id'); – Sukumar Gorai Jul 6 '18 at 7:46
  • In loadByIncrementId function, we can't pass order id, but it should be accepting increment id of the order, which might be different from order_id. – Manish Joy Jul 6 '18 at 7:49
  • @Manish Joy, Did you saw the above comment where he mentioned that $order_id = '100000003'; which is not a order id. I think you are not checking what he is posting. – Sukumar Gorai Jul 6 '18 at 7:50
  • @SukumarGorai yes, I did, but he is using loadByIncrementId so he is putting correct value to the param, I guess – Manish Joy Jul 6 '18 at 7:54
0

You can get order details by using this code snippet:

Mage::getModel('sales/order')->load($order_id);

BTW, you can get the parameter by using:

$this->getRequest()->getParam('index');

--or--

$this->getRequest()->getParams();
  • this is returning me empty array, like this Array ( ) – Subhan Sunny Jul 6 '18 at 7:46
  • can you paste your code along with the question? – Manish Joy Jul 6 '18 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.