Catalin_SEO_Model_Catalog_Layer_Filter_Category::apply PHP Method

apply() public method

Apply category filter to layer
public apply ( Zend_Controller_Request_Abstract $request, Mage_Core_Block_Abstract $filterBlock ) : Mage_Catalog_Model_Layer_Filter_Category
$request Zend_Controller_Request_Abstract
$filterBlock Mage_Core_Block_Abstract
return Mage_Catalog_Model_Layer_Filter_Category
    public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
    {
        if (!Mage::helper('catalin_seo')->isEnabled()) {
            return parent::apply($request, $filterBlock);
        }
        $filter = $request->getParam($this->getRequestVar());
        if (!$filter) {
            return $this;
        }
        $parts = explode('-', $filter);
        // Load the category filter by url_key
        $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->loadByAttribute('url_key', $parts[0]);
        // Extra check in case it is a category id and not url key
        if (!$this->_appliedCategory instanceof Mage_Catalog_Model_Category) {
            return parent::apply($request, $filterBlock);
        }
        $this->_categoryId = $this->_appliedCategory->getId();
        Mage::register('current_category_filter', $this->getCategory(), true);
        if ($this->_isValidCategory($this->_appliedCategory)) {
            $this->getLayer()->getProductCollection()->addCategoryFilter($this->_appliedCategory);
            $this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter));
        }
        return $this;
    }
Catalin_SEO_Model_Catalog_Layer_Filter_Category