<?php
require_once('app/Mage.php');
Mage::app();
$data=Mage::getModel('sales/order')->getCollection();
$fp = fopen('exports_order.csv', 'w+');
//csve headers. You can give your own headers or extra headers
$csvHeader = array('order_id',
'ship_name',
'ship_address1',
'ship_city',
'ship_state',
'ship_zip',
'ship_country',
'item_id',
'qty',
'ship_company',
'phone_day',
'email');
fputcsv( $fp, $csvHeader,",");
foreach($data as $row)
{
//echo "<pre>";Mage::log($row->getData(),null,'orderdata.log');die('here');
$_order=Mage::getModel('sales/order')->load($row->getId());
$_shippingAddress = $_order->getShippingAddress();
//echo "<pre>";Mage::log($_shippingAddress->getData(),null,'shipping.log');die('here');
foreach ($row->getAllItems() as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
//echo "<pre>";Mage::log($item->getData(),null,'noworders.log');die();
fputcsv($fp, array($row->getId(),
$_shippingAddress->getFirstname()." ".$_shippingAddress->getLastname(),
$_shippingAddress->getStreetFull(),
$_shippingAddress->getCity(),
$_shippingAddress->getRegion(),
$_shippingAddress->getPostcode(),
$_shippingAddress->getCountry_id(),
$item->getSku(),
$item->getQtyOrdered(),
$_shippingAddress->getCompany(),
$_shippingAddress->getTelephone(),
$_shippingAddress->getEmail()
) );
}
}
fclose($fp);
require_once('app/Mage.php');
Mage::app();
$data=Mage::getModel('sales/order')->getCollection();
$fp = fopen('exports_order.csv', 'w+');
//csve headers. You can give your own headers or extra headers
$csvHeader = array('order_id',
'ship_name',
'ship_address1',
'ship_city',
'ship_state',
'ship_zip',
'ship_country',
'item_id',
'qty',
'ship_company',
'phone_day',
'email');
fputcsv( $fp, $csvHeader,",");
foreach($data as $row)
{
//echo "<pre>";Mage::log($row->getData(),null,'orderdata.log');die('here');
$_order=Mage::getModel('sales/order')->load($row->getId());
$_shippingAddress = $_order->getShippingAddress();
//echo "<pre>";Mage::log($_shippingAddress->getData(),null,'shipping.log');die('here');
foreach ($row->getAllItems() as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
//echo "<pre>";Mage::log($item->getData(),null,'noworders.log');die();
fputcsv($fp, array($row->getId(),
$_shippingAddress->getFirstname()." ".$_shippingAddress->getLastname(),
$_shippingAddress->getStreetFull(),
$_shippingAddress->getCity(),
$_shippingAddress->getRegion(),
$_shippingAddress->getPostcode(),
$_shippingAddress->getCountry_id(),
$item->getSku(),
$item->getQtyOrdered(),
$_shippingAddress->getCompany(),
$_shippingAddress->getTelephone(),
$_shippingAddress->getEmail()
) );
}
}
fclose($fp);
No comments:
Post a Comment