2

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?

3
  • 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. Aug 1, 2014 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... Aug 2, 2014 at 4:22
  • 1
    Should be $this->getCustomer()->getBillingAddress()->getCompany() then i guess (or getShippingAddress()). Did not try it. Aug 10, 2014 at 13:37

1 Answer 1

12

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.