skip to Main Content

I try to override my layout file from my theme in my child theme

I’m on magento 2.2.11 and I want to override my xml file from my theme with a child theme. I try to follow magento doc without success

I have :

app/design/frontend/Myvendor/mytheme/Myvendor_Header/layout/default.xml

And I want override him.

I try with this:

app/design/frontend/Myvendor/mytheme_child/Myvendor_Header/layout/override/theme/Myvendor/mytheme/default.xml

And my xml child doesn’t work, I don’t have error. It load only my parent xml.

My child theme is defined correctly because my .phtml files override parent file.

Do you have an solution for override my layout parent ?

3

Answers


  1. Chosen as BEST ANSWER

    I found a solution to my problem.

    To start check if the theme is set in physical.

    Go to your database -> table "theme" -> columns "type" must be 0

    If you are testing multiple sites on one domain

    For force a particular website go to index.php and add these lines :

    $params[MagentoStoreModelStoreManager::PARAM_RUN_CODE] = "my_website_view";
    $params[MagentoStoreModelStoreManager::PARAM_RUN_TYPE] = 'store';
    $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params);
    

    Put the child layout in the child theme

    app/design/frontend/Myvendor/mytheme_child/Myvendor_Header/layout/default.xml

    Finally, launch command

    1. rm -rf generated/code/ generated/metadata/* var/page_cache/* var/view_preprocessed/* var/cache/*
    2. php bin/magento cache:flush
    3. php bin/magento setup:upgrade
    4. php bin/magento setup:static-content:deploy -f

  2. Please try to add the layout.xml file in this path and after that run Magento Commands.

    app/design/frontend/Myvendor/mytheme_child/Myvendor_Header/layout/default.xml

    Thanks!!

    Login or Signup to reply.
  3. Thanks a bunch Sebastien, spent almost 2 hours to fix this, you idea of changing type is really worked.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search