Public Member Functions | |
__construct () | |
getTerms () | |
getSearchUrl ($obj) | |
getMaxPopularity () | |
getMinPopularity () | |
Protected Member Functions | |
_loadTerms () | |
Protected Attributes | |
$_terms | |
$_minPopularity | |
$_maxPopularity |
Definition at line 27 of file Term.php.
__construct | ( | ) |
Constructor
By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes
Reimplemented from Varien_Object.
Definition at line 33 of file Term.php.
00034 { 00035 parent::__construct(); 00036 }
_loadTerms | ( | ) | [protected] |
Definition at line 38 of file Term.php.
00039 { 00040 if (empty($this->_terms)) { 00041 $this->_terms = array(); 00042 $terms = Mage::getResourceModel('catalogsearch/query_collection') 00043 ->setPopularQueryFilter(Mage::app()->getStore()->getId()) 00044 ->setOrder('popularity', 'DESC') 00045 ->setPageSize(100) 00046 ->load() 00047 ->getItems(); 00048 00049 if( count($terms) == 0 ) { 00050 return $this; 00051 } 00052 00053 00054 $this->_maxPopularity = reset($terms)->getPopularity(); 00055 $this->_minPopularity = end($terms)->getPopularity(); 00056 $range = $this->_maxPopularity - $this->_minPopularity; 00057 $range = ( $range == 0 ) ? 1 : $range; 00058 foreach ($terms as $term) { 00059 if( !$term->getPopularity() ) { 00060 continue; 00061 } 00062 $term->setRatio(($term->getPopularity()-$this->_minPopularity)/$range); 00063 $this->_terms[$term->getName()] = $term; 00064 } 00065 ksort($this->_terms); 00066 } 00067 return $this; 00068 }
getMaxPopularity | ( | ) |
getMinPopularity | ( | ) |
getSearchUrl | ( | $ | obj | ) |
Definition at line 76 of file Term.php.
00077 { 00078 $url = Mage::getModel('core/url'); 00079 /* 00080 * url encoding will be done in Url.php http_build_query 00081 * so no need to explicitly called urlencode for the text 00082 */ 00083 $url->setQueryParam('q', $obj->getName()); 00084 return $url->getUrl('catalogsearch/result'); 00085 }
getTerms | ( | ) |
Definition at line 70 of file Term.php.
00071 { 00072 $this->_loadTerms(); 00073 return $this->_terms; 00074 }