Public Member Functions | |
getAggregator () | |
getStateKey () | |
getStateTags (array $additionalTags=array()) | |
getProductCollection () | |
prepareProductCollection ($collection) | |
apply () | |
getCurrentCategory () | |
setCurrentCategory ($category) | |
getCurrentStore () | |
getFilterableAttributes () | |
getState () | |
Protected Member Functions | |
_prepareAttribute ($attribute) | |
_prepareAttributeCollection ($collection) | |
_getSetIds () | |
Protected Attributes | |
$_productCollections = array() | |
$_stateKey = null |
Definition at line 35 of file Layer.php.
_getSetIds | ( | ) | [protected] |
Get attribute sets idendifiers of current product set
Definition at line 287 of file Layer.php.
00288 { 00289 $key = $this->getStateKey().'_SET_IDS'; 00290 $setIds = $this->getAggregator()->getCacheData($key); 00291 00292 if ($setIds === null) { 00293 $setIds = $this->getProductCollection()->getSetIds(); 00294 $this->getAggregator()->saveCacheData($setIds, $key, $this->getStateTags()); 00295 } 00296 return $setIds; 00297 }
_prepareAttribute | ( | $ | attribute | ) | [protected] |
Prepare attribute for use in layered navigation
Mage_Eav_Model_Entity_Attribute | $attribute |
Reimplemented in Mage_CatalogSearch_Model_Layer.
Definition at line 247 of file Layer.php.
00248 { 00249 Mage::getResourceSingleton('catalog/product')->getAttribute($attribute); 00250 return $attribute; 00251 }
_prepareAttributeCollection | ( | $ | collection | ) | [protected] |
Add filters to attribute collection
Mage_Eav_Model_Mysql4_Entity_Attribute_Collection | $collection |
Reimplemented in Mage_CatalogSearch_Model_Layer.
Definition at line 259 of file Layer.php.
apply | ( | ) |
Apply layer Method is colling after apply all filters, can be used for prepare some index data before getting information about existing intexes
Definition at line 141 of file Layer.php.
00142 { 00143 $stateSuffix = ''; 00144 foreach ($this->getState()->getFilters() as $filterItem) { 00145 $stateSuffix.= '_'.$filterItem->getFilter()->getRequestVar() 00146 . '_' . $filterItem->getValueString(); 00147 } 00148 if (!empty($stateSuffix)) { 00149 $this->_stateKey = $this->getStateKey().$stateSuffix; 00150 } 00151 return $this; 00152 }
getAggregator | ( | ) |
Get data aggregation object
Definition at line 56 of file Layer.php.
00057 { 00058 return Mage::getSingleton('catalogindex/aggregation'); 00059 }
getCurrentCategory | ( | ) |
Retrieve current category model If no category found in registry, the root will be taken
Definition at line 160 of file Layer.php.
00161 { 00162 $category = $this->getData('current_category'); 00163 if (is_null($category)) { 00164 if ($category = Mage::registry('current_category')) { 00165 $this->setData('current_category', $category); 00166 } 00167 else { 00168 $category = Mage::getModel('catalog/category')->load($this->getCurrentStore()->getRootCategoryId()); 00169 $this->setData('current_category', $category); 00170 } 00171 } 00172 return $category; 00173 }
getCurrentStore | ( | ) |
Retrieve current store model
Definition at line 205 of file Layer.php.
00206 { 00207 return Mage::app()->getStore(); 00208 }
getFilterableAttributes | ( | ) |
Get collection of all filterable attributes for layer products set
Definition at line 215 of file Layer.php.
00216 { 00217 $entity = Mage::getSingleton('eav/config') 00218 ->getEntityType('catalog_product'); 00219 00220 $setIds = $this->_getSetIds(); 00221 if (!$setIds) { 00222 return array(); 00223 } 00224 00225 $collection = Mage::getModel('eav/entity_attribute') 00226 ->getCollection() 00227 ->setItemObjectClass('catalog/resource_eav_attribute'); 00228 00229 /* @var $collection Mage_Eav_Model_Mysql4_Entity_Attribute_Collection */ 00230 $collection->getSelect()->distinct(true); 00231 $collection 00232 ->setEntityTypeFilter($entity->getId()) 00233 ->setAttributeSetFilter($setIds) 00234 ->setOrder('position', 'ASC'); 00235 $collection = $this->_prepareAttributeCollection($collection); 00236 $collection->load(); 00237 00238 return $collection; 00239 }
getProductCollection | ( | ) |
Retrieve current layer product collection
Reimplemented in Mage_CatalogSearch_Model_Layer.
Definition at line 95 of file Layer.php.
00096 { 00097 if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) { 00098 $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; 00099 } 00100 else { 00101 $collection = $this->getCurrentCategory()->getProductCollection(); 00102 $this->prepareProductCollection($collection); 00103 $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; 00104 } 00105 00106 return $collection; 00107 }
getState | ( | ) |
Retrieve layer state object
Definition at line 270 of file Layer.php.
00271 { 00272 $state = $this->getData('state'); 00273 if (is_null($state)) { 00274 Varien_Profiler::start(__METHOD__); 00275 $state = Mage::getModel('catalog/layer_state'); 00276 $this->setData('state', $state); 00277 Varien_Profiler::stop(__METHOD__); 00278 } 00279 return $state; 00280 }
getStateKey | ( | ) |
Get layer state key
Reimplemented in Mage_CatalogSearch_Model_Layer.
Definition at line 66 of file Layer.php.
00067 { 00068 if ($this->_stateKey === null) { 00069 $this->_stateKey = 'STORE_'.Mage::app()->getStore()->getId() 00070 . '_CAT_'.$this->getCurrentCategory()->getId() 00071 . '_CUSTGROUP_' . Mage::getSingleton('customer/session')->getCustomerGroupId(); 00072 } 00073 return $this->_stateKey; 00074 }
Get default tags for current layer state
array | $additionalTags |
Reimplemented in Mage_CatalogSearch_Model_Layer.
Definition at line 82 of file Layer.php.
00083 { 00084 $additionalTags = array_merge($additionalTags, array( 00085 Mage_Catalog_Model_Category::CACHE_TAG.$this->getCurrentCategory()->getId() 00086 )); 00087 return $additionalTags; 00088 }
prepareProductCollection | ( | $ | collection | ) |
Initialize product collection
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection | $collection |
Reimplemented in Mage_CatalogSearch_Model_Layer.
Definition at line 115 of file Layer.php.
00116 { 00117 $attributes = Mage::getSingleton('catalog/config') 00118 ->getProductAttributes(); 00119 $collection->addAttributeToSelect($attributes) 00120 ->addMinimalPrice() 00121 ->addFinalPrice() 00122 ->addTaxPercents() 00123 //->addStoreFilter() 00124 ; 00125 00126 Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); 00127 Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); 00128 $collection->addUrlRewrite($this->getCurrentCategory()->getId()); 00129 00130 return $this; 00131 }
setCurrentCategory | ( | $ | category | ) |
Change current category object
mixed | $category |
Definition at line 181 of file Layer.php.
00182 { 00183 if (is_numeric($category)) { 00184 $category = Mage::getModel('catalog/category')->load($category); 00185 } 00186 if (!$category instanceof Mage_Catalog_Model_Category) { 00187 Mage::throwException(Mage::helper('catalog')->__('Category must be instance of Mage_Catalog_Model_Category')); 00188 } 00189 if (!$category->getId()) { 00190 Mage::throwException(Mage::helper('catalog')->__('Invalid category')); 00191 } 00192 00193 if ($category->getId() != $this->getCurrentCategory()->getId()) { 00194 $this->setData('current_category', $category); 00195 } 00196 00197 return $this; 00198 }