Getting Ordered Items and their Detail from Order ID in Magento

Here is a small snippet of code, yet useful, to get ordered items and its details. I’ve deviced this code a lot before and posted in Magento Commerce’s Forum as well. But felt like writting it again, so that I can have a quick refrence to it as well. Next thing, I’ve tried a lot to get all orders and their items details by single query, but have not yet come up with a solution. If you have any method of finding order and its details by a single query, then please do response. The code below first needs an order ID as it parameters to give order details.

 

01 $order = Mage::getModel( 'sales/order' )->load( $order_id );
02 $items = $order ->getAllItems();
03 $itemcount = count ( $items );
04 $name = array ();
05 $unitPrice = array ();
06 $sku = array ();
07 $ids = array ();
08 $qty = array ();
09 foreach ( $items as $itemId => $item )
10 {
11      $name [] = $item ->getName();
12      $unitPrice []= $item ->getPrice();
13      $sku []= $item ->getSku();
14      $ids []= $item ->getProductId();
15      $qty []= $item ->getQtyToInvoice();
16 }

Hope this might “just” help somebody in need.

Related entries

  1. Create and Download XLS Report file using Magento's Core
  2. Debugging Magento Using Eclipse PDT & Zend Debugger
  3. Getting Customer's Info Using Single Query Including Billing and Shipping Addresses
  4. Getting Configurable Attributes (Super Attributes) of a Configurable Product
  5. Creating Custom Sourced Multiselect Product Attribute
  6. Using Custom Table for Custom Module in Magento
  7. Getting Rescent Rating Summary of a product in Magento
  8. Adding custom options to a product in Magento
  9. Getting all custom options of a product in Magento
  10. Using Custom Query in Magento

你可能感兴趣的:(agent)