Reputation: 9297
How to Get Popular Search Terms on Homepage ??
I have Referenced Following Question : Getting Popular Searches In Magento
So, I have used same code as given as below :
$searchCollectino=Mage::getModel('catalogsearch/query')->getCollection()
->setPopularQueryFilter()
->setPageSize($limit);
They told that using ->getItems() we can get search terms.
But I am not getting what exactly the code can be..??
How to use this code ??
Upvotes: 1
Views: 877
Reputation: 9297
I Got Top 5 Popular Search Terms By Following Code :
$searchCollection = Mage::getModel('catalogsearch/query')->getCollection()
->setOrder('popularity', 'DESC');
$searchCollection->getSelect()->limit(8);
foreach ($searchCollection as $item)
{
echo $item->getData('redirect');
echo $item->getData('query_text');
}
Upvotes: 3
Reputation: 943
`$searchCollection = Mage::getModel('catalogsearch/query')->getCollection()
->setOrder('popularity', 'DESC');
$searchCollection->getSelect()->limit(5);
$searchCollection->getItems();`
This would fetch the popular searches with limit
Hope you enjoy it :)
Upvotes: 1