Mage_Catalog_Model_Layer_Filter_Category Class Reference

Inheritance diagram for Mage_Catalog_Model_Layer_Filter_Category:

Mage_Catalog_Model_Layer_Filter_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getResetValue ()
 apply (Zend_Controller_Request_Abstract $request, $filterBlock)
 getName ()
 getCategory ()

Protected Member Functions

 _isValidCategory ($category)

Protected Attributes

 $_categoryId
 $_appliedCategory = null


Detailed Description

Definition at line 34 of file Category.php.


Constructor & Destructor Documentation

__construct (  ) 

Class constructor

Reimplemented from Varien_Object.

Definition at line 53 of file Category.php.

00054     {
00055         parent::__construct();
00056         $this->_requestVar = 'cat';
00057     }


Member Function Documentation

_isValidCategory ( category  )  [protected]

Validate category for be using as filter

Parameters:
Mage_Catalog_Model_Category $category
Returns:
unknown

Definition at line 112 of file Category.php.

00113     {
00114         return $category->getId();
00115     }

apply ( Zend_Controller_Request_Abstract $  request,
filterBlock 
)

Apply category filter to layer

Parameters:
Zend_Controller_Request_Abstract $request
Mage_Core_Block_Abstract $filterBlock
Returns:
Mage_Catalog_Model_Layer_Filter_Category

Reimplemented from Mage_Catalog_Model_Layer_Filter_Abstract.

Definition at line 86 of file Category.php.

00087     {
00088         $filter = (int) $request->getParam($this->getRequestVar());
00089         $this->_categoryId = $filter;
00090         $this->_appliedCategory = Mage::getModel('catalog/category')
00091             ->setStoreId(Mage::app()->getStore()->getId())
00092             ->load($filter);
00093 
00094         if ($this->_isValidCategory($this->_appliedCategory)) {
00095             $this->getLayer()->getProductCollection()
00096                 ->addCategoryFilter($this->_appliedCategory);
00097 
00098             $this->getLayer()->getState()->addFilter(
00099                 $this->_createItem($this->_appliedCategory->getName(), $filter)
00100             );
00101         }
00102 
00103         return $this;
00104     }

getCategory (  ) 

Get selected category object

Returns:
Mage_Catalog_Model_Category

Definition at line 132 of file Category.php.

00133     {
00134         if (!is_null($this->_categoryId)) {
00135             $category = Mage::getModel('catalog/category')
00136                 ->load($this->_categoryId);
00137             if ($category->getId()) {
00138                 return $category;
00139             }
00140         }
00141         return $this->getLayer()->getCurrentCategory();
00142     }

getName (  ) 

Get filter name

Returns:
string

Reimplemented from Mage_Catalog_Model_Layer_Filter_Abstract.

Definition at line 122 of file Category.php.

00123     {
00124         return Mage::helper('catalog')->__('Category');
00125     }

getResetValue (  ) 

Get filter value for reset current filter state

Returns:
mixed

Revert path ids

Reimplemented from Mage_Catalog_Model_Layer_Filter_Abstract.

Definition at line 64 of file Category.php.

00065     {
00066         if ($this->_appliedCategory) {
00067             /**
00068              * Revert path ids
00069              */
00070             $pathIds = array_reverse($this->_appliedCategory->getPathIds());
00071             $curCategoryId = $this->getLayer()->getCurrentCategory()->getId();
00072             if (isset($pathIds[1]) && $pathIds[1] != $curCategoryId) {
00073                 return $pathIds[1];
00074             }
00075         }
00076         return null;
00077     }


Member Data Documentation

$_appliedCategory = null [protected]

Definition at line 48 of file Category.php.

$_categoryId [protected]

Definition at line 41 of file Category.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