I want to pass the product info after is ordered and i have created this file for testing. The foreach is not working because it show back just one product and not all of them.
Here is the code:
$dirPath = Mage::getBaseDir('var') . DS . 'export';
if (!is_dir($dirPath)) {
mkdir($dirPath, 0777, true);
}
foreach ($order->getAllItems() as $item){
$data = array(
'ID' => $item->getProductId(),
'QTY' => $item->getTotalQtyOrdered(),
'PRICE' => $item->getSubtotal()
);
}
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive($data, array ($xml, 'addChild'));
file_put_contents(
$dirPath. DS .$order->getIncrementId().'.xml',
$xml->asXML()
);