Magento works with .phtml
template files to generate the view layer for the users. The modules and themes in Magento have its specific group of .phtml
files to show data to the users. Let's create a custom template example in the CompStore theme to see how it works:
Create the
Magento_Catalog
directory under thecompstore
theme directory.Copy the contents of
vendor/magento/module_catalog/view/frontend/templates
toapp/design/frontend/Packt/compstore
.Then, open the
app/design/frontend/Packt/compstore/Magento_Catalog/templates/product/view/addto.phtml
file in your favorite code editor.Go to Line 17 and enter the following code:
<div><h2>Buy in CompStore!!!</h2></div>
Save the file.
Delete the
var/view_preprocessed/
andpub/static/frontend/Packt/compstore/
directories.Deploy static content files by running the
php magento setup:static-content:deploy
command.If necessary, give
write
permission to thepub
directory.
Navigate to the product...