I would like to have the same welcome message for all users which you type in at the backend Configuration > Design > Header.

The only difference should be that the logged in users should have their name out front.

For example: the not logged in users should see

"Hello welcome to our store!"

and the ones who are logged in should see

"Mr Brown. Hello welcome to our store!"

So I guess I have to change the code on the following file: code > local > Mage > Page > Block > Html > Header.php

I tried the following but it didn't work:

 * Retrieve page welcome message
 * @deprecated after
 * @see Mage_Page_Block_Html_Welcome
 * @return mixed
public function getWelcome()
    if (empty($this->_data['welcome'])) {
        if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
            $this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome') & $this->__('%s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()));
        } else {
            $this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');

    return $this->_data['welcome'];


I'm not good at coding so it would be great if someone could help me on this. Thanks.

  • 2
    Notice the comment in front of the getWelcome function you are editing. This is deprecated after Magento CE
    – MatthijsIJ
    Dec 17 '15 at 10:45

Please do not just copy the complete file to app/code/local as it was suggested here multiple times. You will have a hard time once you upgrade your shop as you will have to work through all this files manually.

It's better to create a proper rewrite for this.

Create a new module and update your config.xml with the block rewrite:

<?xml version="1.0"?>

Then create a new file app/code/local/YourName/YourModule/Block/Html/Welcome.php which extends from the core class. This will only rewrite the _toHtml method and the rest is still taken from the core class.


class YourName_YourModule_Block_Page_Html_Welcome extends Mage_Page_Block_Html_Welcome {

     * Get block message
     * @return string
    protected function _toHtml()
        if (empty($this->_data['welcome'])) {
            if (Mage::isInstalled() && $this->_getSession()->isLoggedIn()) {
                $this->_data['welcome'] = $this->__('%s. Hello welcome to our store!', $this->escapeHtml($this->_getSession()->getCustomer()->getName()));

            } else {
                $this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');

        return $this->_data['welcome'];

Once the Mage_Page_Block_Html_Welcome is ever updated in a future version of Magento, you will have less trouble and less manual work during upgrade.

In addition to this you need to update the text for the not logged in customers via Configuration > Design > Header > Welcome Text as it was already correctly mentioned here.

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.