Mana_Filters - Version 1.1.0

Version Notes

Release notes for users and developers

Download this release

Release Info

Developer Magento Core Team
Extension Mana_Filters
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/local/Mana/Filters/Block/Filter/Attribute.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing options for filter based on custom attribute
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalog/layer_filter_attribute in Mana_Filters_Block_View_Category::_initBlocks.
12
+ */
13
+ class Mana_Filters_Block_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute {
14
+ /**
15
+ * Overridden constructor injects our template instead of standard one
16
+ */
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->_filterModelName = 'mana_filters/filter_attribute';
21
+ }
22
+
23
+ /**
24
+ * This function is typically called to initialize underlying model of filter and apply it to current
25
+ * product set if needed. Here we leave it as is except that we assign template file here not in constructor,
26
+ * not how standard Magento does.
27
+ * @see Mage_Catalog_Block_Layer_Filter_Abstract::init()
28
+ */
29
+ public function init() {
30
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
31
+ $this->setTemplate($ext->getFilterTemplate($this));
32
+ return parent::init();
33
+ }
34
+
35
+ /**
36
+ * Returns underlying model object which contains actual filter data
37
+ * @return Mage_Catalog_Model_Layer_Filter_Attribute
38
+ */
39
+ public function getFilter() {
40
+ return $this->_filter;
41
+ }
42
+ }
app/code/local/Mana/Filters/Block/Filter/Attribute/Search.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing options for filter based on custom attribute, specific for search
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalog/layer_filter_attribute in Mana_Filters_Block_View_Search::_initBlocks.
12
+ */
13
+ class Mana_Filters_Block_Filter_Attribute_Search extends Mana_Filters_Block_Filter_Attribute {
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->_filterModelName = 'mana_filters/filter_attribute_search';
18
+ }
19
+ }
app/code/local/Mana/Filters/Block/Filter/Category.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing subcategory filter
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalog/layer_filter_category in Mana_Filters_Block_View_Category::_initBlocks.
12
+ */
13
+ class Mana_Filters_Block_Filter_Category extends Mage_Catalog_Block_Layer_Filter_Category {
14
+ /**
15
+ * Overridden constructor injects our template instead of standard one
16
+ */
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->_filterModelName = 'mana_filters/filter_category';
21
+ }
22
+ /**
23
+ * This function is typically called to initialize underlying model of filter and apply it to current
24
+ * product set if needed. Here we leave it as is except that we assign template file here not in constructor,
25
+ * not how standard Magento does.
26
+ * @see Mage_Catalog_Block_Layer_Filter_Abstract::init()
27
+ */
28
+ public function init() {
29
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
30
+ $this->setTemplate($ext->getFilterTemplate($this));
31
+ return parent::init();
32
+ }
33
+
34
+ /**
35
+ * Returns underlying model object which contains actual filter data
36
+ * @return Mage_Catalog_Model_Layer_Filter_Attribute
37
+ */
38
+ public function getFilter() {
39
+ return $this->_filter;
40
+ }
41
+ }
app/code/local/Mana/Filters/Block/Filter/Decimal.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing options for filter based on custom number attribute
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalog/layer_filter_decimal in Mana_Filters_Block_View_Category::_initBlocks.
12
+ */
13
+ class Mana_Filters_Block_Filter_Decimal extends Mage_Catalog_Block_Layer_Filter_Decimal {
14
+ // NO CHANGES HERE, BUT PROBABLY THEY WILL COME IN NEAR FUTURE
15
+
16
+ /**
17
+ * Returns underlying model object which contains actual filter data
18
+ * @return Mage_Catalog_Model_Layer_Filter_Attribute
19
+ */
20
+ public function getFilter() {
21
+ return $this->_filter;
22
+ }
23
+ }
app/code/local/Mana/Filters/Block/Filter/Price.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing price filtering options
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalog/layer_filter_price in Mana_Filters_Block_View_Category::_initBlocks.
12
+ */
13
+ class Mana_Filters_Block_Filter_Price extends Mage_Catalog_Block_Layer_Filter_Price {
14
+ /**
15
+ * Overridden constructor injects our template instead of standard one
16
+ */
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->_filterModelName = 'mana_filters/filter_price';
21
+ }
22
+ /**
23
+ * This function is typically called to initialize underlying model of filter and apply it to current
24
+ * product set if needed. Here we leave it as is except that we assign template file here not in constructor,
25
+ * not how standard Magento does.
26
+ * @see Mage_Catalog_Block_Layer_Filter_Abstract::init()
27
+ */
28
+ public function init() {
29
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
30
+ $this->setTemplate($ext->getFilterTemplate($this));
31
+ return parent::init();
32
+ }
33
+
34
+ /**
35
+ * Returns underlying model object which contains actual filter data
36
+ * @return Mage_Catalog_Model_Layer_Filter_Attribute
37
+ */
38
+ public function getFilter() {
39
+ return $this->_filter;
40
+ }
41
+ }
app/code/local/Mana/Filters/Block/View/Category.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing filters in category view pages.
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalog/layer_view in layout XML file.
12
+ */
13
+ class Mana_Filters_Block_View_Category extends Mage_Catalog_Block_Layer_View {
14
+
15
+ /**
16
+ * This method is called during page rendering to generate additional child blocks for this block.
17
+ * @return Mana_Filters_Block_View_Category
18
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
19
+ * changes are marked with comments.
20
+ * @see app/code/core/Mage/Catalog/Block/Layer/Mage_Catalog_Block_Layer_View::_prepareLayout()
21
+ */
22
+ protected function _prepareLayout()
23
+ {
24
+ $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)
25
+ ->setLayer($this->getLayer());
26
+
27
+ $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)
28
+ ->setLayer($this->getLayer())
29
+ ->init();
30
+
31
+ $this->setChild('layer_state', $stateBlock);
32
+ $this->setChild('category_filter', $categoryBlock);
33
+
34
+ $filterableAttributes = $this->_getFilterableAttributes();
35
+ foreach ($filterableAttributes as $attribute) {
36
+ if ($attribute->getAttributeCode() == 'price') {
37
+ $filterBlockName = $this->_priceFilterBlockName;
38
+ }
39
+ elseif ($attribute->getBackendType() == 'decimal') {
40
+ $filterBlockName = $this->_decimalFilterBlockName;
41
+ }
42
+ else {
43
+ $filterBlockName = $this->_attributeFilterBlockName;
44
+ }
45
+
46
+ $this->setChild($attribute->getAttributeCode() . '_filter',
47
+ $this->getLayout()->createBlock($filterBlockName)
48
+ ->setLayer($this->getLayer())
49
+ ->setAttributeModel($attribute)
50
+ ->init());
51
+ }
52
+
53
+ $this->getLayer()->apply();
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * This method is called during page rendering to determine block types to use inside layered navigation block.
60
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
61
+ * changes are marked with comments.
62
+ * @see Mage_Catalog_Block_Layer_View::_initBlocks()
63
+ */
64
+ protected function _initBlocks()
65
+ {
66
+ $this->_stateBlockName = 'catalog/layer_state';
67
+ // MANA BEGIN: replace standard block types with ours
68
+ $this->_categoryBlockName = 'mana_filters/filter_category';
69
+ $this->_attributeFilterBlockName = 'mana_filters/filter_attribute';
70
+ $this->_priceFilterBlockName = 'mana_filters/filter_price';
71
+ $this->_decimalFilterBlockName = 'mana_filters/filter_decimal';
72
+ // MANA END
73
+ }
74
+
75
+ }
app/code/local/Mana/Filters/Block/View/Search.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Block type for showing filters in search pages.
10
+ * @author Mana Team
11
+ * Injected into layout instead of standard catalogsearch/layer in layout XML file.
12
+ */
13
+ class Mana_Filters_Block_View_Search extends Mage_CatalogSearch_Block_Layer {
14
+ /**
15
+ * This method is called during page rendering to determine block types to use inside layered navigation block.
16
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
17
+ * changes are marked with comments.
18
+ * @see Mage_CatalogSearch_Block_Layer::_initBlocks()
19
+ */
20
+ protected function _initBlocks()
21
+ {
22
+ $this->_stateBlockName = 'catalog/layer_state';
23
+ // MANA BEGIN: replace standard block types with ours
24
+ $this->_categoryBlockName = 'mana_filters/filter_category';
25
+ $this->_attributeFilterBlockName = 'mana_filters/filter_attribute_search';
26
+ $this->_priceFilterBlockName = 'mana_filters/filter_price';
27
+ $this->_decimalFilterBlockName = 'mana_filters/filter_decimal';
28
+ // MANA END
29
+ }
30
+ }
app/code/local/Mana/Filters/Helper/Data.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /* BASED ON SNIPPET: New Module/Helper/Data.php */
9
+ /**
10
+ * Generic helper functions for Mana_Filters module. This class is a must for any module even if empty.
11
+ * @author Mana Team
12
+ */
13
+ class Mana_Filters_Helper_Data extends Mage_Core_Helper_Abstract {
14
+ /**
15
+ * Recognizes block type based on its class.
16
+ * OO purists would say that kind of ifs should be done using virtual functions. Here we ignore OO-ness and
17
+ * micro performance penalty for the sake of clarity and keeping logic in one file.
18
+ * @param Mage_Catalog_Block_Layer_Filter_Abstract $block
19
+ * @return string
20
+ */
21
+ public function getBlockType($block) {
22
+ if ($block instanceof Mana_Filters_Block_Filter_Attribute) return 'attribute';
23
+ elseif ($block instanceof Mana_Filters_Block_Filter_Category) return 'category';
24
+ elseif ($block instanceof Mana_Filters_Block_Filter_Decimal) return 'decimal';
25
+ elseif ($block instanceof Mana_Filters_Block_Filter_Price) return 'price';
26
+ else throw new Exception('Not implemented');
27
+ }
28
+ /**
29
+ * Return unique filter name.
30
+ * OO purists would say that kind of ifs should be done using virtual functions. Here we ignore OO-ness and
31
+ * micro performance penalty for the sake of clarity and keeping logic in one file.
32
+ * @param Mage_Catalog_Model_Layer_Filter_Abstract $model
33
+ * @return string
34
+ */
35
+ public function getFilterName($model) {
36
+ if ($model instanceof Mana_Filters_Model_Filter_Category) return 'category';
37
+ else return $model->getAttributeModel()->getAttributeCode();
38
+ }
39
+ // INSERT HERE: helper functions that should be available from any other place in the system
40
+ public function getJsPriceFormat() {
41
+ return $this->formatPrice(0);
42
+ }
43
+ public function formatPrice($price) {
44
+ $store = Mage::app()->getStore();
45
+ if ($store->getCurrentCurrency()) {
46
+ return $store->getCurrentCurrency()->formatPrecision($price, 0, array(), false, false);
47
+ }
48
+ return $price;
49
+ }
50
+ }
app/code/local/Mana/Filters/Helper/Extended.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Encapsulates extensibility points for Mana_Filters module. Mana_Filters module internals call this helper to
10
+ * invoke this module extensions. Extension mechanisms include registration of additional functionality via
11
+ * config.xml, subscribing to events provided by this module, etc.
12
+ * @author Mana Team
13
+ */
14
+ class Mana_Filters_Helper_Extended extends Mage_Core_Helper_Abstract {
15
+ /**
16
+ * Provides phtml template file name to be used with this filter. Checks global configuration specific for
17
+ * specified filter block
18
+ * @param Mage_Catalog_Block_Layer_Filter_Abstract $filterBlock Block to be rendered in returned template
19
+ * @return string
20
+ */
21
+ public function getFilterTemplate($filterBlock) {
22
+ /* @var $helper Mana_Filters_Helper_Data */ $helper = Mage::helper(strtolower('Mana_Filters'));
23
+ $type = $helper->getBlockType($filterBlock);
24
+ if (/* @var $displayOptions Mage_Core_Model_Config_Element */ $displayOptions = Mage::getConfig()
25
+ ->getNode('mana_filters/display/'.$type))
26
+ {
27
+ $position = 0;
28
+ /* @var $default Mage_Core_Model_Config_Element */ $default = null;
29
+ foreach ($displayOptions->children() as $name => /* @var $options Mage_Core_Model_Config_Element */ $options) {
30
+ if (!$position || $position > (string)$options->position) {
31
+ $position = (string)$options->position;
32
+ $default = $options;
33
+ }
34
+ }
35
+ if ($default) return (string)$default->template;
36
+ }
37
+ throw new Mage_Core_Exception($this->__('Filters of type "%s" can not be displayed - no template installed.'));
38
+ }
39
+
40
+ /**
41
+ * Modifies filter items and filter model itself as specified by extensions subscribed to
42
+ * mana_filters_process_items event.
43
+ * @param Mage_Catalog_Model_Layer_Filter_Abstract $filter
44
+ * @param array $items
45
+ */
46
+ public function processFilterItems($filter, $items) {
47
+ $wrappedItems = new Varien_Object;
48
+ $wrappedItems->setItems($items);
49
+ Mage::dispatchEvent('mana_filters_process_items', array('filter' => $filter, 'items' => $wrappedItems));
50
+ return $wrappedItems->getItems();
51
+ }
52
+
53
+ /**
54
+ * Returns rendered additional markup registered by extensions in configuration under $name key
55
+ * @param string $name
56
+ * @param array $parameters
57
+ * @return string
58
+ */
59
+ public function getNamedHtml($name, $parameters = array()) {
60
+ if (/* @var $markups Mage_Core_Model_Config_Element */ $markups = Mage::getConfig()
61
+ ->getNode('mana_filters/markup/'.$name))
62
+ {
63
+ $templates = array();
64
+ foreach ($markups->children() as $name => /* @var $markup Mage_Core_Model_Config_Element */ $markup) {
65
+ $templates[] = array('name' => $name, 'position' => (string)$markup->position, 'template' => (string)$markup->template);
66
+ }
67
+ usort($templates, array('Mana_Filters_Helper_Extended', '_sortByPosition'));
68
+ $result = '';
69
+ foreach ($templates as $template) {
70
+ $filename = Mage::getBaseDir('design').DS.
71
+ Mage::getDesign()->getTemplateFilename($template['template'], array('_relative'=>true));
72
+ if (file_exists($filename)) {
73
+ $result .= $this->_fetchHtml($filename, $parameters);
74
+ }
75
+ }
76
+ return $result;
77
+ }
78
+ else return '';
79
+ }
80
+ protected function _fetchHtml($filename, $parameters) {
81
+ extract ($parameters, EXTR_OVERWRITE);
82
+ ob_start();
83
+ try {
84
+ include $filename;
85
+ }
86
+ catch (Exception $e) {
87
+ ob_get_clean();
88
+ throw $e;
89
+ }
90
+ return ob_get_clean();
91
+ }
92
+ public static function _sortByPosition($a, $b) {
93
+ if ($a['position'] < $b['position']) return -1;
94
+ elseif ($a['position'] > $b['position']) return 1;
95
+ else return 0;
96
+ }
97
+ public function getFilterUrl($route = '', $params = array()) {
98
+ $wrappedParams = new Varien_Object;
99
+ $wrappedParams->setParams($params);
100
+ $wrappedParams->setIsHandled(false);
101
+ $wrappedParams->setResult('');
102
+ Mage::dispatchEvent('mana_filters_url', array('route' => $route, 'params' => $wrappedParams));
103
+ if ($wrappedParams->getIsHandled()) {
104
+ return $wrappedParams->getResult();
105
+ }
106
+ else {
107
+ return Mage::getUrl($route, $params);
108
+ }
109
+ }
110
+ public function getPriceRange($index, $range) {
111
+ $wrappedParams = new Varien_Object;
112
+ $wrappedParams->setIsHandled(false);
113
+ $wrappedParams->setResult(array());
114
+ Mage::dispatchEvent('mana_filters_price_range', array('index' => $index, 'range' => $range, 'params' => $wrappedParams));
115
+ if ($wrappedParams->getIsHandled()) {
116
+ return $wrappedParams->getResult();
117
+ }
118
+ else {
119
+ return array('from' => $range * ($index - 1), 'to' => $range * $index);
120
+ }
121
+ }
122
+ }
app/code/local/Mana/Filters/Model/Filter/Attribute.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Model type for holding information in memory about possible or applied filter which is based on an attribute
10
+ * @author Mana Team
11
+ * Injected instead of standard catalog/layer_filter_attribute in Mana_Filters_Block_Filter_Attribute constructor.
12
+ */
13
+ class Mana_Filters_Model_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute {
14
+ /**
15
+ * Apply attribute option filter to product collection
16
+ * @param Zend_Controller_Request_Abstract $request
17
+ * @param Mana_Filters_Block_Filter_Attribute $filterBlock
18
+ * @return Mana_Filters_Model_Filter_Attribute
19
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
20
+ * changes are marked with comments.
21
+ * @see app/code/core/Mage/Catalog/Model/Layer/Filter/Mage_Catalog_Model_Layer_Filter_Attribute::apply()
22
+ */
23
+ public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
24
+ {
25
+ $filter = $request->getParam($this->_requestVar);
26
+ if (is_array($filter)) {
27
+ return $this;
28
+ }
29
+
30
+ // MANA BEGIN: when several filter options can be applied, several labels should be added to layer
31
+ // state, on label for each selected option. Here we assume all option ids to be in URL as one string value
32
+ // separated by '_'
33
+ // $text = $this->_getOptionText($filter);
34
+ $text = array();
35
+ foreach ($this->getMSelectedValues() as $optionId) {
36
+ $text[$optionId] = $this->getAttributeModel()->getFrontend()->getOption($optionId);
37
+ }
38
+ // MANA END
39
+
40
+ if ($filter && $text) {
41
+ $this->_getResource()->applyFilterToCollection($this, $filter);
42
+ // MANA BEGIN: create multiple items in layer state, prevent filter from hiding when value is set
43
+ foreach ($this->getMSelectedValues() as $optionId) {
44
+ $this->getLayer()->getState()->addFilter($this->_createItemEx(array(
45
+ 'label' => $text[$optionId],
46
+ 'value' => $optionId,
47
+ 'm_selected' => true,
48
+ )));
49
+ }
50
+ // $this->_items = array();
51
+ // MANA END
52
+ }
53
+ return $this;
54
+ }
55
+ /**
56
+ * Creates in-memory representation of a single option of a filter
57
+ * @param array $data
58
+ * @return Mana_Filters_Model_Item
59
+ * This method is cloned from method _createItem() in parent class (method body was pasted from parent class
60
+ * completely rewritten.
61
+ * Standard method did not give us possibility to initialize non-standard fields.
62
+ */
63
+ protected function _createItemEx($data)
64
+ {
65
+ return Mage::getModel('mana_filters/item')
66
+ ->setData($data)
67
+ ->setFilter($this);
68
+ }
69
+ /**
70
+ * Initializes internal array of in-memory representations of options of a filter
71
+ * @return Mana_Filters_Model_Filter_Attribute
72
+ * @see Mage_Catalog_Model_Layer_Filter_Abstract::_initItems()
73
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
74
+ * changes are marked with comments.
75
+ */
76
+ protected function _initItems()
77
+ {
78
+ $data = $this->_getItemsData();
79
+ $items=array();
80
+ foreach ($data as $itemData) {
81
+ // MANA BEGIN
82
+ $items[] = $this->_createItemEx($itemData);
83
+ // MANA END
84
+ }
85
+ // MANA BEGIN: enable additional filter item processing
86
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
87
+ $items = $ext->processFilterItems($this, $items);
88
+ // MANA END
89
+ $this->_items = $items;
90
+ return $this;
91
+ }
92
+ /**
93
+ * Returns all values currently selected for this filter
94
+ */
95
+ public function getMSelectedValues() {
96
+ $values = Mage::app()->getRequest()->getParam($this->_requestVar);
97
+ return $values ? explode('_', $values) : array();
98
+ }
99
+
100
+ /**
101
+ * Depending on current filter values and on attribute settings, returns available filter options from database
102
+ * and additionally whether individual options are selected or not.
103
+ * @return array
104
+ * @see Mage_Catalog_Model_Layer_Filter_Attribute::_getItemsData()
105
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
106
+ * changes are marked with comments.
107
+ */
108
+ protected function _getItemsData()
109
+ {
110
+ // MANA BEGIN: from url, retrieve ids of all options currently selected
111
+ $selectedOptionIds = $this->getMSelectedValues();
112
+ // MANA END
113
+
114
+ $attribute = $this->getAttributeModel();
115
+ $this->_requestVar = $attribute->getAttributeCode();
116
+
117
+ $key = $this->getLayer()->getStateKey().'_'.$this->_requestVar;
118
+ $data = $this->getLayer()->getAggregator()->getCacheData($key);
119
+
120
+ if ($data === null) {
121
+ $options = $attribute->getFrontend()->getSelectOptions();
122
+ $optionsCount = $this->_getResource()->getCount($this);
123
+ $data = array();
124
+
125
+ foreach ($options as $option) {
126
+ if (is_array($option['value'])) {
127
+ continue;
128
+ }
129
+ if (Mage::helper('core/string')->strlen($option['value'])) {
130
+ // Check filter type
131
+ if ($this->_getIsFilterableAttribute($attribute) == self::OPTIONS_ONLY_WITH_RESULTS) {
132
+ if (!empty($optionsCount[$option['value']])) {
133
+ $data[] = array(
134
+ 'label' => $option['label'],
135
+ 'value' => $option['value'],
136
+ 'count' => $optionsCount[$option['value']],
137
+ // MANA BEGIN: mark each selected item now in memory so we could later mark it
138
+ // visually in markup
139
+ 'm_selected' => in_array($option['value'], $selectedOptionIds),
140
+ // MANA END
141
+ );
142
+ }
143
+ }
144
+ else {
145
+ $data[] = array(
146
+ 'label' => $option['label'],
147
+ 'value' => $option['value'],
148
+ 'count' => isset($optionsCount[$option['value']]) ? $optionsCount[$option['value']] : 0,
149
+ // MANA BEGIN: mark each selected item now in memory so we could later mark it
150
+ // visually in markup
151
+ 'm_selected' => in_array($option['value'], $selectedOptionIds),
152
+ // MANA END
153
+ );
154
+ }
155
+ }
156
+ }
157
+
158
+ $tags = array(
159
+ Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute->getId()
160
+ );
161
+
162
+ $tags = $this->getLayer()->getStateTags($tags);
163
+ $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
164
+ }
165
+ return $data;
166
+ }
167
+
168
+ /**
169
+ * This method locates resource type which should do all dirty job with the database. In this override, we
170
+ * instruct Magento to take our resource type, not standard.
171
+ * @see Mage_Catalog_Model_Layer_Filter_Attribute::_getResource()
172
+ */
173
+ protected function _getResource()
174
+ {
175
+ if (is_null($this->_resource)) {
176
+ $this->_resource = Mage::getResourceModel('mana_filters/filter_attribute');
177
+ }
178
+ return $this->_resource;
179
+ }
180
+ }
app/code/local/Mana/Filters/Model/Filter/Attribute/Search.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ class Mana_Filters_Model_Filter_Attribute_Search extends Mana_Filters_Model_Filter_Attribute {
9
+ /**
10
+ * Check whether specified attribute can be used in LN
11
+ *
12
+ * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
13
+ * @return bool
14
+ */
15
+ protected function _getIsFilterableAttribute($attribute)
16
+ {
17
+ return $attribute->getIsFilterableInSearch();
18
+ }
19
+ }
app/code/local/Mana/Filters/Model/Filter/Category.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Model type for holding information in memory about possible or applied category filter
10
+ * @author Mana Team
11
+ * Injected instead of standard catalog/layer_filter_attribute in Mana_Filters_Block_Filter_Category constructor.
12
+ */
13
+ class Mana_Filters_Model_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category {
14
+ /**
15
+ * Apply category filter to product collection
16
+ * @param Zend_Controller_Request_Abstract $request
17
+ * @param Mana_Filters_Block_Filter_Category $filterBlock
18
+ * @return Mana_Filters_Block_Filter_Category
19
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
20
+ * changes are marked with comments.
21
+ * @see app/code/core/Mage/Catalog/Model/Layer/Filter/Mage_Catalog_Model_Layer_Filter_Category::apply()
22
+ */
23
+ public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
24
+ {
25
+ $filter = (int) $request->getParam($this->getRequestVar());
26
+ if (!$filter) {
27
+ return $this;
28
+ }
29
+ $this->_categoryId = $filter;
30
+
31
+ $category = $this->getCategory();
32
+ Mage::register('current_category_filter', $category);
33
+
34
+ $this->_appliedCategory = Mage::getModel('catalog/category')
35
+ ->setStoreId(Mage::app()->getStore()->getId())
36
+ ->load($filter);
37
+
38
+ if ($this->_isValidCategory($this->_appliedCategory)) {
39
+ $this->getLayer()->getProductCollection()
40
+ ->addCategoryFilter($this->_appliedCategory);
41
+
42
+ $this->getLayer()->getState()->addFilter($this->_createItemEx(array(
43
+ 'label' => $this->_appliedCategory->getName(),
44
+ 'value' => $filter,
45
+ 'm_selected' => true,
46
+ )));
47
+ }
48
+
49
+ return $this;
50
+ }
51
+ /**
52
+ * Returns all values currently selected for this filter
53
+ */
54
+ // public function getMSelectedValues() {
55
+ // $values = Mage::app()->getRequest()->getParam($this->_requestVar);
56
+ // return $values ? explode('_', $values) : array();
57
+ // }
58
+ /**
59
+ * Creates in-memory representation of a single option of a filter
60
+ * @param array $data
61
+ * @return Mana_Filters_Model_Item
62
+ * This method is cloned from method _createItem() in parent class (method body was pasted from parent class
63
+ * completely rewritten.
64
+ * Standard method did not give us possibility to initialize non-standard fields.
65
+ */
66
+ protected function _createItemEx($data)
67
+ {
68
+ return Mage::getModel('mana_filters/item')
69
+ ->setData($data)
70
+ ->setFilter($this);
71
+ }
72
+ /**
73
+ * Initializes internal array of in-memory representations of options of a filter
74
+ * @return Mana_Filters_Model_Filter_Attribute
75
+ * @see Mage_Catalog_Model_Layer_Filter_Abstract::_initItems()
76
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
77
+ * changes are marked with comments.
78
+ */
79
+ protected function _initItems()
80
+ {
81
+ $data = $this->_getItemsData();
82
+ $items=array();
83
+ foreach ($data as $itemData) {
84
+ // MANA BEGIN
85
+ $items[] = $this->_createItemEx($itemData);
86
+ // MANA END
87
+ }
88
+ // MANA BEGIN: enable additional filter item processing
89
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
90
+ $items = $ext->processFilterItems($this, $items);
91
+ // MANA END
92
+ $this->_items = $items;
93
+ return $this;
94
+ }
95
+ }
app/code/local/Mana/Filters/Model/Filter/Price.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Model type for holding information in memory about possible or applied price filter
10
+ * @author Mana Team
11
+ * Injected instead of standard catalog/layer_filter_attribute in Mana_Filters_Block_Filter_Price constructor.
12
+ */
13
+ class Mana_Filters_Model_Filter_Price extends Mage_Catalog_Model_Layer_Filter_Price {
14
+ /**
15
+ * Apply price filter to product collection
16
+ * @param Zend_Controller_Request_Abstract $request
17
+ * @param Mana_Filters_Block_Filter_Price $filterBlock
18
+ * @return Mana_Filters_Model_Filter_Price
19
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
20
+ * changes are marked with comments.
21
+ * @see app/code/core/Mage/Catalog/Model/Layer/Filter/Mage_Catalog_Model_Layer_Filter_Price::apply()
22
+ */
23
+ public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
24
+ {
25
+ // MANA BEGIN: read multiple price ranges from URL instead of single range read in standard code,
26
+ // apply multiple ranges, show multiple ranges in state and do not hide selected ranges from filter options
27
+ $selections = $this->getMSelectedValues();
28
+
29
+ if (count($selections) > 0) {
30
+ list($index, $range) = explode(',', $selections[0]);
31
+ if ((int)$range) {
32
+ $this->setPriceRange((int)$range);
33
+ $this->_applyToCollectionEx($selections);
34
+ foreach ($selections as $selection) {
35
+ list($index, $range) = explode(',', $selection);
36
+ $this->getLayer()->getState()->addFilter($this->_createItemEx(array(
37
+ 'label' => $this->_renderItemLabel($range, $index),
38
+ 'value' => $selection,
39
+ 'm_selected' => true,
40
+ )));
41
+ }
42
+ }
43
+ // $this->_items = array();
44
+ }
45
+ // MANA END
46
+ return $this;
47
+ }
48
+ /**
49
+ * Prepare text of item label
50
+ *
51
+ * @param int $range
52
+ * @param float $value
53
+ * @return string
54
+ */
55
+ protected function _renderItemLabel($range, $value)
56
+ {
57
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
58
+ $range = $ext->getPriceRange($value, $range);
59
+ $store = Mage::app()->getStore();
60
+ $fromPrice = $store->formatPrice($range['from']);
61
+ $toPrice = $store->formatPrice($range['to']);
62
+ return Mage::helper('catalog')->__('%s - %s', $fromPrice, $toPrice);
63
+ }
64
+
65
+ /**
66
+ * Applies one or more price filters to currently viewed product collection
67
+ * @param array $selections
68
+ * @return Mana_Filters_Model_Filter_Price
69
+ * This method is cloned from method _applyToCollection() in parent class (method body was pasted from parent class
70
+ * completely rewritten.
71
+ * Standard method did not give us possibility to filter multiple ranges.
72
+ */
73
+ protected function _applyToCollectionEx($selections)
74
+ {
75
+ $this->_getResource()->applyFilterToCollectionEx($this, $selections);
76
+ return $this;
77
+ }
78
+ /**
79
+ * Creates in-memory representation of a single option of a filter
80
+ * @param array $data
81
+ * @return Mana_Filters_Model_Item
82
+ * This method is cloned from method _createItem() in parent class (method body was pasted from parent class
83
+ * completely rewritten.
84
+ * Standard method did not give us possibility to initialize non-standard fields.
85
+ */
86
+ protected function _createItemEx($data)
87
+ {
88
+ return Mage::getModel('mana_filters/item')
89
+ ->setData($data)
90
+ ->setFilter($this);
91
+ }
92
+ /**
93
+ * Initializes internal array of in-memory representations of options of a filter
94
+ * @return Mana_Filters_Model_Filter_Attribute
95
+ * @see Mage_Catalog_Model_Layer_Filter_Abstract::_initItems()
96
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
97
+ * changes are marked with comments.
98
+ */
99
+ protected function _initItems()
100
+ {
101
+ $data = $this->_getItemsData();
102
+ $items=array();
103
+ foreach ($data as $itemData) {
104
+ // MANA BEGIN
105
+ $items[] = $this->_createItemEx($itemData);
106
+ // MANA END
107
+ }
108
+ // MANA BEGIN: enable additional filter item processing
109
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
110
+ $items = $ext->processFilterItems($this, $items);
111
+ // MANA END
112
+ $this->_items = $items;
113
+ return $this;
114
+ }
115
+ /**
116
+ * Returns all values currently selected for this filter
117
+ */
118
+ public function getMSelectedValues() {
119
+ $values = Mage::app()->getRequest()->getParam($this->_requestVar);
120
+ return $values ? explode('_', $values) : array();
121
+ // $result = array();
122
+ // foreach ($values as $value) {
123
+ // list($index, $range) = explode(',', $value);
124
+ // $result[] = array('index' => $index, 'range' => $range);
125
+ // }
126
+ // return $result;
127
+ }
128
+ /**
129
+ * Depending on current filter values, returns available filter options from database
130
+ * and additionally whether individual options are selected or not.
131
+ * @return array
132
+ * @see Mage_Catalog_Model_Layer_Filter_Price::_getItemsData()
133
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
134
+ * changes are marked with comments.
135
+ */
136
+ protected function _getItemsData()
137
+ {
138
+ $range = $this->getPriceRange();
139
+ $dbRanges = $this->getRangeItemCounts($range);
140
+ $data = array();
141
+
142
+ // MANA BEGIN
143
+ $selectedIndexes = array();
144
+ foreach ($this->getMSelectedValues() as $selection) {
145
+ list($index, $range) = explode(',', $selection);
146
+ $selectedIndexes[] = $index;
147
+ }
148
+ // MANA END
149
+
150
+ foreach ($dbRanges as $index=>$count) {
151
+ $data[] = array(
152
+ 'label' => $this->_renderItemLabel($range, $index),
153
+ 'value' => $index . ',' . $range,
154
+ 'count' => $count,
155
+ // MANA BEGIN
156
+ 'm_selected' => in_array($index, $selectedIndexes),
157
+ // MANA END
158
+ );
159
+ }
160
+
161
+ return $data;
162
+ }
163
+ /**
164
+ * This method locates resource type which should do all dirty job with the database. In this override, we
165
+ * instruct Magento to take our resource type, not standard.
166
+ * @see Mage_Catalog_Model_Layer_Filter_Price::_getResource()
167
+ */
168
+ protected function _getResource()
169
+ {
170
+ if (is_null($this->_resource)) {
171
+ $this->_resource = Mage::getResourceModel('mana_filters/filter_price');
172
+ }
173
+ return $this->_resource;
174
+ }
175
+ public function getLowestPossibleValue() {
176
+ return 0;
177
+ }
178
+ public function getHighestPossibleValue() {
179
+ return $this->getMaxPriceInt() + 1;
180
+ }
181
+ public function getCurrentRangeLowerBound() {
182
+ $selections = $this->getMSelectedValues();
183
+ if ($selections && count($selections) == 1) {
184
+ list($index, $range) = explode(',', $selections[0]);
185
+ return $index;
186
+ }
187
+ else {
188
+ return $this->getLowestPossibleValue();
189
+ }
190
+ }
191
+ public function getCurrentRangeHigherBound() {
192
+ $selections = $this->getMSelectedValues();
193
+ if ($selections && count($selections) == 1) {
194
+ list($index, $range) = explode(',', $selections[0]);
195
+ return $range;
196
+ }
197
+ else {
198
+ return $this->getHighestPossibleValue();
199
+ }
200
+ }
201
+ }
app/code/local/Mana/Filters/Model/Item.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * In-memory representation of a single option of a filter
10
+ * @method bool getMSelected()
11
+ * @method Mana_Filters_Model_Item setMSelected(bool $value)
12
+ * @author Mana Team
13
+ * Injected instead of standard catalog/layer_filter_item in Mana_Filters_Model_Filter_Attribute::_createItemEx()
14
+ * method.
15
+ */
16
+ class Mana_Filters_Model_Item extends Mage_Catalog_Model_Layer_Filter_Item {
17
+ /**
18
+ * Returns URL which should be loaded if person chooses to add this filter item into active filters
19
+ * @return string
20
+ * @see Mage_Catalog_Model_Layer_Filter_Item::getUrl()
21
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
22
+ * changes are marked with comments.
23
+ */
24
+ public function getUrl()
25
+ {
26
+ // MANA BEGIN: add multivalue filter handling
27
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
28
+ $values = $this->getFilter()->getMSelectedValues(); // this could fail if called from some kind of standard filter
29
+ if (!in_array($this->getValue(), $values)) $values[] = $this->getValue();
30
+ // MANA END
31
+
32
+ $query = array(
33
+ // MANA BEGIN: save multiple values in URL as concatenated with '_'
34
+ $this->getFilter()->getRequestVar()=>implode('_', $values),
35
+ // MANA_END
36
+ Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null // exclude current page from urls
37
+ );
38
+ return $ext->getFilterUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));
39
+ }
40
+
41
+ /**
42
+ * Returns URL which should be loaded if person chooses to remove this filter item from active filters
43
+ * @return string
44
+ * @see Mage_Catalog_Model_Layer_Filter_Item::getRemoveUrl()
45
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
46
+ * changes are marked with comments.
47
+ */
48
+ public function getRemoveUrl()
49
+ {
50
+ // MANA BEGIN: add multivalue filter handling
51
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
52
+ $values = $this->getFilter()->getMSelectedValues(); // this could fail if called from some kind of standard filter
53
+ unset($values[array_search($this->getValue(), $values)]);
54
+ if (count($values) > 0) {
55
+ $query = array(
56
+ $this->getFilter()->getRequestVar()=>implode('_', $values),
57
+ Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null // exclude current page from urls
58
+ );
59
+ }
60
+ else {
61
+ $query = array($this->getFilter()->getRequestVar()=>$this->getFilter()->getResetValue());
62
+ }
63
+ // MANA END
64
+
65
+ $params['_current'] = true;
66
+ $params['_use_rewrite'] = true;
67
+ $params['_query'] = $query;
68
+ $params['_escape'] = true;
69
+ return $ext->getFilterUrl('*/*/*', $params);
70
+ }
71
+ public function getUniqueId() {
72
+ /* @var $helper Mana_Filters_Helper_Data */ $helper = Mage::helper(strtolower('Mana_Filters'));
73
+ return 'filter_'.$helper->getFilterName($this->getFilter()).'_'.$this->getValue();
74
+ }
75
+ }
app/code/local/Mana/Filters/Resource/Filter/Attribute.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Resource type which contains sql code for applying filters and related operations
10
+ * @author Mana Team
11
+ * Injected instead of standard resource catalog/layer_filter_attribute in
12
+ * Mana_Filters_Model_Filter_Attribute::_getResource().
13
+ */
14
+ class Mana_Filters_Resource_Filter_Attribute extends Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute {
15
+ /**
16
+ * Modifies product collection select sql to include only those products which conforms this filter's conditions
17
+ * @param Mana_Filters_Model_Filter_Attribute $filter
18
+ * @param string $value
19
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
20
+ * changes are marked with comments.
21
+ * @see Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute::applyFilterToCollection()
22
+ */
23
+ public function applyFilterToCollection($filter, $value)
24
+ {
25
+ $collection = $filter->getLayer()->getProductCollection();
26
+
27
+ // MANA BEGIN: prevent product to appear twice if it conforms joined codition 2 times (e.g. if product
28
+ // has two values assigned for an attribute and both are filtered).
29
+ $collection->getSelect()->distinct(true);
30
+ // MANA END
31
+
32
+ $attribute = $filter->getAttributeModel();
33
+ $connection = $this->_getReadAdapter();
34
+ $tableAlias = $attribute->getAttributeCode() . '_idx';
35
+ $conditions = array(
36
+ "{$tableAlias}.entity_id = e.entity_id",
37
+ $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
38
+ $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()),
39
+ // MANA BEGIN: apply multiple values for filtered field
40
+ "{$tableAlias}.value in (".implode(',', explode('_', $value)).")"
41
+ // $connection->quoteInto("{$tableAlias}.value = ?", $value)
42
+ // MANA END
43
+ );
44
+
45
+ $collection->getSelect()->join(
46
+ array($tableAlias => $this->getMainTable()),
47
+ join(' AND ', $conditions),
48
+ array()
49
+ );
50
+
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * For each option visible to person as a filter choice counts how many products are there given that all the
56
+ * other filters are applied
57
+ * @param Mana_Filters_Model_Filter_Attribute $filter
58
+ * @return array Each entry in result is int option_id => int count
59
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
60
+ * changes are marked with comments.
61
+ * @see Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute::getCount()
62
+ */
63
+ public function getCount($filter)
64
+ {
65
+ // clone select from collection with filters
66
+ $select = clone $filter->getLayer()->getProductCollection()->getSelect();
67
+ // reset columns, order and limitation conditions
68
+ $select->reset(Zend_Db_Select::COLUMNS);
69
+ $select->reset(Zend_Db_Select::ORDER);
70
+ $select->reset(Zend_Db_Select::LIMIT_COUNT);
71
+ $select->reset(Zend_Db_Select::LIMIT_OFFSET);
72
+
73
+ $connection = $this->_getReadAdapter();
74
+ $attribute = $filter->getAttributeModel();
75
+ $tableAlias = $attribute->getAttributeCode() . '_idx';
76
+
77
+ // MANA BEGIN: if there is already applied filter with the same name, then unjoin it from select.
78
+ // TODO: comment on Mage::registry('mana_cat_index_from_condition') after we edit category filters
79
+ $from = array();
80
+ $catIndexCondition = Mage::registry('mana_cat_index_from_condition');
81
+ foreach ($select->getPart(Zend_Db_Select::FROM) as $key => $value) {
82
+ if ($key != $tableAlias) {
83
+ if ($catIndexCondition && ($catIndexCondition == $value['joinCondition'])) {
84
+ $value['joinCondition'] = Mage::registry('mana_cat_index_to_condition');
85
+ }
86
+ $from[$key] = $value;
87
+ }
88
+ }
89
+ $select->setPart(Zend_Db_Select::FROM, $from);
90
+ // MANA END
91
+
92
+ $conditions = array(
93
+ "{$tableAlias}.entity_id = e.entity_id",
94
+ $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
95
+ $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()),
96
+ );
97
+
98
+ $select
99
+ ->join(
100
+ array($tableAlias => $this->getMainTable()),
101
+ join(' AND ', $conditions),
102
+ array('value', 'count' => "COUNT({$tableAlias}.entity_id)"))
103
+ ->group("{$tableAlias}.value");
104
+
105
+ return $connection->fetchPairs($select);
106
+ }
107
+
108
+ }
app/code/local/Mana/Filters/Resource/Filter/Price.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Resource type which contains sql code for applying filters and related operations
10
+ * @author Mana Team
11
+ * Injected instead of standard resource catalog/layer_filter_attribute in
12
+ * Mana_Filters_Model_Filter_Price::_getResource().
13
+ */
14
+ class Mana_Filters_Resource_Filter_Price extends Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Price {
15
+ /**
16
+ * Applies one or more price filters to currently viewed product collection
17
+ * @param Mana_Filters_Model_Filter_Price $filter
18
+ * @param array $selections
19
+ * @return Mana_Filters_Resource_Filter_Price
20
+ * This method is cloned from method applyFilterToCollection() in parent class (method body was pasted from parent class
21
+ * and changed as needed. All changes marked with comments
22
+ * Standard method did not give us possibility to filter multiple ranges.
23
+ */
24
+ public function applyFilterToCollectionEx($filter, $selections)
25
+ {
26
+ $collection = $filter->getLayer()->getProductCollection();
27
+ $collection->addPriceData($filter->getCustomerGroupId(), $filter->getWebsiteId());
28
+
29
+ $select = $collection->getSelect();
30
+ $response = $this->_dispatchPreparePriceEvent($filter, $select);
31
+
32
+ $table = $this->_getIndexTableAlias();
33
+ $additional = join('', $response->getAdditionalCalculations());
34
+ $rate = $filter->getCurrencyRate();
35
+ $priceExpr = new Zend_Db_Expr("(({$table}.min_price {$additional}) * {$rate})");
36
+
37
+ // MANA BEGIN: modify select formation to include multiple price ranges
38
+ /* @var $ext Mana_Filters_Helper_Extended */ $ext = Mage::helper(strtolower('Mana_Filters/Extended'));
39
+ $condition = '';
40
+ foreach ($selections as $selection) {
41
+ list($index, $range) = explode(',', $selection);
42
+ $range = $ext->getPriceRange($index, $range);
43
+ if ($condition != '') $condition .= ' OR ';
44
+ $condition .= '(('.$priceExpr . ' >= '. $range['from'].') '.
45
+ 'AND ('.$priceExpr . ' < '. $range['to'].'))';
46
+ }
47
+ $select
48
+ ->where($condition);
49
+ // MANA END
50
+ return $this;
51
+ }
52
+ /**
53
+ * For each option visible to person as a filter choice counts how many products are there given that all the
54
+ * other filters are applied
55
+ * @param Mana_Filters_Model_Filter_Price $filter
56
+ * @param int $range The whole price range is split into several using this range step
57
+ * @return array Each entry in result is int index => int count
58
+ * This method is overridden by copying (method body was pasted from parent class and modified as needed). All
59
+ * changes are marked with comments.
60
+ * @see Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute::getCount()
61
+ */
62
+ public function getCount($filter, $range)
63
+ {
64
+ $select = $this->_getSelect($filter);
65
+ $connection = $this->_getReadAdapter();
66
+ $response = $this->_dispatchPreparePriceEvent($filter, $select);
67
+ $table = $this->_getIndexTableAlias();
68
+
69
+ $additional = join('', $response->getAdditionalCalculations());
70
+ $rate = $filter->getCurrencyRate();
71
+ $countExpr = new Zend_Db_Expr('COUNT(*)');
72
+ $rangeExpr = new Zend_Db_Expr("FLOOR((({$table}.min_price {$additional}) * {$rate}) / {$range}) + 1");
73
+
74
+ $select->columns(array(
75
+ 'range' => $rangeExpr,
76
+ 'count' => $countExpr
77
+ ));
78
+
79
+ // MANA BEGIN: make sure price filter is not applied
80
+ $select->reset(Zend_Db_Select::WHERE);
81
+ // MANA END
82
+
83
+ $select->where("{$table}.min_price > 0");
84
+ $select->group('range');
85
+
86
+ return $connection->fetchPairs($select);
87
+ }
88
+ /**
89
+ * Retrieve maximal price for attribute
90
+ *
91
+ * @param Mage_Catalog_Model_Layer_Filter_Price $filter
92
+ * @return float
93
+ */
94
+ public function getMaxPrice($filter)
95
+ {
96
+ $select = $this->_getSelect($filter);
97
+ $connection = $this->_getReadAdapter();
98
+ $response = $this->_dispatchPreparePriceEvent($filter, $select);
99
+
100
+ $table = $this->_getIndexTableAlias();
101
+
102
+ $additional = join('', $response->getAdditionalCalculations());
103
+ $maxPriceExpr = new Zend_Db_Expr("MAX({$table}.min_price {$additional})");
104
+
105
+ // MANA BEGIN: make sure no filter is applied
106
+ $select->reset(Zend_Db_Select::WHERE);
107
+ $from = $select->getPart(Zend_Db_Select::FROM);
108
+ foreach ($from as $key => $options) {
109
+ if ($key == 'cat_index') {
110
+ /* @var $layer Mage_Catalog_Model_Layer */ $layer = Mage::getSingleton('catalog/layer');
111
+ $needle = "cat_index.category_id='";
112
+ $startPos = strpos($options['joinCondition'], $needle);
113
+ if ($startPos === false) throw new Exception('Not implemented');
114
+ $endPos = strpos($options['joinCondition'], "'", $startPos + strlen($needle));
115
+ $from[$key]['joinCondition'] =
116
+ substr($options['joinCondition'], 0, $startPos + strlen($needle)).
117
+ $layer->getCurrentCategory()->getId().
118
+ substr($options['joinCondition'], $endPos);
119
+ }
120
+ elseif (strrpos($key, '_idx') === strlen($key) - strlen('_idx')) {
121
+ unset($from[$key]);
122
+ }
123
+ }
124
+ $select->setPart(Zend_Db_Select::FROM, $from);
125
+ // MANA END
126
+ $select->columns(array($maxPriceExpr));
127
+
128
+ return $connection->fetchOne($select) * $filter->getCurrencyRate();
129
+ }
130
+
131
+ }
app/code/local/Mana/Filters/etc/config.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ @category Mana
4
+ @package Mana_Filters
5
+ @copyright Copyright (c) http://www.manadev.com
6
+ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ -->
8
+ <!-- BASED ON SNIPPET: New Module/etc/config.xml -->
9
+ <config>
10
+ <!-- This section registers module with Magento system. -->
11
+ <modules>
12
+ <Mana_Filters>
13
+ <!-- This version number identifies version of database tables specific to this extension. It is written to
14
+ core_resource table. -->
15
+ <version>1.1.0</version>
16
+ </Mana_Filters>
17
+ </modules>
18
+
19
+ <!-- This section contains module settings which are merged into global configuration during each page load,
20
+ each ajax request. -->
21
+ <global>
22
+ <!-- This section registers helper classes to be accessible through Mage::helper() method. Mana_Filters_Helper_Data
23
+ class is accessible through Mage::helper('mana_filters') call, other Mana_Filters_Helper_XXX_YYY classes are accessible
24
+ through Mage::helper('mana_filters/xxx_yyy') call. -->
25
+ <helpers>
26
+ <mana_filters>
27
+ <!-- This says that string 'mana_filters' corresponds to Mana_Filters_Helper pseudo-namespace in
28
+ Mage::helper() calls. -->
29
+ <class>Mana_Filters_Helper</class>
30
+ </mana_filters>
31
+ </helpers>
32
+
33
+ <!-- BASED ON SNIPPET: Blocks/Block support (config.xml) -->
34
+ <!-- This section registers helper classes to be accessible from layout XML files (in type="<block type>") or
35
+ through calls to $this->getLayout()->createBlock('<block type>') in block or controller code. That is,
36
+ Mana_Filters_Block_XXX_YYY classes are accessible as 'mana_filters/xxx_yyy' type strings both in layout files
37
+ and in createBlock() calls. -->
38
+ <blocks>
39
+ <!-- This says that string 'mana_filters' corresponds to Mana_Filters_Block pseudo-namespace in
40
+ layout xml files and in createBlock() calls. -->
41
+ <mana_filters>
42
+ <class>Mana_Filters_Block</class>
43
+ </mana_filters>
44
+ </blocks>
45
+
46
+ <!-- BASED ON SNIPPET: Models/Model support (config.xml) -->
47
+ <!-- This section registers model classes to be accessible through Mage::getModel('<model type>') and through
48
+ Mage::getSingleton('<model type>') calls. That is, Mana_Filters_Model_XXX_YYY classes are accessible as
49
+ 'mana_filters/xxx_yyy' type strings both in getModel() and getSingleton() calls. -->
50
+ <models>
51
+ <!-- This says that string 'mana_filters' corresponds to Mana_Filters_Model pseudo-namespace in
52
+ getModel() and getSingleton() calls. -->
53
+ <mana_filters>
54
+ <class>Mana_Filters_Model</class>
55
+ <!-- BASED ON SNIPPET: Resources/Declare resource section (config.xml) -->
56
+ <!-- This tells Magento to read config/global/models/mana_filters_resources sections and register
57
+ resource model information from there -->
58
+ <resourceModel>mana_filters_resources</resourceModel>
59
+ <!-- INSERT HERE: resource section name -->
60
+ </mana_filters>
61
+
62
+ <!-- BASED ON SNIPPET: Resources/Resource support (config.xml) -->
63
+ <!-- This says that string 'mana_filters' corresponds to Mana_Filters_Resource pseudo-namespace in
64
+ getResourceModel() calls. -->
65
+ <mana_filters_resources>
66
+ <class>Mana_Filters_Resource</class>
67
+ <entities>
68
+ <!-- INSERT HERE: table-entity mappings -->
69
+ </entities>
70
+ </mana_filters_resources>
71
+
72
+ <!-- INSERT HERE: rewrites, ... -->
73
+ </models>
74
+
75
+ <!-- INSERT HERE: blocks, models, ... -->
76
+ </global>
77
+
78
+ <!-- BASED ON SNIPPET: Static Visuals/Frontend section (config.xml) -->
79
+ <!-- This section enables static visual changes in store frontend. -->
80
+ <frontend>
81
+ <!-- BASED ON SNIPPET: Static Visuals/Layout file support (config.xml) -->
82
+ <!-- This section registers additional layout XML file with our module-specific layout changes to be loaded
83
+ and executes during page rendering. -->
84
+ <layout>
85
+ <updates>
86
+ <mana_filters>
87
+ <file>mana_filters.xml</file>
88
+ </mana_filters>
89
+ </updates>
90
+ </layout>
91
+ <!-- BASED ON SNIPPET: Translation support/Frontend (config.xml) -->
92
+ <!-- This section registers additional translation file with our module-specific strings to be loaded
93
+ during frontend request processing -->
94
+ <translate>
95
+ <modules>
96
+ <Mana_Filters>
97
+ <files>
98
+ <default>Mana_Filters.csv</default>
99
+ </files>
100
+ </Mana_Filters>
101
+ </modules>
102
+ </translate>
103
+ <!-- INSERT HERE: layout, translate, routers -->
104
+ </frontend>
105
+ <!-- BASED ON SNIPPET: Static Visuals/Adminhtml section (config.xml) -->
106
+ <!-- This section enables static visual changes in admin area. -->
107
+ <adminhtml>
108
+ <!-- BASED ON SNIPPET: Translation support/Adminhtml (config.xml) -->
109
+ <!-- This section registers additional translation file with our module-specific strings to be loaded
110
+ during admin area request processing -->
111
+ <translate>
112
+ <modules>
113
+ <Mana_Filters>
114
+ <files>
115
+ <default>Mana_Filters.csv</default>
116
+ </files>
117
+ </Mana_Filters>
118
+ </modules>
119
+ </translate>
120
+ <!-- INSERT HERE: layout, translate, routers -->
121
+ </adminhtml>
122
+ <!-- INSERT HERE: adminhtml, frontend, ... -->
123
+
124
+ <!-- This section enumerates configuration based extensibility points and provides default entries -->
125
+ <mana_filters>
126
+ <display><!-- display options for individual filters -->
127
+ <attribute> <!-- available display options for attribute-based filters -->
128
+ <!-- by default, filter items are displayed as HTML list -->
129
+ <list translate="title" module="mana_filters">
130
+ <title>List</title><!-- this one is displayed in admin -->
131
+ <template>mana/filters/items/list.phtml</template><!-- PHTML to be rendered -->
132
+ <position>100</position><!-- Position in "Display as" list. The item with least position is the default one. -->
133
+ </list>
134
+ </attribute>
135
+ <price> <!-- available display options for price filter -->
136
+ <!-- by default, filter items are displayed as HTML list -->
137
+ <list translate="title" module="mana_filters">
138
+ <title>List</title><!-- this one is displayed in admin -->
139
+ <template>mana/filters/items/list.phtml</template><!-- PHTML to be rendered -->
140
+ <position>100</position><!-- Position in "Display as" list. The item with least position is the default one. -->
141
+ </list>
142
+ </price>
143
+ <category> <!-- available display options for category filter -->
144
+ <!-- by default, filter items are displayed as HTML list -->
145
+ <list translate="title" module="mana_filters">
146
+ <title>List</title><!-- this one is displayed in admin -->
147
+ <template>mana/filters/items/list.phtml</template><!-- PHTML to be rendered -->
148
+ <position>100</position><!-- Position in "Display as" list. The item with least position is the default one. -->
149
+ </list>
150
+ </category>
151
+ <decimal> <!-- available display options for decimal filters -->
152
+ <!-- No entries here. We do not know how to handle this by default -->
153
+ </decimal>
154
+ </display>
155
+
156
+ </mana_filters>
157
+ </config>
app/design/frontend/base/default/layout/mana_filters.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ @category Mana
4
+ @package Mana_Filters
5
+ @copyright Copyright (c) http://www.manadev.com
6
+ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ -->
8
+ <!-- BASED ON SNIPPET: Static Visuals/Empty layout file -->
9
+ <!-- This file defines the rules which should be applied when module mana_filters is installed and active. Typically,
10
+ rules consists of the following parts:
11
+ 1. You say on which types of pages you would like your changes to be applied (in Magento wording, you need to
12
+ specify layout handle), for example, layout handle "catalog_category_layered" selects all pages where
13
+ specific category products are shown and where layered navigation is enabled. Layout handle "default" selects
14
+ every each page rendered by Magento.
15
+ 2. You say in which blocks you would like to make the changes (in Magento wording you reference parent block).
16
+ 3. You say what changes you would like to apply to that block (you could specify to remove child blocks, to add
17
+ your own blocks, to invoke methods on referenced block).
18
+ Review standard Magento layout XML's for full list of available layout handles, blocks to be referenced, and for
19
+ examples on what kind of actions can be applied to referenced blocks.
20
+ -->
21
+ <layout version="0.1.0">
22
+ <catalog_category_layered> <!-- find all category pages with layered navigation -->
23
+ <reference name="left"> <!-- find left column block -->
24
+ <remove name="catalog.leftnav"/> <!-- remove standard layered navigation -->
25
+ <block type="mana_filters/view_category" name="mana.catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
26
+ </reference>
27
+ </catalog_category_layered>
28
+ <catalogsearch_result_index> <!-- find all catalog search result page -->
29
+ <reference name="left"> <!-- find left column block -->
30
+ <remove name="catalogsearch.leftnav"/> <!-- remove standard layered navigation -->
31
+ <block type="mana_filters/view_search" name="mana.catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
32
+ </reference>
33
+ </catalogsearch_result_index>
34
+ </layout>
app/design/frontend/base/default/template/mana/filters/items/list.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Mana
4
+ * @package Mana_Filters
5
+ * @copyright Copyright (c) http://www.manadev.com
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ /**
9
+ * Template for showing options for filter as a HTML list
10
+ * @author Mana Team
11
+ * Injected instead of standard catalog/layer/filter.phtml in Mana_Filters_Block_Filter_Attribute constructor.
12
+ * This template is overridden by copying (template body was pasted from catalog/layer/filter.phtml
13
+ * and modified as needed). All changes are marked with comments.
14
+ */
15
+ /* @var $this Mana_Filters_Block_Filter_Attribute */
16
+ ?>
17
+ <?php /* @var $_ext Mana_Filters_Helper_Extended */ $_ext = Mage::helper(strtolower('Mana_Filters/Extended')); ?>
18
+ <ol>
19
+ <?php foreach ($this->getItems() as $_item): ?>
20
+ <li>
21
+ <?php // MANA BEGIN ?>
22
+ <?php if ($_item->getMSelected()): ?>
23
+ <span class="m-selected-filter-item"><?php echo $_item->getLabel() ?></span>
24
+ <?php else : ?>
25
+ <?php if ($_item->getCount() > 0): ?>
26
+ <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
27
+ <?php else: echo $_item->getLabel() ?>
28
+ <?php endif; ?>
29
+ <?php endif; ?>
30
+ <?php // MANA END ?>
31
+ (<?php echo $_item->getCount() ?>)
32
+ </li>
33
+ <?php endforeach ?>
34
+ </ol>
35
+ <?php echo $_ext->getNamedHtml('show_more', array('block' => $this)) ?>
app/etc/modules/Mana_Filters.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ @category Mana
4
+ @package Mana_Filters
5
+ @copyright Copyright (c) http://www.manadev.com
6
+ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ -->
8
+ <!-- BASED ON SNIPPET: New Module/etc/modules/<module>.xml -->
9
+ <config>
10
+ <!-- This section activates module in Magento system. -->
11
+ <modules>
12
+ <Mana_Filters>
13
+ <!-- This actually an activation instruction. You can set it to false to temporarily deactivate module (
14
+ in this case Magento will behave as if module does not exist). -->
15
+ <active>true</active>
16
+ <!-- This instructs Magento to search for module code in app/code/local directory. -->
17
+ <codePool>local</codePool>
18
+ <!-- This declares our module dependency on other modules and instructs Magento to load our module
19
+ after these modules. -->
20
+ <depends>
21
+ <Mage_Catalog />
22
+ <Mage_CatalogSearch />
23
+ </depends>
24
+ </Mana_Filters>
25
+ </modules>
26
+ </config>
app/locale/en_US/Mana_Filters.csv ADDED
@@ -0,0 +1,2 @@
 
 
1
+ "Filters of type ""%s"" can not be displayed - no template installed.","Filters of type ""%s"" can not be displayed - no template installed."
2
+ "List","List"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Mana_Filters</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Advanced layered navigation</summary>
10
+ <description>Add multiple selection features for attribute and price filters in Magento layered navigation</description>
11
+ <notes>Release notes for users and developers</notes>
12
+ <authors><author><name>Mana Team</name><user>auto-converted</user><email>team@manadev.com</email></author></authors>
13
+ <date>2011-05-25</date>
14
+ <time>15:27:34</time>
15
+ <contents><target name="magelocale"><dir name="en_US"><file name="Mana_Filters.csv" hash="7cbfd6ded4829ef8559c5bf7247d49cf"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mana_filters.xml" hash="12018b1fce14f58fd454dcfbca70c0f7"/></dir><dir name="template"><dir name="mana"><dir name="filters"><dir name="items"><file name="list.phtml" hash="b9687285113279f922353a07b21ffca0"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Mana"><dir name="Filters"><dir name="Block"><dir name="Filter"><file name="Attribute.php" hash="19afbe32ec264c1147df9e545406c99a"/><file name="Category.php" hash="f08b3e39f583e1705dc2bda82d44f8ba"/><file name="Decimal.php" hash="c2406a87202a54dfcd789440287e4e62"/><file name="Price.php" hash="96bdb9f2282d78d987c859b4bbd2d466"/><dir name="Attribute"><file name="Search.php" hash="bea74954f81e1f7c0fdeaa26177f56c6"/></dir></dir><dir name="View"><file name="Category.php" hash="54a2b62e7177994d45324b2b718a979e"/><file name="Search.php" hash="054b82a37b566ad6394d6d36decd195a"/></dir></dir><dir name="etc"><file name="config.xml" hash="10a9c36fd45ab1a60c2ce07ede46fdd6"/></dir><dir name="Helper"><file name="Data.php" hash="f6a2bfdcdc84c52503f3b2efb367b3c8"/><file name="Extended.php" hash="9a8bb6e655ed7054787f4ac8b45803fd"/></dir><dir name="Model"><file name="Item.php" hash="078f13d0040fa506119eaa312b730458"/><dir name="Filter"><file name="Attribute.php" hash="9183b3616743a320ac4ed019fa0ac026"/><file name="Category.php" hash="165b9e9ea332ab2db8608f0bc2aa3ae6"/><file name="Price.php" hash="9ed25dca2fdbf08c20ccb0b56a6efea9"/><dir name="Attribute"><file name="Search.php" hash="eb8ecb0ac2cd035b25124ee68828ff3a"/></dir></dir></dir><dir name="Resource"><dir name="Filter"><file name="Attribute.php" hash="eded20fdd1e50a22e770b5828acf3048"/><file name="Price.php" hash="14321ed677abc35a7b2560f22f1c49ce"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mana_Filters.xml" hash="262a99d3ab3e0c929317cdb2193393fb"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>