title: Extracting Country name (or initials) from Magento
body: <p>I'm trying to get the country name "United States" (or initials "USA"/"US"). I've tried a bunch of variations on the following: </p>
  
  <pre><code>echo Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getCountry();
  $countryName = Mage::getModel('directory/country')-&gt;load(Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getCountry())-&gt;getName();
  error_log("countryName = $countryName");
  </code></pre>
  
  <p>The first call "seems" to work, as I get a 6 back (USA). But after that I'm not able to find out how to map that to a proper name or slug. </p>
  
  <p>I've seen posts where the programmers gets a list of all the country names and id's but I don't want to iterate through all the combinations to find the name. </p>
  
  <p>TIA!</p>
  
  <p>EDIT:
  Per clockworkgeeks' suggestion, I've tried:</p>
  
  <pre><code>$customer = Mage::getSingleton('customer/session')-&gt;getCustomer();
  error_log(print_r($customer, true));
  $countryCode = $customer-&gt;getDefaultBillingAddress()-&gt;getCountry();
  </code></pre>
  
  <p>However, the 3rd line fails w/the call to getCountry(). Perhaps getDefaultBillingAddress() is not returning on object. Error message:</p>
  
  <pre><code>PHP Fatal error:  Call to a member function getCountry() on a non-object in ...
  </code></pre>
  
  <p>Thoughts? The $customer object is coming back correctly, though the <strong>CLASS</strong> is a MYCLIENT_Customer_Model_Customer Object ... perhaps it doens't extend the proper parent to give it access to getCountry?</p>
  
  <p>Edit: (Solution):  Added as an answer. </p>