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
);
|
05
|
$unitPrice
=
array
();
|
09
|
foreach
(
$items
as
$itemId
=>
$item
)
|
11
|
$name
[] =
$item
->getName();
|
12
|
$unitPrice
[]=
$item
->getPrice();
|
13
|
$sku
[]=
$item
->getSku();
|
14
|
$ids
[]=
$item
->getProductId();
|
15
|
$qty
[]=
$item
->getQtyToInvoice();
|
Hope this might “just” help somebody in need.
Related entries
-
Create and Download XLS Report file using Magento's Core
-
Debugging Magento Using Eclipse PDT & Zend Debugger
-
Getting Customer's Info Using Single Query Including Billing and Shipping Addresses
-
Getting Configurable Attributes (Super Attributes) of a Configurable Product
-
Creating Custom Sourced Multiselect Product Attribute
-
Using Custom Table for Custom Module in Magento
-
Getting Rescent Rating Summary of a product in Magento
-
Adding custom options to a product in Magento
-
Getting all custom options of a product in Magento
-
Using Custom Query in Magento