How to give 2 different layout xmls within a single module.
My module has one routes.xml
with route_id='catalogsearch'
My folder structure:
Vendor\Module\Controller\Result\Index.php //For CatalogSearch
Vendor\Module\Controller\Category\View.php //For Catalog
So one of my overridden catalogsearch layout file is:
catalogsearch_result_index.xml
Now I want to override magento catalog module xml. Magento maintains the route name for catalog as 'catalog' itself.
Now how should I create a separate layout file for my custom module.
Should it be: catalogsearch_category_view.xml
?
If I had done like above, even if I search for keyword, in frontpage, I guess toolbar.phtml
is calling, instead of catalog search.
My catalogsearch_result_index.xml (which seems to be fine):
<?xml version="1.0"?>
<referenceBlock name="catalogsearch.leftnav">
<action method="setTemplate">
<argument name="template" xsi:type="string">Vendor_Module::layer/view.phtml</argument>
</action>
</referenceBlock>
UPDATED: My catalog_category_view.xml:
<?xml version="1.0"?>
<referenceBlock name="product_list_toolbar">
<action method="setTemplate">
<argument name="template" xsi:type="string">Vendor_Module::product/list/toolbar.phtml</argument>
</action>
</referenceBlock>
routes.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="catalogsearch" frontName="catalogsearch">
<module name="Vendor_Module"/>
</route>
</router>
</config>
UPDATED: