1

I want to overide files located in

vendor/magento/module-theme/view/frontend/templates/html/header.phtml

to

app/design/frontend/Magento/theme-frontend-luma/Magento_Theme/templates/html/header.php

but the old file is being called from vendor folder, maybe above structure is wrong?

  • The file should be named 'header.phtml' rather than 'header.php' – mtr.web Mar 29 '18 at 18:45
  • magento.stackexchange.com/a/138358 – Kalpesh Mar 29 '18 at 18:52
  • You need to create first a luma_child theme to not update the natif one Magento_Luma then you place your new file in : app/design/frontend/Magento/luma_child/templates/header.phtml – PЯINCƏ Mar 29 '18 at 20:18
  • I would recommend against using the Magento vendor namespace in the app design folder, it's better to use your own namespace. There might be a time and place for it, but better to have it follow the magento standards. – circlesix Mar 29 '18 at 21:45
1

You need to create a custom theme that inherits from Luma to be able to override the file correctly. Create the needed files:

app/design/frontend/{vendor_namespace}/{theme_name}/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/{vendor_namespace}/{theme_name}',
    __DIR__
);

app/design/frontend/{vendor_namespace}/{theme_name}/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Your Custom Theme</title>
    <parent>Magento/luma</parent>
</theme>

And then place your override here:

app/design/frontend/{vendor_namespace}/{theme_name}/Magento_Theme/templates/html/header.php

You then need to set your theme in the admin under Content -> Theme -> Configurations

Once the site is using your theme you will have the file override correctly. Note that you will have to replace all the default luma static blocks that are on the home page and category pages, the widgets that place them there are locked to the theme and will vanish when you switch this.

I also did a deeper write up on this: https://www.customerparadigm.com/magento-2-theming-basics/

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.