0

I want to override the product div in list.phtml for both search view and category view i have replaced list.phtml by this way

catalog_category_view.xml

<?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="category.products.list">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">vendor_Module::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

But it only override "product-item-info" div in list.phtml in category view when access product through search the "product-item-info" div in list.phtml is not replaced.How can i override the list.phtml in custom module for search also.

1 Answer 1

0

The core layout is there: vendor/magento/module-catalog-search/view/frontend/layout/catalogsearch_result_index.xml

Make changes in your custom catalogsearch_result_index.xml:

<?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="search_result_list">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">vendor_Module::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>
2
  • thanks it worked! Commented May 31, 2021 at 9:14
  • @Magento2-learner Great to hear! :)
    – dudzio
    Commented May 31, 2021 at 9:18

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.