Strategery_InfiniteScroll2 - Version 2.1.6

Version Notes

Automatic load next page of current product list.
Support for Magento 1.3 up to 1.7.2

Download this release

Release Info

Developer Magento Core Team
Extension Strategery_InfiniteScroll2
Version 2.1.6
Comparing to
See all releases


Code changes from version 2.1.5 to 2.1.6

app/code/community/Strategery/Infinitescroll2/Model/Catalog/Observer.php CHANGED
@@ -21,117 +21,131 @@ class Strategery_Infinitescroll2_Model_Catalog_Observer
21
 
22
  public function modifyCollection($observer)
23
  {
24
- // reset:
25
- $this->hardReset();
26
- // helper:
27
- $helper = Mage::helper('infinitescroll2');
28
- // observer data:
29
- $event = $observer->getEvent();
30
- $cacheName = str_replace('/','_',Mage::app()->getRequest()->getRequestString());
31
- if(Mage::registry('current_category'))
32
- {
33
- $cacheName = Mage::registry('current_category')->getId();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
- $collection = $this->_getCache($observer, $cacheName);
36
- $lastPageNumber = $collection->getLastPageNumber();
37
- if(Mage::registry('current_category') && $helper->isMemoryActive() && $lastPageNumber>1)
38
- {
39
- // info:
40
- $pageId = Mage::registry('current_category')->getId();
41
- $pageByParam = $helper->getNextPageNumber();
42
- $pageLoaded = $helper->loadMemory($pageId);
43
- // default page size save:
44
- $defaultPageSize = $collection->getPageSize();
45
- Mage::getSingleton('checkout/session')->setData('defautlPageSize',$defaultPageSize);
46
- // actions:
47
- if(!$helper->isScrollCall())
48
- {
49
- if(!Mage::getSingleton('checkout/session')->getData('recursiveCollection'))
50
- {
51
- if($pageLoaded>1)
52
- {
53
- Mage::getSingleton('checkout/session')->setData('recursiveCollection',true);
54
- Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageLoaded);
55
- // replace page size:
56
- $tmpPageSize = $defaultPageSize*$pageLoaded;
57
- $collection->setPageSize($tmpPageSize);
58
- }
59
- else
60
- {
61
- Mage::getSingleton('checkout/session')->setData('pageLoaded','');
62
- Mage::getSingleton('checkout/session')->setData('nextPage','');
63
- }
64
- }
65
- }
66
- else
67
- {
68
- $nextPage = Mage::getSingleton('checkout/session')->getData('nextPage');
69
- if($pageLoaded>$nextPage)
70
- {
71
- $nextPage = $pageLoaded+1;
72
- }
73
- if($nextPage>1 && $nextPage<=$lastPageNumber)
74
- {
75
- $pageByParam=$nextPage;
76
- }
77
- if($nextPage<=$lastPageNumber)
78
- {
79
- $helper->saveMemory($pageByParam,$pageId);
80
- }
81
- $collection->setCurPage($pageByParam);
82
- Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageByParam);
83
- }
84
- }
85
- return $this;
86
  }
87
 
88
  public function restoreCollection($observer)
89
  {
90
- // helper:
91
- $helper = Mage::helper('infinitescroll2');
92
- // observer data:
93
- $event = $observer->getEvent();
94
- $collection = $event->getCollection();
95
- $lastPageNumber = $collection->getLastPageNumber();
96
- if(Mage::registry('current_category') && $helper->isMemoryActive() && $lastPageNumber>1)
97
- {
98
- // info:
99
- $pageLoaded = Mage::getSingleton('checkout/session')->getData('pageLoaded');
100
- $nextPageSaved = Mage::getSingleton('checkout/session')->getData('nextPage');
101
- $tmpNext = false;
102
- // restore page number:
103
- $restorePageSize = Mage::getSingleton('checkout/session')->getData('defautlPageSize');
104
- $collection->setPageSize($restorePageSize);
105
- Mage::getSingleton('checkout/session')->setData('recursiveCollection',false);
106
- // last page:
107
- $lastPageNumber = $collection->getLastPageNumber();
108
- // actions:
109
- if(Mage::getSingleton('checkout/session')->getData('recursiveCollection'))
110
- {
111
- if($pageLoaded>1)
112
- {
113
- $tmpNext=$pageLoaded+1;
114
- if($tmpNext<=$lastPageNumber)
115
- {
116
- Mage::getSingleton('checkout/session')->setData('nextPage',$tmpNext);
117
- }
118
- $collection->setCurPage($pageLoaded);
119
- }
120
- }
121
- if(!$tmpNext)
122
- {
123
- $tmpNext=$pageLoaded+1;
124
- }
125
- if($helper->isScrollCall() && $nextPageSaved>$lastPageNumber)
126
- {
127
- die();
128
- }
129
- if($helper->isScrollCall() && $pageLoaded>1 && $pageLoaded<=$lastPageNumber)
130
- {
131
- Mage::getSingleton('checkout/session')->setData('nextPage',$tmpNext);
132
- }
133
- }
134
- return $this;
 
 
 
 
 
135
  }
136
 
137
  public function hardReset()
@@ -154,6 +168,15 @@ class Strategery_Infinitescroll2_Model_Catalog_Observer
154
  }
155
  }
156
 
 
 
 
 
 
 
 
 
 
157
  protected function _getCache ($observer, $categoryId)
158
  {
159
  $collection = $observer->getCollection();
21
 
22
  public function modifyCollection($observer)
23
  {
24
+ // check general and instance enable:
25
+ $whereare = $this->_whereAreWe();
26
+ if(Mage::getStoreConfig('infinitescroll2/general/enable') && Mage::getStoreConfig('infinitescroll2/instances/'.$whereare))
27
+ {
28
+ // reset:
29
+ $this->hardReset();
30
+ // helper:
31
+ $helper = Mage::helper('infinitescroll2');
32
+ // observer data:
33
+ $event = $observer->getEvent();
34
+ $cacheName = str_replace('/','_',Mage::app()->getRequest()->getRequestString());
35
+ if(Mage::registry('current_category'))
36
+ {
37
+ $cacheName = Mage::registry('current_category')->getId();
38
+ }
39
+ $collection = $this->_getCache($observer, $cacheName);
40
+ $lastPageNumber = $collection->getLastPageNumber();
41
+ if(Mage::registry('current_category') && $helper->isMemoryActive() && $lastPageNumber>1)
42
+ {
43
+ // info:
44
+ $pageId = Mage::registry('current_category')->getId();
45
+ $pageByParam = $helper->getNextPageNumber();
46
+ $pageLoaded = $helper->loadMemory($pageId);
47
+ // chek page size or default
48
+ if (Mage::getStoreConfig('infinitescroll2/instances/size_'.$whereare.''))
49
+ $defaultPageSize = Mage::getStoreConfig('infinitescroll2/instances/size_'.$whereare.'');
50
+ else
51
+ $defaultPageSize = $collection->getPageSize();
52
+
53
+ Mage::getSingleton('checkout/session')->setData('defautlPageSize',$defaultPageSize);
54
+ // actions:
55
+ if(!$helper->isScrollCall())
56
+ {
57
+ if(!Mage::getSingleton('checkout/session')->getData('recursiveCollection'))
58
+ {
59
+ if($pageLoaded>1)
60
+ {
61
+ Mage::getSingleton('checkout/session')->setData('recursiveCollection',true);
62
+ Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageLoaded);
63
+ // replace page size:
64
+ $tmpPageSize = $defaultPageSize*$pageLoaded;
65
+ $collection->setPageSize($tmpPageSize);
66
+ }
67
+ else
68
+ {
69
+ Mage::getSingleton('checkout/session')->setData('pageLoaded','');
70
+ Mage::getSingleton('checkout/session')->setData('nextPage','');
71
+ }
72
+ }
73
+ }
74
+ else
75
+ {
76
+ $nextPage = Mage::getSingleton('checkout/session')->getData('nextPage');
77
+ if($pageLoaded>$nextPage)
78
+ {
79
+ $nextPage = $pageLoaded+1;
80
+ }
81
+ if($nextPage>1 && $nextPage<=$lastPageNumber)
82
+ {
83
+ $pageByParam=$nextPage;
84
+ }
85
+ if($nextPage<=$lastPageNumber)
86
+ {
87
+ $helper->saveMemory($pageByParam,$pageId);
88
+ }
89
+ $collection->setCurPage($pageByParam);
90
+ Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageByParam);
91
+ }
92
+ }
93
+ return $this;
94
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
  public function restoreCollection($observer)
98
  {
99
+ // check general and instance enable:
100
+ $whereare = $this->_whereAreWe();
101
+ if(Mage::getStoreConfig('infinitescroll2/general/enable') && Mage::getStoreConfig('infinitescroll2/instances/'.$whereare))
102
+ {
103
+ // helper:
104
+ $helper = Mage::helper('infinitescroll2');
105
+ // observer data:
106
+ $event = $observer->getEvent();
107
+ $collection = $event->getCollection();
108
+ $lastPageNumber = $collection->getLastPageNumber();
109
+ if(Mage::registry('current_category') && $helper->isMemoryActive() && $lastPageNumber>1)
110
+ {
111
+ // info:
112
+ $pageLoaded = Mage::getSingleton('checkout/session')->getData('pageLoaded');
113
+ $nextPageSaved = Mage::getSingleton('checkout/session')->getData('nextPage');
114
+ $tmpNext = false;
115
+ // restore page number:
116
+ $restorePageSize = Mage::getSingleton('checkout/session')->getData('defautlPageSize');
117
+ $collection->setPageSize($restorePageSize);
118
+ Mage::getSingleton('checkout/session')->setData('recursiveCollection',false);
119
+ // last page:
120
+ $lastPageNumber = $collection->getLastPageNumber();
121
+ // actions:
122
+ if(Mage::getSingleton('checkout/session')->getData('recursiveCollection'))
123
+ {
124
+ if($pageLoaded>1)
125
+ {
126
+ $tmpNext=$pageLoaded+1;
127
+ if($tmpNext<=$lastPageNumber)
128
+ {
129
+ Mage::getSingleton('checkout/session')->setData('nextPage',$tmpNext);
130
+ }
131
+ $collection->setCurPage($pageLoaded);
132
+ }
133
+ }
134
+ if(!$tmpNext)
135
+ {
136
+ $tmpNext=$pageLoaded+1;
137
+ }
138
+ if($helper->isScrollCall() && $nextPageSaved>$lastPageNumber)
139
+ {
140
+ die();
141
+ }
142
+ if($helper->isScrollCall() && $pageLoaded>1 && $pageLoaded<=$lastPageNumber)
143
+ {
144
+ Mage::getSingleton('checkout/session')->setData('nextPage',$tmpNext);
145
+ }
146
+ }
147
+ return $this;
148
+ }
149
  }
150
 
151
  public function hardReset()
168
  }
169
  }
170
 
171
+ protected function _whereAreWe()
172
+ {
173
+ if (Mage::registry('current_category')) { $where = "grid"; }
174
+ if (Mage::registry('current_category')->getIsAnchor()){ $where = "layer"; }
175
+ if (Mage::app()->getRequest()->getControllerName() == "result"){ $where = "search"; }
176
+ if (Mage::app()->getRequest()->getControllerName() == "advanced") { $where = "advanced"; }
177
+ return $where;
178
+ }
179
+
180
  protected function _getCache ($observer, $categoryId)
181
  {
182
  $collection = $observer->getCollection();
app/code/community/Strategery/Infinitescroll2/etc/system.xml CHANGED
@@ -67,6 +67,88 @@
67
  </debug>
68
  </fields>
69
  </general>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  <cache translate="label">
71
  <label>Cache</label>
72
  <frontend_type>text</frontend_type>
@@ -274,6 +356,7 @@
274
  <label>Processed Callback</label>
275
  <frontend_type>textarea</frontend_type>
276
  <sort_order>1</sort_order>
 
277
  <show_in_default>1</show_in_default>
278
  <show_in_website>1</show_in_website>
279
  <show_in_store>1</show_in_store>
67
  </debug>
68
  </fields>
69
  </general>
70
+ <instances translate="label">
71
+ <label>Instances</label>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>1</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <fields>
78
+ <grid>
79
+ <label>Use in Grid/List mode</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>0</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </grid>
87
+ <size_grid>
88
+ <label>Page size (Grid/List)</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>1</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ <comment>Default page size will be used if blank.</comment>
95
+ </size_grid>
96
+ <layer>
97
+ <label>Use in Layer mode</label>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>adminhtml/system_config_source_yesno</source_model>
100
+ <sort_order>2</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </layer>
105
+ <size_layer>
106
+ <label>Page size (Layer)</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>3</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ <comment>Default page size will be used if blank.</comment>
113
+ </size_layer>
114
+ <search>
115
+ <label>Use in Search</label>
116
+ <frontend_type>select</frontend_type>
117
+ <source_model>adminhtml/system_config_source_yesno</source_model>
118
+ <sort_order>4</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </search>
123
+ <size_search>
124
+ <label>Page size (Search)</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>5</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ <comment>Default page size will be used if blank.</comment>
131
+ </size_search>
132
+ <advanced>
133
+ <label>Use in Advanced Search</label>
134
+ <frontend_type>select</frontend_type>
135
+ <source_model>adminhtml/system_config_source_yesno</source_model>
136
+ <sort_order>6</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ </advanced>
141
+ <size_advanced>
142
+ <label>Page size (Advanced Search)</label>
143
+ <frontend_type>text</frontend_type>
144
+ <sort_order>7</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ <comment>Default page size will be used if blank.</comment>
149
+ </size_advanced>
150
+ </fields>
151
+ </instances>
152
  <cache translate="label">
153
  <label>Cache</label>
154
  <frontend_type>text</frontend_type>
356
  <label>Processed Callback</label>
357
  <frontend_type>textarea</frontend_type>
358
  <sort_order>1</sort_order>
359
+ <validate>required-entry</validate>
360
  <show_in_default>1</show_in_default>
361
  <show_in_website>1</show_in_website>
362
  <show_in_store>1</show_in_store>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Strategery_InfiniteScroll2</name>
4
- <version>2.1.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/afl-3.0.php">Academic Free License (AFL 3.0)</license>
7
  <channel>community</channel>
@@ -31,9 +31,9 @@ NOTE: If you have another JS module that adds some custom behavior to the produc
31
  <notes>Automatic load next page of current product list.&#xD;
32
  Support for Magento 1.3 up to 1.7.2</notes>
33
  <authors><author><name>Damian Alberto Pastorini</name><user>auto-converted</user><email>damian.pastorini@usestrategery.com</email></author></authors>
34
- <date>2012-12-21</date>
35
- <time>16:09:29</time>
36
- <contents><target name="mageetc"><dir name="modules"><file name="Strategery_Infinitescroll2.xml" hash="8724cb82b6d47b9996610029e302e5d4"/></dir></target><target name="magecommunity"><dir name="Strategery"><dir name="Infinitescroll2"><dir name="Block"><file name="Config.php" hash="a587b8e8ed1ab41594bd0db6e320358b"/><file name="Flush.php" hash="d04139875ed190aec2431a7a83deaa21"/></dir><dir name="Helper"><file name="Data.php" hash="05de0d81682ca71b7d34e82e1ba2be60"/></dir><dir name="Model"><dir name="Catalog"><file name="Observer.php" hash="b9b07a84d3eb50906db995bdfcf4636a"/></dir></dir><dir name="controllers"><file name="CacheController.php" hash="1029bfa5495cfcf02cad62aa8a40ace3"/><file name="JsController.php" hash="3d97abe7a35b69bb70e6bb3ab1414f47"/></dir><dir name="etc"><file name="config.xml" hash="d84bb42e5ea917a69563e0883b6eea91"/><file name="system.xml" hash="b07bf39a7ec5fa96a192749e9afa3e4b"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="strategery-infinitescroll2.xml" hash="f8c0447f74f31b576d9e9cee89c99b8f"/></dir><dir name="template"><dir name="strategery"><dir name="infinitescroll2"><file name="js.phtml" hash="85f7a4b3265da1693c03ff97ac17094e"/><file name="toolbar.phtml" hash="d16882d540e2c23501f84a64e33c67e2"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="jquery"><dir name="infinitescroll2"><dir name="behaviors"><file name="infinitescroll-magento.js" hash="88a5a092c68911819302952e2128fe34"/></dir><file name="https.js" hash="be476c35fecb93b0a88625d8bc8a128b"/><file name="jquery.infinitescroll.js" hash="862b580a996c3f7a9daa1fcc1fae808d"/><file name="jquery.infinitescroll.min.js" hash="24131ba057a50077af7a97dfa1fcde30"/></dir><file name="jquery.latest.min.js" hash="7ffe78e450bedfa8878241c3abc5edba"/></dir></dir></target></contents>
37
  <compatible/>
38
  <dependencies/>
39
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Strategery_InfiniteScroll2</name>
4
+ <version>2.1.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/afl-3.0.php">Academic Free License (AFL 3.0)</license>
7
  <channel>community</channel>
31
  <notes>Automatic load next page of current product list.&#xD;
32
  Support for Magento 1.3 up to 1.7.2</notes>
33
  <authors><author><name>Damian Alberto Pastorini</name><user>auto-converted</user><email>damian.pastorini@usestrategery.com</email></author></authors>
34
+ <date>2013-01-28</date>
35
+ <time>13:17:55</time>
36
+ <contents><target name="mageetc"><dir name="modules"><file name="Strategery_Infinitescroll2.xml" hash="8724cb82b6d47b9996610029e302e5d4"/></dir></target><target name="magecommunity"><dir name="Strategery"><dir name="Infinitescroll2"><dir name="Block"><file name="Config.php" hash="a587b8e8ed1ab41594bd0db6e320358b"/><file name="Flush.php" hash="d04139875ed190aec2431a7a83deaa21"/></dir><dir name="Helper"><file name="Data.php" hash="05de0d81682ca71b7d34e82e1ba2be60"/></dir><dir name="Model"><dir name="Catalog"><file name="Observer.php" hash="074206ffc36b2e694da07f0dd0a02896"/></dir></dir><dir name="controllers"><file name="CacheController.php" hash="1029bfa5495cfcf02cad62aa8a40ace3"/><file name="JsController.php" hash="3d97abe7a35b69bb70e6bb3ab1414f47"/></dir><dir name="etc"><file name="config.xml" hash="d84bb42e5ea917a69563e0883b6eea91"/><file name="system.xml" hash="6c0034e3648fc34d730642876f376161"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="strategery-infinitescroll2.xml" hash="f8c0447f74f31b576d9e9cee89c99b8f"/></dir><dir name="template"><dir name="strategery"><dir name="infinitescroll2"><file name="js.phtml" hash="85f7a4b3265da1693c03ff97ac17094e"/><file name="toolbar.phtml" hash="d16882d540e2c23501f84a64e33c67e2"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="jquery"><dir name="infinitescroll2"><dir name="behaviors"><file name="infinitescroll-magento.js" hash="88a5a092c68911819302952e2128fe34"/></dir><file name="https.js" hash="be476c35fecb93b0a88625d8bc8a128b"/><file name="jquery.infinitescroll.js" hash="862b580a996c3f7a9daa1fcc1fae808d"/><file name="jquery.infinitescroll.min.js" hash="24131ba057a50077af7a97dfa1fcde30"/></dir><file name="jquery.latest.min.js" hash="7ffe78e450bedfa8878241c3abc5edba"/></dir></dir></target></contents>
37
  <compatible/>
38
  <dependencies/>
39
  </package>