Naming the custom module to override the logo.phtml file found at the path seen in the screenshot below a bit confusing to me as the module name is too long to decide on the naming. The vendor of the custom theme being used is Swissup.

I know the module name should begin with Swissup_(What comes here) with me not being able to figure out how to complete the module name after Swissup_. Any advice or help, please.

enter image description here

2 Answers 2


You can override the logo.phtml file under your custom module by making preference for Magento\Theme\Block\Html\Header\Logo class.

Add di.xml file under app/code/Vendor/Module/etc/frontend/di.xml with below content.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <preference for="Magento\Theme\Block\Html\Header\Logo" type="Vendor\Module\Block\Rewrite\Html\Header\Logo"/>

After that, create Logo.php under app/code/Vendor/Module/Block/Rewrite/Html/Header with below content.


namespace Vendor\Module\Block\Rewrite\Html\Header;

class Logo extends \Magento\Theme\Block\Html\Header\Logo
     * Current template name
     * @var string
    protected $_template = 'Vendor_Module::html/header/logo.phtml';

Copy the logo.phtml file from your theme and placed under app/code/Vendor/Module/view/frontend/templates/html/header.

Run the deployment commands and check your changes.

Hope it helps!!!

  • thanks for your time and the help. Could the module name be anything? Will it do if I name it as Swissup_Logo or Mycompanyname_Logo? Apr 28, 2020 at 6:17
  • Yes, you can change the name of the module whatever you want. Also, please add all required files to create a module Registration.php and module.xml.
    – Sumit
    Apr 28, 2020 at 6:19
  • I am trying your solution now. In type="Vendor\Module\Block\Rewrite\Html\Header\Logo" do I need to replace the Vendor with my company name and Module with module name? Apr 28, 2020 at 10:07
  • Yes, you're right. You can replace it with your names. Please make sure you can change the names in the Logo.php file as well.
    – Sumit
    Apr 28, 2020 at 10:37
  • Followed all the instructions by you, but the logo part itself is now missing from the homepage. I wonder what must have gone wrong. Apr 28, 2020 at 10:42

You can manage via after plugin on getTemplate() .

Create di.xml at app/code/StackExchange/Theme/etc/frontend

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Theme\Block\Html\Header\Logo">
        <plugin disabled="false" name="StackExchange_Theme_Plugin_Magento_Theme_Block_Html_Header_Logo" sortOrder="10" type="StackExchange\Theme\Plugin\Magento\Theme\Block\Html\Header\Logo"/>

Then on plugin class StackExchange\Theme\Plugin\Magento\Theme\Block\Html\Header\Logo.php and

from afterGetTemplate() changes template from here.

<?php  declare(strict_types=1);

namespace StackExchange\Theme\Plugin\Magento\Theme\Block\Html\Header;

class Logo

    public function afterGetTemplate(
        \Magento\Theme\Block\Html\Header\Logo $subject,
    ) {

        return 'StackExchange_Theme::html/header/logo.phtml';
  • thanks a lot for the help.I presume I must replace app/code/StackExchange/Theme/etc/frontend with app/code/MyCompanyName/Swissup/etc/frontend. Is this correct? Apr 28, 2020 at 7:44
  • yes.. app/code/StackExchange/Theme/etc/frontend
    – Amit Bera
    Apr 28, 2020 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.