I tried to export sales order customer details, its working fine, but i want customer country code
(country name) not id. below i mention my full code.
<?php
require_once("app/Mage.php");
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
$orders = Mage::getModel('sales/order')->getCollection();
$orders->addAttributeToFilter('grand_total', array('gt' => '0.00'));
$orders->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE);
$fp = fopen('file.csv', 'w');
foreach($orders as $order) {
$fields = array($order->getId(), $order->getBillingAddress()->getFirstname(),$order->getBillingAddress()->getLastname(), $order->getBillingAddress()->getEmail(), $order->getBillingAddress()->getCity(), $order->getBillingAddress()->getTelephone(), $order->getBillingAddress()->getCountryId(), $order->getStatus());
fputcsv($fp, $fields);
}
?>
Best Answer
Finally i got solution. This is my final code:
Please try this, Its working for me