I am trying to get Company Name to display in Magento admin but I can't get the value for just the Company name and nothing else.

Here is my code

<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>

Can anyone let me know what I've done wrong here?

  • Please add some details: In which function/class are you trying to echo the value => which class/super class is $this of? What does "cant't get the value" mean: error, empty value? Try to var_dump the value and see what is returned. – Anna Völkl Aug 1 '14 at 21:45
  • Hi, I am inside Mage_Adminhtml_Block_Customer_Edit_Tab_View and need to echo the value inside app/design/adminhtml/default/default/template/customer/tab/view.phtml and the moment I am not getting the value for company using the code above... – user1704524 Aug 2 '14 at 4:22
  • 1
    Should be $this->getCustomer()->getBillingAddress()->getCompany() then i guess (or getShippingAddress()). Did not try it. – Anna Völkl Aug 10 '14 at 13:37

You can get the company name inside app/design/adminhtml/default/default/template/customer/tab/view.phtml by using the following code:

Getting the company name from the billing address:

<?php echo $this->htmlEscape($this->getCustomer()->getBillingAddress()->getCompany()); ?>

Getting the company name from the shipping address:

<?php echo $this->htmlEscape($this->getCustomer()->getShippingAddress()->getCompany()); ?>

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.