How to write the equivalent layout xml file in magento 2

<layout version="0.1.0">
  <merchandisingpage_index_index translate="label">
    <reference name="head">
      <action method="setTitle">

 <reference name="root">
  <action method="setTemplate">

<reference name="left">
  <block type="merchandisingpage/filter" name="custom_filter" before="-"/>

<reference name="content">
  <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

   <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="tagalys_toolbar/toolbar.phtml">

    <block type="page/html_pager" name="product_list_toolbar_pager"/>

    <action method="setToolbarBlockName">



As Magento 2 has quite a lot of differences with Magento 1, providing an equivalence of a layout XML file will not necessarily reproduce the same behavior as the equivalent file in Magento 1.

However, I'm assuming here that you've taken that into consideration and that you are willing to spend some time debugging and investigating time in the module you're trying to convert to Magento 2.

Thus, the equivalence of this file would be a file called merchandising_index_index.xml under app/code/Vendor/Module/view/frontend/layout with the following content:

<?xml version="1.0"?>
<page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

    <referenceContainer name="left">
        <block class="Vendor\Module\Block\Merchandising\Filter" name="custom_filter" />

    <referenceContainer name="content">
        <block class="Magento\Catalog\Block\Product\ListProduct" name="product_list" template="Magento_Catalog::product/list.phtml">
            <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
                <block class="Magento\Framework\View\Element\Template" as="default"/>
            <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml">
                <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
             <action method="setToolbarBlockName">
                 <argument name="name" xsi:type="string">product_list_toolbar</argument>

Please note that you will have to make sure that the block that corresponds to merchandising/filter in your original layout file is located under Vendor/Module/Block/Merchandising/Filter

  • Hi Raphael, in magento 1.8 Filter.php is in Vendor/Module/Block/Filter.php and in my magento2 layout file i have used <referenceContainer name="left"> <block class="Vendor\Module\Block\Filter" name="custom_filter" before="-"/> </referenceContainer> is tat correct? – Sushivam Jun 20 '16 at 7:10
  • @SachinS yes it sounds correct – Raphael at Digital Pianism Jun 20 '16 at 7:11
  • ok, i have a doubt in the content tag as to why blocktype 'catalog/product_list_toolbar' and 'page/html_page' is split into blockClass. Could you pls explain – Sushivam Jun 20 '16 at 7:16
  • @SachinS toolbar and pager are split in Magento 2 that's why ;) – Raphael at Digital Pianism Jun 20 '16 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.