0

I am having trouble getting the following function to work:

Mage::getModel('sales/order');

I attempted this, however it returned no results:

$res=Mage::getModel('sales/order');
$orderId=$res->getOrderId();

echo '<pre>';
print_r($orderId);
Community
  • 1
  • 1
mjdevloper
  • 1,553
  • 8
  • 33
  • 69
  • possible duplicate of [Get Order Increment Id in Magento](http://stackoverflow.com/questions/2195743/get-order-increment-id-in-magento) – RobertPitt Jan 27 '11 at 13:01
  • Are you trying to find the order ids of all orders on your Magento install? – Nick Jan 27 '11 at 13:10

2 Answers2

4

I guess by res you mean resource so I'll make a leap of logic and assume you mean to query a resource collection.

echo '<pre>';
$resource = Mage::getModel('sales/order')->getCollection();
foreach ($resource as $order) {
    echo $order->getId(), "\n";
}
echo '</pre>';
clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
0
$order = Mage::getModel('sales/order')->load($order_id);
$items = $order->getAllItems();
$itemcount=count($items);
$name=array();
$unitPrice=array();
$sku=array();
$ids=array();
$qty=array();
foreach ($items as $itemId => $item)
{
 $name[] = $item->getName();
 $unitPrice[]=$item->getPrice();
 $sku[]=$item->getSku();
 $ids[]=$item->getProductId();
 $qty[]=$item->getQtyToInvoice();
}
Pradeep Singh
  • 3,582
  • 3
  • 29
  • 42
  • i dont have $order_id.then how can i move further.Please tell me another way or please tell me how can i find $order_id – mjdevloper Jan 27 '11 at 13:07