Mage_CatalogSearch_Model_Mysql4_Query_Collection Class Reference

Inheritance diagram for Mage_CatalogSearch_Model_Mysql4_Query_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 setStoreId ($store)
 getStoreId ()
 setQueryFilter ($query)
 setPopularQueryFilter ($storeIds=null)
 setRecentQueryFilter ()
 addStoreFilter ($storeIds)

Protected Member Functions

 _construct ()

Protected Attributes

 $_storeId


Detailed Description

Catalog search query collection

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

Definition at line 32 of file Collection.php.


Member Function Documentation

_construct (  )  [protected]

Init model for collection

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 45 of file Collection.php.

00046     {
00047         $this->_init('catalogsearch/query');
00048     }

addStoreFilter ( storeIds  ) 

Filter collection by specified store ids

Parameters:
array|int $storeIds
Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 141 of file Collection.php.

00142     {
00143         if (!is_array($storeIds)) {
00144             $storeIds = array($storeIds);
00145         }
00146         $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
00147         return $this;
00148     }

getStoreId (  ) 

Retrieve Store ID Filter

Returns:
int|null

Definition at line 70 of file Collection.php.

00071     {
00072         return $this->_storeId;
00073     }

setPopularQueryFilter ( storeIds = null  ) 

Set Popular Search Query Filter

Parameters:
int|array $storeIds
Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 103 of file Collection.php.

00104     {
00105         $this->getSelect()->reset(Zend_Db_Select::FROM)->distinct(true)
00106             ->from(
00107                 array('main_table'=>$this->getTable('catalogsearch/search_query')),
00108                 array('name'=>"if(ifnull(synonim_for,'')<>'', synonim_for, query_text)", 'num_results')
00109             );
00110         if ($storeIds) {
00111             $this->addStoreFilter($storeIds);
00112             $this->getSelect()->where('num_results > 0');
00113         }
00114         elseif (null === $storeIds) {
00115             $this->addStoreFilter(Mage::app()->getStore()->getId());
00116             $this->getSelect()->where('num_results > 0');
00117         }
00118 
00119         $this->getSelect()->order(array('popularity desc','name'));
00120 
00121         return $this;
00122     }

setQueryFilter ( query  ) 

Set search query text to filter

Parameters:
string $query
Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 81 of file Collection.php.

00082     {
00083         $this->getSelect()->reset(Zend_Db_Select::FROM)->distinct(true)
00084             ->from(
00085                 array('main_table' => $this->getTable('catalogsearch/search_query')),
00086                 array('query' => "IF(IFNULL(synonim_for,'')<>'', synonim_for, query_text)", 'num_results')
00087             )
00088             ->where('num_results>0 AND display_in_terms=1 AND query_text LIKE ?', $query.'%')
00089             ->order('popularity desc');
00090         if ($this->getStoreId()) {
00091             $this->getSelect()
00092                 ->where('store_id=?', $this->getStoreId());
00093         }
00094         return $this;
00095     }

setRecentQueryFilter (  ) 

Set Recent Queries Order

Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 129 of file Collection.php.

00130     {
00131         $this->setOrder('updated_at', 'desc');
00132         return $this;
00133     }

setStoreId ( store  ) 

Set Store ID for filter

Parameters:
mixed $store
Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 56 of file Collection.php.

00057     {
00058         if ($store instanceof Mage_Core_Model_Store) {
00059             $store = $store->getId();
00060         }
00061         $this->_storeId = $store;
00062         return $this;
00063     }


Member Data Documentation

$_storeId [protected]

Definition at line 39 of file Collection.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