9

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?

15

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 :)

7

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 – Sukeshini Dec 31 '13 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 – Pradeep Singh Jul 28 '17 at 7:29
2

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.

  • 2
    I 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 – Sukeshini Sep 25 '13 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.