Magento : set list sort order for categories and search

Big online shops have a lot of users, and as such they can afford to try features that most novice users won't even understand : that is the case for the sort order for lists, that in Magento displays name, price and relevance. It is very nice to have that feature but in my customer's case the default list was ordered by "best choice", which doesn't mean a lot to users. Of course, the magento configuration allows to set the list default order, but that only works for categories, not for search. And that is a big problem because search results should be ordered by relevance : that is the principle of the search.

I decided to work on search and installed the better store search plugin, which after a few hours of hard work on my magento install gave me full satisfaction. But to my surprise, it is not the plugin itself which gave me hard work, but magento 's undocumented feature of list sorting. Here is what I did to get my search results ordered by relevance descending always 


  • Magento configuration : I display onlists
  • view/lists.phtml  . removed the toolbar display
  • extension  : wrote my own Mage_Catalog_Product_List extension that overrides the session / default valur for the sort order :
     class Webmsterbulletin_Catalog_Block_Product_List   extends Mage_Catalog_Block_Product_List 
    function  _getProductCollection() {
         if (strstr($_SERVER["REQUEST_URI"], "catalogsearch")) 
         {$orderField="relevance";$orderOrder="desc";} else {$orderField="name";$orderOrder="asc";}
         Mage::log($_SERVER["REQUEST_URI"] . $orderField,null,'layout.log');
           return  parent::_getProductCollection()
           ->setOrder($orderField, $orderOrder);
           //->addAttributeToSort('relevance', 'desc');
           // return  parent::_getProductCollection()->setOrder('name', 'ASC');

    What's happening here ? as you can see I rely (very bad practise) on the good old php_self  variable to detect if we are in the processs of returning search results. If so, then we set the order to relevance desc, otherwise we go name ascending, you could go price ascending too if you wanted !!

  • Oh, last but not least, the config.xml  that overrides  Mage_Catalog_Product_List :
    <?xml version="1.0"?>  

We’re developing EYELASH 3

following success of our eyeleash flash gallery (version 1), jquery gallery (version 2), we are now actively developing the third release of EYELAHS, a php jquery drag and drop image gallery with templating features. Good for webmasters, good for developers, here is a set of features it is going to provide

  • for webmasters
    • front end with gallery, slider
    • admin back end with categories, sub categories (albums / sub albums)
    • resizing, watermarking
    • SEO friendly
  • for developers: 
    • based on famous CodeIgniter PHP framework
    • extensible
    • jquery showcase !
    • lightweight and server friendly
    • available as wordpress plugin

Please comment this article if you want to be on the release mailing list

Ionize cms & Fuel Cms

This is not just another content management system. Built on top of the popular Code Igniter PHP framework, Ionize Cms integrates a lot of very itneresting native features that make it a good candidate for challenging monsters like worpdress, typo3.

Native features of Ionize CMs include multilinguism, tree based page management, media library, custom fields, article and blog, nad most importantly it comes with a good looking backend that can easily be extended to develop custom modules.

Another interesting dvelopment tootl is Fuelm CMs, which is distributed the basic CMS features such as tree based page management, or blog, but alos with extensive documentation on how to develop new modules :  basic scaffolding is done in 5 minutes, including table managment with relation ships : all simple tasks are explained in the simple module tutorial, which starts from the sql database creation script and renders a very useful adminstration panel.