Magento – How to override .phtml files in Magento 2

magento2moduleoverridestheme

I want to customize product details page, So it required to override some .phtml files in following locations.

So I want to know, how to override .phtml files in vendor\magento\module-catalog\view\frontend\templates\product or vendor\magento\module-theme\view

Best Answer

Sometimes we need to make modifications to existing templates. Instead of making changes directly to existing template files, we should override them in our own theme. Let us assume that we want to update the category listing page ( list.phtml ). To do so, create following directory structure:

app/design/frontend/Mycompany/Basic/Magento_Catalog/templates/product

Here I assume that our current theme is Basic. Now copy the list.phtml file into product directory from the following location:

app/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

Now you can make any modifications you want to your overridden file.

For detail please read this tutorial it's help you lot.

Related Topic