Mage_Catalog_Model_Layer_Filter_Abstract Class Reference

Inheritance diagram for Mage_Catalog_Model_Layer_Filter_Abstract:

Varien_Object Mage_Catalog_Model_Layer_Filter_Attribute Mage_Catalog_Model_Layer_Filter_Category Mage_Catalog_Model_Layer_Filter_Price

List of all members.

Public Member Functions

 setRequestVar ($varName)
 getRequestVar ()
 getResetValue ()
 apply (Zend_Controller_Request_Abstract $request, $filterBlock)
 getItemsCount ()
 getItems ()
 getLayer ()
 setAttributeModel ($attribute)
 getAttributeModel ()
 getName ()

Protected Member Functions

 _getItemsData ()
 _initItems ()
 _createItem ($label, $value, $count=0)
 _getFilterEntityIds ()
 _getBaseCollectionSql ()

Protected Attributes

 $_requestVar
 $_items


Detailed Description

Definition at line 34 of file Abstract.php.


Member Function Documentation

_createItem ( label,
value,
count = 0 
) [protected]

Create filter item object

Parameters:
string $label
mixed $value
int $count
Returns:
Mage_Catalog_Model_Layer_Filter_Item

Definition at line 178 of file Abstract.php.

00179     {
00180         return Mage::getModel('catalog/layer_filter_item')
00181             ->setFilter($this)
00182             ->setLabel($label)
00183             ->setValue($value)
00184             ->setCount($count);
00185     }

_getBaseCollectionSql (  )  [protected]

Get product collection select object with applied filters

Returns:
Varien_Db_Select

Definition at line 202 of file Abstract.php.

00203     {
00204         return $this->getLayer()->getProductCollection()->getSelect();
00205     }

_getFilterEntityIds (  )  [protected]

Get all product ids from from collection with applied filters

Returns:
array

Definition at line 192 of file Abstract.php.

00193     {
00194         return $this->getLayer()->getProductCollection()->getAllIdsCache();
00195     }

_getItemsData (  )  [protected]

Get data array for building filter items

result array should have next structure: array( $index => array( 'label' => $label, 'value' => $value, 'count' => $count ) )

Returns:
array

Reimplemented in Mage_Catalog_Model_Layer_Filter_Attribute, and Mage_Catalog_Model_Layer_Filter_Price.

Definition at line 129 of file Abstract.php.

00130     {
00131         return array();
00132     }

_initItems (  )  [protected]

Initialize filter items

Returns:
Mage_Catalog_Model_Layer_Filter_Abstract

Definition at line 139 of file Abstract.php.

00140     {
00141         $data = $this->_getItemsData();
00142         $items=array();
00143         foreach ($data as $itemData) {
00144             $items[] = $this->_createItem(
00145                 $itemData['label'],
00146                 $itemData['value'],
00147                 $itemData['count']
00148             );
00149         }
00150         $this->_items = $items;
00151         return $this;
00152     }

apply ( Zend_Controller_Request_Abstract $  request,
filterBlock 
)

Apply filter to collection

Parameters:
Zend_Controller_Request_Abstract $request

Reimplemented in Mage_Catalog_Model_Layer_Filter_Attribute, Mage_Catalog_Model_Layer_Filter_Category, and Mage_Catalog_Model_Layer_Filter_Price.

Definition at line 87 of file Abstract.php.

00088     {
00089         return $this;
00090     }

getAttributeModel (  ) 

Get attribute model associated with filter

Returns:
Mage_Eav_Model_Entity_Attribute

Definition at line 225 of file Abstract.php.

00226     {
00227         $attribute = $this->getData('attribute_model');
00228         if (is_null($attribute)) {
00229             Mage::throwException(Mage::helper('catalog')->__('Attribute model not defined'));
00230         }
00231         return $attribute;
00232     }

getItems (  ) 

Get all filter items

Returns:
array

Definition at line 107 of file Abstract.php.

00108     {
00109         if (is_null($this->_items)) {
00110             $this->_initItems();
00111         }
00112         return $this->_items;
00113     }

getItemsCount (  ) 

Get fiter items count

Returns:
int

Definition at line 97 of file Abstract.php.

00098     {
00099         return count($this->getItems());
00100     }

getLayer (  ) 

Retrieve layer object

Returns:
Mage_Catalog_Model_Layer

Definition at line 160 of file Abstract.php.

00161     {
00162         $layer = $this->_getData('layer');
00163         if (is_null($layer)) {
00164             $layer = Mage::getSingleton('catalog/layer');
00165             $this->setData('layer', $layer);
00166         }
00167         return $layer;
00168     }

getName (  ) 

Get filter text label

Returns:
string

Reimplemented in Mage_Catalog_Model_Layer_Filter_Category.

Definition at line 239 of file Abstract.php.

00240     {
00241         return $this->getAttributeModel()->getFrontendLabel();
00242     }

getRequestVar (  ) 

Get request variable name which is used for apply filter

Returns:
string

Definition at line 67 of file Abstract.php.

00068     {
00069         return $this->_requestVar;
00070     }

getResetValue (  ) 

Get filter value for reset current filter state

Returns:
mixed

Reimplemented in Mage_Catalog_Model_Layer_Filter_Category.

Definition at line 77 of file Abstract.php.

00078     {
00079         return null;
00080     }

setAttributeModel ( attribute  ) 

Set attribute model to filter

Parameters:
Mage_Eav_Model_Entity_Attribute $attribute
Returns:
Mage_Catalog_Model_Layer_Filter_Abstract

Definition at line 213 of file Abstract.php.

00214     {
00215         $this->setRequestVar($attribute->getAttributeCode());
00216         $this->setData('attribute_model', $attribute);
00217         return $this;
00218     }

setRequestVar ( varName  ) 

Set request variable name which is used for apply filter

Parameters:
string $varName
Returns:
Mage_Catalog_Model_Layer_Filter_Abstract

Definition at line 56 of file Abstract.php.

00057     {
00058         $this->_requestVar = $varName;
00059         return $this;
00060     }


Member Data Documentation

$_items [protected]

Definition at line 48 of file Abstract.php.

$_requestVar [protected]

Definition at line 41 of file Abstract.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:39 2009 for Magento by  doxygen 1.5.8