Magento – How to get Search Result Count in head.phtml

catalogsearchsearch

I am trying to get total number of results count in head.phtml page.
I have used following code to get search term. But I am not sure how to get total number of results count here.

$term = Mage::helper('catalogsearch')->getQueryText();

Any help will be appreciated.
Thanks,

Best Answer

Please try bellow code

 if($listBlock = $this->getLayout()->getBlock('search_result_list')) {
    $productCollection = $listBlock->getLoadedProductCollection();
    echo $productCollection->getSize();
 }
Related Topic