Mage_CatalogSearch_Block_Term Class Reference

Inheritance diagram for Mage_CatalogSearch_Block_Term:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getTerms ()
 getSearchUrl ($obj)
 getMaxPopularity ()
 getMinPopularity ()

Protected Member Functions

 _loadTerms ()

Protected Attributes

 $_terms
 $_minPopularity
 $_maxPopularity


Detailed Description

Definition at line 27 of file Term.php.


Constructor & Destructor Documentation

__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     }


Member Function Documentation

_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 (  ) 

Definition at line 87 of file Term.php.

00088     {
00089         return $this->_maxPopularity;
00090     }

getMinPopularity (  ) 

Definition at line 92 of file Term.php.

00093     {
00094         return $this->_minPopularity;
00095     }

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     }


Member Data Documentation

$_maxPopularity [protected]

Definition at line 31 of file Term.php.

$_minPopularity [protected]

Definition at line 30 of file Term.php.

$_terms [protected]

Definition at line 29 of file Term.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:49 2009 for Magento by  doxygen 1.5.8