(ALL OF THE INSTRUCTIONS ON THIS WEBSITE WERE TESTED ON VERSION 1.3.2.4)
This was a fun one to figure out.
The Background: We have a Magento installation which requires two different default product list views; one for featured vendors and the other for the actual products. The way we set it up was by creating a new store view for one of the product lists (“Featured Vendors” which must always remain in list view) and another store view for the other product list (“Products” which must always remain in grid view). We then simply changed the links to each list by adding &mode=list or &mode=grid to the end of the URLs. A simple change and it worked like a charm. (Some may ask…well why don’t you just change the allowed views within the configuration area for each store view. We tried that, and it failed to work. The way we created the store was sort of ghettofied by just copying and pasting the app and skin directory of the original into a new folder since creating a store within the Admin caused all sorts of design issues which would need to be changed again. *sigh*)
The Problem: While the customer is visiting the “Featured Vendors” list, they feel like performing a search for a product. They type their query in and then hit “go!”. Unfortunately the product list would then continue with the last view mode so the results page now shows list mode instead of the required grid mode. We tried to amend the URL of the search results page by adding &mode=grid, and it worked by manually typing it in but whenever we tried to do it within the code it failed miserably. Thus, the fix…
————————————-
The Fix: Simply duplicate the list.phtml file and rename the new one as list2.phtml and change the catalogsearch.xml to reflect it.
—————————————-
1) Open app/design/frontend/[theme folders...]/template/catalog/product/list.phtml
—————————————-
2) This step removes the list mode from the soon to be new list2.phtml in order for the search results page to always be in one predetermined mode instead of using the last known mode.
If you want to remove list mode:
- Comment out or remove from: <?php // List mode ?> to the line: <?php else: ?>
- Comment out or remove the second to last: <?php endif; ?>
If you want to remove grid mode:
- Comment out or remove: <?php if($this->getMode()!=’grid’): ?>
- Comment out or remove from: <?php endforeach; ?> to the line: </script>
—————————————-
3) Rename the changed file to list2.phtml and save in the same folder as the original
—————————————-
4) This step changes the catalog search layout file to reflect the new list2.phtml. I’ve included the lines for simple search and advanced search results:
Open app/design/frontend/[theme folders...]/layout/catalogsearch.xml
- SIMPLE: Change the following line (somewhere around line 53):
From: <block type=”catalog/product_list” name=”search_result_list” template=”catalog/product/list.phtml”></block>
To: <block type=”catalog/product_list” name=”search_result_list” template=”catalog/product/list2.phtml”></block>
- ADVANCED: Find the following line (somewhere around line 92)
From: <block type=”catalog/product_list” name=”search_result_list” template=”catalog/product/list.phtml”></block>
To: <block type=”catalog/product_list” name=”search_result_list” template=”catalog/product/list2.phtml”></block>
—————————————-
5) Save the changed catalogsearch.xml file…
—————————————-
Perform a search and the search results page should always display the required view mode (grid or list).
(I’m sure there is an easier way of doing this, please share if you know of it)
—————————————-
*Make sure you study prior to making changes to your Magento files section. These settings have great ramifications as to the operations of your website.

