getCompany for templates/account/dashboard/info.phtml doesn't work when I use a block at all or otherwise. Anyway I can display the contact's company name where the first and last name are being displayed? Thanks. I am pretty sure I am exhausted and just not thinking.


As Company is the part of address and its an address attribute, you cannot get the data directly from customer object. First you have the get the default shipping address ID then get the address by that ID and then you will get the Company name from address object.

Use the below code:

<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); ?>
<?php $shippingAddressId = $block->getCustomer()->getDefaultShipping() ?>        
<?php $shippingAddress = $objectManager->get('Magento\Customer\Model\AddressFactory')->create()->load($shippingAddressId); ?>
<?php echo $shippingAddress->getCompany() ?>

Note: Don't use object manager directly in your file. You have to inject the addressFactory class.

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.