2

I have created a new child theme from Luma. The admin panel recognizes that it's registered and I have set it up to be used for my store.

One of the things I tried to achieve was changing the logo for a store, tried to define it in default.xml, and flushed the cache, but nothing changed on the frontend.

Afterward, I tried to insert a container with a block on top of the header, but also no sign of any changes.

What exactly I am doing wrong? Can't seem to figure it out with just the help of Google.

Files structure

📦frontend
 ┣ 📂MyVendor
 ┃ ┗ 📂MyTheme
 ┃ ┃ ┣ 📂etc
 ┃ ┃ ┃ ┗ 📜view.xml
 ┃ ┃ ┣ 📂layout
 ┃ ┃ ┃ ┗ 📜default.xml
 ┃ ┃ ┣ 📂templates
 ┃ ┃ ┃ ┗ 📜top_message.phtml
 ┃ ┃ ┣ 📂web
 ┃ ┃ ┃ ┣ 📂css
 ┃ ┃ ┃ ┃ ┗ 📂source
 ┃ ┃ ┃ ┣ 📂fonts
 ┃ ┃ ┃ ┣ 📂images
 ┃ ┃ ┃ ┃ ┗ 📜my_logo.png
 ┃ ┃ ┃ ┗ 📂js
 ┃ ┃ ┣ 📜registration.php
 ┃ ┃ ┗ 📜theme.xml
 ┗ 📜.DS_Store

default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    
        <referenceContainer name="header.container">
            <container name="header.message.wrapper" htmlTag="div" htmlClass="header-message-wrapper">
                <block name="header.message" template="MyTheme::top_message.phtml" class="Magento\Framework\View\Element\Template" />
            </container>
        </referenceContainer>

        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">
                    images/my_logo.png
                </argument>
                <argument name="logo_alt" xsi:type="string">
                    Awesome logo
                </argument>
            </arguments>
        </referenceBlock>

    </body>
</page>

top_message.phtml

<p>Free shipping for all orders.</p>

1 Answer 1

0
  1. Create the Magento_Theme directory inside your theme. frontend/MyVendor/MyTheme/Magento_Theme

  2. Move the layout and templates directory to Magento_Theme.

  3. Update the default.xml file like this.

<referenceBlock name="logo">
    <action method="setLogoFile">
        <argument name="logo_file" xsi:type="string">images/my_logo.png</argument>
    </action>
    <arguments>
        <argument name="logo_alt" xsi:type="string">Awesome logo</argument>
    </arguments>
</referenceBlock>
1
  • hah, apparently it was that easy. thank you!
    – Aivars
    Commented Aug 30, 2022 at 6:44

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.