public function getSearchUrl($obj) { if (!Mage::helper('magenotification')->checkLicenseKey('Seoplus')) { return parent::getSearchUrl($obj); } $url = Mage::getModel('core/url'); if ($this->getHelper()->getConfig('enable')) { $rewrite = Mage::getModel('core/url_rewrite')->loadByIdPath("seoplus/{$obj->getQueryId()}"); if ((!$this->getHelper()->getConfig('cache') || !$rewrite->getId()) && $obj->getQueryId()) { try { $model = Mage::getModel('catalogsearch/query')->load($obj->getQueryId())->setId($obj->getQueryId())->save(); $rewrite->loadByIdPath("seoplus/{$model->getId()}"); } catch (Exception $e) { $url->setQueryParam('q', $obj->getName()); return $url->getUrl('catalogsearch/result'); } } if ($rewrite->getTargetPath() != $this->getHelper()->prepareTargetPath($obj->getName())) { try { $rewrite->setTargetPath($this->getHelper()->prepareTargetPath($obj->getName()))->save(); } catch (Exception $e) { $url->setQueryParam('q', $obj->getName()); return $url->getUrl('catalogsearch/result'); } } return $url->getUrl(null, array('_direct' => $rewrite->getRequestPath())); } $url->setQueryParam('q', $obj->getName()); return $url->getUrl('catalogsearch/result'); }
public function testGetSearchUrl() { $query = uniqid(); $obj = new Varien_Object(array('name' => $query)); $this->assertStringEndsWith("/catalogsearch/result/?q={$query}", $this->_block->getSearchUrl($obj)); }