/** * 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(); }
protected function _toHtml() { $html = parent::_toHtml(); if (!$this->getResultCount()) { $html = Mage::helper('adjnav')->wrapProducts($html); } return $html; }
/** * If layouts in other themes add this block too, we clear template * for not output search results twice. */ public function _toHtml() { self::$_outputs++; if (self::$_outputs > 1) { $this->setTemplate(null); } return parent::_toHtml(); }
/** * Set search available list orders * * @return Mage_CatalogSearch_Block_Result */ public function setListOrders() { parent::setListOrders(); if (!$this->_helper()->checkVersion('1.4.0.0') && $this->getListBlock() && $this->getListBlock()->getSortBy() == 'relevance') { $this->getListBlock()->setDefaultDirection('asc'); } return $this; }
/** * If layouts in other themes add this block too, we clear template * for not output search results twice */ public function _toHtml() { $uid = Mage::helper('mstcore/debug')->start(); self::$_outputs++; if (self::$_outputs > 1) { $this->setTemplate(null); } Mage::helper('mstcore/debug')->end($uid); return parent::_toHtml(); }
/** * Prepare layout * * @return Mage_CatalogSearch_Block_Result */ protected function _prepareLayout() { // add Home breadcrumb $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbs) { $title = $this->__("Search results for: '%s'", $this->helper('catalogsearch')->getQueryText()); $breadcrumbs->addCrumb('home', array('label' => $this->__('Home'), 'title' => $this->__('Go to Home Page'), 'link' => Mage::getBaseUrl()))->addCrumb('search', array('label' => $title, 'title' => $title)); } // modify page title $title = $this->__("Search results for: '%s'", $this->helper('catalogsearch')->getEscapedQueryText()); $this->getLayout()->getBlock('head')->setTitle($title); return parent::_prepareLayout(); }
/** * Retrieve search result count * * @return string */ public function getResultCount() { if (!Mage::helper('searchanise/ApiSe')->checkSearchaniseResult(true)) { return parent::getResultCount(); } $collection = $this->_getProductCollection(); if (!method_exists($collection, 'checkSearchaniseResult') || !$collection->checkSearchaniseResult()) { return parent::getResultCount(); } if (!$this->getData('result_count')) { $size = $collection->getSearchaniseRequest()->getTotalProduct(); $this->_getQuery()->setNumResults($size); $this->setResultCount($size); } return $this->getData('result_count'); }
/** * Retrieve Search result list HTML output, wrapped with <div> * * @return string */ public function getProductListHtml() { $html = parent::getProductListHtml(); $html = Mage::helper('adjnav')->wrapProducts($html); return $html; }
/** * Retrieve Search result list HTML output, wrapped with <div> * * @return string */ public function getProductListHtml() { $html = parent::getProductListHtml(); $html = Mage::helper('multiselectnavigation')->wrapProducts($html); return $html; }
protected function _prepareLayout() { parent::_prepareLayout(); $this->setTemplate('clerk/search.phtml'); }