I have the order object. From that I can get the shipping address id. Can anyone suggest how to derive Shipping address by shipping address id?
3 Answers
You could use the order_address object to get the shipping address:
$address = Mage::getModel('sales/order_address')->load($shippingId);
// $shippingId is the id you get from order object.
$custName = $address->getName();
$custAddr = $address->getStreetFull();
$region = $address->getRegion();
$country = $address->getCountry();
or use
print_r(get_class_methods($address));
to see what are the methods that can be used on the address object ($address).
hope it solves your prob :)
To get the Address from an order object you could simple do $order->getShippingAddress()
Assuming
$order_id = 123; // put your order id here
$order = Mage::getModel('sales/order')->load($order_id);
Then
$address = $order->getShippingAddress();
$custName = $address->getName();
$custAddr = $address->getStreetFull();
$region = $address->getRegion();
$country = $address->getCountry();
-
I've already solved my question months ago. Even though appreciate the response. +1 Commented Dec 31, 2013 at 3:05
-
$address
is empty when i use$address = $order->getShippingAddress()
but when i use$address = Mage::getModel('sales/order_address')->load($shippingId);
It returns the address Commented Jul 28, 2017 at 7:29
Shathish has given you a nice and correct answer.
However, you can use the singleton method and a query:
$shimnetId = "1"; // use your shipment id:
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$query = "SELECT * FROM sales_flat_order_address WHERE entity_id='".$shipmentId."'";
$results = $read->fetchAll($query);
var_dump($results);
sales_flat_order_address
contains both the billing and shipping address.
Hope it will work for you.
-
2I didn't tested your solution. But I think developing according to the way the Magento has developed is better rather than using direct SQL queries in the source. Anyway appreciate your suggestion. Thank you Commented Sep 25, 2013 at 5:19