Public Member Functions | |
setStoreId ($store) | |
getStoreId () | |
setQueryFilter ($query) | |
setPopularQueryFilter ($storeIds=null) | |
setRecentQueryFilter () | |
addStoreFilter ($storeIds) | |
Protected Member Functions | |
_construct () | |
Protected Attributes | |
$_storeId |
Definition at line 32 of file Collection.php.
_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
array|int | $storeIds |
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 | ( | ) |
setPopularQueryFilter | ( | $ | storeIds = null |
) |
Set Popular Search Query Filter
int|array | $storeIds |
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
string | $query |
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
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
mixed | $store |
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 }
$_storeId [protected] |
Definition at line 39 of file Collection.php.