简体   繁体   中英

Not Getting Popular Searches In Magento Using Code

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 ??

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');
}
`$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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM