I want to prevent a fatal error if object is not available.
Background: I wrote an observer to catch data from the shipping object.
$o = Mage::getModel('sales/order')->load($observer->getOrderIds());
if (is_object($o->getShippingAddress()->getPostcode()))
$zip = $o->getShippingAddress()->getPostcode()
But I get an fatal error if the Shipping Address object will not be loaded (i.e. for downloadable products).
Fatal error: Call to a member function getPostcode() on a non-object in /var/www/app/code/local/MyModule/Model/Observer.php on line 22
How can I get rid of it?
Thank you so much