Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_CatalogSearch_AdvancedController
  • Mage_CatalogSearch_AjaxController
  • Mage_CatalogSearch_Block_Advanced_Form
  • Mage_CatalogSearch_Block_Advanced_Result
  • Mage_CatalogSearch_Block_Autocomplete
  • Mage_CatalogSearch_Block_Layer
  • Mage_CatalogSearch_Block_Layer_Filter_Attribute
  • Mage_CatalogSearch_Block_Result
  • Mage_CatalogSearch_Block_Term
  • Mage_CatalogSearch_Helper_Data
  • Mage_CatalogSearch_Model_Advanced
  • Mage_CatalogSearch_Model_Fulltext
  • Mage_CatalogSearch_Model_Fulltext_Observer
  • Mage_CatalogSearch_Model_Indexer_Fulltext
  • Mage_CatalogSearch_Model_Layer
  • Mage_CatalogSearch_Model_Layer_Filter_Attribute
  • Mage_CatalogSearch_Model_Mysql4_Advanced
  • Mage_CatalogSearch_Model_Mysql4_Advanced_Collection
  • Mage_CatalogSearch_Model_Mysql4_Fulltext
  • Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
  • Mage_CatalogSearch_Model_Mysql4_Fulltext_Engine
  • Mage_CatalogSearch_Model_Mysql4_Indexer_Fulltext
  • Mage_CatalogSearch_Model_Mysql4_Query
  • Mage_CatalogSearch_Model_Mysql4_Query_Collection
  • Mage_CatalogSearch_Model_Mysql4_Search_Collection
  • Mage_CatalogSearch_Model_Query
  • Mage_CatalogSearch_Model_Resource_Advanced
  • Mage_CatalogSearch_Model_Resource_Advanced_Collection
  • Mage_CatalogSearch_Model_Resource_Fulltext
  • Mage_CatalogSearch_Model_Resource_Fulltext_Collection
  • Mage_CatalogSearch_Model_Resource_Fulltext_Engine
  • Mage_CatalogSearch_Model_Resource_Indexer_Fulltext
  • Mage_CatalogSearch_Model_Resource_Query
  • Mage_CatalogSearch_Model_Resource_Query_Collection
  • Mage_CatalogSearch_Model_Resource_Search_Collection
  • Mage_CatalogSearch_Model_Session
  • Mage_Catalogsearch_Model_System_Config_Backend_Sitemap
  • Mage_CatalogSearch_ResultController
  • Mage_CatalogSearch_TermController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_CatalogSearch
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Catalog search query model
 29:  *
 30:  * @method Mage_CatalogSearch_Model_Resource_Query _getResource()
 31:  * @method Mage_CatalogSearch_Model_Resource_Query getResource()
 32:  * @method string getQueryText()
 33:  * @method Mage_CatalogSearch_Model_Query setQueryText(string $value)
 34:  * @method int getNumResults()
 35:  * @method Mage_CatalogSearch_Model_Query setNumResults(int $value)
 36:  * @method int getPopularity()
 37:  * @method Mage_CatalogSearch_Model_Query setPopularity(int $value)
 38:  * @method string getRedirect()
 39:  * @method Mage_CatalogSearch_Model_Query setRedirect(string $value)
 40:  * @method string getSynonymFor()
 41:  * @method Mage_CatalogSearch_Model_Query setSynonymFor(string $value)
 42:  * @method int getDisplayInTerms()
 43:  * @method Mage_CatalogSearch_Model_Query setDisplayInTerms(int $value)
 44:  * @method int getIsActive()
 45:  * @method Mage_CatalogSearch_Model_Query setIsActive(int $value)
 46:  * @method int getIsProcessed()
 47:  * @method Mage_CatalogSearch_Model_Query setIsProcessed(int $value)
 48:  * @method string getUpdatedAt()
 49:  * @method Mage_CatalogSearch_Model_Query setUpdatedAt(string $value)
 50:  *
 51:  * @category    Mage
 52:  * @package     Mage_CatalogSearch
 53:  * @author      Magento Core Team <core@magentocommerce.com>
 54:  */
 55: class Mage_CatalogSearch_Model_Query extends Mage_Core_Model_Abstract
 56: {
 57:     /**
 58:      * Event prefix
 59:      *
 60:      * @var string
 61:      */
 62:     protected $_eventPrefix = 'catalogsearch_query';
 63: 
 64:     /**
 65:      * Event object key name
 66:      *
 67:      * @var string
 68:      */
 69:     protected $_eventObject = 'catalogsearch_query';
 70: 
 71:     const CACHE_TAG                     = 'SEARCH_QUERY';
 72:     const XML_PATH_MIN_QUERY_LENGTH     = 'catalog/search/min_query_length';
 73:     const XML_PATH_MAX_QUERY_LENGTH     = 'catalog/search/max_query_length';
 74:     const XML_PATH_MAX_QUERY_WORDS      = 'catalog/search/max_query_words';
 75: 
 76:     /**
 77:      * Init resource model
 78:      *
 79:      */
 80:     protected function _construct()
 81:     {
 82:         $this->_init('catalogsearch/query');
 83:     }
 84: 
 85:     /**
 86:      * Retrieve search collection
 87:      *
 88:      * @return Mage_CatalogSearch_Model_Resource_Search_Collection
 89:      */
 90:     public function getSearchCollection()
 91:     {
 92:         return Mage::getResourceModel('catalogsearch/search_collection');
 93:     }
 94: 
 95:     /**
 96:      * Retrieve collection of search results
 97:      *
 98:      * @return Mage_Eav_Model_Entity_Collection_Abstract
 99:      */
100:     public function getResultCollection()
101:     {
102:         $collection = $this->getData('result_collection');
103:         if (is_null($collection)) {
104:             $collection = $this->getSearchCollection();
105: 
106:             $text = $this->getSynonymFor();
107:             if (!$text) {
108:                 $text = $this->getQueryText();
109:             }
110: 
111:             $collection->addSearchFilter($text)
112:                 ->addStoreFilter()
113:                 ->addMinimalPrice()
114:                 ->addTaxPercents();
115:             $this->setData('result_collection', $collection);
116:         }
117:         return $collection;
118:     }
119: 
120:     /**
121:      * Retrieve collection of suggest queries
122:      *
123:      * @return Mage_CatalogSearch_Model_Resource_Query_Collection
124:      */
125:     public function getSuggestCollection()
126:     {
127:         $collection = $this->getData('suggest_collection');
128:         if (is_null($collection)) {
129:             $collection = Mage::getResourceModel('catalogsearch/query_collection')
130:                 ->setStoreId($this->getStoreId())
131:                 ->setQueryFilter($this->getQueryText());
132:             $this->setData('suggest_collection', $collection);
133:         }
134:         return $collection;
135:     }
136: 
137:     /**
138:      * Load Query object by query string
139:      *
140:      * @param string $text
141:      * @return Mage_CatalogSearch_Model_Query
142:      */
143:     public function loadByQuery($text)
144:     {
145:         $this->_getResource()->loadByQuery($this, $text);
146:         $this->_afterLoad();
147:         $this->setOrigData();
148:         return $this;
149:     }
150: 
151:     /**
152:      * Load Query object only by query text (skip 'synonym For')
153:      *
154:      * @param string $text
155:      * @return Mage_CatalogSearch_Model_Query
156:      */
157:     public function loadByQueryText($text)
158:     {
159:         $this->_getResource()->loadByQueryText($this, $text);
160:         $this->_afterLoad();
161:         $this->setOrigData();
162:         return $this;
163:     }
164: 
165:     /**
166:      * Set Store Id
167:      *
168:      * @param int $storeId
169:      * @return Mage_CatalogSearch_Model_Query
170:      */
171:     public function setStoreId($storeId)
172:     {
173:         $this->setData('store_id', $storeId);
174:     }
175: 
176:     /**
177:      * Retrieve store Id
178:      *
179:      * @return int
180:      */
181:     public function getStoreId()
182:     {
183:         if (!$storeId = $this->getData('store_id')) {
184:             $storeId = Mage::app()->getStore()->getId();
185:         }
186:         return $storeId;
187:     }
188: 
189:     /**
190:      * Prepare save query for result
191:      *
192:      * @return Mage_CatalogSearch_Model_Query
193:      */
194:     public function prepare()
195:     {
196:         if (!$this->getId()) {
197:             $this->setIsActive(0);
198:             $this->setIsProcessed(0);
199:             $this->save();
200:             $this->setIsActive(1);
201:         }
202: 
203:         return $this;
204:     }
205: 
206:     /**
207:      * Retrieve minimum query length
208:      *
209:      * @deprecated after 1.3.2.3 use getMinQueryLength() instead
210:      * @return int
211:      */
212:     public function getMinQueryLenght()
213:     {
214:         return Mage::getStoreConfig(self::XML_PATH_MIN_QUERY_LENGTH, $this->getStoreId());
215:     }
216: 
217:     /**
218:      * Retrieve minimum query length
219:      *
220:      * @return int
221:      */
222:     public function getMinQueryLength(){
223:         return $this->getMinQueryLenght();
224:     }
225: 
226:     /**
227:      * Retrieve maximum query length
228:      *
229:      * @deprecated after 1.3.2.3 use getMaxQueryLength() instead
230:      * @return int
231:      */
232:     public function getMaxQueryLenght()
233:     {
234:         return 0;
235:     }
236: 
237:     /**
238:      * Retrieve maximum query length
239:      *
240:      * @return int
241:      */
242:     public function getMaxQueryLength()
243:     {
244:         return Mage::getStoreConfig(self::XML_PATH_MAX_QUERY_LENGTH, $this->getStoreId());
245:     }
246: 
247:     /**
248:      * Retrieve maximum query words for like search
249:      *
250:      * @return int
251:      */
252:     public function getMaxQueryWords()
253:     {
254:         return Mage::getStoreConfig(self::XML_PATH_MAX_QUERY_WORDS, $this->getStoreId());
255:     }
256: }
257: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0