public function testApply() { $request = new Magento_Test_Request(); $request->setParam('cat', 3); $this->_model->apply($request, Mage::app()->getLayout()->createBlock('Mage_Core_Block_Text')); /** @var $category Mage_Catalog_Model_Category */ $category = Mage::registry('current_category_filter'); $this->assertInstanceOf('Mage_Catalog_Model_Category', $category); $this->assertEquals(3, $category->getId()); return $this->_model; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { // very small optimization $catId = (int) Mage::helper('adjnav')->getParam($this->getRequestVar()); if ($catId) { $request->setParam($this->getRequestVar(), $catId); parent::apply($request, $filterBlock); } $category = $this->getCategory(); if (!Mage::registry('current_category_filter')) { Mage::register('current_category_filter', $category); } if (!isset($filter) || !$filter) { $this->addCategoryFilter($category, null); return $this; } $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($filter); if ($this->_isValidCategory($this->_appliedCategory)) { /* $this->getLayer()->getProductCollection() ->addCategoryFilter($this->_appliedCategory); */ $this->addCategoryFilter($this->_appliedCategory, $filter); $this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter)); } return $this; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { if (Mage::getStoreConfig('mageworx_seo/seosuite/disable_layered_rewrites')) { return parent::apply($request, $filterBlock); } $filter = $request->getParam($this->getRequestVar()); if (is_null($filter)) { return parent::apply($request, $filterBlock); } if (!is_numeric($filter)) { if (Mage::registry('current_category')) { $collection = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('parent_id', Mage::registry('current_category')->getId())->addAttributeToFilter('is_active', 1)->addAttributeToSelect('name')->addAttributeToFilter('name', $filter); if (count($collection) == 0) { return parent::apply($request, $filterBlock); } $this->_appliedCategory = $collection->getFirstItem(); if (!$this->_appliedCategory->getProductCollection()->count()) { $this->_appliedCategory = $this->_getCategoryByName($filter); } } else { $this->_appliedCategory = $this->_getCategoryByName($filter); } if ($this->_appliedCategory) { $this->_categoryId = $filter = $this->_appliedCategory->getId(); } } else { $this->_categoryId = $filter; $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($filter); } if ($this->_isValidCategory($this->_appliedCategory)) { $this->getLayer()->getProductCollection()->addCategoryFilter($this->_appliedCategory); $this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter)); } return $this; }
/** * Retrieves request parameter and applies it to product collection. * * @param Zend_Controller_Request_Abstract $request * @param Mage_Core_Block_Abstract $filterBlock * @return Pocketphp_Elasticsearch_Model_Catalog_Layer_Filter_Category */ public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { if (!Mage::helper('elasticsearch')->isActiveEngine()) { return parent::apply($request, $filterBlock); } $filter = (int) $request->getParam($this->getRequestVar()); if ($filter) { $this->_categoryId = $filter; } /** @var $category Mage_Catalog_Model_Category */ $category = $this->getCategory(); if (!Mage::registry('current_category_filter')) { Mage::register('current_category_filter', $category); } if (!$filter) { $this->addCategoryFilter($category, null); return $this; } $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($filter); if ($this->_isValidCategory($this->_appliedCategory)) { $this->getLayer()->getProductCollection()->addCategoryFilter($this->_appliedCategory); $this->addCategoryFilter($this->_appliedCategory); $this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter)); } return $this; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { $catId = (int) Mage::helper('multilayer')->getParam($this->getRequestVar()); if ($catId) { $request->setParam($this->getRequestVar(), $catId); parent::apply($request, $filterBlock); } return $this; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { // very small optimization $catId = (int) $request->getParam($this->getRequestVar()); if ($catId) { parent::apply($request, $filterBlock); } return $this; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { // very small optimization $catId = (int) Mage::helper('layerednav')->getParam($this->getRequestVar()); if ($catId) { $request->setParam($this->getRequestVar(), $catId); parent::apply($request, $filterBlock); } return $this; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { if (!Mage::helper('sm_shopby')->isEnabled()) { return parent::apply($request, $filterBlock); } $filter = $request->getParam($this->getRequestVar()); if (!$filter) { return $this; } $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->loadByAttribute('url_key', $filter); 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; }