/** * Return product url of first item * * @param Mage_CatalogSearch_Block_Result $oBlock * @throws Mage_Exception if the fetched item of the collection of not of type Mage_Catalog_Model_Product * @return String */ private function getProductUrl(Mage_CatalogSearch_Block_Result $oBlock) { /* @var Mage_Catalog_Block_Product_List $oListBlock */ $oListBlock = $oBlock->getListBlock(); // we have to execute toHtml so all events get fired which filter the product collection $oListBlock->toHtml(); /* @var Mage_Catalog_Model_Resource_Product_Collection $oProductCollection */ $oProductCollection = $oListBlock->getLoadedProductCollection(); /* @var Mage_Catalog_Model_Product $oProduct */ $oProduct = $oProductCollection->fetchItem(); if (!$oProduct instanceof Mage_Catalog_Model_Product) { throw new Mage_Exception('fetched item is not a product'); } return $oProduct->getProductUrl() . $oProduct->getUrlPath(); }