您的位置:首页 > 大数据 > 人工智能

Getting Ordered Items and their Detail from Order ID in Magento

2011-03-22 15:32 447 查看
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.

 

view source
print
?

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

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐