Magento – magento2 -custom layout file not loading

blockserrorlayoutmagento2

i have followed the below link in order to get check if our custom layout xml file is loaded or not using the event: layout_generate_blocks_after

In the log file i just get:

2016-06-29T11:07:40+00:00 INFO (6):

 <layout/>

which should actually load my custom layout file :
catalogsearch_catalogsearch_resultcontroller.xml

Could any1 please help why my layout file is not loading.

UPDATED: LAYOUT file catalogsearch_catalogsearch_resultcontroller.xml

controller path:

  • Vendor\Module\Controller\Catalog

  • Vendor\Module\Controller\CatalogSearch

  • Vendor\Module\Controller\CatalogSearch\Result.php

  • Vendor\Module\Controller\CatalogSearch\ResultController.php

\Vendor\Module\view\frontend\layout\catalogsearch_catalogsearch_resultcontroller.xml

<?xml version="1.0"?>
   <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
     <referenceBlock name="catalogsearch.leftnav"><arguments>
        <argument name="setTemplate" xsi:type="string">Vendor\Module::search/filter.phtml</argument>
        </arguments>
    </referenceBlock>

    <referenceBlock name="product_searchlist_toolbar">
        <arguments>
            <argument name="template" xsi:type="string">Vendor\Module::toolbar/toolbar.phtml</argument>
        </arguments>
     </referenceBlock>  

</body>

Above xml was replicated from 1x code which was as :

<?xml version="1.0"?>
<layout version="0.1.0">
 <catalogsearch_result_index>        
    <reference name="catalogsearch.leftnav">
        <action method="setTemplate">
            <setTemplate>/filter.phtml</setTemplate>
        </action>
    </reference>
      <reference name="content">
        <reference type="catalogsearch/result" name="search.result">
            <reference name="search_result_list">
                <reference name="product_list_toolbar">
                    <action method="setTemplate">
                        <template>toolbar.phtml</template>
                    </action>
                 </reference>
            </reference>
        </reference>
    </reference>
</catalogsearch_result_index>
 </layout>

system.log :

Cache file with merged layout: LAYOUT_frontend_STORE1_3d41d8cd98f00b204e9800998ecf8427e and handles : Please correct the XML data and try again.  [] []

Best Answer

It is because your file is not properly named.

It should be catalogsearch_result_index.xml instead of catalogsearch_catalogsearch_resultcontroller.xml

Related Topic