Magento – How to get most popular search terms for each storeid

catalogsearchsearch-termsstores

I want to read to top 10 search terms from magento.
This works:

$items = Mage::getModel( 'catalogsearch/query' )
    ->getCollection()
    ->setOrder("popularity")
    ->setPageSize( 10 )
    ->getItems();

foreach ( $items as $item )
{
    echo sprintf("%s\n", $item->getQueryText());
}

But how can I get the results for each store-id?

Best Answer

Just Add setStoreId in your code.

i.e,

$items = Mage::getModel( 'catalogsearch/query' )
    ->getCollection()
    ->setOrder("popularity")
    ->setPageSize(10)
    ->setStoreId(1) //your store id
    ->getItems();

Refer this file

Related Topic