I am getting this issue now. I can pass the productId but the foreach it looks like it does not work, When customer order 2 items the result i get is just the last item productId.
Here is the code:
class Order_OrderExport_Model_Export
{
public function exportOrder($order,$sku)
{
$dirPath = Mage::getBaseDir('var') . DS . 'export';
if (!is_dir($dirPath)) {
mkdir($dirPath, 0777, true);
}
foreach ($order->getAllItems() as $item) {
$data = array(
'getIncrementId' => $order->getIncrementId(),
'created_at' => $order->getCreatedAt(),
'customer_id' => $order->getCustomerId(),
'customer_firstname' => $order->getCustomerFirstname(),
'customer_lastname' => $order->getCustomerLastname(),
'customer_email' => $order->getCustomerEmail(),
'telephone' => $order->getBillingAddress()->getTelephone(),
'street' => $order->getBillingAddress()->getStreet(),
'get_city' => $order->getBillingAddress()->getCity(),
'postcode' => $order->getBillingAddress()->getPostcode(),
'region' => $order->getBillingAddress()->getRegion(),
'get_country' => $order->getBillingAddress()->getCountry(),
'tax_amount' => $order->getTaxAmount(),
'shipping_amount' => $order->getShippingAmount(),
'remote_ip' => $order->getRemoteIp(),
'total_qty_ordered' => $order->getTotalQtyOrdered(),
'subtotal' => $order->getSubtotal(),
'grand_total' => $order->getGrandTotal(),
'order_currency_code' => $order->getOrderCurrencyCode(),
//Here is the output of the items
'item' => $item->getProductId(),
);
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive($data, array ($xml, 'addChild'));
file_put_contents(
$dirPath. DS .$order->getIncrementId().'.xml',
$xml->asXML()
);
}
}
The XML i am outputting display only on product. Thank you
exportOrder
? – FlorinelChis Oct 10 '13 at 16:11print_r($order->getData())
... what do you get in there? Can you see the fields you were looking for? – FlorinelChis Oct 10 '13 at 16:29sales_order_place_before
event – Sukeshini Oct 10 '13 at 17:15