2

How to set the list grid to be the default preview when product/products are displayed using the search bar?

4
  • Are you saying that you want a different default mode (grid/list) on search result pages than in the catalog pages?
    – zigojacko
    Jul 16, 2015 at 11:47
  • yes for example, when a customer is browsing through my shop and he observes products to see the products as grid, but when a customer is searching for a product/products i want the product to appear as list.
    – vasilisdmr
    Jul 16, 2015 at 11:50
  • Answered - hope it helps.
    – zigojacko
    Jul 16, 2015 at 12:25
  • Could you please give me an extension for magento 2.1.9 for this title?
    – MGPM
    Apr 26, 2018 at 9:11

2 Answers 2

1
<catalog_category_layered>
 <reference name="product_list_toolbar">
  <action method="setData">
   <key>_current_grid_mode</key>
   <value>grid</value>
  </action>
 </reference>
</catalog_category_layered>
3
1

1. Making catalogsearch use it's own template

Duplicate list.phtml like for example, listsearch.phtml.

Then you can either completely remove the list mode section if you don't want customers to be able to switch between modes or modify it to set the default...

Within listsearch.phtml, at the top of the page (just above <div class="category-products">), specify the default mode with:-

$this->getChild('toolbar')->setCurrentMode('grid');

Then make the catalog search use this new template file:-

<block type="catalogsearch/result" name="search.result" template="catalogsearch/result.phtml">
    <block type="catalog/product_list" name="search_result_list" template="catalog/product/listsearch.phtml">
        <!-- etc etc -->
    </block>
</block>

2. Declaring the default mode via XML

In your local.xml, specify the config values for the product_list_toolbar like:-

<catalogsearch_result_index translate="label">
    <reference name="product_list_toolbar">
        <action method="setData">
            <key>_current_grid_mode</key>
            <value>grid</value>
        </action>
    </reference>
</catalogsearch_result_index>

Either of these methods should work depending on the extend of how much you wish to customise the product listings in the catalog search results differently from the main catalog.

Your Answer

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

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