Magento 2 Not Showing Changes in Frontend – Troubleshooting

magento2product-list

I am new in Magento 2. I want to add new custom text on listing page. I've attached a screenshot for reference.I have copy list.phtml from

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

to dafault LUMA theme

   app/design/frontend/Magento/Luma/Magento_Catalog/templates/product/list.phtml

I have added text in list.phtml of theme location file.my problem is that changes is not showing list page. but when i have same text changed in core list.phtml file changes is showing.

After Following commands run

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy 
php bin/magento cache:flush
php bin/magento cache:clean

Best Answer

If you using magento default luma theme that you cannot use Template changes logic -

app/design/frontend/{Vendor}/{Theme}/Magento_Catalog/templates/product/list.phtml

for luma theme bcoz of this theme is register under vendor/ folder.

In this create case, you should edit at core or need to create custom module from where you can template via layout

This module should consist of below files:

  • app/code/app/code/{vendorname}/{Modulename}/registration.php
  • app/code/{vendorname}/{Modulename}/composer.json
  • app/code/{vendorname}/{Modulename}/etc/module.xml
  • app/code/{vendorname}/view/frontend/layout/catalog_category_view.xml
  • app/code/{vendorname}/view/frontend/templates/product/list.phtml

catalog_category_view.xml code should be:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <referenceBlock name="category.products.list">
         <action method="setTemplate">
            <argument name="template" xsi:type="string">{vendorname}_{Modulename}::product/list.phtml</argument>
         </action>
    </referenceBlock>
</body></page>

And app/design/frontend/Magento/Luma/Magento_Catalog/templates/product/list.phtml need to copy at app/code/{vendorname}/view/frontend/templates/product/list.phtml

Related Topic