If it was in M1, we have to create a layout handle named `<category_id>` under local.xml and add blocks or customize as accordingly. But now in magento 2 neither here is local.xml nor a layout handle. We need to have a different xml file for each layout handle we used to have in M1.

For eg. for a homepage layout handle in Magento 1.x `<cms_index_index/>` = we have to create a xml file `cms_index_index.xml` in Magento 2

Now let’s get to the creating different template file for different categories in Magento 2. Obviously the identifier should be category id. We can achieve that by creating a new xml file named `catalog_category_view_id_{{id}}.xml` under our theme > Magento_Catalog > layout.

For eg. for a category id. 23, the xml file we need to create is `catalog_category_view_id_23.xml`  and change the list.phtml file under this.

 

 

Suman K.C

eCommerce Developer, writes about stuff related to eCommerce development. Currently based in Kathmandu, loves reading about startups & new technology, introvert nature, fond of traveling & playing futsal.

More Posts