I want to set custom template file for different categories.
How to set custom phtml file for different categories using XML file?
Any help would be appreciated.
For that, you need to create xml file under Your_Theme/Magento_Catalog/layout
and create file catalog_category_view_id_{{id}}.xml
.
For ex : For creating different view for category with id 10 then, create catalog_category_view_id_10.xml
. In that, you can call template file.
catalog_category_view_id_10.xml :
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/custom.phtml"/>
</referenceContainer>
Hope, it will helpful for you.