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;
}