Friday 26 June 2015

How to get top search terms in magento - Magento.

To get Top Search Terms on your Magento Store Programmatically.Use the Following Condition.

<?php 
$topsearchterms = Mage::getModel('catalogsearch/query')->getCollection()
->setPopularQueryFilter()
->setPageSize($limit); // if you want only Top 5 Search Terms just replace $limit in the above line with that number like in this case 5.
?>

<?php foreach($topsearchterms as $topsearchterm) { ?>

<?php $topsearchterm->getName(); // if you want only the search terms name use this code. ?>
<a href="<?php echo Mage::getBaseUrl().'catalogsearch/result/?q='.$topsearchterm->getName(); ?>"><?php echo $topsearchterm->getName(); ?></a><?php //if you want this top quries as the clickable use this code. ?>
<?php } ?>

No comments:

Post a Comment