Magehouse_Slider - Version 2.0.0

Version Notes

First Release

Features:

- Customization of slider theme from backend.
- Can use both Images and background color for the slider.
- Can specify whether to include the jQuery or not.

Relase Notes 1.0.2

- Fixed bug : jQuery & jQuery UI not getting included.

Relase Notes 1.0.3

- Fixed bug : Do not Use Images has no effect on frontend.

Relase Notes 1.0.4

- Added : Special Price in filtering

Relase Notes 1.0.5

Bugs Solved :
- Currency symbol do not change - Solved

Improvements:
- Removed theme file dependency

Relase Notes 2.0.0

Bugs Solved :
- Catalog search not working - Solved

Improvements:
- Price Slider now available on search page also

Download this release

Release Info

Developer Mrugesh Mistry
Extension Magehouse_Slider
Version 2.0.0
Comparing to
See all releases


Code changes from version 1.0.5 to 2.0.0

app/code/community/Magehouse/Slider/Block/Catalog/Layer/Filter/Price.php CHANGED
@@ -10,6 +10,7 @@ class Magehouse_Slider_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Blo
10
  {
11
 
12
  public $_currentCategory;
 
13
  public $_productCollection;
14
  public $_maxPrice;
15
  public $_minPrice;
@@ -20,11 +21,13 @@ class Magehouse_Slider_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Blo
20
  public function __construct(){
21
 
22
  $this->_currentCategory = Mage::registry('current_category');
 
23
  $this->setProductCollection();
24
  $this->setMinPrice();
25
  $this->setMaxPrice();
26
  $this->setCurrentPrices();
27
  $this->_imagePath = $this->getUrl('media/magehouse/slider');
 
28
  parent::__construct();
29
  }
30
 
@@ -70,7 +73,9 @@ class Magehouse_Slider_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Blo
70
  }
71
 
72
  public function getSliderJs(){
73
- $baseUrl = $this->_currentCategory->getUrl();
 
 
74
  $timeout = $this->getConfig('price_slider/price_slider_conf/timeout');
75
  $styles = $this->prepareCustomStyles();
76
  if($this->_currMaxPrice > 0){$max = $this->_currMaxPrice;} else{$max = $this->_maxPrice;}
@@ -89,7 +94,7 @@ class Magehouse_Slider_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Blo
89
  var x1 = ui.values[0];
90
  var x2 = ui.values[1];
91
  $( "#amount" ).val( "'.$this->getCurrencySymbol().'"+x1+" - '.$this->getCurrencySymbol().'"+x2 );
92
- var url = "'.$baseUrl.'"+"/?min="+x1+"&max="+x2+"'.$this->prepareParams().'";
93
  if(x1 != '.$min.' && x2 != '.$max.'){
94
  clearTimeout(timer);
95
  window.location= url;
@@ -161,22 +166,42 @@ class Magehouse_Slider_Block_Catalog_Layer_Filter_Price extends Mage_Catalog_Blo
161
  }
162
 
163
  public function setMinPrice(){
 
164
  $this->_minPrice = $this->_productCollection
165
  ->getFirstItem()
166
  ->getPrice();
 
 
 
 
 
167
  }
168
 
169
  public function setMaxPrice(){
 
170
  $this->_maxPrice = $this->_productCollection
171
  ->getLastItem()
172
  ->getPrice();
 
 
 
 
173
  }
174
 
175
  public function setProductCollection(){
176
- $this->_productCollection = $this->_currentCategory
 
 
177
  ->getProductCollection()
178
  ->addAttributeToSelect('*')
179
  ->setOrder('price', 'ASC');
 
 
 
 
 
 
 
180
  }
181
 
182
  public function setCurrentPrices(){
10
  {
11
 
12
  public $_currentCategory;
13
+ public $_searchSession;
14
  public $_productCollection;
15
  public $_maxPrice;
16
  public $_minPrice;
21
  public function __construct(){
22
 
23
  $this->_currentCategory = Mage::registry('current_category');
24
+ $this->_searchSession = Mage::getSingleton('catalogsearch/session');
25
  $this->setProductCollection();
26
  $this->setMinPrice();
27
  $this->setMaxPrice();
28
  $this->setCurrentPrices();
29
  $this->_imagePath = $this->getUrl('media/magehouse/slider');
30
+
31
  parent::__construct();
32
  }
33
 
73
  }
74
 
75
  public function getSliderJs(){
76
+
77
+ $baseUrl = explode('?',Mage::helper('core/url')->getCurrentUrl());
78
+ $baseUrl = $baseUrl[0];
79
  $timeout = $this->getConfig('price_slider/price_slider_conf/timeout');
80
  $styles = $this->prepareCustomStyles();
81
  if($this->_currMaxPrice > 0){$max = $this->_currMaxPrice;} else{$max = $this->_maxPrice;}
94
  var x1 = ui.values[0];
95
  var x2 = ui.values[1];
96
  $( "#amount" ).val( "'.$this->getCurrencySymbol().'"+x1+" - '.$this->getCurrencySymbol().'"+x2 );
97
+ var url = "'.$baseUrl.'"+"?min="+x1+"&max="+x2+"'.$this->prepareParams().'";
98
  if(x1 != '.$min.' && x2 != '.$max.'){
99
  clearTimeout(timer);
100
  window.location= url;
166
  }
167
 
168
  public function setMinPrice(){
169
+ if( (isset($_GET['q']) && !isset($_GET['min'])) || !isset($_GET['q'])){
170
  $this->_minPrice = $this->_productCollection
171
  ->getFirstItem()
172
  ->getPrice();
173
+ $this->_searchSession->setMinPrice($this->_minPrice);
174
+
175
+ }else{
176
+ $this->_minPrice = $this->_searchSession->getMinPrice();
177
+ }
178
  }
179
 
180
  public function setMaxPrice(){
181
+ if( (isset($_GET['q']) && !isset($_GET['max'])) || !isset($_GET['q'])){
182
  $this->_maxPrice = $this->_productCollection
183
  ->getLastItem()
184
  ->getPrice();
185
+ $this->_searchSession->setMaxPrice($this->_maxPrice);
186
+ }else{
187
+ $this->_maxPrice = $this->_searchSession->getMaxPrice();
188
+ }
189
  }
190
 
191
  public function setProductCollection(){
192
+
193
+ if($this->_currentCategory){
194
+ $this->_productCollection = $this->_currentCategory
195
  ->getProductCollection()
196
  ->addAttributeToSelect('*')
197
  ->setOrder('price', 'ASC');
198
+ }else{
199
+ $this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection()
200
+ ->addAttributeToSelect('*')
201
+ ->setOrder('price', 'ASC');
202
+
203
+ }
204
+
205
  }
206
 
207
  public function setCurrentPrices(){
app/code/community/Magehouse/Slider/Model/Catalogsearch/Layer.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_CatalogSearch
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Magehouse_Slider_Model_Catalogsearch_Layer extends Mage_CatalogSearch_Model_Layer
28
+ {
29
+ const XML_PATH_DISPLAY_LAYER_COUNT = 'catalog/search/use_layered_navigation_count';
30
+
31
+ /**
32
+ * Get current layer product collection
33
+ *
34
+ * @return Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection
35
+ */
36
+ public function getProductCollection()
37
+ {
38
+ if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
39
+ $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
40
+ } else {
41
+ $collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
42
+ $this->prepareProductCollection($collection);
43
+
44
+ $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
45
+ }
46
+ return $collection;
47
+ }
48
+
49
+ /**
50
+ * Prepare product collection
51
+ *
52
+ * @param Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection $collection
53
+ * @return Mage_Catalog_Model_Layer
54
+ */
55
+ public function prepareProductCollection($collection)
56
+ {
57
+ $collection
58
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
59
+ ->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())
60
+ ->setStore(Mage::app()->getStore())
61
+ ->addMinimalPrice()
62
+ ->addFinalPrice()
63
+ ->addTaxPercents()
64
+ ->addStoreFilter()
65
+ ->addUrlRewrite();
66
+
67
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
68
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
69
+
70
+ /*PRICE SLIDER FILTER*/
71
+ $max=$_GET['max'];
72
+ $min=$_GET['min'];
73
+
74
+ //print_r($collection->getData());
75
+
76
+ if($min && $max){
77
+ //$collection= $collection->addAttributeToFilter('price',array('from'=>$min, 'to'=>$max));
78
+ $collection->getSelect()->where(' final_price >= "'.$min.'" AND final_price <= "'.$max.'" ');
79
+
80
+ //echo $collection->getSelect();exit;
81
+ }
82
+
83
+ /*PRICE SLIDER FILTER*/
84
+
85
+
86
+
87
+ return $this;
88
+ }
89
+
90
+
91
+
92
+
93
+
94
+
95
+ }
app/code/community/Magehouse/Slider/etc/config.xml CHANGED
@@ -24,6 +24,11 @@
24
  <layer>Magehouse_Slider_Model_Catalog_Layer</layer>
25
  </rewrite>
26
  </catalog>
 
 
 
 
 
27
  </models>
28
  </global>
29
  <frontend>
24
  <layer>Magehouse_Slider_Model_Catalog_Layer</layer>
25
  </rewrite>
26
  </catalog>
27
+ <catalogsearch>
28
+ <rewrite>
29
+ <layer>Magehouse_Slider_Model_Catalogsearch_Layer</layer>
30
+ </rewrite>
31
+ </catalogsearch>
32
  </models>
33
  </global>
34
  <frontend>
app/design/frontend/base/default/layout/slider.xml CHANGED
@@ -17,4 +17,21 @@
17
  <action method="addCss" ifconfig="price_slider/price_slider_settings/slider_loader_active"><script>css/slider/jquery-ui-1.8.23.custom.css</script></action>
18
  </reference>
19
  </catalog_category_view>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  </layout>
17
  <action method="addCss" ifconfig="price_slider/price_slider_settings/slider_loader_active"><script>css/slider/jquery-ui-1.8.23.custom.css</script></action>
18
  </reference>
19
  </catalog_category_view>
20
+ <catalogsearch_result_index>
21
+ <reference name="head">
22
+ <block type="core/text" name="google.cdn.jquery.slider" >
23
+ <action method="setText" ifconfig="price_slider/price_slider_settings/include_jquery">
24
+ <text><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>]]> </text>
25
+ </action>
26
+ </block>
27
+
28
+ <block type="core/text" name="google.cdn.jquery.ui" >
29
+ <action method="setText" ifconfig="price_slider/price_slider_settings/include_jquery_ui">
30
+ <text><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>]]></text>
31
+ </action>
32
+ </block>
33
+
34
+ <action method="addCss" ifconfig="price_slider/price_slider_settings/slider_loader_active"><script>css/slider/jquery-ui-1.8.23.custom.css</script></action>
35
+ </reference>
36
+ </catalogsearch_result_index>
37
  </layout>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magehouse_Slider</name>
4
- <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -37,11 +37,19 @@ Bugs Solved :&#xD;
37
  &#xD;
38
  Improvements:&#xD;
39
  - Removed theme file dependency&#xD;
 
 
 
 
 
 
 
 
40
  </notes>
41
  <authors><author><name>Mrugesh Mistry</name><user>mrugeshrocks</user><email>mrugesh.rocks@gmail.com</email></author></authors>
42
- <date>2012-11-06</date>
43
- <time>22:12:01</time>
44
- <contents><target name="magecommunity"><dir name="Magehouse"><dir name="Slider"><dir name="Block"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><dir name="Price"><file name="Slider.php" hash="a856cbd9e4d8e8dc7355f5d2258988bb"/></dir><file name="Price.php" hash="4b96409f75ca21f0ae4cd9afda4b9daa"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a065b8f56bbda2943734e76139883220"/></dir><dir name="Model"><dir name="Catalog"><file name="Layer.php" hash="6a721e4f0118d0353a9f6b7838c5aeaf"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c728cee82276d42e77808bf48fdd0cdf"/><file name="config.xml" hash="d407f9a60301cc33eedcf607445ad68d"/><file name="system.xml" hash="3c7bd19dd730500a9271f762624552ce"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magehouse_Slider.xml" hash="43112ba587c13efb57d3b9471498a814"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="slider"><dir name="images"><file name="Thumbs.db" hash="c192da3c422ad168eecbe155887757f4"/><file name="ui-bg_diagonals-thick_18_b81900_40x40.png" hash="95f9cceeb9d742dd3e917ec16ed754f8"/><file name="ui-bg_diagonals-thick_20_666666_40x40.png" hash="f040b255ca13e693da34ab33c7d6b554"/><file name="ui-bg_flat_10_000000_40x100.png" hash="c18cd01623c7fed23c80d53e2f5e7c78"/><file name="ui-bg_glass_100_f6f6f6_1x400.png" hash="4c494f261d76fd2c344853b64a09371b"/><file name="ui-bg_glass_100_fdf5ce_1x400.png" hash="4c494f261d76fd2c344853b64a09371b"/><file name="ui-bg_glass_65_ffffff_1x400.png" hash="4c494f261d76fd2c344853b64a09371b"/><file name="ui-bg_gloss-wave_35_f6a828_500x100.png" hash="8c06b9c15ea2bef5ff5f1c7468bdc106"/><file name="ui-bg_highlight-soft_100_eeeeee_1x100.png" hash="f00e2ff3af640da7ee8915791b947349"/><file name="ui-bg_highlight-soft_75_ffe45c_1x100.png" hash="b806658954cb4d16ade8977af737f486"/><file name="ui-icons_222222_256x240.png" hash="ebe6b6902a408fbf9cac6379a1477525"/><file name="ui-icons_228ef1_256x240.png" hash="79f41c0765e9ec18562b20b0801d748b"/><file name="ui-icons_ef8c08_256x240.png" hash="ef9a6ccfe3b14041928ddc708665b226"/><file name="ui-icons_ffd27a_256x240.png" hash="39c5a5f53ff0e6cebaec731706427bbb"/><file name="ui-icons_ffffff_256x240.png" hash="342bc03f6264c75d3f1d7f99e34295b9"/></dir><file name="jquery-ui-1.8.23.custom.css" hash="408147096939c6ddb0becced6cdc1197"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="slider.xml" hash="059f6a61697fda8974f1dc52e9cf291d"/></dir></dir></dir></dir></target></contents>
45
  <compatible/>
46
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
47
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magehouse_Slider</name>
4
+ <version>2.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
37
  &#xD;
38
  Improvements:&#xD;
39
  - Removed theme file dependency&#xD;
40
+ &#xD;
41
+ Relase Notes 2.0.0&#xD;
42
+ &#xD;
43
+ Bugs Solved :&#xD;
44
+ - Catalog search not working - Solved&#xD;
45
+ &#xD;
46
+ Improvements:&#xD;
47
+ - Price Slider now available on search page also&#xD;
48
  </notes>
49
  <authors><author><name>Mrugesh Mistry</name><user>mrugeshrocks</user><email>mrugesh.rocks@gmail.com</email></author></authors>
50
+ <date>2012-11-07</date>
51
+ <time>21:46:51</time>
52
+ <contents><target name="magecommunity"><dir name="Magehouse"><dir name="Slider"><dir name="Block"><dir name="Catalog"><dir name="Layer"><dir name="Filter"><dir name="Price"><file name="Slider.php" hash="a856cbd9e4d8e8dc7355f5d2258988bb"/></dir><file name="Price.php" hash="85e227e7f5ecda256e42b832956cfe54"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a065b8f56bbda2943734e76139883220"/></dir><dir name="Model"><dir name="Catalog"><file name="Layer.php" hash="6a721e4f0118d0353a9f6b7838c5aeaf"/></dir><dir name="Catalogsearch"><file name="Layer.php" hash="e75760252676747cd68039c6ba4920f6"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c728cee82276d42e77808bf48fdd0cdf"/><file name="config.xml" hash="f5766d492dcc0aef353d97b07c201620"/><file name="system.xml" hash="3c7bd19dd730500a9271f762624552ce"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magehouse_Slider.xml" hash="43112ba587c13efb57d3b9471498a814"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="slider"><dir name="images"><file name="Thumbs.db" hash="c192da3c422ad168eecbe155887757f4"/><file name="ui-bg_diagonals-thick_18_b81900_40x40.png" hash="95f9cceeb9d742dd3e917ec16ed754f8"/><file name="ui-bg_diagonals-thick_20_666666_40x40.png" hash="f040b255ca13e693da34ab33c7d6b554"/><file name="ui-bg_flat_10_000000_40x100.png" hash="c18cd01623c7fed23c80d53e2f5e7c78"/><file name="ui-bg_glass_100_f6f6f6_1x400.png" hash="4c494f261d76fd2c344853b64a09371b"/><file name="ui-bg_glass_100_fdf5ce_1x400.png" hash="4c494f261d76fd2c344853b64a09371b"/><file name="ui-bg_glass_65_ffffff_1x400.png" hash="4c494f261d76fd2c344853b64a09371b"/><file name="ui-bg_gloss-wave_35_f6a828_500x100.png" hash="8c06b9c15ea2bef5ff5f1c7468bdc106"/><file name="ui-bg_highlight-soft_100_eeeeee_1x100.png" hash="f00e2ff3af640da7ee8915791b947349"/><file name="ui-bg_highlight-soft_75_ffe45c_1x100.png" hash="b806658954cb4d16ade8977af737f486"/><file name="ui-icons_222222_256x240.png" hash="ebe6b6902a408fbf9cac6379a1477525"/><file name="ui-icons_228ef1_256x240.png" hash="79f41c0765e9ec18562b20b0801d748b"/><file name="ui-icons_ef8c08_256x240.png" hash="ef9a6ccfe3b14041928ddc708665b226"/><file name="ui-icons_ffd27a_256x240.png" hash="39c5a5f53ff0e6cebaec731706427bbb"/><file name="ui-icons_ffffff_256x240.png" hash="342bc03f6264c75d3f1d7f99e34295b9"/></dir><file name="jquery-ui-1.8.23.custom.css" hash="408147096939c6ddb0becced6cdc1197"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="slider.xml" hash="da969ff5627360deff16fcdaba4468ed"/></dir></dir></dir></dir></target></contents>
53
  <compatible/>
54
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
55
  </package>