2

How to show different logo when the user is logged in?

Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69

1 Answers1

3

You can set different logo while customer is logged in using a helper method, You have to Create a custom module for this.

In your layout you have to pass helper method for logo path,By adding below code in file

Magento_Theme/layout/default.xml

<argument name="logo_file" xsi:type="helper" helper="Namespace\ModuleName\Helper\Data::getLogoImage"></argument>

After that in your modules helper file you have to add below code

<?php

    namespace Namespace\ModuleName\Helper;

    class Data extends \Magento\Framework\App\Helper\AbstractHelper
    {
        protected $_request;
        protected $_session;

        public function __construct
        (
            \Magento\Framework\App\Request\Http $request,
            \Magento\Customer\Model\Session $session
        ) {
            $this->_request = $request;
            $this->_session = $session;
        }

        public function getLogoImage()
        {
            if ($this->_session->isLoggedIn()) {
                $logo =  'path/to/logo/for/logged_in/customer.png';
            } else {
                $logo = 'path/to/logo/for/guest/customer.png';
            }

            return $logo;
        }
    } 

Note: Change Namespace and ModuleName based on your custom Module

Piyush
  • 5,893
  • 9
  • 34
  • 64