Override Magento 2 phtml Files?

The question:

Is it possible to override Magento 2 Luma phtml Files? I’ve created a new theme based on Luma which is working perfectly but I can’t find any phtml files anywhere.

I’ve also noticed my app/code directory is completely empty.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

you can find luma theme files are located

copy from here

vendor/magento/theme-frontend-luma

add in your theme

app/design/frontend/spacename/theme/

you are missing templates in path /app/design/frontend/Penguin/default/Magento_Theme/templates/html/header.phtml

Method 2

App/code empty is ok if you installed via Composer!

In your app/design/frontend/Magento/luma folder you can find all your modules that are customized either from app/design/frontend/Magento/luma or the core modules app/code/Magento/

For catalog list phtml you can for example copy the files from
app/code/Magento/catalog/view/frontend/templates/product/list.phtml into your custom app/design/frontend/<yourvendorfolder>/<yourthemefolder>/Magento_Catalog/templates/html/list.phtml

here you go, think you should run through the devdocs some more to get to know the logic behind the magento2 file and override structure.
its not like Magento1 just copy over few templates files and done. 85% is done via layout xml files and just small bits via phtml.

Good luck!


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment