Getting Popular Searches In Magento

I want to display the top 10 searches on my Magento store. Magento already stores searches made on the store under Admin > Catalog > Search Terms, so it’s just a matter of getting it into my view. Does anyone know which helper or function I can access to get this list?

2 thoughts on “Getting Popular Searches In Magento”

  1. You have a setPopularQueryFilter method in the class Mage_CatalogSearch_Model_Mysql4_Query_Collection, after that you only have to set a limit I guess 🙂

    Without trying, it should be something like that :

    $searchCollectino=Mage::getModel('catalogsearch/query')->getCollection()
         ->setPopularQueryFilter()
         ->setPageSize($limit);
    

  2. If anyone needs the Magento 2 solution:

    inject the class MagentoSearchModelQuery in your constructor and then retrieve the collection like so:
    $collection = $this->query->getSuggestCollection()

    This will return a collection of most popular search terms sorted by the popularity.

Leave a Reply

Your email address will not be published. Required fields are marked *