Magento Get Shipping Address Outside Magento

By | November 17, 2013

Magento one of the most powerful tool in E-commerce which allow us to access the core Functionlity outside the Root directory also where magento been installed.
We have try to get the shipping address of customer whose order are under processing ,outside the Magento in .doc Format

Create a file in root where magento install and add the below code you will get the shipping address.In order to customize more you can bring product data also

<?php
require_once("app/Mage.php");
Mage::app('default');

$_orders = Mage::getModel("sales/order")->getCollection()
->addAttributeToSelect('*')
->addFieldToFilter('status', 'processing');

header("Cache-Control: ");
header('Content-Description: File Transfer');
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=exportorder.doc");

echo "<html>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\">";
echo "<body>";
echo "<table width=100%>";
echo "<tr width=49px>";
$i = 0;
foreach($_orders as $order) {
foreach($order->getAllItems() as $item){

if ($i % 3 === 0) {
echo '</tr><tr>';
}

echo "<td width=25px>"
.$order->getShippingAddress()->getFirstname().' '.$order->getShippingAddress()->getLastname() .'['.(int)$order->getTotalQtyOrdered().' '.$item->getSku().']'.'<br>'
.$order->getShippingAddress()->getStreetFull() .'<br>'
.$order->getShippingAddress()->getCity() .','.$order->getShippingAddress()->getRegion().'<br>'
.$order->getShippingAddress()->getCountry() .','.$order->getShippingAddress()->getPostcode()
."</td>";
$i++;
}

}

echo "</tr>";
echo "</table>";
echo "</body>";
echo "</html>";

?>

Hope this will help you

Leave a Reply