Mage_CatalogSearch_Model_Query Class Reference

Inheritance diagram for Mage_CatalogSearch_Model_Query:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 getResultCollection ()
 getSuggestCollection ()
 loadByQuery ($text)
 setStoreId ($storeId)
 getStoreId ()
 prepare ()
 getMinQueryLenght ()
 getMaxQueryLenght ()
 getMaxQueryWords ()

Public Attributes

const CACHE_TAG = 'SEARCH_QUERY'
const XML_PATH_MIN_QUERY_LENGTH = 'catalog/search/min_query_length'
const XML_PATH_MAX_QUERY_LENGTH = 'catalog/search/max_query_length'
const XML_PATH_MAX_QUERY_WORDS = 'catalog/search/max_query_words'

Protected Member Functions

 _construct ()


Detailed Description

Catalog search query model

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Query.php.


Member Function Documentation

_construct (  )  [protected]

Init resource model

Reimplemented from Varien_Object.

Definition at line 43 of file Query.php.

00044     {
00045         $this->_init('catalogsearch/query');
00046     }

getMaxQueryLenght (  ) 

Retrieve maximum query length

Returns:
int

Definition at line 160 of file Query.php.

00161     {
00162         return Mage::getStoreConfig(self::XML_PATH_MAX_QUERY_LENGTH, $this->getStoreId());
00163     }

getMaxQueryWords (  ) 

Retrieve maximum query words for like search

Returns:
int

Definition at line 170 of file Query.php.

00171     {
00172         return Mage::getStoreConfig(self::XML_PATH_MAX_QUERY_WORDS, $this->getStoreId());
00173     }

getMinQueryLenght (  ) 

Retrieve minimum query length

Returns:
int

Definition at line 150 of file Query.php.

00151     {
00152         return Mage::getStoreConfig(self::XML_PATH_MIN_QUERY_LENGTH, $this->getStoreId());
00153     }

getResultCollection (  ) 

Retrieve collection of search results

Returns:
Mage_Eav_Model_Entity_Collection_Abstract

Definition at line 53 of file Query.php.

00054     {
00055         $collection = $this->getData('result_collection');
00056         if (is_null($collection)) {
00057             $collection = Mage::getResourceModel('catalogsearch/search_collection');
00058 
00059             $text = $this->getSynonimFor();
00060             if (!$text) {
00061                 $text = $this->getQueryText();
00062             }
00063 
00064             $collection->addSearchFilter($text)
00065                 ->addStoreFilter()
00066                 ->addMinimalPrice()
00067                 ->addTaxPercents();
00068             $this->setData('result_collection', $collection);
00069         }
00070         return $collection;
00071     }

getStoreId (  ) 

Retrieve store Id

Returns:
int

Definition at line 120 of file Query.php.

00121     {
00122         if (!$storeId = $this->getData('store_id')) {
00123             $storeId = Mage::app()->getStore()->getId();
00124         }
00125         return $storeId;
00126     }

getSuggestCollection (  ) 

Retrieve collection of suggest queries

Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 78 of file Query.php.

00079     {
00080         $collection = $this->getData('suggest_collection');
00081         if (is_null($collection)) {
00082             $collection = Mage::getResourceModel('catalogsearch/query_collection')
00083                 ->setStoreId($this->getStoreId())
00084                 ->setQueryFilter($this->getQueryText());
00085             $this->setData('suggest_collection', $collection);
00086         }
00087         return $collection;
00088     }

loadByQuery ( text  ) 

Load Query object by query string

Parameters:
string $text
Returns:
Mage_CatalogSearch_Model_Query

Definition at line 96 of file Query.php.

00097     {
00098         $this->_getResource()->loadByQuery($this, $text);
00099         $this->_afterLoad();
00100         $this->setOrigData();
00101         return $this;
00102     }

prepare (  ) 

Prepare save query for result

Returns:
Mage_CatalogSearch_Model_Query

Definition at line 133 of file Query.php.

00134     {
00135         if (!$this->getId()) {
00136             $this->setIsActive(0);
00137             $this->setIsProcessed(0);
00138             $this->save();
00139             $this->setIsActive(1);
00140         }
00141 
00142         return $this;
00143     }

setStoreId ( storeId  ) 

Set Store Id

Parameters:
int $storeId
Returns:
Mage_CatalogSearch_Model_Query

Definition at line 110 of file Query.php.

00111     {
00112         $this->setData('store_id', $storeId);
00113     }


Member Data Documentation

const CACHE_TAG = 'SEARCH_QUERY'

Definition at line 34 of file Query.php.

const XML_PATH_MAX_QUERY_LENGTH = 'catalog/search/max_query_length'

Definition at line 36 of file Query.php.

const XML_PATH_MAX_QUERY_WORDS = 'catalog/search/max_query_words'

Definition at line 37 of file Query.php.

const XML_PATH_MIN_QUERY_LENGTH = 'catalog/search/min_query_length'

Definition at line 35 of file Query.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