4

How to solve the template error in system.log which says:

Invalid template file: 'product/list/toolbar.phtml' in module: 'Vendor_Module' block's name: 'product_list_toolbar' [] []

I have overridden the catalog search module.

In view/frontend/templates: I have oly result.phtml

view/frontend/layout: catalogsearch_result_index

<?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>

etc/frontend/routes

<?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>

etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="2.2.0">
    <sequence>
        <module name="Magento_Catalog"/>
        <module name="Magento_CatalogSearch"/>
        <module name="Magento_Swatches"/>
        <module name="Magento_ConfigurableProduct"/>
        <module name="Magento_Eav"/>
        <module name="Magento_Customer"/>
        <module name="Magento_Store"/>
        <module name="Magento_Backend"/>
        <module name="Magento_MediaStorage"/>
        <module name="Magento_Config"/>
        <module name="Magento_LayeredNavigation"/>
        <module name="Magento_Theme"/>
    </sequence>
</module>
</config>

How to override the toolbar.phtml What should be my layout file contents??

I heard we have to place our custom template in app/design/frontend/myvendor/mytheme..?

I mean why do we have to keep our templates in theme folder? is that necessary? If so how ?

1
  • If i include, product/list/toolbar.phtml file in my template folder, my "catalogsearch/result/?q=keyword" url navigates to catalog's toolbar page !
    – Sushivam
    Commented Jul 15, 2016 at 12:28

1 Answer 1

2

Try this way :

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product_list_toolbar">
          <action method="setTemplate">
            <argument name="template" xsi:type="string">Vendor_Module::product/list/toolbar.phtml</argument>
          </action>
        </referenceBlock>
    </body>
</page>

I was just add page tag and body tag in your catalogsearch_result_index.xml file.

9
  • have tried tat buddy..no use :(
    – Sushivam
    Commented Jul 15, 2016 at 13:05
  • your code is working fine in mine after update catalogsearch_result_index.xml file. Commented Jul 15, 2016 at 13:28
  • are u getting proper Catalogsearch and catalog pages rendered properly? like i have mentioned in this link magento.stackexchange.com/questions/125727/…
    – Sushivam
    Commented Jul 15, 2016 at 13:30
  • Could you please share your code, i want to see the file structure?
    – Sushivam
    Commented Jul 15, 2016 at 13:35
  • Not doing any changes in toolbar.phtml, just override it in my custom extension. and it works fine. Commented Jul 15, 2016 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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