Public Member Functions | |
addIdFilter ($categoryIds) | |
setStoreId ($storeId) | |
getStoreId () | |
addParentPathFilter ($parent) | |
addStoreFilter () | |
addSortedField ($sorted) | |
addIsActiveFilter () | |
addNameToResult () | |
addAttributeToSelect ($attribute= '*') | |
getResource () | |
addAttributeToSort ($attribute, $dir='asc') | |
addAttributeToFilter ($attribute, $condition=null) | |
addUrlRewriteToResult () | |
addPathsFilter ($paths) | |
addLevelFilter ($level) | |
addOrderField ($field) | |
Protected Member Functions | |
_construct () | |
_initSelect () | |
_beforeLoad () | |
_afterLoad () | |
Protected Attributes | |
$_eventPrefix = 'catalog_category_collection' | |
$_eventObject = 'category_collection' | |
$_storeId = null |
Definition at line 35 of file Collection.php.
_afterLoad | ( | ) | [protected] |
After collection load
Reimplemented from Varien_Data_Collection_Db.
Definition at line 119 of file Collection.php.
00120 { 00121 Mage::dispatchEvent($this->_eventPrefix . '_load_after', 00122 array($this->_eventObject => $this)); 00123 00124 return parent::_afterLoad(); 00125 }
_beforeLoad | ( | ) | [protected] |
Before collection load
Definition at line 107 of file Collection.php.
00108 { 00109 Mage::dispatchEvent($this->_eventPrefix . '_load_before', 00110 array($this->_eventObject => $this)); 00111 return parent::_beforeLoad(); 00112 }
_construct | ( | ) | [protected] |
Initialization here
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 59 of file Collection.php.
00060 { 00061 $this->_init('catalog/category_flat'); 00062 $this->setModel('catalog/category'); 00063 }
_initSelect | ( | ) | [protected] |
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 65 of file Collection.php.
00066 { 00067 $this->getSelect()->from( 00068 array('main_table' => $this->getResource()->getMainStoreTable($this->getStoreId())), 00069 array('entity_id', 'level', 'path', 'position', 'is_active', 'is_anchor') 00070 ); 00071 return $this; 00072 }
addAttributeToFilter | ( | $ | attribute, | |
$ | condition = null | |||
) |
Emulate simple add attribute filter to collection
string | $attribute | |
mixed | $condition |
Definition at line 280 of file Collection.php.
00281 { 00282 if (!is_string($attribute) || $condition === null) { 00283 return $this; 00284 } 00285 00286 return $this->addFieldToFilter($attribute, $condition); 00287 }
addAttributeToSelect | ( | $ | attribute = '*' |
) |
Add attribute to select
array|string | $attribute |
Definition at line 213 of file Collection.php.
00214 { 00215 if ($attribute == '*') { 00216 // Save previous selected columns 00217 $columns = $this->getSelect()->getPart(Zend_Db_Select::COLUMNS); 00218 $this->getSelect()->reset(Zend_Db_Select::COLUMNS); 00219 foreach ($columns as $column) { 00220 if ($column[0] == 'main_table') { 00221 // If column selected from main table, 00222 // no need to select it again 00223 continue; 00224 } 00225 00226 // Joined columns 00227 if ($column[2] !== null) { 00228 $expression = array($column[2] => $column[1]); 00229 } else { 00230 $expression = $column[2]; 00231 } 00232 $this->getSelect()->columns($expression, $column[0]); 00233 } 00234 00235 $this->getSelect()->columns('*', 'main_table'); 00236 return $this; 00237 } 00238 00239 if (!is_array($attribute)) { 00240 $attribute = array($attribute); 00241 } 00242 00243 $this->getSelect()->columns($attribute, 'main_table'); 00244 return $this; 00245 }
addAttributeToSort | ( | $ | attribute, | |
$ | dir = 'asc' | |||
) |
Add attribute to sort order
string | $attribute | |
string | $dir |
Definition at line 264 of file Collection.php.
00265 { 00266 if (!is_string($attribute)) { 00267 return $this; 00268 } 00269 $this->setOrder($attribute, $dir); 00270 return $this; 00271 }
addIdFilter | ( | $ | categoryIds | ) |
Add filter by entity id(s).
mixed | $categoryIds |
Definition at line 80 of file Collection.php.
00081 { 00082 if (is_array($categoryIds)) { 00083 if (empty($categoryIds)) { 00084 $condition = ''; 00085 } else { 00086 $condition = array('in' => $categoryIds); 00087 } 00088 } elseif (is_numeric($categoryIds)) { 00089 $condition = $categoryIds; 00090 } elseif (is_string($categoryIds)) { 00091 $ids = explode(',', $categoryIds); 00092 if (empty($ids)) { 00093 $condition = $categoryIds; 00094 } else { 00095 $condition = array('in' => $ids); 00096 } 00097 } 00098 $this->addFieldToFilter('entity_id', $condition); 00099 return $this; 00100 }
addIsActiveFilter | ( | ) |
Definition at line 193 of file Collection.php.
00194 { 00195 $this->addFieldToFilter('is_active', 1); 00196 Mage::dispatchEvent($this->_eventPrefix . '_add_is_active_filter', 00197 array($this->_eventObject => $this)); 00198 return $this; 00199 }
addLevelFilter | ( | $ | level | ) |
Definition at line 318 of file Collection.php.
00319 { 00320 $this->getSelect()->where('main_table.level <= ?', $level); 00321 return $this; 00322 }
addNameToResult | ( | ) |
Definition at line 201 of file Collection.php.
00202 { 00203 $this->addAttributeToSelect('name'); 00204 return $this; 00205 }
addOrderField | ( | $ | field | ) |
Definition at line 324 of file Collection.php.
00325 { 00326 $this->setOrder('main_table.' . $field, 'ASC'); 00327 return $this; 00328 }
addParentPathFilter | ( | $ | parent | ) |
Add filter by path to collection
string | $parent |
Definition at line 160 of file Collection.php.
00161 { 00162 $this->addFieldToFilter('path', array('like' => "{$parent}/%")); 00163 return $this; 00164 }
addPathsFilter | ( | $ | paths | ) |
Definition at line 300 of file Collection.php.
00301 { 00302 if (!is_array($paths)) { 00303 $paths = array($paths); 00304 } 00305 $select = $this->getSelect(); 00306 $orWhere = false; 00307 foreach ($paths as $path) { 00308 if ($orWhere) { 00309 $select->orWhere('main_table.path LIKE ?', "$path%"); 00310 } else { 00311 $select->where('main_table.path LIKE ?', "$path%"); 00312 $orWhere = true; 00313 } 00314 } 00315 return $this; 00316 }
addSortedField | ( | $ | sorted | ) |
Set field to sort by
string | $sorted |
Definition at line 183 of file Collection.php.
00184 { 00185 if (is_string($sorted)) { 00186 $this->addOrder($sorted, 'ASC'); 00187 } else { 00188 $this->addOrder('name', 'ASC'); 00189 } 00190 return $this; 00191 }
addStoreFilter | ( | ) |
Add store filter
Definition at line 171 of file Collection.php.
00172 { 00173 $this->addFieldToFilter('main_table.store_id', $this->getStoreId()); 00174 return $this; 00175 }
addUrlRewriteToResult | ( | ) |
Definition at line 289 of file Collection.php.
00290 { 00291 $storeId = Mage::app()->getStore()->getId(); 00292 $this->getSelect()->joinLeft( 00293 array('url_rewrite' => $this->getTable('core/url_rewrite')), 00294 'url_rewrite.category_id=main_table.entity_id AND url_rewrite.is_system=1 AND url_rewrite.product_id IS NULL AND url_rewrite.store_id="'.$storeId.'" AND url_rewrite.id_path LIKE "category/%"', 00295 array('request_path') 00296 ); 00297 return $this; 00298 }
getResource | ( | ) |
Retrieve resource instance
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 252 of file Collection.php.
00253 { 00254 return parent::getResource(); 00255 }
getStoreId | ( | ) |
Return store id. If store id is not set yet, return store of application
Definition at line 146 of file Collection.php.
00147 { 00148 if (is_null($this->_storeId)) { 00149 return Mage::app()->getStore()->getId(); 00150 } 00151 return $this->_storeId; 00152 }
setStoreId | ( | $ | storeId | ) |
$_eventObject = 'category_collection' [protected] |
Definition at line 49 of file Collection.php.
$_eventPrefix = 'catalog_category_collection' [protected] |
Definition at line 42 of file Collection.php.
$_storeId = null [protected] |
Definition at line 57 of file Collection.php.