I need some assistance retrieving magento order information.
1.I need to retrieve the order information for all orders that have a status of completed.
2. I need to output the data into an XML array "shown below"
3. The code is executed from outside of the Magento application.
Thanks!
1: #Here is the script to retrieve the order array:
2: require_once("../app/Mage.php");
3: Mage::app();
4: // We will retrieve only order items for orders with these states
5: $order_states = array(
6: Mage_Sales_Model_Order::STATE_NEW,
7: Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
8: Mage_Sales_Model_Order::STATE_PROCESSING,
9: Mage_Sales_Model_Order::STATE_HOLDED,
10: Mage_Sales_Model_Order::STATE_COMPLETE
11: );
12: //First get set the state order attribute
13: $orderStateAttribute = Mage::getResourceSingleton('sales/order')->getAttribute('state');
14: //Call The Order Item
15: $orderItemsCollection = Mage::getModel('sales/order_item')->getCollection();
16: $orderItemsCollection->getSelect()
17: // optionally join the sales/order table
18: // ->joinLeft(Array('orders' => Mage::getSingleton('core/resource')->getTableName('sales/order')), '`main_table`.`order_id`=`orders`.`entity_id`', '')
19: ->joinLeft(Array('state_eav' => $orderStateAttribute->getBackendTable()),
20: '(`main_table`.`order_id`=`state_eav`.`entity_id` AND '.
21: '`state_eav`.`entity_type_id` = '.$orderStateAttribute->getEntityTypeId().' AND '.
22: '`state_eav`.`attribute_id` = '.$orderStateAttribute->getAttributeId().')', '')
23: ->where('`state_eav`.`value` IN(''.implode("','",$order_states).'')')
24: ;
25: foreach($orderItemsCollection as $orderItem)
26: {
27: print $orderItem->getSku().": ".$orderItem->getQtyToShip()."
";
28:
29: }
30: #This is as far as I have gotten.
31: # Here is the XML array that I need to build
32:
33:
34: 1442
35: 1214
36:
37: 1442
38: 03-12-2009 6:30 PM
39: 255.255.255.255
40:
41: Doe, John
42: John
43: Doe
44: 123 somestreet
45: Suit 2
46: Orlando
47: 32855
48: FL
49: US
50: 8005551212
51: me@domain.com
52:
53:
54: John
55: Doe
56: 123 Somestreet
57: Suit 2
58: Orlando
59: FL
60: 32805
61: US
62:
63: 8005551212
64: me@domain.com
65:
66: 167.07
67: 156.47
68:
69: 0
70: 0
71: 0
72: 0
73: 0
74:
75:
76:
77:
78:
79:
80:
81:
82: 1442
83: 100
84: 1
85: 156.47
86: MFJ0913
87: S
88: Balun 4:1 Current 300 Watts
89: MFJ-913
90: A
91: Y
92:
93:
94: 1442
95: 500
96: 1
97: 10.60
98: SHIPPING
99: F
100: UPS Ground
101: 0
102: 0
103:
104:
105: 1442
106: 600
107:
108: C
109: Call Sign:
110:
111:
112: 1442
113: 601
114:
115: C
116: KI4NCX
117:
118:
接包方 | 国家/地区 | |
---|---|---|
3
Colorgraphicz
|
||
3
Slavikos
|
||
2
Smarttechno
|
||
2
Geeksinaflash
|
||
2
Colincornaby
|
||
2
Dougallbright
|