I want to change the frontend of product list page like in picture below. What file should i change? The product list i mean is each product list in each home page and category page.
Magento 2 – Product List PHTML File for Each Page
frontendmagento2PHPproduct-list
Best Answer
So a quick answer on this :
You can find the list.phtml in
catalog_category_view.xml
under the line of
If you want to change default logics behind the class you can extend
Magento\Catalog\Block\Product\ListProduct
and use that in your own Block that replaces this one.If you just want to change html things you can just replace
Magento_Catalog::product/list.phtml
In your theme copy the file under
Vendor/Theme/Magento_Catalog/templates/product/list.phtml
and ajust it how you would like.
If you want to replace it by Module you need to have a
view/frontend
folder withing your module directory and adjust the xml by using referenceBlocks :with the code :
and then have a
copy/paste the Magento list.phtml there.
Notice how in the list.phtml it sometimes calls for
ChildBlocks
. Childblocks are blocks that are defined within a level 0 block (so container->block->childblocks). These are not outputted unless you call them in your phtml fille by using the ->getChildBlock() function.If you want to adjust the those you will need to do the same thing for
For example :
Magento calls for
'$block->getChildBlock('addto'))->getChildHtml('compare')'
You can find this in the file
Magento_Catalog::product/list/addto/compare.phtml
More information
If you are new to this its a lot of information to take in. I suggest you look at the following info page :