autocompleteplus_autosuggest - Version 3.0.0.7

Version Notes

ECG compatibility refactor

Download this release

Release Info

Developer Adar
Extension autocompleteplus_autosuggest
Version 3.0.0.7
Comparing to
See all releases


Code changes from version 3.0.0.6 to 3.0.0.7

Files changed (46) hide show
  1. app/code/local/Autocompleteplus/Autosuggest/Block/Inject.php +6 -0
  2. app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php +25 -38
  3. app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php.bak +0 -783
  4. app/code/local/Autocompleteplus/Autosuggest/Model/Catalog.php +263 -907
  5. app/code/local/Autocompleteplus/Autosuggest/Model/Catalogreport.php +7 -5
  6. app/code/local/Autocompleteplus/Autosuggest/Model/Config.php +68 -73
  7. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches.php +9 -0
  8. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches/Collection.php +9 -0
  9. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum.php +9 -0
  10. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum/Collection.php +9 -0
  11. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Fulltext/Collection.php +9 -0
  12. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications.php +9 -0
  13. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications/Collection.php +9 -0
  14. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher.php +9 -0
  15. app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher/Collection.php +9 -0
  16. app/code/local/Autocompleteplus/Autosuggest/Model/Observer.php +49 -27
  17. app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Abstract.php +84 -0
  18. app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Batches.php +27 -0
  19. app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Catalog/Product.php +555 -0
  20. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches.php +1 -1
  21. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches/Collection.php +1 -1
  22. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum.php +1 -1
  23. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum/Collection.php +1 -1
  24. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Fulltext/Collection.php +1 -1
  25. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications.php +1 -1
  26. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications/Collection.php +1 -1
  27. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher.php +1 -1
  28. app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher/Collection.php +1 -1
  29. app/code/local/Autocompleteplus/Autosuggest/controllers/Adminhtml/Autocompleteplus/PushController.php +2 -7
  30. app/code/local/Autocompleteplus/Autosuggest/controllers/CategoriesController.php +1 -5
  31. app/code/local/Autocompleteplus/Autosuggest/controllers/LayeredController.php +4 -16
  32. app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsController.php +160 -120
  33. app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsbyidController.php +9 -8
  34. app/code/local/Autocompleteplus/Autosuggest/controllers/SearchesController.php +8 -5
  35. app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-install-3.0.0.5.php +8 -0
  36. app/code/local/Autocompleteplus/Autosuggest/etc/config.xml +13 -5
  37. app/code/local/Autocompleteplus/Autosuggest/etc/config.xml.bak +213 -0
  38. app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.5.4-2.0.5.5.php +12 -6
  39. app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.2-2.0.7.3.php +16 -4
  40. app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.8.8-3.0.0.0.php +16 -3
  41. app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.4-3.0.0.5.php +6 -0
  42. app/design/adminhtml/default/default/layout/autocompleteplus.xml +13 -0
  43. app/design/{frontend/base → adminhtml/default}/default/template/autocompleteplus/process.phtml +55 -54
  44. lib/Autocompleteplus/Autosuggest/Xml/Generator.php +87 -0
  45. lib/Autocompleteplus/Autosuggest/Xml/GeneratorInterface.php +12 -0
  46. package.xml +5 -5
app/code/local/Autocompleteplus/Autosuggest/Block/Inject.php CHANGED
@@ -137,6 +137,11 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
137
  {
138
  return Mage::getSingleton('checkout/session')->getQuoteId();
139
  }
 
 
 
 
 
140
 
141
  /**
142
  * Return a formatted string for the <script src> attr.
@@ -156,6 +161,7 @@ class Autocompleteplus_Autosuggest_Block_Inject extends Mage_Checkout_Block_Cart
156
  'is_admin_user' => $this->_isAdminLoggedIn(),
157
  'sessionID' => $this->_helper->getSessionId(),
158
  'QuoteID' => $this->getQuoteId(),
 
159
  );
160
 
161
  return self::AUTOCOMPLETE_JS_URL.'?'.http_build_query($parameters, '', '&');
137
  {
138
  return Mage::getSingleton('checkout/session')->getQuoteId();
139
  }
140
+
141
+ public function isLoggedInUser(){
142
+ $session_customer = Mage::getSingleton('customer/session');
143
+ return $session_customer->isLoggedIn();
144
+ }
145
 
146
  /**
147
  * Return a formatted string for the <script src> attr.
161
  'is_admin_user' => $this->_isAdminLoggedIn(),
162
  'sessionID' => $this->_helper->getSessionId(),
163
  'QuoteID' => $this->getQuoteId(),
164
+ 'is_user_logged_in'=> $this->isLoggedInUser()
165
  );
166
 
167
  return self::AUTOCOMPLETE_JS_URL.'?'.http_build_query($parameters, '', '&');
app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php CHANGED
@@ -41,6 +41,11 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
41
  return Mage::getModel('autocompleteplus_autosuggest/config');
42
  }
43
 
 
 
 
 
 
44
  public function getVersion()
45
  {
46
  return (string) Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
@@ -439,6 +444,7 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
439
 
440
  public function updateSavedProductChecksum($product_id, $sku, $store_id, $checksum)
441
  {
 
442
  if ($product_id == null || $sku == null) {
443
  return;
444
  }
@@ -464,6 +470,7 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
464
 
465
  public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
466
  {
 
467
  if ($product_id == null) {
468
  return;
469
  }
@@ -594,6 +601,19 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
594
  return $this->getConfig()->getUUID();
595
  }
596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  public function getIsReachable()
598
  {
599
  return $this->getConfig()->isReachable();
@@ -678,31 +698,19 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
678
  {
679
  $collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
680
 
681
- $count = $collection->count();
682
-
683
- if ($count == 0) {
684
- return false;
685
- } else {
686
- return true;
687
- }
688
  }
689
 
690
  public function getPushId()
691
  {
692
- $collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()
 
693
  ->addFilter('sent', 0);
694
 
695
  $collection->getSelect()->limit(1);
696
-
697
  $collection->load();
698
 
699
- $id = '';
700
-
701
- foreach ($collection as $p) {
702
- $id = $p->getId();
703
- }
704
-
705
- return $id;
706
  }
707
 
708
  public function getPushUrl($id = null)
@@ -711,7 +719,7 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
711
  $id = $this->getPushId();
712
  }
713
 
714
- $url = Mage::getUrl();//'',array('pushid'=>$id));
715
 
716
  if (strpos($url, 'index.php') !== false) {
717
  $url = $url.'/autocompleteplus/products/pushbulk/pushid/'.$id;
@@ -759,25 +767,4 @@ class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
759
  {
760
  return (string) Mage::getConfig()->getNode('global/crypt/key');
761
  }
762
-
763
- public function validateInput($input, $type = "integer", $default = null, $on_failure = null){
764
- $validated_input = $default;
765
- $sanity_type = FILTER_SANITIZE_NUMBER_INT;
766
- $type = strtolower($type);
767
- if ($type == "integer" || $type == 'int'){
768
- $sanity_type = FILTER_SANITIZE_NUMBER_INT;
769
- } else if ($type == 'boolean' || $type == 'bool'){
770
- $sanity_type = FILTER_VALIDATE_BOOLEAN;
771
- }
772
-
773
- $filter_input = filter_var($input, $sanity_type, FILTER_NULL_ON_FAILURE);
774
- if ($filter_input || ($sanity_type == FILTER_SANITIZE_NUMBER_INT && $filter_input === "0")){
775
- $validated_input = $filter_input;
776
- $status = settype($validated_input, $type);
777
- if (!$status){
778
- $validated_input = $on_failure;
779
- }
780
- }
781
- return $validated_input;
782
- }
783
  }
41
  return Mage::getModel('autocompleteplus_autosuggest/config');
42
  }
43
 
44
+ public function getMageVersion()
45
+ {
46
+ return Mage::getVersion();
47
+ }
48
+
49
  public function getVersion()
50
  {
51
  return (string) Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
444
 
445
  public function updateSavedProductChecksum($product_id, $sku, $store_id, $checksum)
446
  {
447
+ return;
448
  if ($product_id == null || $sku == null) {
449
  return;
450
  }
470
 
471
  public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
472
  {
473
+ return;
474
  if ($product_id == null) {
475
  return;
476
  }
601
  return $this->getConfig()->getUUID();
602
  }
603
 
604
+ /**
605
+ * Deprecated, use getAuthorizationKey()
606
+ */
607
+ public function getKey()
608
+ {
609
+ return $this->getAuthorizationKey();
610
+ }
611
+
612
+ public function getAuthorizationKey()
613
+ {
614
+ return $this->getConfig()->getAuthorizationKey();
615
+ }
616
+
617
  public function getIsReachable()
618
  {
619
  return $this->getConfig()->isReachable();
698
  {
699
  $collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
700
 
701
+ return $collection->getSize() > 0;
 
 
 
 
 
 
702
  }
703
 
704
  public function getPushId()
705
  {
706
+ $collection = Mage::getModel('autocompleteplus_autosuggest/pusher')
707
+ ->getCollection()
708
  ->addFilter('sent', 0);
709
 
710
  $collection->getSelect()->limit(1);
 
711
  $collection->load();
712
 
713
+ return $collection->getLastItem()->getId();
 
 
 
 
 
 
714
  }
715
 
716
  public function getPushUrl($id = null)
719
  $id = $this->getPushId();
720
  }
721
 
722
+ $url = Mage::getUrl();
723
 
724
  if (strpos($url, 'index.php') !== false) {
725
  $url = $url.'/autocompleteplus/products/pushbulk/pushid/'.$id;
767
  {
768
  return (string) Mage::getConfig()->getNode('global/crypt/key');
769
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770
  }
app/code/local/Autocompleteplus/Autosuggest/Helper/Data.php.bak DELETED
@@ -1,783 +0,0 @@
1
- <?php
2
- /**
3
- * InstantSearchPlus (Autosuggest).
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- *
11
- * @category Mage
12
- *
13
- * @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
14
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
- */
16
- class Autocompleteplus_Autosuggest_Helper_Data extends Mage_Core_Helper_Abstract
17
- {
18
- // private $server_url = 'http://0-2vk.acp-magento.appspot.com';
19
- private $server_url = 'http://magento.instantsearchplus.com';
20
-
21
- protected $_authKey;
22
-
23
- public function getServerUrl()
24
- {
25
- return $this->server_url;
26
- }
27
-
28
- public function validateUuid($uuid)
29
- {
30
- if (strlen($uuid) == 36
31
- && substr_count($uuid, '-') == 4
32
- ) {
33
- return true;
34
- }
35
-
36
- return false;
37
- }
38
-
39
- public function getConfig()
40
- {
41
- return Mage::getModel('autocompleteplus_autosuggest/config');
42
- }
43
-
44
- public function getVersion()
45
- {
46
- return (string) Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
47
- }
48
-
49
- public function getConfigDataByFullPath($path)
50
- {
51
- if (!$row = Mage::getSingleton('core/config_data')->getCollection()->getItemByColumnValue('path', $path)) {
52
- $conf = Mage::getSingleton('core/config')->init()->getXpath('/config/default/'.$path);
53
- if (is_array($conf)) {
54
- $value = array_shift($conf);
55
- } else {
56
- return '';
57
- }
58
- } else {
59
- $value = $row->getValue();
60
- }
61
-
62
- return $value;
63
- }
64
-
65
- public function getConfigMultiDataByFullPath($path)
66
- {
67
- $values = array();
68
-
69
- if (!$rows = Mage::getSingleton('core/config_data')->getCollection()->getItemsByColumnValue('path', $path)) {
70
- $conf = Mage::getSingleton('core/config')->init()->getXpath('/config/default/'.$path);
71
- $values[] = array_shift($conf);
72
- } else {
73
- foreach ($rows as $row) {
74
- $values[$row->getScopeId()] = $row->getValue();
75
- }
76
- }
77
-
78
- return $values;
79
- }
80
-
81
- public function sendCurl($command)
82
- {
83
- if (isset($ch)) {
84
- unset($ch);
85
- }
86
-
87
- if (function_exists('curl_setopt')) {
88
- $ch = curl_init();
89
- curl_setopt($ch, CURLOPT_URL, $command);
90
- curl_setopt($ch, CURLOPT_HEADER, 0);
91
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
92
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
93
- $str = curl_exec($ch);
94
- } else {
95
- $str = 'failed';
96
- }
97
-
98
- return $str;
99
- }
100
-
101
- public static function sendPostCurl($command, $data = array(), $cookie_file = 'genCookie.txt')
102
- {
103
- if (isset($ch)) {
104
- unset($ch);
105
- }
106
-
107
- if (function_exists('curl_setopt')) {
108
- $ch = curl_init();
109
- curl_setopt($ch, CURLOPT_URL, $command);
110
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
111
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
112
- curl_setopt($ch, CURLOPT_HEADER, 0);
113
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
114
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
115
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0');
116
- //curl_setopt($ch,CURLOPT_POST,0);
117
- if (!empty($data)) {
118
- curl_setopt_array($ch, array(
119
- CURLOPT_POSTFIELDS => $data,
120
- ));
121
- }
122
-
123
- // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
124
- // 'Connection: Keep-Alive',
125
- // 'Keep-Alive: 800'
126
- // ));
127
-
128
- $str = curl_exec($ch);
129
- } else {
130
- $str = 'failed';
131
- }
132
-
133
- return $str;
134
- }
135
-
136
- public function prepareGroupedProductPrice($groupedProduct)
137
- {
138
- $aProductIds = $groupedProduct->getTypeInstance()->getChildrenIds($groupedProduct->getId());
139
-
140
- $prices = array();
141
- foreach ($aProductIds as $ids) {
142
- foreach ($ids as $id) {
143
- try {
144
- $aProduct = Mage::getModel('catalog/product')->load($id);
145
- $prices[] = $aProduct->getPriceModel()->getPrice($aProduct);
146
- } catch (Exception $e) {
147
- continue;
148
- }
149
- }
150
- }
151
-
152
- krsort($prices);
153
- try {
154
- if (count($prices) > 0) {
155
- $groupedProduct->setPrice($prices[0]);
156
- } else {
157
- $groupedProduct->setPrice(0);
158
- }
159
- } catch (Exception $e) {
160
- $groupedProduct->setPrice(0);
161
- }
162
-
163
- // or you can return price
164
- }
165
-
166
- public function getBundlePrice($product)
167
- {
168
- $optionCol = $product->getTypeInstance(true)
169
- ->getOptionsCollection($product);
170
- $selectionCol = $product->getTypeInstance(true)
171
- ->getSelectionsCollection(
172
- $product->getTypeInstance(true)->getOptionsIds($product),
173
- $product
174
- );
175
- $optionCol->appendSelections($selectionCol);
176
- $price = $product->getPrice();
177
-
178
- foreach ($optionCol as $option) {
179
- if ($option->required) {
180
- $selections = $option->getSelections();
181
- $selPricesArr = array();
182
-
183
- if (is_array($selections)) {
184
- foreach ($selections as $s) {
185
- $selPricesArr[] = $s->price;
186
- }
187
-
188
- $minPrice = min($selPricesArr);
189
-
190
- if ($product->getSpecialPrice() > 0) {
191
- $minPrice *= $product->getSpecialPrice() / 100;
192
- }
193
-
194
- $price += round($minPrice, 2);
195
- }
196
- }
197
- }
198
-
199
- return $price;
200
- }
201
-
202
- public function getMultiStoreDataJson()
203
- {
204
- $websites = Mage::getModel('core/website')->getCollection();
205
-
206
- $multistoreData = array();
207
- $multistoreJson = '';
208
- $useStoreCode = $this->getConfigDataByFullPath('web/url/use_store');
209
- $mage = Mage::getVersion();
210
- $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
211
- $version = array('mage' => $mage, 'ext' => $ext);
212
-
213
- //getting site url
214
- $url = $this->getConfigDataByFullPath('web/unsecure/base_url');
215
-
216
- //getting site owner email
217
- $storeMail = $this->getConfigDataByFullPath('autocompleteplus/config/store_email');
218
-
219
- if (!$storeMail) {
220
- $storeMail = $this->getConfigDataByFullPath('trans_email/ident_general/email');
221
- }
222
-
223
- $collection = Mage::getModel('catalog/product')->getCollection();
224
- //$productCount=$collection->count();
225
-
226
- $storesArr = array();
227
- foreach ($websites as $website) {
228
- $code = $website->getCode();
229
- $stores = $website->getStores();
230
- foreach ($stores as $store) {
231
- $storesArr[$store->getStoreId()] = $store->getData();
232
- }
233
- }
234
-
235
- if (count($storesArr) == 1) {
236
- try {
237
- $dataArr = array(
238
- // 'stores' => array(array_pop($storesArr)),
239
- 'stores' => array_pop($storesArr),
240
- 'version' => $version,
241
- );
242
- } catch (Exception $e) {
243
- $dataArr = array(
244
- 'stores' => $multistoreData,
245
- 'version' => $version,
246
- );
247
- }
248
-
249
- $dataArr['site'] = $url;
250
- $dataArr['email'] = $storeMail;
251
-
252
- $multistoreJson = json_encode($dataArr);
253
- } else {
254
- $storeUrls = $this->getConfigMultiDataByFullPath('web/unsecure/base_url');
255
- $locales = $this->getConfigMultiDataByFullPath('general/locale/code');
256
- $storeComplete = array();
257
-
258
- foreach ($storesArr as $key => $value) {
259
- if (!$value['is_active']) {
260
- continue;
261
- }
262
-
263
- $storeComplete = $value;
264
- if (array_key_exists($key, $locales)) {
265
- $storeComplete['lang'] = $locales[$key];
266
- } else {
267
- $storeComplete['lang'] = $locales[0];
268
- }
269
-
270
- if (array_key_exists($key, $storeUrls)) {
271
- $storeComplete['url'] = $storeUrls[$key];
272
- } else {
273
- $storeComplete['url'] = $storeUrls[0];
274
- }
275
-
276
- if ($useStoreCode) {
277
- $storeComplete['url'] = $storeUrls[0].$value['code'];
278
- }
279
-
280
- $multistoreData[] = $storeComplete;
281
- }
282
-
283
- $dataArr = array(
284
- 'stores' => $multistoreData,
285
- 'version' => $version,
286
- );
287
-
288
- $dataArr['site'] = $url;
289
- $dataArr['email'] = $storeMail;
290
- //$dataArr['product_count']=$productCount;
291
-
292
- $multistoreJson = json_encode($dataArr);
293
- }
294
-
295
- return $multistoreJson;
296
- }
297
-
298
- public function getExtensionConflict($all_conflicts = false)
299
- {
300
- $all_rewrite_classes = array();
301
- $node_type_list = array('model', 'helper', 'block');
302
-
303
- foreach ($node_type_list as $node_type) {
304
- foreach (Mage::getConfig()->getNode('modules')->children() as $name => $module) {
305
- if ($module->codePool == 'core' || $module->active != 'true') {
306
- continue;
307
- }
308
- $config_file_path = Mage::getConfig()->getModuleDir('etc', $name).DS.'config.xml';
309
- $config = new Varien_Simplexml_Config();
310
- $config->loadString('<config/>');
311
- $config->loadFile($config_file_path);
312
- $config->extend($config, true);
313
-
314
- $nodes = $config->getNode()->global->{$node_type.'s'};
315
- if (!$nodes) {
316
- continue;
317
- }
318
- foreach ($nodes->children() as $node_name => $config) {
319
- if ($config->rewrite) { // there is rewrite for current config
320
- foreach ($config->rewrite->children() as $class_tag => $derived_class) {
321
- $base_class_name = $this->_getMageBaseClass($node_type, $node_name, $class_tag);
322
-
323
- $lead_derived_class = '';
324
- $conf = Mage::getConfig()->getNode()->global->{$node_type.'s'}->{$node_name};
325
- if (isset($conf->rewrite->$class_tag)) {
326
- $lead_derived_class = (string) $conf->rewrite->$class_tag;
327
- }
328
- if ($derived_class == '') {
329
- $derived_class = $lead_derived_class;
330
- }
331
-
332
- if (empty($all_rewrite_classes[$base_class_name])) {
333
- $all_rewrite_classes[$base_class_name] = array(
334
- 'derived' => array((string) $derived_class),
335
- 'lead' => (string) $lead_derived_class,
336
- 'tag' => $class_tag,
337
- 'name' => array((string) $name),
338
- );
339
- } else {
340
- array_push($all_rewrite_classes[$base_class_name]['derived'], (string) $derived_class);
341
- array_push($all_rewrite_classes[$base_class_name]['name'], (string) $name);
342
- }
343
- }
344
- }
345
- }
346
- }
347
- }
348
- if ($all_conflicts) {
349
- return $all_rewrite_classes;
350
- }
351
-
352
- $isp_rewrite_classes = array();
353
- $isp_module_name = 'Autocompleteplus_Autosuggest';
354
- foreach ($all_rewrite_classes as $base => $conflict_info) {
355
- if (in_array($isp_module_name, $conflict_info['name'])) { // if isp extension rewrite this base class
356
- if (count($conflict_info['derived']) > 1) { // more then 1 class rewrite this base class => there is a conflict
357
- $isp_rewrite_classes[$base] = $conflict_info;
358
- }
359
- }
360
- }
361
-
362
- return $isp_rewrite_classes;
363
- }
364
-
365
- protected function _getMageBaseClass($node_type, $node_name, $class_tag)
366
- {
367
- $config = Mage::getConfig()->getNode()->global->{$node_type.'s'}->$node_name;
368
-
369
- if (!empty($config)) {
370
- $className = $config->getClassName();
371
- }
372
- if (empty($className)) {
373
- $className = 'mage_'.$node_name.'_'.$node_type;
374
- }
375
- if (!empty($class_tag)) {
376
- $className .= '_'.$class_tag;
377
- }
378
-
379
- return uc_words($className);
380
- }
381
-
382
- /**
383
- * Checksum functionality.
384
- */
385
- public function isChecksumTableExists()
386
- {
387
- $table_prefix = (string) Mage::getConfig()->getTablePrefix();
388
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
389
- if ($read->showTableStatus($table_prefix.'autocompleteplus_checksum')) {
390
- return true;
391
- } else {
392
- return false;
393
- }
394
- }
395
-
396
- public function calculateChecksum($product)
397
- {
398
- $product_id = $product->getId();
399
- $product_title = $product->getName();
400
- $product_description = $product->getDescription();
401
- $product_short_desc = $product->getShortDescription();
402
- $product_url = $product->getUrlPath(); //Mage::helper('catalog/product')->getProductUrl($product_id); | $product->getProductUrl()
403
- $product_visibility = $product->getVisibility();
404
- $product_in_stock = $product->isInStock();
405
- $product_price = (float) $product->getPrice();
406
- try {
407
- $product_thumb_url = '/'.$product->getImage();
408
-
409
- // $product_thumb_url = $product->getThumbnailUrl(); //Mage::helper('catalog/image')->init($product, 'thumbnail');
410
- // $thumb_pattern = '/\/[^\/]+(?![^\/]*\/)/';
411
- // if (preg_match($thumb_pattern, $product_thumb_url, $matches) && count($matches) > 0){
412
- // $product_thumb_url = $matches[0];
413
- // } else {
414
- // $product_thumb_url = '';
415
- // }
416
- } catch (Exception $e) {
417
- $product_thumb_url = '';
418
- }
419
- $product_type = $product->getTypeID();
420
-
421
- $checksum_string = $product_id.$product_title.$product_description.$product_short_desc.$product_url.
422
- $product_visibility.$product_in_stock.$product_price.$product_thumb_url.$product_type;
423
-
424
- $checksum_md5 = md5($checksum_string);
425
-
426
- return $checksum_md5;
427
- }
428
-
429
- public function getSavedChecksum($table_prefix, $read, $product_id, $store_id)
430
- {
431
- $sql_fetch = 'SELECT checksum FROM '.$table_prefix.'autocompleteplus_checksum WHERE identifier=? AND store_id=?';
432
- $updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
433
- if ($updates && (count($updates) != 0)) {
434
- return $updates[0]['checksum'];
435
- } else {
436
- return '';
437
- }
438
- }
439
-
440
- public function updateSavedProductChecksum($product_id, $sku, $store_id, $checksum)
441
- {
442
- if ($product_id == null || $sku == null) {
443
- return;
444
- }
445
- $checksumModel = Mage::getModel('autocompleteplus_autosuggest/checksum');
446
- $collection = $checksumModel->getCollection()
447
- ->addFieldToFilter('identifier', $product_id)
448
- ->addFieldToFilter('store_id', $store_id);
449
-
450
- $row = $collection->getFirstItem();
451
-
452
- if ($row && $collection->getSize() > 0) {
453
- if ($row->getChecksum() != $checksum) {
454
- $row->setChecksum($checksum)->save();
455
- }
456
- } else {
457
- $checksumModel->setIdentifier($product_id)
458
- ->setSku($sku)
459
- ->setStoreId($store_id)
460
- ->setChecksum($checksum)
461
- ->save();
462
- }
463
- }
464
-
465
- public function updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id)
466
- {
467
- if ($product_id == null) {
468
- return;
469
- }
470
-
471
- $checksums = Mage::getModel('autocompleteplus_autosuggest/checksum')->getCollection()
472
- ->addFieldToFilter('identifier', $product_id)
473
- ->addFieldToFilter('store_id', $store_id);
474
-
475
- if ($checksums->getSize() > 0) {
476
- // @codingStandardsIgnoreLine
477
- $checksum = $checksums->getFirstItem();
478
- $checksum->delete();
479
- }
480
- }
481
-
482
- private function setUpdateNeededForProduct($read, $write, $product_id, $product_sku, $store_id)
483
- {
484
- if ($product_id == null) {
485
- return;
486
- }
487
- if ($product_sku == null) {
488
- $product_sku = 'dummy_sku';
489
- }
490
- try {
491
- $table_prefix = (string) Mage::getConfig()->getTablePrefix();
492
- $is_table_exist = $write->showTableStatus($table_prefix.'autocompleteplus_batches');
493
- if (!$is_table_exist) { // table not exists
494
- return;
495
- }
496
-
497
- $sql_fetch = 'SELECT * FROM '.$table_prefix.'autocompleteplus_batches WHERE product_id=? AND store_id=?';
498
- $updates = $read->fetchAll($sql_fetch, array($product_id, $store_id));
499
-
500
- if ($updates && (count($updates) != 0)) {
501
- $sql = 'UPDATE '.$table_prefix.'autocompleteplus_batches SET update_date=?,action=? WHERE product_id=? AND store_id=?';
502
- $write->query($sql, array(strtotime('now'), 'update', $product_id, $store_id));
503
- } else {
504
- $sql = 'INSERT INTO '.$table_prefix.'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
505
- $write->query($sql, array($product_id, $store_id, strtotime('now'), 'update', $product_sku));
506
- }
507
- } catch (Exception $e) {
508
- Mage::log('Exception raised in setUpdateNeededForProduct() - '.$e->getMessage(), null, 'autocompleteplus.log');
509
- $this->ispErrorLog('Exception raised in setUpdateNeededForProduct() - '.$e->getMessage());
510
- }
511
- }
512
-
513
- public function compareProductsChecksum($from, $count, $store_id = null)
514
- {
515
- $num_of_updates = 0;
516
- if (!$this->isChecksumTableExists()) {
517
- return;
518
- }
519
-
520
- $products = Mage::getModel('catalog/product')->getCollection();
521
- if ($store_id) {
522
- $products->addStoreFilter($store_id);
523
- }
524
- $products->getSelect()->limit($count, $from);
525
- $products->load();
526
-
527
- $table_prefix = (string) Mage::getConfig()->getTablePrefix();
528
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
529
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
530
-
531
- foreach ($products as $product) {
532
- try {
533
- $product_collection_data = $product->getData();
534
- $product_model = Mage::getModel('catalog/product')
535
- ->setStore($store_id)->setStoreId($store_id)
536
- ->load($product_collection_data['entity_id']);
537
-
538
- $current_checksum = $this->getSavedChecksum($table_prefix, $read, $product_model->getId(), $store_id);
539
- $new_checksum = $this->calculateChecksum($product_model);
540
- } catch (Exception $e) {
541
- Mage::log('Exception raised in compareProductsChecksum() on id: '.$product->getId().' -> '.$e->getMessage(), null, 'autocompleteplus.log');
542
- $this->ispErrorLog('Exception raised in compareProductsChecksum() on id: '.$product->getId().' -> '.$e->getMessage());
543
-
544
- return 0;
545
- }
546
- if ($current_checksum == '' || $current_checksum != $new_checksum) {
547
- ++$num_of_updates;
548
- $this->updateSavedProductChecksum($table_prefix, $read, $write, $product_model->getId(), $product_model->getSku(),
549
- $store_id, $new_checksum);
550
- $this->setUpdateNeededForProduct($read, $write, $product_model->getId(), $product_model->getSku(), $store_id);
551
- }
552
- }
553
-
554
- return $num_of_updates;
555
- }
556
-
557
- public function deleteProductFromTables($read, $write, $table_prefix, $product_id, $store_id)
558
- {
559
- $dt = strtotime('now');
560
- $sku = 'dummy_sku';
561
- $sqlFetch = 'SELECT * FROM '.$table_prefix.'autocompleteplus_batches WHERE product_id = ? AND store_id=?';
562
- $updates = $read->fetchAll($sqlFetch, array($product_id, $store_id));
563
-
564
- if ($updates && count($updates) != 0) {
565
- $sql = 'UPDATE '.$table_prefix.'autocompleteplus_batches SET update_date=?,action=? WHERE product_id = ? AND store_id = ?';
566
- $write->query($sql, array($dt, 'remove', $product_id, $store_id));
567
- } else {
568
- $sql = 'INSERT INTO '.$table_prefix.'autocompleteplus_batches (product_id,store_id,update_date,action,sku) VALUES (?,?,?,?,?)';
569
- $write->query($sql, array($product_id, $store_id, $dt, 'remove', $sku));
570
- }
571
-
572
- $this->updateDeletedProductChecksum($table_prefix, $read, $write, $product_id, $sku, $store_id);
573
- }
574
-
575
- public function ispLog($log)
576
- {
577
- Mage::log($log, null, 'autocompleteplus.log');
578
- }
579
-
580
- public function ispErrorLog($log)
581
- {
582
- $uuid = $this->getUUID();
583
- $site_url = $this->getConfigDataByFullPath('web/unsecure/base_url');
584
- $store_id = Mage::app()->getStore()->getStoreId();
585
-
586
- $server_url = $this->server_url.'/magento_logging_error';
587
- $request = $server_url.'?uuid='.$uuid.'&site_url='.$site_url.'&store_id='.$store_id.'&msg='.urlencode($log);
588
-
589
- $resp = $this->sendCurl($request);
590
- }
591
-
592
- public function getUUID()
593
- {
594
- return $this->getConfig()->getUUID();
595
- }
596
-
597
- public function getIsReachable()
598
- {
599
- return $this->getConfig()->isReachable();
600
- }
601
-
602
- public function getServerEndPoint()
603
- {
604
- try {
605
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
606
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
607
- $_tableprefix = (string) Mage::getConfig()->getTablePrefix();
608
- $tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
609
-
610
- if (!$tblExist) {
611
- return '';
612
- }
613
-
614
- $sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
615
- $licenseData = $read->fetchAll($sql);
616
- if (array_key_exists('server_type', $licenseData[0])) {
617
- $key = $licenseData[0]['server_type'];
618
- } else {
619
- $key = '';
620
- }
621
- } catch (Exception $e) {
622
- $key = '';
623
- }
624
-
625
- return $key;
626
- }
627
-
628
- public function setServerEndPoint($end_point)
629
- {
630
- try {
631
- $_tableprefix = (string) Mage::getConfig()->getTablePrefix();
632
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
633
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
634
- $tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
635
-
636
- if (!$tblExist) {
637
- return;
638
- }
639
-
640
- $sqlFetch = 'SELECT * FROM '.$_tableprefix.'autocompleteplus_config WHERE id = 1';
641
- $updates = $write->fetchAll($sqlFetch);
642
-
643
- if ($updates && count($updates) != 0) {
644
- $sql = 'UPDATE '.$_tableprefix.'autocompleteplus_config SET server_type=? WHERE id = 1';
645
- $write->query($sql, array($end_point));
646
- } else {
647
- Mage::log('cant update server_type', null, 'autocompleteplus.log');
648
- }
649
- } catch (Exception $e) {
650
- Mage::log($e->getMessage(), null, 'autocompleteplus.log');
651
- }
652
- }
653
-
654
- public function getErrormessage()
655
- {
656
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
657
-
658
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
659
-
660
- $_tableprefix = (string) Mage::getConfig()->getTablePrefix();
661
-
662
- $tblExist = $write->showTableStatus($_tableprefix.'autocompleteplus_config');
663
-
664
- if (!$tblExist) {
665
- return '';
666
- }
667
-
668
- $sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_config` WHERE `id` =1';
669
-
670
- $licenseData = $read->fetchAll($sql);
671
-
672
- $errormessage = $licenseData[0]['errormessage'];
673
-
674
- return $errormessage;
675
- }
676
-
677
- public function getIfSyncWasInitiated()
678
- {
679
- $collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection();
680
-
681
- $count = $collection->count();
682
-
683
- if ($count == 0) {
684
- return false;
685
- } else {
686
- return true;
687
- }
688
- }
689
-
690
- public function getPushId()
691
- {
692
- $collection = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()
693
- ->addFilter('sent', 0);
694
-
695
- $collection->getSelect()->limit(1);
696
-
697
- $collection->load();
698
-
699
- $id = '';
700
-
701
- foreach ($collection as $p) {
702
- $id = $p->getId();
703
- }
704
-
705
- return $id;
706
- }
707
-
708
- public function getPushUrl($id = null)
709
- {
710
- if ($id == null) {
711
- $id = $this->getPushId();
712
- }
713
-
714
- $url = Mage::getUrl();//'',array('pushid'=>$id));
715
-
716
- if (strpos($url, 'index.php') !== false) {
717
- $url = $url.'/autocompleteplus/products/pushbulk/pushid/'.$id;
718
- } else {
719
- $url = $url.'index.php/autocompleteplus/products/pushbulk/pushid/'.$id;
720
- }
721
-
722
- return $url;
723
- }
724
-
725
- public function escapeXml($xml)
726
- {
727
- // $pairs = array(
728
- // "\x03" => "&#x03;",
729
- // "\x05" => "&#x05;",
730
- // "\x0E" => "&#x0E;",
731
- // "\x16" => "&#x16;",
732
- // );
733
- // $xml = strtr($xml, $pairs);
734
-
735
- $xml = preg_replace('/[\x00-\x1f]/', '', $xml);
736
-
737
- return $xml;
738
- }
739
-
740
- /**
741
- * Get the session cookie value
742
- * protected with a salt (the store encryption key).
743
- *
744
- * @return string
745
- */
746
- public function getSessionId()
747
- {
748
- return md5(Mage::app()->getCookie()->get('frontend').$this->_getEncryptionKey());
749
- }
750
-
751
- /**
752
- * Return encryption key in Magento to use as salt
753
- * Requires getting from configNode so that it is backward
754
- * compatible with later versions.
755
- *
756
- * @return string
757
- */
758
- protected function _getEncryptionKey()
759
- {
760
- return (string) Mage::getConfig()->getNode('global/crypt/key');
761
- }
762
-
763
- public function validateInput($input, $type = "integer", $default = null, $on_failure = null){
764
- $validated_input = $default;
765
- $sanity_type = FILTER_SANITIZE_NUMBER_INT;
766
- $type = strtolower($type);
767
- if ($type == "integer" || $type == 'int'){
768
- $sanity_type = FILTER_SANITIZE_NUMBER_INT;
769
- } else if ($type == 'boolean' || $type == 'bool'){
770
- $sanity_type = FILTER_VALIDATE_BOOLEAN;
771
- }
772
-
773
- $filter_input = filter_var($input, $sanity_type, FILTER_NULL_ON_FAILURE);
774
- if ($filter_input || ($sanity_type == FILTER_SANITIZE_NUMBER_INT && $filter_input === "0")){
775
- $validated_input = $filter_input;
776
- $status = settype($validated_input, $type);
777
- if (!$status){
778
- $validated_input = $on_failure;
779
- }
780
- }
781
- return $validated_input;
782
- }
783
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Autocompleteplus/Autosuggest/Model/Catalog.php CHANGED
@@ -2,132 +2,185 @@
2
 
3
  class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstract
4
  {
5
- private $imageField;
6
- private $standardImageFields;
7
- private $useAttributes;
8
- private $attributes;
9
- private $currency;
10
- private $pageNum;
11
-
12
- public function renderCatalogXml($startInd, $count, $storeId = '', $orders = '', $month_interval = '', $checksum = '')
 
 
 
 
13
  {
14
- $this->_initCatalogCommonFields($storeId);
15
-
16
- if (!$startInd) {
17
- $startInd = 0;
18
  }
19
 
20
- //maxim products on one page is 1000
21
- if (!$count || $count > 1000) {
22
- $count = 1000;
 
 
 
 
23
  }
24
- //retrieving page number
25
- $this->pageNum = floor(($startInd / $count));
26
 
27
- $mage = Mage::getVersion();
28
- $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
 
29
 
30
- $xml = '<?xml version="1.0"?>';
31
- $xml .= '<catalog version="'.$ext.'" magento="'.$mage.'">';
 
 
 
 
 
 
32
 
33
- $collection = Mage::getModel('catalog/product')->getCollection();
34
- if (isset($storeId) && $storeId != '') {
35
- $collection->addStoreFilter($storeId);
36
- $store_id = $storeId;
37
- } else {
38
- $store_id = Mage::app()->getStore()->getStoreId();
39
  }
40
 
41
- //setting page+products on the page
42
- $collection->getSelect()->limit($count, $startInd);//->limitPage($pageNum, $count);//setPage($pageNum, $count)->load();
43
- $collection->load();
44
 
45
- // number of orderes per product section
46
- if (isset($orders) && $orders == '1') {
47
- $product_id_list = array();
48
- foreach ($collection as $product) {
49
- $product_id_list[] = $product->getId();
50
- }
51
 
52
- if (isset($month_interval) && $month_interval != '') {
53
- $month_interval = $month_interval;
54
- } else {
55
- $month_interval = 12;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
- $orders_per_product = $this->_getOrdersPerProduct($store_id, $product_id_list, $month_interval);
58
- } else {
59
- // end - number of orderes per product section
60
- $orders_per_product = null;
61
  }
62
 
63
- $this->_root_category_id = Mage::app()->getStore($store_id)->getRootCategoryId();
64
-
65
- if (isset($checksum) && $checksum != '') {
66
- $is_checksum = $checksum;
67
- $helper = Mage::helper('autocompleteplus_autosuggest');
68
- $_tableprefix = (string) Mage::getConfig()->getTablePrefix();
69
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
70
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
71
- } else {
72
- $is_checksum = 0;
73
- $helper = null;
74
- $_tableprefix = null;
75
- $write = null;
76
- $read = null;
77
  }
78
 
79
- foreach ($collection as $product) {
80
- $productCollData = $product->getData();
81
- try {
82
- $productModel = Mage::getModel('catalog/product')
83
- ->setStore($storeId)->setStoreId($storeId)
84
- ->load($productCollData['entity_id']);
85
- } catch (Exception $e) {
86
- continue;
87
- }
88
- $prodId = $productModel->getId();
89
- $sku = $productModel->getSku();
90
- $row = $this->renderProductXmlRow($productModel, $orders_per_product);
91
- $xml .= $row;
92
- if ($is_checksum && $helper) {
93
- if ($helper->isChecksumTableExists()) {
94
- $checksum = $helper->calculateChecksum($productModel);
95
- $helper->updateSavedProductChecksum($_tableprefix, $read, $write, $prodId, $sku, $store_id, $checksum);
96
  }
97
  }
98
  }
99
- $xml .= '</catalog>';
100
 
101
- return $xml;
102
  }
103
 
104
- public function renderUpdatesCatalogXml($count, $from, $to, $storeId)
105
  {
106
- $storeQ = '';
107
-
108
- if ($storeId != '') {
109
- $storeQ = 'AND store_id='.$storeId;
110
- } else {
111
- $storeId = Mage::app()->getStore()->getStoreId();
112
  }
113
- $this->_initCatalogCommonFields($storeId);
114
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
115
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
116
-
117
- $_tableprefix = (string) Mage::getConfig()->getTablePrefix();
118
- $sql = 'SELECT * FROM `'.$_tableprefix.'autocompleteplus_batches` WHERE update_date BETWEEN ? AND ? '.$storeQ.' order by update_date'.' LIMIT '.$count;
119
- $updates = $read->fetchAll($sql, array($from, $to));
120
 
121
- $mage = Mage::getVersion();
122
- $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
123
- $this->_root_category_id = Mage::app()->getStore($storeId)->getRootCategoryId();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- $xml = '<?xml version="1.0"?>';
126
- $xml .= '<catalog fromdatetime="'.$from.'" version="'.$ext.'" magento="'.$mage.'">';
127
  foreach ($updates as $batch) {
128
  if ($batch['action'] == 'update') {
129
  $productId = $batch['product_id'];
130
- $sku = $batch['sku'];
131
  $batchStoreId = $batch['store_id'];
132
 
133
  if ($storeId != $batchStoreId) {
@@ -144,21 +197,18 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
144
  ->load($productId);
145
  } catch (Exception $e) {
146
  $batch['action'] = 'remove';
147
- $xml .= $this->_makeRemoveRow($batch);
 
 
148
  continue;
149
  }
150
  } else {
151
  // product not found - changing action to remove
152
  $batch['action'] = 'remove';
153
- $xml .= $this->_makeRemoveRow($batch);
 
 
154
  continue;
155
-
156
- /*
157
- * FIX - Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Flat::loadAllAttributes()
158
- */
159
- // $productModel=Mage::getModel('catalog/product')
160
- // ->loadByAttribute('sku', $sku)
161
- // ->setStoreId($batchStoreId);
162
  }
163
 
164
  if ($productModel == null) {
@@ -167,58 +217,85 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
167
 
168
  $updatedate = $batch['update_date'];
169
  $action = $batch['action'];
170
- $xmlAttrs = 'action="'.$action.'" updatedate="'.$updatedate.'" storeid="'.$storeId.'"';
171
- // $xmlAttrs='action="'.$action.'" updatedate="'.$updatedate.'"';
172
- $xml .= $this->renderProductXmlRow($productModel, null, $xmlAttrs);
 
 
 
 
 
 
 
 
173
  } else {
174
- $xml .= $this->_makeRemoveRow($batch);
 
 
175
  }
176
  }
177
- $xml .= '</catalog>';
178
 
179
- return $xml;
180
  }
181
 
182
  public function renderCatalogFromIds($count, $fromId, $storeId)
183
  {
184
- $this->_initCatalogCommonFields($storeId);
185
-
186
- $mage = Mage::getVersion();
187
- $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
188
- $xml = '<catalog version="'.$ext.'" magento="'.$mage.'">';
189
-
190
- $_productCollection = Mage::getModel('catalog/product')->getCollection()
191
- ->addStoreFilter($storeId)
192
- ->addAttributeToSelect('*')
193
- ->addAttributeToFilter('entity_id', array('from' => $fromId));
194
-
195
- $_productCollection->getSelect()->limit($count);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
- //add media gallery to collection
 
 
198
 
199
- $action = 'getfromid';
200
 
201
- foreach ($_productCollection as $product) {
202
- if ($product) {
203
- $id = $product->getId();
204
- $lastUpdateddt = $product->getUpdatedAt();
205
 
206
- $xmlAttrTemplate = 'last_updated="%s" get_by_id_status="1" action="%s" storeid="%s"';
207
- $xmlAttrs = sprintf($xmlAttrTemplate,
208
- $lastUpdateddt,
209
- $action,
210
- $storeId
211
- );
212
 
213
- $xml .= $this->renderProductXmlRow($product, null, $xmlAttrs);
214
- } else {
215
- $xml .= '<product action="'.$action.'" product="'.$id.'" get_by_id_status="0"></product>';
216
- }
 
 
 
 
 
217
  }
218
 
219
- $xml .= '</catalog>';
220
-
221
- return $xml;
222
  }
223
 
224
  /**
@@ -231,780 +308,59 @@ class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstrac
231
  */
232
  public function renderCatalogByIds($ids, $storeId = 0)
233
  {
234
- $this->_initCatalogCommonFields($storeId);
235
-
236
- $mage = Mage::getVersion();
237
- $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
238
- $xml = '<catalog version="'.$ext.'" magento="'.$mage.'">';
239
-
240
- $_productCollection = Mage::getModel('catalog/product')->getCollection()
241
- //->addStoreFilter($storeId)
242
- //->addAttributeToSelect('*')
243
- ->addAttributeToFilter('entity_id', array(
244
- 'in' => $ids,
245
- ));
246
-
247
- $this->_root_category_id = Mage::app()->getStore($storeId)->getRootCategoryId();
248
-
249
- $action = 'getbyid';
250
-
251
- foreach ($ids as $id) {
252
- $productModel = Mage::getModel('catalog/product')
253
- ->setStoreId($storeId)
254
- ->load($id);
255
-
256
- if ($productModel->getId()) {
257
- $lastUpdateddt = $productModel->getUpdatedAt();
258
-
259
- $xmlAttrs = 'last_updated="'.$lastUpdateddt.'" get_by_id_status="1" action="'.$action.'" storeid="'.$storeId.'"';
260
-
261
- $xml .= $this->renderProductXmlRow($productModel, null, $xmlAttrs);
262
- } else {
263
- $xml .= '<product action="'.$action.'" product="'.$id.'" get_by_id_status="0"></product>';
264
- }
265
- }
266
-
267
- $xml .= '</catalog>';
268
-
269
- return $xml;
270
- }
271
-
272
- public function getCategoryMap()
273
- {
274
- if (!$this->_categories) {
275
- Mage::log('creating categories once', false, 'pjackson.log');
276
- $categoryMap = array();
277
- $categories = Mage::getModel('catalog/category')->getCollection()->load();
278
-
279
- foreach ($categories as $category) {
280
- $categoryMap[] = new Varien_Object(array(
281
- 'id' => $category->getId(),
282
- 'path' => $category->getPath(),
283
- 'parent_id' => $category->getParentId(),
284
- ));
285
- }
286
-
287
- $this->_categories = $categoryMap;
288
- }
289
-
290
- return $this->_categories;
291
- }
292
-
293
- public function getCategoryPathsByProduct(Mage_Catalog_Model_Product $product)
294
- {
295
- $productCategories = $product->getCategoryIds();
296
- $root_category_id = $this->_root_category_id;
297
- $paths = array_map(function ($category) use ($productCategories, $root_category_id) {
298
- if (in_array($category->getId(), $productCategories)) {
299
- $path = explode('/', $category->getPath());
300
- //we don't want the root category for the entire site
301
- array_shift($path);
302
- if ($root_category_id && is_array($path) && $path[0] != $root_category_id) {
303
- return array();
304
- }
305
- //we want more specific categories first
306
- return implode(':', array_reverse($path));
307
- }
308
- }, $this->getCategoryMap());
309
-
310
- return array_filter($paths);
311
- }
312
-
313
- public function renderProductXmlRow($productModel, $orders_per_product, $xmlAttrs = 'action="insert"')
314
- {
315
- $helper = Mage::helper('autocompleteplus_autosuggest');
316
- $categories = $this->getCategoryPathsByProduct($productModel);
317
- $price = $this->_getPrice($productModel);
318
- $sku = $productModel->getSku();
319
- $stock_status = $productModel->isInStock();
320
- $stockItem = $productModel->getStockItem();
321
-
322
- if ($stockItem) {
323
- if ($stockItem->getIsInStock() && $stock_status) {
324
- $sell = 1;
325
- } else {
326
- $sell = 0;
327
- }
328
- } else {
329
- if ($stock_status) {
330
- $sell = 1;
331
- } else {
332
- $sell = 0;
333
- }
334
- }
335
-
336
- $productUrl = ''; // getting the product's url according to the store_id
337
-
338
- $is_getUrlPath_supported = true;
339
- if (method_exists('Mage', 'getVersionInfo')) { // getUrlPath is not supported on EE 1.13... & 1.14...
340
- $edition_info = Mage::getVersionInfo();
341
- if ($edition_info['major'] == 1 && $edition_info['minor'] >= 13) {
342
- $is_getUrlPath_supported = false;
343
- }
344
- }
345
-
346
- if (method_exists($productModel, 'getUrlPath') && $is_getUrlPath_supported) {
347
- $productUrl = $productModel->getUrlPath();
348
- if ($productUrl != '') {
349
- $productUrl = Mage::getUrl($productUrl);
350
- }
351
- }
352
- if ($productUrl == '' && method_exists($productModel, 'getProductUrl')) {
353
- $productUrl = $productModel->getProductUrl();
354
- // $pattern = '/\?___.*/';
355
- // $productUrl = preg_replace($pattern, '', $productUrl);
356
- }
357
- if ($productUrl == '') {
358
- $productUrl = Mage::helper('catalog/product')->getProductUrl($productModel->getId());
359
- }
360
-
361
- $prodId = $productModel->getId();
362
- $prodDesc = $productModel->getDescription();
363
- $prodShortDesc = $productModel->getShortDescription();
364
- $prodName = $productModel->getName();
365
- $visibility = $productModel->getVisibility();
366
-
367
- if (defined('Mage_Catalog_Model_Product_Status::STATUS_ENABLED')) {
368
- if ($productModel->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
369
- $product_status = 1;
370
- } else {
371
- $product_status = 0;
372
- }
373
- } else {
374
- if ($productModel->getStatus() == 1) {
375
- $product_status = 1;
376
- } else {
377
- $product_status = 0;
378
- }
379
- }
380
-
381
- try {
382
- if (in_array($this->imageField, $this->standardImageFields)) {
383
- $prodImage = Mage::helper('catalog/image')->init($productModel, $this->imageField);
384
- } else {
385
- $function = 'get'.$this->imageField;
386
- $prodImage = $productModel->$function();
387
- }
388
-
389
- try {
390
- $product_media_config = Mage::getModel('catalog/product_media_config');
391
- $product_base_image = $product_media_config->getMediaUrl($productModel->getImage());
392
- } catch (Exception $e) {
393
- $product_base_image = '';
394
- }
395
- } catch (Exception $e) {
396
- $prodImage = '';
397
- $product_base_image = '';
398
- }
399
-
400
- if ($productModel->getTypeID() == 'configurable') {
401
- $configurableAttributes = $this->_getConfigurableAttributes($productModel);
402
-
403
- $configurableChildren = $this->_getConfigurableChildren($productModel);
404
-
405
- // getting all children's ids
406
- $configurable_children_ids = array();
407
- foreach ($configurableChildren as $child_product) {
408
- $configurable_children_ids[] = $child_product->getId();
409
- }
410
-
411
- // getting sellable option for the configurable product
412
- if ($sell) { // Configurable is in stock
413
- $is_in_stock_child_exist = false;
414
- foreach ($configurableChildren as $child_product) {
415
- if ($child_product->getStockItem()->getIsInStock()) {
416
- if (method_exists($child_product, 'isSaleable') && !$child_product->isSaleable()) {
417
- // the simple product is probably disabled (because its in stock)
418
- continue;
419
- }
420
- $is_in_stock_child_exist = true;
421
- break;
422
- }
423
- }
424
- if (!$is_in_stock_child_exist) {
425
- # Configurable is in stock, but has no in stock children
426
- $sell = 0;
427
- }
428
- }
429
-
430
- try {
431
- $priceRange = $this->_getPriceRange($productModel);
432
- } catch (Exception $e) {
433
- $priceRange = 'price_min="" price_max=""';
434
- }
435
- } elseif ($productModel->getTypeID() == 'simple') {
436
- $simple_product_parents = $this->_getSimpleProductParent($productModel);
437
- $priceRange = 'price_min="" price_max=""';
438
- } else {
439
- $priceRange = 'price_min="" price_max=""';
440
- }
441
-
442
- $num_of_orders = ($orders_per_product != null && array_key_exists($prodId, $orders_per_product)) ? $orders_per_product[$prodId] : 0;
443
- $row = '<product '.$priceRange.' id="'.$prodId.'" type="'.$productModel->getTypeID().'" currency="'.$this->currency.'" visibility="'.$visibility.'" price="'.$price.'" url="'.$productUrl.'" thumbs="'.$prodImage.'" base_image="'.$product_base_image.'" selleable="'.$sell.'" '.$xmlAttrs.' >';
444
- $row .= '<description><![CDATA['.$prodDesc.']]></description>';
445
- $row .= '<short><![CDATA['.$prodShortDesc.']]></short>';
446
- $row .= '<name><![CDATA['.$prodName.']]></name>';
447
- $row .= '<sku><![CDATA['.$sku.']]></sku>';
448
-
449
- $summaryData = Mage::getModel('review/review_summary')
450
- ->setStoreId($productModel->getStoreId())
451
- ->load($prodId);
452
- if (($summaryData['rating_summary'] || $summaryData['rating_summary'] == 0) && $summaryData['rating_summary'] != '') {
453
- $row .= '<review><![CDATA['.$summaryData['rating_summary'].']]></review>';
454
- $row .= '<reviews_count><![CDATA['.$summaryData['reviews_count'].']]></reviews_count>';
455
- }
456
-
457
- $new_from_date = $productModel->getNewsFromDate();
458
- $new_to_date = $productModel->getNewsToDate();
459
- if ($new_from_date) {
460
- $row .= '<newfrom><![CDATA['.Mage::getModel('core/date')->timestamp($new_from_date).']]></newfrom>';
461
- if ($new_to_date) {
462
- $row .= '<newto><![CDATA['.Mage::getModel('core/date')->timestamp($new_to_date).']]></newto>';
463
- }
464
- }
465
-
466
- $row .= '<purchase_popularity><![CDATA['.$num_of_orders.']]></purchase_popularity>';
467
- $row .= '<product_status><![CDATA['.$product_status.']]></product_status>';
468
-
469
- try {
470
- $row .= '<creation_date><![CDATA['.Mage::getModel('core/date')->timestamp($productModel->getCreatedAt()).']]></creation_date>';
471
- $row .= '<updated_date><![CDATA['.Mage::getModel('core/date')->timestamp($productModel->getUpdatedAt()).']]></updated_date>';
472
- } catch (Exception $e) {
473
- }
474
-
475
- if ($this->useAttributes != '0') {
476
- foreach ($this->attributes as $attr) {
477
  $action = $attr->getAttributeCode();
478
- $is_filterable = $attr->getis_filterable();
479
- $attribute_label = $attr->getStoreLabel($productModel->getStoreId());
480
-
481
- if ($attr->getfrontend_input() == 'select') {
482
- if ($productModel->getData($action)) {
483
- if (method_exists($productModel, 'getAttributeText')) {
484
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'">
485
- <attribute_values><![CDATA['.$productModel->getAttributeText($action).']]></attribute_values>
486
- <attribute_label><![CDATA['.$attribute_label.']]></attribute_label>
487
- </attribute>';
488
- } else {
489
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'">
490
- <attribute_values><![CDATA['.$productModel->getData($action).']]></attribute_values>
491
- <attribute_label><![CDATA['.$attribute_label.']]></attribute_label>
492
- </attribute>';
493
- }
494
- }
495
- } elseif ($attr->getfrontend_input() == 'textarea') {
496
- if ($productModel->getData($action)) {
497
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'">
498
- <attribute_values><![CDATA['.$productModel->getData($action).']]></attribute_values>
499
- <attribute_label><![CDATA['.$attribute_label.']]></attribute_label>
500
- </attribute>';
501
- }
502
- } elseif ($attr->getfrontend_input() == 'price') {
503
- if ($productModel->getData($action)) {
504
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'">
505
- <attribute_values><![CDATA['.$productModel->getData($action).']]></attribute_values>
506
- <attribute_label><![CDATA['.$attribute_label.']]></attribute_label>
507
- </attribute>';
508
- }
509
- } elseif ($attr->getfrontend_input() == 'text') {
510
- if ($productModel->getData($action)) {
511
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'">
512
- <attribute_values><![CDATA['.$productModel->getData($action).']]></attribute_values>
513
- <attribute_label><![CDATA['.$attribute_label.']]></attribute_label>
514
- </attribute>';
515
- }
516
- } elseif ($attr->getfrontend_input() == 'multiselect') {
517
- if ($productModel->getData($action)) {
518
- $values = $productModel->getResource()->getAttribute($action)->getFrontend()->getValue($productModel);
519
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'">
520
- <attribute_values><![CDATA['.$values.']]></attribute_values>
521
- <attribute_label><![CDATA['.$attribute_label.']]></attribute_label>
522
- </attribute>';
523
- }
524
- }
525
- }
526
 
527
- if ($productModel->getTypeID() == 'configurable' && count($configurableAttributes) > 0) {
528
- $configural_attributes = array();
529
- foreach ($configurableAttributes as $attrName => $confAttrN) {
530
- if (is_array($confAttrN) && array_key_exists('values', $confAttrN)) {
531
- $configural_attributes[] = $attrName;
532
- $values = implode(' , ', $confAttrN['values']);
533
- $row .= '<attribute is_configurable="1" is_filterable="'.$confAttrN['is_filterable'].'" name="'.$attrName.'"><![CDATA['.$values.']]></attribute>';
534
- }
535
- }
536
- $simple_products_price = $this->_getSimpleProductsPriceOfConfigurable($productModel, $configurableChildren);
537
-
538
- if (!empty($configural_attributes)) {
539
- $product_variation = '<variants>';
540
- try {
541
- foreach ($configurableChildren as $child_product) {
542
- if (!in_array($productModel->getStoreId(), $child_product->getStoreIds())) {
543
- continue;
544
- }
545
-
546
- $is_variant_in_stock = ($child_product->getStockItem()->getIsInStock()) ? 1 : 0;
547
-
548
- if (method_exists($child_product, 'isSaleable')) {
549
- $is_variant_sellable = ($child_product->isSaleable()) ? 1 : 0;
550
- } else {
551
- $is_variant_sellable = '';
552
- // $is_variant_sellable = (Mage::getModel('catalog/product')
553
- // ->setStore($productModel->getStoreId())
554
- // ->setStoreId($productModel->getStoreId())
555
- // ->load($child_product->getId())
556
- // ->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
557
- }
558
-
559
- if (method_exists($child_product, 'getVisibility')) {
560
- $is_variant_visible = ($child_product->getVisibility()) ? 1 : 0;
561
- } else {
562
- $is_variant_visible = '';
563
- // $is_variant_visible = (Mage::getModel('catalog/product')
564
- // ->setStore($productModel->getStoreId())
565
- // ->setStoreId($productModel->getStoreId())
566
- // ->load($child_product->getId())
567
- // ->getVisibility());
568
- }
569
-
570
- $variant_price = (array_key_exists($child_product->getId(), $simple_products_price)) ?
571
- $simple_products_price[$child_product->getId()] : '';
572
-
573
- $product_variation .= '<variant id="'.$child_product->getId().'" type="'.$child_product->getTypeID().
574
- '" visibility="'.$is_variant_visible.'" is_in_stock="'.$is_variant_in_stock.'" is_seallable="'.$is_variant_sellable.'" price="'.$variant_price.'">';
575
- $product_variation .= '<name><![CDATA['.$child_product->getName().']]></name>';
576
-
577
- $attributes = $child_product->getAttributes();
578
- foreach ($attributes as $attribute) {
579
- if (!$attribute['is_configurable'] || !in_array($attribute['store_label'], $configural_attributes)) { // || !$attribute->getIsVisibleOnFront()
580
- continue;
581
- }
582
-
583
- $product_variation .= '<variant_attribute is_configurable="1" is_filterable="'.$attribute->getis_filterable().
584
- '" name="'.$attribute['store_label'].'" name_code="'.$attribute->getId().
585
- '" value_code="'.$child_product->getData($attribute->getAttributeCode()).
586
- '"><![CDATA['.$attribute->getFrontend()->getValue($child_product).
587
- ']]></variant_attribute>';
588
- }
589
- $product_variation .= '</variant>';
590
- }
591
- } catch (Exception $e) {
592
- }
593
- $product_variation .= '</variants>';
594
- $row .= $product_variation;
595
- }
596
-
597
- $row .= '<simpleproducts><![CDATA['.implode(',', $configurable_children_ids).']]></simpleproducts>';
598
- }
599
-
600
- if ($productModel->getTypeID() == 'simple') {
601
- $row .= '<product_parents><![CDATA['.implode(',', $simple_product_parents).']]></product_parents>';
602
  }
603
  }
604
 
605
- $row .= '<categories><![CDATA['.implode(';', $categories).']]></categories>';
606
- $row .= '</product>';
607
-
608
- return $helper->escapeXml($row);
609
- }
610
-
611
- private function _makeUpdateRow($batch, $attributes)
612
- {
613
- $productId = $batch['product_id'];
614
-
615
- $sku = $batch['sku'];
616
 
617
- $storeId = $batch['store_id'];
618
 
619
- $updatedate = $batch['update_date'];
620
-
621
- $action = $batch['action'];
622
-
623
- $currency = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
624
-
625
- if ($productId != null) {
626
- $productModel = Mage::getModel('catalog/product')
627
 
 
 
 
 
628
  ->setStoreId($storeId)
629
-
630
- ->load($productId);
631
-
632
- if ($productModel == null) {
633
- return '';
634
- }
635
- } else {
636
-
637
- /*
638
-
639
- * FIX - Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Flat::loadAllAttributes()
640
-
641
- */
642
-
643
- $productModel = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
644
-
645
- if ($productModel == null) {
646
- return '';
647
- }
648
-
649
- $productModel = $productModel->setStoreId($storeId);
650
-
651
- $productId = $productModel->getId();
652
- }
653
-
654
- if ($productModel == null) {
655
- return '';
656
- }
657
-
658
- $price = $this->getPrice($productModel);
659
-
660
- $sku = $productModel->getSku();
661
-
662
- $status = $productModel->isInStock();
663
-
664
- $stockItem = $productModel->getStockItem();
665
-
666
- $categoriesNames = '';
667
-
668
- $categories = $productModel->getCategoryCollection()
669
- ->addAttributeToSelect('name');
670
-
671
- foreach ($categories as $category) {
672
- $categoriesNames .= $category->getName().':'.$category->getId().';';
673
- }
674
-
675
- if ($stockItem->getIsInStock() && $status) {
676
- $sell = 1;
677
- } else {
678
- $sell = 0;
679
- }
680
-
681
- $productUrl = Mage::helper('catalog/product')->getProductUrl($productId);
682
-
683
- $prodId = $productModel->getId();
684
-
685
- $prodDesc = $productModel->getDescription();
686
-
687
- $prodShortDesc = $productModel->getShortDescription();
688
-
689
- $prodName = $productModel->getName();
690
-
691
- $visibility = $productModel->getVisibility();
692
-
693
- try {
694
- if (in_array($this->imageField, $this->standardImageFields)) {
695
- $prodImage = Mage::helper('catalog/image')->init($productModel, $this->imageField);
696
- } else {
697
- $function = 'get'.$this->imageField;
698
-
699
- $prodImage = $productModel->$function();
700
- }
701
- } catch (Exception $e) {
702
- $prodImage = '';
703
- }
704
-
705
- if ($productModel->getTypeID() == 'configurable') {
706
- $configurableAttributes = $this->_getConfigurableAttributes($productModel);
707
-
708
- try {
709
- $priceRange = $this->_getPriceRange($productModel);
710
- } catch (Exception $e) {
711
- $priceRange = 'price_min="" price_max=""';
712
- }
713
- } else {
714
- $priceRange = 'price_min="" price_max=""';
715
- }
716
-
717
- $row = '<product '.$priceRange.' id="'.$prodId.'" type="'.$productModel->getTypeID().'" updatedate="'.$updatedate.'" currency="'.$currency.'" storeid="'.$storeId.'" visibility="'.$visibility.'" price="'.$price.'" url="'.$productUrl.'" thumbs="'.$prodImage.'" selleable="'.$sell.'" action="'.$action.'" >';
718
-
719
- $row .= '<description><![CDATA['.$prodDesc.']]></description>';
720
-
721
- $row .= '<short><![CDATA['.$prodShortDesc.']]></short>';
722
-
723
- $row .= '<name><![CDATA['.$prodName.']]></name>';
724
-
725
- $row .= '<sku><![CDATA['.$sku.']]></sku>';
726
-
727
- if ($attributes != null) {
728
- foreach ($attributes as $attr) {
729
- $action = $attr->getAttributeCode();
730
-
731
- $is_filterable = $attr->getis_filterable();
732
-
733
- if ($attr->getfrontend_input() == 'select') {
734
- if ($productModel->getData($action)) {
735
- $row .= '<attribute is_filterable="'.$is_filterable.'" attribute_type="'.$attr->getfrontend_input().'" name="'.$attr->getAttributeCode().'"><![CDATA['.$productModel->getAttributeText($action).']]></attribute>';
736
- }
737
- } elseif ($attr->getfrontend_input() == 'textarea') {
738
- if ($productModel->getData($action)) {
739
- $row .= '<attribute is_filterable="'.$is_filterable.'" attribute_type="'.$attr->getfrontend_input().'" name="'.$attr->getAttributeCode().'"><![CDATA['.$productModel->getData($action).']]></attribute>';
740
- }
741
- } elseif ($attr->getfrontend_input() == 'price') {
742
- if ($productModel->getData($action)) {
743
- $row .= '<attribute is_filterable="'.$is_filterable.'" attribute_type="'.$attr->getfrontend_input().'" name="'.$attr->getAttributeCode().'"><![CDATA['.$productModel->getData($action).']]></attribute>';
744
- }
745
- } elseif ($attr->getfrontend_input() == 'text') {
746
- if ($productModel->getData($action)) {
747
- $row .= '<attribute is_filterable="'.$is_filterable.'" attribute_type="'.$attr->getfrontend_input().'" name="'.$attr->getAttributeCode().'"><![CDATA['.$productModel->getData($action).']]></attribute>';
748
- }
749
- } elseif ($attr->getfrontend_input() == 'multiselect') {
750
- if ($productModel->getData($action)) {
751
- $values = $productModel->getResource()->getAttribute($action)->getFrontend()->getValue($productModel);
752
-
753
- $row .= '<attribute is_filterable="'.$is_filterable.'" name="'.$attr->getAttributeCode().'"><![CDATA['.$values.']]></attribute>';
754
- }
755
- }
756
- }
757
-
758
- if ($productModel->getTypeID() == 'configurable' && count($configurableAttributes) > 0) {
759
- foreach ($configurableAttributes as $attrName => $confAttrN) {
760
- if (is_array($confAttrN) && array_key_exists('values', $confAttrN)) {
761
- $values = implode(' , ', $confAttrN['values']);
762
-
763
- $row .= '<attribute is_configurable="1" is_filterable="'.$confAttrN['is_filterable'].'" name="'.$attrName.'"><![CDATA['.$values.']]></attribute>';
764
- }
765
- }
766
- }
767
- }
768
-
769
- $row .= '<categories><![CDATA['.$categoriesNames.']]></categories>';
770
-
771
- $row .= '</product>';
772
-
773
- return $row;
774
- }
775
-
776
- private function _makeRemoveRow($batch)
777
- {
778
- $updatedate = $batch['update_date'];
779
- $action = $batch['action'];
780
- $sku = $batch['sku'];
781
- $productId = $batch['product_id'];
782
- $storeId = $batch['store_id'];
783
-
784
- $row = '<product updatedate="'.$updatedate.'" action="'.$action.'" id="'.$productId.'" storeid="'.$storeId.'">';
785
- $row .= '<sku><![CDATA['.$sku.']]></sku>';
786
- $row .= '<id><![CDATA['.$productId.']]></id>';
787
- $row .= '</product>';
788
-
789
- return $row;
790
- }
791
-
792
- private function _getConfigurableChildren($product)
793
- {
794
- $childProducts = Mage::getModel('catalog/product_type_configurable')
795
- ->getUsedProducts(null, $product);
796
-
797
- return $childProducts;
798
- }
799
-
800
- private function _getSimpleProductParent($product)
801
- {
802
- try {
803
- $parent_products_ids_list = Mage::getModel('catalog/product_type_configurable')
804
- ->getParentIdsByChild($product->getId());
805
-
806
- return $parent_products_ids_list;
807
- } catch (Exception $e) {
808
- return array();
809
- }
810
- }
811
-
812
- private function _getConfigurableAttributes($product)
813
- {
814
- try {
815
- // Collect options applicable to the configurable product
816
- $productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
817
-
818
- $attributeOptions = array();
819
-
820
- foreach ($productAttributeOptions as $productAttribute) {
821
- $attributeFull = Mage::getModel('eav/config')->getAttribute('catalog_product', $productAttribute['attribute_code']);
822
-
823
- foreach ($productAttribute['values'] as $attribute) {
824
- $attributeOptions[$productAttribute['store_label']]['values'][] = $attribute['store_label'];
825
- }
826
-
827
- $attributeOptions[$productAttribute['store_label']]['is_filterable'] = $attributeFull['is_filterable'];
828
- $attributeOptions[$productAttribute['store_label']]['frontend_input'] = $attributeFull['frontend_input'];
829
- }
830
-
831
- return $attributeOptions;
832
- } catch (Exception $e) {
833
- return array();
834
- }
835
- }
836
-
837
- private function _getPriceRange($product)
838
- {
839
- $max = '';
840
- $min = '';
841
-
842
- $pricesByAttributeValues = array();
843
- $attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
844
- $basePrice = $product->getFinalPrice();
845
- $items = $attributes->getItems();
846
- if (is_array($items)) {
847
- foreach ($items as $attribute) {
848
- $prices = $attribute->getPrices();
849
- if (is_array($prices)) {
850
- foreach ($prices as $price) {
851
- if ($price['is_percent']) { //if the price is specified in percents
852
- $pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'] * $basePrice / 100;
853
- } else { //if the price is absolute value
854
- $pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'];
855
- }
856
- }
857
- }
858
- }
859
- }
860
-
861
- $simple = $product->getTypeInstance()->getUsedProducts();
862
- foreach ($simple as $sProduct) {
863
- $totalPrice = $basePrice;
864
- foreach ($attributes as $attribute) {
865
- $value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
866
- if (isset($pricesByAttributeValues[$value])) {
867
- $totalPrice += $pricesByAttributeValues[$value];
868
- }
869
- }
870
- if (!$max || $totalPrice > $max) {
871
- $max = $totalPrice;
872
- }
873
- if (!$min || $totalPrice < $min) {
874
- $min = $totalPrice;
875
- }
876
  }
877
- $priceRange = 'price_min="'.$min.'" price_max="'.$max.'"';
878
-
879
- return $priceRange;
880
- }
881
-
882
- private function _getSimpleProductsPriceOfConfigurable($product, $configurable_children)
883
- {
884
- $simple_products_price = array();
885
- $pricesByAttributeValues = array();
886
- $attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
887
- $basePrice = $product->getFinalPrice();
888
- $items = $attributes->getItems();
889
- if (is_array($items)) {
890
- foreach ($items as $attribute) {
891
- $prices = $attribute->getPrices();
892
- if (is_array($prices)) {
893
- foreach ($prices as $price) {
894
- if ($price['is_percent']) { //if the price is specified in percents
895
- $pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'] * $basePrice / 100;
896
- } else { //if the price is absolute value
897
- $pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'];
898
- }
899
- }
900
- }
901
- }
902
- }
903
-
904
- foreach ($configurable_children as $sProduct) {
905
- $totalPrice = $basePrice;
906
- foreach ($attributes as $attribute) {
907
- $value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
908
- if (isset($pricesByAttributeValues[$value])) {
909
- $totalPrice += $pricesByAttributeValues[$value];
910
- }
911
- }
912
- $simple_products_price[$sProduct->getId()] = $totalPrice;
913
- }
914
-
915
- return $simple_products_price;
916
- }
917
-
918
- private function _getOrdersPerProduct($store_id, $product_id_list, $month_interval)
919
- {
920
- if (count($product_id_list) <= 0) {
921
- return;
922
- }
923
-
924
- $id_str = implode(',', $product_id_list);
925
-
926
- $query = Mage::getResourceModel('sales/order_item_collection');
927
 
928
- $select = $query->getSelect()->reset(Zend_Db_Select::COLUMNS)
929
-
930
- ->columns(array('product_id', 'SUM(qty_ordered)'))
931
-
932
- ->where(new Zend_Db_Expr('store_id = '.$store_id))
933
-
934
- ->where(new Zend_Db_Expr('product_id IN ('.$id_str.')'))
935
-
936
- ->where(new Zend_Db_Expr('created_at BETWEEN NOW() - INTERVAL '.$month_interval.' MONTH AND NOW()'))
937
-
938
- ->group(array('product_id'));
939
-
940
- $resource = Mage::getSingleton('core/resource');
941
-
942
- $readConnection = $resource->getConnection('core_read');
943
-
944
- $results = $readConnection->fetchAll($select);
945
-
946
- $orders_per_product = array();
947
-
948
- foreach ($results as $res) {
949
- $orders_per_product[$res['product_id']] = (int) $res['SUM(qty_ordered)'];
950
- }
951
-
952
- return $orders_per_product;
953
- }
954
-
955
- private function _getPrice($product)
956
- {
957
- $price = 0;
958
- $helper = Mage::helper('autocompleteplus_autosuggest');
959
- if ($product->getTypeId() == 'grouped') {
960
- $helper->prepareGroupedProductPrice($product);
961
- $_minimalPriceValue = $product->getPrice();
962
- if ($_minimalPriceValue) {
963
- $price = $_minimalPriceValue;
964
- }
965
- } elseif ($product->getTypeId() == 'bundle') {
966
- if (!$product->getFinalPrice()) {
967
- $price = $helper->getBundlePrice($product);
968
- } else {
969
- $price = $product->getFinalPrice();
970
- }
971
- } else {
972
- $price = $product->getFinalPrice();
973
- }
974
- if (!$price) {
975
- $price = 0;
976
- }
977
-
978
- return $price;
979
- }
980
-
981
- /**
982
- * @param $storeId
983
- */
984
- private function _initCatalogCommonFields($storeId)
985
- {
986
- $this->imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
987
-
988
- if (!$this->imageField) {
989
- $this->imageField = 'thumbnail';
990
- }
991
-
992
- $this->useAttributes = Mage::getStoreConfig('autocompleteplus/config/attributes');
993
-
994
- $this->currency = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
995
-
996
- $this->standardImageFields = array('image', 'small_image', 'thumbnail');
997
-
998
- $productScheme = Mage::getModel('catalog/product');
999
-
1000
- if ($this->useAttributes != '0') {
1001
- $this->attributes = Mage::getResourceModel('eav/entity_attribute_collection')
1002
-
1003
- ->setEntityTypeFilter($productScheme->getResource()->getTypeId())
1004
-
1005
- ->addFieldToFilter('is_user_defined', '1') // This can be changed to any attribute code
1006
-
1007
- ->load(false);
1008
- }
1009
  }
1010
  }
2
 
3
  class Autocompleteplus_Autosuggest_Model_Catalog extends Mage_Core_Model_Abstract
4
  {
5
+ protected $imageField;
6
+ protected $standardImageFields = array('image', 'small_image', 'thumbnail');
7
+ protected $useAttributes;
8
+ protected $attributes;
9
+ protected $currency;
10
+ protected $pageNum;
11
+ protected $_productCollection;
12
+ protected $_xmlGenerator;
13
+ protected $_helper;
14
+ protected $_attributes;
15
+
16
+ public function getXmlGenerator()
17
  {
18
+ if (!$this->_xmlGenerator) {
19
+ $this->_xmlGenerator = new Autocompleteplus_Autosuggest_Xml_Generator();
 
 
20
  }
21
 
22
+ return $this->_xmlGenerator;
23
+ }
24
+
25
+ public function getHelper()
26
+ {
27
+ if (!$this->_helper) {
28
+ $this->_helper = Mage::helper('autocompleteplus_autosuggest');
29
  }
30
+ return $this->_helper;
31
+ }
32
 
33
+ public function getAttributes()
34
+ {
35
+ if (!$this->_attributes) {
36
 
37
+ $productModel = Mage::getModel('catalog/product');
38
+ $this->_attributes = Mage::getResourceModel('eav/entity_attribute_collection')
39
+ ->setEntityTypeFilter($productModel->getResource()->getTypeId())
40
+ ->addFieldToFilter('is_user_defined', '1')
41
+ ;
42
+ }
43
+ return $this->_attributes;
44
+ }
45
 
46
+ public function getProductCollection($new = false)
47
+ {
48
+ if (!$this->_productCollection) {
49
+ $this->_productCollection = Mage::getModel('catalog/product')->getCollection();
 
 
50
  }
51
 
52
+ if ($new === true) {
53
+ return Mage::getModel('catalog/product')->getCollection();
54
+ }
55
 
56
+ return $this->_productCollection;
57
+ }
 
 
 
 
58
 
59
+ public function getProductRenderer()
60
+ {
61
+ return Mage::getSingleton('autocompleteplus_autosuggest/renderer_catalog_product');
62
+ }
63
+
64
+ public function getBatchRenderer()
65
+ {
66
+ return Mage::getSingleton('autocompleteplus_autosuggest/renderer_batches');
67
+ }
68
+
69
+ public function renderCatalogXml($startInd = 0,
70
+ $count = 10000,
71
+ $storeId = false,
72
+ $orders = false,
73
+ $monthInterval = 12,
74
+ $checksum = false)
75
+ {
76
+ $xmlGenerator = $this->getXmlGenerator();
77
+ $count = ($count > 10000) ? 10000 : $count;
78
+ $this->setStoreId($storeId);
79
+ $this->setOrders($orders);
80
+ $this->setMonthInterval($monthInterval);
81
+ $this->setChecksum($checksum);
82
+
83
+
84
+ $xmlGenerator->setRootAttributes(array(
85
+ 'version' => $this->getHelper()->getVersion(),
86
+ 'magento' => $this->getHelper()->getMageVersion()
87
+ ))->setRootElementName('catalog');
88
+
89
+ $productCollection = $this->getProductCollection();
90
+
91
+ // @codingStandardsIgnoreLine
92
+ $productCollection->getSelect()->limit($count, $startInd);
93
+ if (is_numeric($storeId)) {
94
+ $productCollection->addStoreFilter($storeId);
95
+ $productCollection->setStoreId($storeId);
96
+ }
97
+
98
+ $attributesToSelect = array(
99
+ 'store_id',
100
+ 'name',
101
+ 'description',
102
+ 'short_description',
103
+ 'visibility',
104
+ 'thumbnail',
105
+ 'image',
106
+ 'small_image',
107
+ 'url',
108
+ 'status',
109
+ 'updated_at',
110
+ 'price',
111
+ 'meta_title',
112
+ 'meta_description');
113
+
114
+ if($this->canUseAttributes()){
115
+ foreach ($this->getAttributes() as $attr) {
116
+ $action = $attr->getAttributeCode();
117
+
118
+ $attributesToSelect[] = $action;
119
  }
 
 
 
 
120
  }
121
 
122
+ $productCollection->addAttributeToSelect($attributesToSelect);
123
+
124
+ Mage::getModel('review/review')->appendSummary($productCollection);
125
+
126
+ if ($this->getChecksum() !== false) {
127
+ $this->setHasChecksum($checksum);
 
 
 
 
 
 
 
 
128
  }
129
 
130
+ foreach ($productCollection as $product) {
131
+ $this->getProductRenderer()
132
+ ->setAction('insert')
133
+ ->setProduct($product)
134
+ ->setStoreId($this->getStoreId())
135
+ ->setOrders($this->getOrders())
136
+ ->setMonthInterval($this->getMonthInterval())
137
+ ->setXmlElement($xmlGenerator)
138
+ ->setAttributes($this->getAttributes())
139
+ ->renderXml();
140
+ if ($this->getHasChecksum()) {
141
+ if ($this->getHelper()->isChecksumTableExists()) {
142
+ $checksum = $this->getHelper()->calculateChecksum($product);
143
+ $this->getHelper()->updateSavedProductChecksum($product->getId(), $product->getSku(), $this->getStoreId(), $checksum);
 
 
 
144
  }
145
  }
146
  }
 
147
 
148
+ return $xmlGenerator->generateXml();
149
  }
150
 
151
+ public function canUseAttributes()
152
  {
153
+ if (!$this->_useAttributes) {
154
+ $this->_useAttributes = Mage::getStoreConfigFlag('autocompleteplus/config/attributes');
 
 
 
 
155
  }
156
+ return $this->_useAttributes;
157
+ }
 
 
 
 
 
158
 
159
+ public function renderUpdatesCatalogXml($count, $from, $to, $storeId)
160
+ {
161
+ $updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
162
+ ->addFieldToFilter('update_date', array(
163
+ 'from' => $from,
164
+ 'to' => $to
165
+ ))
166
+ ->addFieldToFilter('store_id', $storeId);
167
+
168
+ $this->setStoreId($storeId);
169
+ $updates->setOrder('update_date', 'ASC');
170
+
171
+ $updates->setPageSize($count);
172
+ $updates->setCurPage(1);
173
+ $xmlGenerator= $this->getXmlGenerator();
174
+
175
+ $xmlGenerator->setRootAttributes(array(
176
+ 'version' => $this->getHelper()->getVersion(),
177
+ 'magento' => $this->getHelper()->getMageVersion(),
178
+ 'fromdatetime' => $from
179
+ ))->setRootElementName('catalog');
180
 
 
 
181
  foreach ($updates as $batch) {
182
  if ($batch['action'] == 'update') {
183
  $productId = $batch['product_id'];
 
184
  $batchStoreId = $batch['store_id'];
185
 
186
  if ($storeId != $batchStoreId) {
197
  ->load($productId);
198
  } catch (Exception $e) {
199
  $batch['action'] = 'remove';
200
+ $this->getBatchRenderer()
201
+ ->setXmlElement($xmlGenerator)
202
+ ->makeRemoveRow($batch);
203
  continue;
204
  }
205
  } else {
206
  // product not found - changing action to remove
207
  $batch['action'] = 'remove';
208
+ $this->getBatchRenderer()
209
+ ->setXmlElement($xmlGenerator)
210
+ ->makeRemoveRow($batch);
211
  continue;
 
 
 
 
 
 
 
212
  }
213
 
214
  if ($productModel == null) {
217
 
218
  $updatedate = $batch['update_date'];
219
  $action = $batch['action'];
220
+ $this->getProductRenderer()
221
+ ->setXmlElement($xmlGenerator)
222
+ ->setAction($action)
223
+ ->setProduct($productModel)
224
+ ->setStoreId($this->getStoreId())
225
+ ->setOrders($this->getOrders())
226
+ ->setMonthInterval($this->getMonthInterval())
227
+ ->setXmlElement($xmlGenerator)
228
+ ->setAttributes($this->getAttributes())
229
+ ->setUpdateDate($updatedate)
230
+ ->renderXml();
231
  } else {
232
+ $this->getBatchRenderer()
233
+ ->setXmlElement($xmlGenerator)
234
+ ->makeRemoveRow($batch);
235
  }
236
  }
 
237
 
238
+ return $xmlGenerator->generateXml();
239
  }
240
 
241
  public function renderCatalogFromIds($count, $fromId, $storeId)
242
  {
243
+ $xmlGenerator = $this->getXmlGenerator();
244
+ $xmlGenerator->setRootAttributes(array(
245
+ 'version' => $this->getHelper()->getVersion(),
246
+ 'magento' => $this->getHelper()->getMageVersion()
247
+ ))->setRootElementName('catalog');
248
+
249
+ $productCollection = $this->getProductCollection();
250
+ if (is_numeric($storeId)) {
251
+ $productCollection->addStoreFilter($storeId);
252
+ $productCollection->setStoreId($storeId);
253
+ }
254
+
255
+ $attributesToSelect = array(
256
+ 'store_id',
257
+ 'name',
258
+ 'description',
259
+ 'short_description',
260
+ 'visibility',
261
+ 'thumbnail',
262
+ 'image',
263
+ 'small_image',
264
+ 'url',
265
+ 'status',
266
+ 'updated_at',
267
+ 'price',
268
+ 'meta_title',
269
+ 'meta_description');
270
+
271
+ if($this->canUseAttributes()){
272
+ foreach ($this->getAttributes() as $attr) {
273
+ $action = $attr->getAttributeCode();
274
 
275
+ $attributesToSelect[] = $action;
276
+ }
277
+ }
278
 
279
+ $productCollection->addAttributeToSelect($attributesToSelect);
280
 
281
+ $productCollection->addAttributeToFilter('entity_id', array('from' => $fromId));
282
+ $productCollection->setPageSize($count);
283
+ $productCollection->setCurPage(1);
 
284
 
285
+ Mage::getModel('review/review')->appendSummary($productCollection);
 
 
 
 
 
286
 
287
+ foreach ($productCollection as $product) {
288
+ $this->getProductRenderer()
289
+ ->setAction('getfromid')
290
+ ->setProduct($product)
291
+ ->setStoreId($storeId)
292
+ ->setXmlElement($xmlGenerator)
293
+ ->setAttributes($this->getAttributes())
294
+ ->setGetByIdStatus(1)
295
+ ->renderXml();
296
  }
297
 
298
+ return $xmlGenerator->generateXml();
 
 
299
  }
300
 
301
  /**
308
  */
309
  public function renderCatalogByIds($ids, $storeId = 0)
310
  {
311
+ $xmlGenerator = $this->getXmlGenerator();
312
+ $xmlGenerator->setRootAttributes(array(
313
+ 'version' => $this->getHelper()->getVersion(),
314
+ 'magento' => $this->getHelper()->getMageVersion()
315
+ ))->setRootElementName('catalog');
316
+
317
+ $productCollection = $this->getProductCollection();
318
+ if (is_numeric($storeId)) {
319
+ $productCollection->addStoreFilter($storeId);
320
+ $productCollection->setStoreId($storeId);
321
+ }
322
+
323
+ $attributesToSelect = array(
324
+ 'store_id',
325
+ 'name',
326
+ 'description',
327
+ 'short_description',
328
+ 'visibility',
329
+ 'thumbnail',
330
+ 'image',
331
+ 'small_image',
332
+ 'url',
333
+ 'status',
334
+ 'updated_at',
335
+ 'price',
336
+ 'meta_title',
337
+ 'meta_description');
338
+
339
+ if($this->canUseAttributes()){
340
+ foreach ($this->getAttributes() as $attr) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  $action = $attr->getAttributeCode();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
 
343
+ $attributesToSelect[] = $action;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  }
345
  }
346
 
347
+ $productCollection->addAttributeToSelect($attributesToSelect);
 
 
 
 
 
 
 
 
 
 
348
 
349
+ $productCollection->addAttributeToFilter('entity_id', array('in' => $ids));
350
 
351
+ Mage::getModel('review/review')->appendSummary($productCollection);
 
 
 
 
 
 
 
352
 
353
+ foreach ($productCollection as $product) {
354
+ $this->getProductRenderer()
355
+ ->setAction('getbyid')
356
+ ->setProduct($product)
357
  ->setStoreId($storeId)
358
+ ->setXmlElement($xmlGenerator)
359
+ ->setAttributes($this->getAttributes())
360
+ ->setGetByIdStatus(1)
361
+ ->renderXml();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
 
364
+ return $xmlGenerator->generateXml();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  }
366
  }
app/code/local/Autocompleteplus/Autosuggest/Model/Catalogreport.php CHANGED
@@ -93,11 +93,13 @@ class Autocompleteplus_Autosuggest_Model_Catalogreport extends Mage_Core_Model_A
93
  public function getCurrentStoreId()
94
  {
95
  if (!$this->_storeId) {
96
- $request = $this->getRequest();
97
- $helper = Mage::helper('autocompleteplus_autosuggest');
98
- $this->_storeId = $helper->validateInput($request->getParam('store_id'), 'integer', null, null);
99
- if (!$this->_storeId){
100
- $this->_storeId = $helper->validateInput($request->getParam('store', Mage::app()->getStore()->getStoreId()), 'integer', Mage::app()->getStore()->getStoreId(), null);
 
 
101
  }
102
  }
103
 
93
  public function getCurrentStoreId()
94
  {
95
  if (!$this->_storeId) {
96
+ $post = $this->getRequest()->getParams();
97
+ if (array_key_exists('store_id', $post)) {
98
+ $this->_storeId = $post['store_id'];
99
+ } elseif (array_key_exists('store', $post)) {
100
+ $this->_storeId = $post['store'];
101
+ } else {
102
+ $this->_storeId = Mage::app()->getStore()->getStoreId();
103
  }
104
  }
105
 
app/code/local/Autocompleteplus/Autosuggest/Model/Config.php CHANGED
@@ -213,6 +213,31 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
213
  return Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /**
217
  * Generate Config for AutocompletePlus.
218
  *
@@ -225,19 +250,6 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
225
  */
226
  public function generateConfig($UUID = null, $key = null)
227
  {
228
-
229
- $client = new Varien_Http_Client();
230
- $fileIo = new Varien_Io_File();
231
- $fileIo->open(array('path' => Mage::getBaseDir()));
232
- $robotsTxtContent = $fileIo->read('robots.txt');
233
-
234
- $config = array(
235
- 'adapter' => 'Zend_Http_Client_Adapter_Curl',
236
- 'curloptions' => array(
237
- CURLOPT_RETURNTRANSFER => 1,
238
- ),
239
- );
240
-
241
  $params = array(
242
  'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
243
  'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
@@ -250,60 +262,36 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
250
  $params['key'] = $key;
251
  }
252
 
253
- $client->setUri($this->getEndpoint().'/install')
254
- ->setMethod('POST')
255
- ->setConfig($config);
256
-
257
- $client->setParameterPost($params);
258
-
259
- try {
260
- $response = $client->request();
261
-
262
- if ($response->isSuccessful()) {
263
- $responseData = json_decode($response->getBody(), true);
264
-
265
- /*
266
- * Validate uuid exists
267
- */
268
- if (isset($responseData['uuid']) && strlen($responseData['uuid']) > 50) {
269
- Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
270
- $this->_sendError('Could not get license string.');
271
-
272
- return false;
273
- } elseif (!isset($responseData['uuid'])) {
274
- Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
275
- $this->_sendError('Could not get license string.');
276
-
277
- return false;
278
- }
279
-
280
- $siteMapUrl = 'Sitemap:http://magento.instantsearchplus.com/ext_sitemap?u='.$responseData['uuid'].PHP_EOL;
281
- if ($fileIo->fileExists('robots.txt')) {
282
- if (strpos($robotsTxtContent, $siteMapUrl) === false) {
283
- if ($fileIo->isWriteable('robots.txt')) {
284
- $fileIo->write('robots.txt', $robotsTxtContent.$siteMapUrl);
285
- } else {
286
- //write message that file is not writteble
287
- $this->_sendError('File '.$fileIo->pwd().DS.'robots.txt is not writable.');
288
- }
289
- }
290
- } else {
291
- //create file
292
- if ($fileIo->isWriteable(Mage::getBaseDir())) {
293
- //create robots sitemap
294
- $fileIo->write('robots.txt', $siteMapUrl);
295
- } else {
296
- //write message that directory is not writeable
297
- $this->_sendError('Directory '.Mage::getBaseDir().' is not writable..');
298
- }
299
- }
300
  }
301
- } catch (Exception $e) {
302
- $responseData['uuid'] = 'failed';
303
- $errorMessage = $e->getMessage();
304
- Mage::logException($e);
305
- Mage::log('Install failed with a message: '.$e->getMessage(), null, 'autocomplete.log', true);
306
- $this->_sendError($e->getMessage());
307
  }
308
 
309
  $this->setAuthorizationKey($responseData['authentication_key']);
@@ -334,19 +322,26 @@ class Autocompleteplus_Autosuggest_Model_Config extends Mage_Core_Model_Abstract
334
  */
335
  protected function _sendError($message = 'No Message Provided')
336
  {
337
- $errClient = new Varien_Http_Client();
338
- $errClient->setUri($this->getEndpoint().'/install_error')
339
- ->setMethod('POST');
340
-
341
- $errClient->setParameterPost(array(
342
  'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
343
  'msg' => $message,
344
  'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
345
  'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
346
  'f' => $this->getModuleVersion(),
347
- ));
348
 
349
- return $errClient->request();
 
 
 
 
 
 
 
 
 
 
 
350
  }
351
 
352
  /**
213
  return Mage::getConfig()->getModuleConfig('Autocompleteplus_Autosuggest')->version;
214
  }
215
 
216
+ /**
217
+ * Update robots.txt file with ISP sitemap URL
218
+ * @param $responseData
219
+ */
220
+ protected function _updateRobotsTxt($responseData)
221
+ {
222
+ $fileIo = new Varien_Io_File();
223
+ $baseDir = Mage::getBaseDir();
224
+ $fileIo->open(array('path' => $baseDir));
225
+ $robotsTxtContent = $fileIo->read('robots.txt');
226
+ $siteMapUrl = 'Sitemap:http://magento.instantsearchplus.com/ext_sitemap?u='.$responseData['uuid'].PHP_EOL;
227
+ $robotsTxtExists = $fileIo->fileExists('robots.txt');
228
+ $baseDirWritable = $fileIo->isWriteable($baseDir);
229
+ $siteMapExists = strpos($robotsTxtContent, $siteMapUrl) === false;
230
+ $robotsTxtWritable = $fileIo->isWriteable('robots.txt');
231
+
232
+ if ($robotsTxtExists && $robotsTxtWritable && !$siteMapExists) {
233
+ $fileIo->write('robots.txt', $robotsTxtContent . $siteMapUrl);
234
+ } else if (!$robotsTxtExists && $baseDirWritable) {
235
+ $fileIo->write('robots.txt', $siteMapUrl);
236
+ } else {
237
+ $this->_sendError('Unable to properly update robots.txt with ISP Sitemap');
238
+ }
239
+ }
240
+
241
  /**
242
  * Generate Config for AutocompletePlus.
243
  *
250
  */
251
  public function generateConfig($UUID = null, $key = null)
252
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  $params = array(
254
  'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
255
  'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
262
  $params['key'] = $key;
263
  }
264
 
265
+ // @codingStandardsIgnoreStart
266
+ /**
267
+ * Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
268
+ * We need to use PHP's implementation of cURL directly rather than Zend or Varien
269
+ */
270
+ $client = curl_init($this->getEndpoint() . '/install');
271
+ curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
272
+ curl_setopt($client, CURLOPT_POSTFIELDS, $params);
273
+
274
+ $response = curl_exec($client);
275
+ curl_close($client);
276
+ // @codingStandardsIgnoreEnd
277
+
278
+ if ($response) {
279
+ $responseData = json_decode($response, true);
280
+
281
+ /*
282
+ * Validate uuid exists
283
+ */
284
+ if (isset($responseData['uuid']) && strlen($responseData['uuid']) > 50) {
285
+ Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
286
+ $this->_sendError('Could not get license string.');
287
+ return false;
288
+ } elseif (!isset($responseData['uuid'])) {
289
+ Mage::log('Registration failed - please check response below', null, 'autocomplete.log', true);
290
+ $this->_sendError('Could not get license string.');
291
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  }
293
+
294
+ $this->_updateRobotsTxt($responseData);
 
 
 
 
295
  }
296
 
297
  $this->setAuthorizationKey($responseData['authentication_key']);
322
  */
323
  protected function _sendError($message = 'No Message Provided')
324
  {
325
+ $params = array(
 
 
 
 
326
  'site' => $this->_getHelper()->getConfigDataByFullPath('web/unsecure/base_url'),
327
  'msg' => $message,
328
  'email' => Mage::getStoreConfig(self::XML_STORE_EMAIL_CONFIG),
329
  'multistore' => $this->_getHelper()->getMultiStoreDataJson(),
330
  'f' => $this->getModuleVersion(),
331
+ );
332
 
333
+ // @codingStandardsIgnoreStart
334
+ /**
335
+ * Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
336
+ * We need to use PHP's implementation of cURL directly rather than Zend or Varien
337
+ */
338
+ $client = curl_init($this->getEndpoint() . '/install_error');
339
+ curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
340
+ curl_setopt($client, CURLOPT_POSTFIELDS, $params);
341
+ $response = curl_exec($client);
342
+ curl_close($client);
343
+ // @codingStandardsIgnoreEnd
344
+ return $response;
345
  }
346
 
347
  /**
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Batches extends Autocompleteplus_Autosuggest_Model_Resource_Batches
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Batches/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Batches_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Checksum extends Autocompleteplus_Autosuggest_Model_Resource_Checksum
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Checksum/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Checksum_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Fulltext/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Fulltext_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Notifications extends Autocompleteplus_Autosuggest_Model_Resource_Notifications
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Notifications/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Notifications_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Pusher extends Autocompleteplus_Autosuggest_Model_Resource_Pusher
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Mysql4/Pusher/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * For Magento < 1.6 backward compatibility
5
+ */
6
+ class Autocompleteplus_Autosuggest_Model_Mysql4_Pusher_Collection extends Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection
7
+ {
8
+
9
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Observer.php CHANGED
@@ -139,27 +139,18 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
139
 
140
  protected function _sendUpdate($data)
141
  {
142
- $client = new Varien_Http_Client();
143
- $config = array(
144
- 'adapter' => 'Zend_Http_Client_Adapter_Curl',
145
- 'curloptions' => array(
146
- CURLOPT_RETURNTRANSFER => 1,
147
- ),
148
- );
149
- $client->setUri(self::API_UPDATE_URI)
150
- ->setMethod('POST')
151
- ->setConfig($config);
152
-
153
- if (!empty($data)) {
154
- $client->setParameterPost($data);
155
- }
156
-
157
- return $client->request();
158
  }
159
 
160
  public function catalog_product_save_after($observer)
161
  {
162
- date_default_timezone_set('Asia/Jerusalem');
163
  $product = $observer->getProduct();
164
  $origData = $observer->getProduct()->getOrigData();
165
  $storeId = $product->getStoreId();
@@ -172,7 +163,8 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
172
  $this->_writeproductDeletion($oldSku, $productId, $storeId, $product);
173
  }
174
  }
175
- $dt = strtotime('now');
 
176
  $simple_product_parents = ($product->getTypeID() == 'simple') ? Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()) : array();
177
 
178
  $product_stores = ($storeId == 0 && method_exists($product, 'getStoreIds')) ? $product->getStoreIds() : array($storeId);
@@ -246,6 +238,32 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
246
  }
247
  }
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  protected function _writeproductDeletion($sku, $productId, $storeId, $product = null)
250
  {
251
  $dt = strtotime('now');
@@ -266,7 +284,7 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
266
  }
267
  foreach ($product_stores as $product_store) {
268
  $batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
269
- ->addFieldToFilter('product_id', $configurable_product)
270
  ->addFieldToFilter('store_id', $product_store);
271
 
272
  // @codingStandardsIgnoreLine
@@ -278,7 +296,7 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
278
  ->save();
279
  } else {
280
  $newBatch = Mage::getModel('autocompleteplus_autosuggest/batches');
281
- $newBatch->setProductId($configurable_product)
282
  ->setStoreId($product_store)
283
  ->setUpdateDate($dt)
284
  ->setAction('update')
@@ -372,13 +390,17 @@ class Autocompleteplus_Autosuggest_Model_Observer extends Mage_Core_Model_Abstra
372
  */
373
  public function webhook_service_call()
374
  {
375
- $curl = new Varien_Http_Adapter_Curl();
376
- $curl->setConfig(array(
377
- 'timeout' => static::WEBHOOK_CURL_TIMEOUT_LENGTH,
378
- ));
379
- $curl->write(Zend_Http_Client::GET, $this->_getWebhookObjectUri());
380
- $curl->read();
381
- $curl->close();
 
 
 
 
382
  }
383
 
384
  /**
139
 
140
  protected function _sendUpdate($data)
141
  {
142
+ // @codingStandardsIgnoreStart
143
+ $client = curl_init(self::API_UPDATE_URI);
144
+ curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
145
+ curl_setopt($client, CURLOPT_POSTFIELDS, $data);
146
+ $response = curl_exec($client);
147
+ curl_close($client);
148
+ // @codingStandardsIgnoreEnd
149
+ return $response;
 
 
 
 
 
 
 
 
150
  }
151
 
152
  public function catalog_product_save_after($observer)
153
  {
 
154
  $product = $observer->getProduct();
155
  $origData = $observer->getProduct()->getOrigData();
156
  $storeId = $product->getStoreId();
163
  $this->_writeproductDeletion($oldSku, $productId, $storeId, $product);
164
  }
165
  }
166
+ $dt = Mage::getSingleton('core/date')->gmtTimestamp();
167
+ //$dt = Mage::getSingleton('core/date')->gmtDate();
168
  $simple_product_parents = ($product->getTypeID() == 'simple') ? Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()) : array();
169
 
170
  $product_stores = ($storeId == 0 && method_exists($product, 'getStoreIds')) ? $product->getStoreIds() : array($storeId);
238
  }
239
  }
240
 
241
+ public function catalog_product_save_after_real($observer)
242
+ {
243
+ $product = $observer->getProduct();
244
+
245
+ $productId = $product->getId();
246
+
247
+ $sku = $product->getSku();
248
+
249
+ try {
250
+
251
+ $updates = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
252
+ ->addFieldToFilter('product_id', array('null' => true))
253
+ ->addFieldToFilter('sku', $sku)
254
+ ;
255
+
256
+ foreach ($updates as $update) {
257
+ $update->setProductId($productId);
258
+
259
+ $update->save();
260
+ }
261
+
262
+ } catch (Exception $e) {
263
+ Mage::logException($e);
264
+ }
265
+ }
266
+
267
  protected function _writeproductDeletion($sku, $productId, $storeId, $product = null)
268
  {
269
  $dt = strtotime('now');
284
  }
285
  foreach ($product_stores as $product_store) {
286
  $batches = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection()
287
+ ->addFieldToFilter('product_id', $productId)
288
  ->addFieldToFilter('store_id', $product_store);
289
 
290
  // @codingStandardsIgnoreLine
296
  ->save();
297
  } else {
298
  $newBatch = Mage::getModel('autocompleteplus_autosuggest/batches');
299
+ $newBatch->setProductId($productId)
300
  ->setStoreId($product_store)
301
  ->setUpdateDate($dt)
302
  ->setAction('update')
390
  */
391
  public function webhook_service_call()
392
  {
393
+ // @codingStandardsIgnoreStart
394
+ /**
395
+ * Due to backward compatibility issues with Magento < 1.8.1 and cURL/Zend
396
+ * We need to use PHP's implementation of cURL directly rather than Zend or Varien
397
+ */
398
+ $client = curl_init($this->_getWebhookObjectUri());
399
+ curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
400
+ $response = curl_exec($client);
401
+ curl_close($client);
402
+ // @codingStandardsIgnoreEnd
403
+ return $response;
404
  }
405
 
406
  /**
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Abstract.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Autocompleteplus_Autosuggest_Model_Renderer_Abstract extends Mage_Core_Model_Abstract
4
+ {
5
+ protected $_currency;
6
+ protected $_pageNum;
7
+ protected $_productCollection;
8
+ protected $_xmlGenerator;
9
+ protected $_imageField;
10
+ protected $_storeId;
11
+ protected $_monthInterval;
12
+ protected $_helper;
13
+
14
+ public function getStoreId()
15
+ {
16
+ if (!$this->_storeId) {
17
+ $this->_storeId = Mage::app()->getStore()->getId();
18
+ }
19
+ return $this->_storeId;
20
+ }
21
+
22
+ public function setStoreId($storeId)
23
+ {
24
+ $this->_storeId = $storeId;
25
+ return $this;
26
+ }
27
+
28
+ public function getCurrency()
29
+ {
30
+ if (!$this->_currency) {
31
+ $this->_currency = Mage::app()->getStore($this->getStoreId())->getCurrentCurrencyCode();
32
+ }
33
+ return $this->_currency;
34
+ }
35
+
36
+ public function getMonthInterval()
37
+ {
38
+ if (!$this->_monthInterval) {
39
+ $this->_monthInterval = 12;
40
+ }
41
+ return $this->_monthInterval;
42
+ }
43
+
44
+ public function setMonthInterval($monthInterval)
45
+ {
46
+ $this->_monthInterval = $monthInterval;
47
+ return $this;
48
+ }
49
+
50
+ public function getPageNum()
51
+ {
52
+ if ($this->_pageNum) {
53
+ $this->_pageNum = 1;
54
+ }
55
+ return $this->_pageNum;
56
+ }
57
+
58
+ public function setPageNum($pageNum)
59
+ {
60
+ $this->_pageNum = $pageNum;
61
+ return $this;
62
+ }
63
+
64
+ public function getHelper()
65
+ {
66
+ if (!$this->_helper) {
67
+ $this->_helper = Mage::helper('autocompleteplus_autosuggest');
68
+ }
69
+ return $this->_helper;
70
+ }
71
+
72
+ public function getProductCollection($new = false)
73
+ {
74
+ if (!$this->_productCollection) {
75
+ $this->_productCollection = Mage::getModel('catalog/product')->getCollection();
76
+ }
77
+
78
+ if ($new === true) {
79
+ return Mage::getModel('catalog/product')->getCollection();
80
+ }
81
+
82
+ return $this->_productCollection;
83
+ }
84
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Batches.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Autocompleteplus_Autosuggest_Model_Renderer_Batches extends Autocompleteplus_Autosuggest_Model_Renderer_Abstract
4
+ {
5
+ public function setXmlElement(&$xmlGenerator)
6
+ {
7
+ $this->_xmlElement = $xmlGenerator;
8
+ return $this;
9
+ }
10
+
11
+ public function getXmlElement()
12
+ {
13
+ return $this->_xmlElement;
14
+ }
15
+
16
+ public function makeRemoveRow($batch) {
17
+ $productElement = $this->getXmlElement()->createChild('product', array(
18
+ 'updatedate' => $batch['update_date'],
19
+ 'action' => $batch['action'],
20
+ 'id' => $batch['product_id'],
21
+ 'storeid' => $batch['store_id']
22
+ ));
23
+
24
+ $this->getXmlElement()->createChild('sku', false, $batch['sku'], $productElement);
25
+ $this->getXmlElement()->createChild('id', false, $batch['product_id'], $productElement);
26
+ }
27
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Renderer/Catalog/Product.php ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Autocompleteplus_Autosuggest_Model_Renderer_Catalog_Product extends Autocompleteplus_Autosuggest_Model_Renderer_Abstract
4
+ {
5
+ protected $_standardImageFields = array('image', 'small_image', 'thumbnail');
6
+ protected $_useAttributes;
7
+ protected $_attributes;
8
+ protected $_xmlGenerator;
9
+ protected $_categories;
10
+ protected $_configurableAttributes;
11
+ protected $_configurableChildren;
12
+ protected $_configurableChildrenIds;
13
+ protected $_saleable;
14
+ protected $_simpleProductIds;
15
+ protected $_xmlElement;
16
+ protected $_productAttributes;
17
+ protected $_product;
18
+ protected $_rootCategoryId;
19
+ protected $_outputHelper;
20
+
21
+ public function setXmlElement(&$xmlGenerator)
22
+ {
23
+ $this->_xmlElement = $xmlGenerator;
24
+ return $this;
25
+ }
26
+
27
+ public function getXmlElement()
28
+ {
29
+ return $this->_xmlElement;
30
+ }
31
+
32
+ public function setProduct($product)
33
+ {
34
+ $this->_product = $product;
35
+ return $this;
36
+ }
37
+
38
+ public function getProduct()
39
+ {
40
+ return $this->_product;
41
+ }
42
+
43
+ public function getImageField()
44
+ {
45
+ if (!$this->_imageField) {
46
+ $this->_imageField = Mage::getStoreConfig('autocompleteplus/config/imagefield');
47
+ }
48
+ return $this->_imageField;
49
+ }
50
+
51
+ public function canUseAttributes()
52
+ {
53
+ if (!$this->_useAttributes) {
54
+ $this->_useAttributes = Mage::getStoreConfigFlag('autocompleteplus/config/attributes');
55
+ }
56
+ return $this->_useAttributes;
57
+ }
58
+
59
+ public function getRootCategoryId()
60
+ {
61
+ if (!$this->_rootCategoryId) {
62
+ $this->_rootCategoryId = Mage::app()->getStore($this->getStoreId())->getRootCategoryId();
63
+ }
64
+ return $this->_rootCategoryId;
65
+ }
66
+
67
+ public function getSaleable()
68
+ {
69
+ return !!$this->_saleable;
70
+ }
71
+
72
+ public function getConfigurableChildren()
73
+ {
74
+ return $this->getProduct()->getTypeInstance()->getUsedProducts();
75
+ }
76
+
77
+ public function getConfigurableChildrenIds()
78
+ {
79
+ $configurableChildrenIds = array();
80
+ foreach ($this->getConfigurableChildren() as $child) {
81
+ $configurableChildrenIds[] = $child->getId();
82
+ if ($this->getProduct()->isInStock()) {
83
+ if (method_exists($child, 'isSaleable') && !$child->isSaleable()) {
84
+ // the simple product is probably disabled (because its in stock)
85
+ continue;
86
+ }
87
+ $this->_saleable = true;
88
+ }
89
+ }
90
+
91
+ return $configurableChildrenIds;
92
+ }
93
+
94
+ public function getProductCollection($new = false)
95
+ {
96
+ if (!$this->_productCollection) {
97
+ $this->_productCollection = Mage::getModel('catalog/product')->getCollection();
98
+ }
99
+
100
+ if ($new === true) {
101
+ return Mage::getModel('catalog/product')->getCollection();
102
+ }
103
+
104
+ return $this->_productCollection;
105
+ }
106
+
107
+ public function getCategoryMap()
108
+ {
109
+ if (!$this->_categories) {
110
+ $categoryMap = array();
111
+ $categories = Mage::getModel('catalog/category')->getCollection();
112
+
113
+ foreach ($categories as $category) {
114
+ $categoryMap[] = new Varien_Object(array(
115
+ 'id' => $category->getId(),
116
+ 'path' => $category->getPath(),
117
+ 'parent_id' => $category->getParentId(),
118
+ ));
119
+ }
120
+ $this->_categories = $categoryMap;
121
+ }
122
+ return $this->_categories;
123
+ }
124
+
125
+ public function getSimpleProductsPriceOfConfigurable()
126
+ {
127
+ $simple_products_price = array();
128
+ $pricesByAttributeValues = array();
129
+ $attributes = $this->getProduct()->getTypeInstance(true)->getConfigurableAttributes($this->getProduct());
130
+ $basePrice = $this->getProduct()->getFinalPrice();
131
+ $items = $attributes->getItems();
132
+ if (is_array($items)) {
133
+ foreach ($items as $attribute) {
134
+ $prices = $attribute->getPrices();
135
+ if (is_array($prices)) {
136
+ foreach ($prices as $price) {
137
+ if ($price['is_percent']) { //if the price is specified in percents
138
+ $pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'] * $basePrice / 100;
139
+ } else { //if the price is absolute value
140
+ $pricesByAttributeValues[$price['value_index']] = (float) $price['pricing_value'];
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ foreach ($this->getConfigurableChildren() as $sProduct) {
148
+ $totalPrice = $basePrice;
149
+ foreach ($attributes as $attribute) {
150
+ $value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
151
+ if (isset($pricesByAttributeValues[$value])) {
152
+ $totalPrice += $pricesByAttributeValues[$value];
153
+ }
154
+ }
155
+ $simple_products_price[$sProduct->getId()] = $totalPrice;
156
+ }
157
+
158
+ return $simple_products_price;
159
+ }
160
+
161
+ public function getCategoryPathsByProduct()
162
+ {
163
+ $productCategories = $this->getProduct()->getCategoryIds();
164
+ $rootCategoryId = $this->getRootCategoryId();
165
+ $paths = array_map(function ($category) use ($productCategories, $rootCategoryId) {
166
+ if (in_array($category->getId(), $productCategories)) {
167
+ $path = explode('/', $category->getPath());
168
+ //we don't want the root category for the entire site
169
+ array_shift($path);
170
+ if ($rootCategoryId &&
171
+ is_array($path) &&
172
+ isset($path[0]) &&
173
+ $path[0] != $rootCategoryId
174
+ ) {
175
+ return array();
176
+ }
177
+ //we want more specific categories first
178
+ return implode(':', array_reverse($path));
179
+ }
180
+ }, $this->getCategoryMap());
181
+ return array_filter($paths);
182
+ }
183
+
184
+ public function getConfigurableAttributes()
185
+ {
186
+ // Collect options applicable to the configurable product
187
+ $productAttributeOptions = $this->getProduct()->getTypeInstance()->getConfigurableAttributesAsArray($this->getProduct());
188
+ $configurableAttributes = array();
189
+
190
+ foreach ($productAttributeOptions as $productAttribute) {
191
+ $attributeFull = Mage::getModel('eav/config')->getAttribute('catalog_product', $productAttribute['attribute_code']);
192
+ foreach ($productAttribute['values'] as $attribute) {
193
+ $configurableAttributes[$productAttribute['store_label']]['values'][] = $attribute['store_label'];
194
+ }
195
+ $configurableAttributes[$productAttribute['store_label']]['is_filterable'] = $attributeFull['is_filterable'];
196
+ $configurableAttributes[$productAttribute['store_label']]['frontend_input'] = $attributeFull['frontend_input'];
197
+ }
198
+ return $configurableAttributes;
199
+ }
200
+
201
+ public function getProductAttributes()
202
+ {
203
+ return $this->getProduct()->getTypeInstance()->getConfigurableAttributes($this->getProduct());
204
+ }
205
+
206
+ public function getPriceRange()
207
+ {
208
+ $pricesByAttributeValues = array();
209
+ $attributes = $this->getProductAttributes();
210
+ $basePrice = $this->getProduct()->getFinalPrice();
211
+ $items = $attributes->getItems();
212
+ $min_price = null;
213
+ $max_price = null;
214
+ $totalPrice = false;
215
+ if (is_array($items)) {
216
+ foreach ($items as $attribute) {
217
+ $prices = $attribute->getPrices();
218
+ if (is_array($prices)) {
219
+ foreach ($prices as $price) {
220
+ if ($price['is_percent']) { //if the price is specified in percents
221
+ $pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'] * $basePrice / 100;
222
+ } else { //if the price is absolute value
223
+ $pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'];
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
+ $simple = $this->getConfigurableChildren();
231
+ foreach ($simple as $sProduct) {
232
+ $totalPrice = $basePrice;
233
+ foreach ($attributes as $attribute) {
234
+ $value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
235
+ if (isset($pricesByAttributeValues[$value])) {
236
+ $totalPrice += $pricesByAttributeValues[$value];
237
+ }
238
+ }
239
+ if (!$min_price || $totalPrice < $min_price){
240
+ $min_price = $totalPrice;
241
+ }
242
+ if (!$max_price || $totalPrice > $max_price){
243
+ $max_price = $totalPrice;
244
+ }
245
+ }
246
+ if (is_null($min_price)){
247
+ $min_price = 0;
248
+ }
249
+ if (is_null($max_price)){
250
+ $max_price = 0;
251
+ }
252
+
253
+ return array(
254
+ 'price_min' => $min_price,
255
+ 'price_max' => $max_price
256
+ );
257
+ }
258
+
259
+ public function getSimpleProductParent()
260
+ {
261
+ return Mage::getModel('catalog/product_type_configurable')
262
+ ->getParentIdsByChild($this->getProduct()->getId());
263
+ }
264
+
265
+ public function getOrdersPerProduct()
266
+ {
267
+ $productIds = implode(',', $this->getProductCollection()->getAllIds());
268
+ $salesOrderItemCollection = Mage::getResourceModel('sales/order_item_collection');
269
+ $salesOrderItemCollection->getSelect()->reset(Zend_Db_Select::COLUMNS)
270
+ ->columns(array('product_id', array('qty_ordered' => 'SUM(qty_ordered)')))
271
+ ->where(new Zend_Db_Expr('store_id = ' . $this->getStoreId()))
272
+ ->where(new Zend_Db_Expr('product_id IN (' . $productIds . ')'))
273
+ ->where(new Zend_Db_Expr('created_at BETWEEN NOW() - INTERVAL ' . $this->getMonthInterval() . ' MONTH AND NOW()'))
274
+ ->group(array('product_id'));
275
+
276
+ $products = array();
277
+
278
+ foreach ($salesOrderItemCollection as $item) {
279
+ $products[$item['product_id']] = (int)$item['qty_ordered'];
280
+ }
281
+
282
+ return $products;
283
+ }
284
+
285
+ public function getOrderCount()
286
+ {
287
+ $orderData = $this->getOrderData();
288
+ return ($this->getOrderData() != null && array_key_exists($this->getProduct()->getId(), $orderData)) ? $orderData[$this->getProduct()->getId()] : 0;
289
+ }
290
+
291
+ public function getProductResource()
292
+ {
293
+ return Mage::getResourceSingleton('catalog/product');
294
+ }
295
+
296
+ /**
297
+ * @TODO Refactor indentation/conditions
298
+ */
299
+ public function renderProductVariantXml($productXmlElem)
300
+ {
301
+ if ($this->canUseAttributes()) {
302
+ if ($this->getProduct()->isConfigurable() && count($this->getConfigurableAttributes()) > 0) {
303
+ $variants = array();
304
+ foreach ($this->getConfigurableAttributes() as $attrName => $confAttrN) {
305
+ if (is_array($confAttrN) && array_key_exists('values', $confAttrN)) {
306
+ $variants[] = $attrName;
307
+ $values = implode(' , ', $confAttrN['values']);
308
+ $this->getXmlElement()->createChild('attribute', array(
309
+ 'is_configurable' => 1,
310
+ 'is_filterable' => $confAttrN['is_filterable'],
311
+ 'name' => $attrName
312
+ ),
313
+ $values,
314
+ $productXmlElem
315
+ );
316
+ }
317
+ }
318
+
319
+ $simple_products_price = $this->getSimpleProductsPriceOfConfigurable();
320
+
321
+ if (count($variants) > 0) {
322
+ $variantElem = $this->getXmlElement()->createChild('variants', false, false, $productXmlElem);
323
+ foreach ($this->getConfigurableChildren() as $child_product) {
324
+ if (!in_array($this->getProduct()->getStoreId(), $child_product->getStoreIds())) {
325
+ continue;
326
+ }
327
+
328
+ $is_variant_in_stock = ($child_product->getStockItem()->getIsInStock()) ? 1 : 0;
329
+
330
+ if (method_exists($child_product, 'isSaleable')) {
331
+ $is_variant_sellable = ($child_product->isSaleable()) ? 1 : 0;
332
+ } else {
333
+ $is_variant_sellable = '';
334
+ }
335
+
336
+ if (method_exists($child_product, 'getVisibility')) {
337
+ $is_variant_visible = ($child_product->getVisibility()) ? 1 : 0;
338
+ } else {
339
+ $is_variant_visible = '';
340
+ }
341
+
342
+ $variant_price = (array_key_exists($child_product->getId(), $simple_products_price)) ?
343
+ $simple_products_price[$child_product->getId()] : '';
344
+
345
+
346
+ $productVariation = $this->getXmlElement()->createChild('variant', array(
347
+ 'id' => $child_product->getId(),
348
+ 'type' => $child_product->getTypeID(),
349
+ 'visibility' => $is_variant_visible,
350
+ 'is_in_stock' => $is_variant_in_stock,
351
+ 'is_seallable' => $is_variant_sellable,
352
+ 'price' => $variant_price
353
+ ), false, $variantElem);
354
+
355
+ $this->getXmlElement()->createChild('name', false, $child_product->getName(), $productVariation);
356
+
357
+ $attributes = $child_product->getAttributes();
358
+ foreach ($attributes as $attribute) {
359
+ if (!$attribute['is_configurable'] || !in_array($attribute['store_label'], $variants)) {
360
+ continue;
361
+ }
362
+
363
+ if (!$attribute['store_label']){
364
+ // skip variant attribute without a name
365
+ continue;
366
+ }
367
+
368
+ $this->getXmlElement()->createChild('variant_attribute', array(
369
+ 'is_configurable' => 1,
370
+ 'is_filterable' => $attribute->getIsFilterable(),
371
+ 'name' => $attribute['store_label'],
372
+ 'name_code' => $attribute->getId(),
373
+ 'value_code' => $child_product->getData($attribute->getAttributeCode())
374
+ ), utf8_encode(htmlspecialchars($attribute->getFrontend()->getValue($child_product))), $productVariation
375
+ );
376
+ }
377
+ }
378
+ }
379
+ }
380
+ }
381
+ }
382
+
383
+ public function renderProductAttributeXml($attr, $productXmlElem)
384
+ {
385
+ if ($this->canUseAttributes()) {
386
+ $action = $attr->getAttributeCode();
387
+ $is_filterable = $attr->getIsFilterable();
388
+ $attribute_label = $attr->getFrontendLabel();
389
+ $attrValue = null;
390
+ $_helper=$this->_getOutputHelper();
391
+
392
+ switch ($attr->getFrontendInput()) {
393
+ case 'select':
394
+ $attrValue = method_exists($this->getProduct(), 'getAttributeText') ?
395
+ $_helper->productAttribute($this->getProduct(),$this->getProduct()->getAttributeText($action),$action)
396
+ : $this->getProduct()->getData($action);
397
+ break;
398
+ case 'textarea':
399
+ case 'price':
400
+ case 'text':
401
+ $attrValue = $this->getProduct()->getData($action);
402
+ break;
403
+ case 'multiselect':
404
+ $attrValue = $this->getProduct()->getResource()
405
+ ->getAttribute($action)->getFrontend()->getValue($this->getProduct());
406
+ break;
407
+ }
408
+
409
+ if ($attrValue) {
410
+ $attributeElem = $this->getXmlElement()->createChild('attribute', array(
411
+ 'is_filterable' => $is_filterable,
412
+ 'name' => $attr->getAttributeCode()
413
+ ), false, $productXmlElem);
414
+
415
+ $this->getXmlElement()->createChild('attribute_values', false,
416
+ $attrValue, $attributeElem);
417
+ $this->getXmlElement()->createChild('attribute_label', false,
418
+ $attribute_label, $attributeElem);
419
+ }
420
+ }
421
+ }
422
+
423
+ public function renderXml()
424
+ {
425
+ $categories = $this->getCategoryPathsByProduct();
426
+ $saleable = $this->getProduct()->isSalable() ? 1 : 0;
427
+
428
+ if ($this->getProduct()->isConfigurable()) {
429
+ $priceRange = $this->getPriceRange();
430
+ } elseif ($this->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
431
+ $priceRange = array('price_min' => 0, 'price_max' => 0);
432
+ } else {
433
+ $priceRange = array('price_min' => 0, 'price_max' => 0);
434
+ }
435
+
436
+ $productElement = $this->getXmlElement()->createChild('product', array(
437
+ 'price_min' => ($priceRange['price_min']),
438
+ 'price_max' => ($priceRange['price_max']),
439
+ 'store' => ($this->getStoreId()),
440
+ 'store_id' => ($this->getStoreId()),
441
+ 'storeid' => ($this->getStoreId()),
442
+ 'id' => ($this->getProduct()->getId()),
443
+ 'type' => ($this->getProduct()->getTypeId()),
444
+ 'currency' => ($this->getCurrency()),
445
+ 'visibility' => ($this->getProduct()->getVisibility()),
446
+ 'price' => ($this->getProduct()->getFinalPrice()),
447
+ 'url' => (Mage::helper('catalog/product')->getProductUrl($this->getProduct()->getId())),
448
+ 'thumbs' => utf8_encode(htmlspecialchars((Mage::helper('catalog/image')->init($this->getProduct(), $this->getImageField())))),
449
+ 'base_image' => utf8_encode(htmlspecialchars((Mage::getModel('catalog/product_media_config')->getMediaUrl($this->getProduct()->getImage())))),
450
+ 'selleable' => ($saleable),
451
+ 'action' => ($this->getAction()),
452
+ 'get_by_id_status' => 1,
453
+ 'last_updated' => ($this->getProduct()->getUpdatedAt()),
454
+ 'updatedate' => ($this->getUpdateDate()),
455
+ 'get_by_id_status' => intval($this->getGetByIdStatus())
456
+ ));
457
+ //Mage::getResourceModel('catalog/product')->getAttributeRawValue($this->getProduct()->getId(), 'description', $this->getStoreId());
458
+ $productRating = $this->getProduct()->getRatingSummary();
459
+ $this->getXmlElement()->createChild('description', false,
460
+ $this->getProduct()->getDescription(), $productElement);
461
+ $this->getXmlElement()->createChild('short', false,
462
+ $this->getProduct()->getShortDescription(), $productElement);
463
+ $this->getXmlElement()->createChild('name', false,
464
+ $this->getProduct()->getName(), $productElement);
465
+ $this->getXmlElement()->createChild('sku', false,
466
+ $this->getProduct()->getSku(), $productElement);
467
+
468
+
469
+ $this->getXmlElement()->createChild('url_additional', false,
470
+ $this->_getAdditionalProductUrl(), $productElement);
471
+
472
+ if ($productRating) {
473
+ $this->getXmlElement()->createChild('review', false, $productRating->getRatingSummary(),
474
+ $productElement);
475
+ $this->getXmlElement()->createChild('reviews_count', false,
476
+ $productRating->getReviewsCount(), $productElement);
477
+ }
478
+
479
+ $newFromDate = $this->getProduct()->getNewsFromDate();
480
+ $newToDate = $this->getProduct()->getNewsToDate();
481
+ if ($newFromDate) {
482
+ $this->getXmlElement()->createChild('newfrom', false,
483
+ Mage::getModel('core/date')->timestamp($newFromDate), $productElement);
484
+ if ($newToDate) {
485
+ $this->getXmlElement()->createChild('newto', false,
486
+ Mage::getModel('core/date')->timestamp($newToDate), $productElement);
487
+ }
488
+ }
489
+
490
+ $this->getXmlElement()->createChild('purchase_popularity', false,
491
+ $this->getOrderCount(), $productElement);
492
+ $this->getXmlElement()->createChild('product_status', false,
493
+ (($this->getProduct()->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) ? 1 : 0), $productElement);
494
+ $this->getXmlElement()->createChild('creation_date', false,
495
+ Mage::getModel('core/date')->timestamp($this->getProduct()->getCreatedAt()), $productElement);
496
+ $this->getXmlElement()->createChild('updated_date', false,
497
+ Mage::getModel('core/date')->timestamp($this->getProduct()->getUpdatedAt()), $productElement);
498
+
499
+ if ($this->canUseAttributes()) {
500
+ foreach ($this->getAttributes() as $attr) {
501
+ $this->renderProductAttributeXml($attr, $productElement);
502
+ }
503
+ }
504
+
505
+ if ($this->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
506
+ $this->getXmlElement()->createChild('product_parents', false,
507
+ implode(',', $this->getSimpleProductParent()), $productElement);
508
+ }
509
+
510
+ if ($this->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
511
+ $this->getXmlElement()->createChild('simpleproducts', false,
512
+ implode(',', $this->getConfigurableChildrenIds()), $productElement);
513
+ $this->renderProductVariantXml($productElement);
514
+ }
515
+
516
+ $this->getXmlElement()->createChild('categories', false,
517
+ implode(';', $categories), $productElement);
518
+
519
+ $this->getXmlElement()->createChild('meta_title', false,
520
+ $this->getProduct()->getMetaTitle(), $productElement);
521
+ $this->getXmlElement()->createChild('meta_description', false,
522
+ $this->getProduct()->getMetaDescription(), $productElement);
523
+
524
+ }
525
+
526
+ protected function _getOutputHelper()
527
+ {
528
+
529
+ if($this->_outputHelper==null){
530
+ $this->_outputHelper = Mage::helper('catalog/output');
531
+ }
532
+
533
+ return $this->_outputHelper;
534
+ }
535
+
536
+ public function _getAdditionalProductUrl()
537
+ {
538
+ $is_get_url_path_supported = true;
539
+ if (method_exists('Mage' , 'getVersionInfo')){ // getUrlPath is not supported on EE 1.13... & 1.14...
540
+ $edition_info = Mage::getVersionInfo();
541
+ if ($edition_info['major'] == 1 && $edition_info['minor'] >= 13){
542
+ $is_get_url_path_supported = false;
543
+ }
544
+ }
545
+
546
+ if (method_exists($this->getProduct(), 'getUrlPath') && $is_get_url_path_supported){
547
+ $product_url = $this->getProduct()->getUrlPath();
548
+ if ($product_url != ''){
549
+ $product_url = Mage::getUrl($product_url);
550
+ return $product_url;
551
+ }
552
+ }
553
+ return '';
554
+ }
555
+ }
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Autocompleteplus_Autosuggest_Model_Resource_Batches extends Mage_Core_Model_Resource_Db_Abstract
4
  {
5
  /**
6
  * Resource initialization.
1
  <?php
2
 
3
+ class Autocompleteplus_Autosuggest_Model_Resource_Batches extends Mage_Core_Model_Mysql4_Abstract
4
  {
5
  /**
6
  * Resource initialization.
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Batches/Collection.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
  {
5
  /**
6
  * Initialize resource collection.
1
  <?php
2
 
3
+ class Autocompleteplus_Autosuggest_Model_Resource_Batches_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
  {
5
  /**
6
  * Initialize resource collection.
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Autocompleteplus_Autosuggest_Model_Resource_Checksum extends Mage_Core_Model_Resource_Db_Abstract
4
  {
5
  /**
6
  * Resource initialization.
1
  <?php
2
 
3
+ class Autocompleteplus_Autosuggest_Model_Resource_Checksum extends Mage_Core_Model_Mysql4_Abstract
4
  {
5
  /**
6
  * Resource initialization.
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Checksum/Collection.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
  {
5
  /**
6
  * Initialize resource collection.
1
  <?php
2
 
3
+ class Autocompleteplus_Autosuggest_Model_Resource_Checksum_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
  {
5
  /**
6
  * Initialize resource collection.
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Fulltext/Collection.php CHANGED
@@ -31,7 +31,7 @@
31
  *
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
- class Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection extends Mage_Catalog_Model_Resource_Product_Collection
35
  {
36
  protected $list_ids = array();
37
  protected $is_fulltext_enabled = false;
31
  *
32
  * @author Magento Core Team <core@magentocommerce.com>
33
  */
34
+ class Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
35
  {
36
  protected $list_ids = array();
37
  protected $is_fulltext_enabled = false;
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications.php CHANGED
@@ -13,7 +13,7 @@
13
  * @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
14
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
  */
16
- class Autocompleteplus_Autosuggest_Model_Resource_Notifications extends Mage_Core_Model_Resource_Db_Abstract
17
  {
18
  protected function _construct()
19
  {
13
  * @copyright Copyright (c) 2014 Fast Simon (http://www.instantsearchplus.com)
14
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
  */
16
+ class Autocompleteplus_Autosuggest_Model_Resource_Notifications extends Mage_Core_Model_Mysql4_Abstract
17
  {
18
  protected function _construct()
19
  {
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Notifications/Collection.php CHANGED
@@ -14,7 +14,7 @@
14
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
  */
16
  class Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
17
- extends Mage_Core_Model_Resource_Db_Collection_Abstract
18
  {
19
  protected function _construct()
20
  {
14
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
  */
16
  class Autocompleteplus_Autosuggest_Model_Resource_Notifications_Collection
17
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
18
  {
19
  protected function _construct()
20
  {
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Autocompleteplus_Autosuggest_Model_Resource_Pusher extends Mage_Core_Model_Resource_Db_Abstract
4
  {
5
  protected function _construct()
6
  {
1
  <?php
2
 
3
+ class Autocompleteplus_Autosuggest_Model_Resource_Pusher extends Mage_Core_Model_Mysql4_Abstract
4
  {
5
  protected function _construct()
6
  {
app/code/local/Autocompleteplus/Autosuggest/Model/Resource/Pusher/Collection.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
  {
5
  public function _construct()
6
  {
1
  <?php
2
 
3
+ class Autocompleteplus_Autosuggest_Model_Resource_Pusher_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
  {
5
  public function _construct()
6
  {
app/code/local/Autocompleteplus/Autosuggest/controllers/Adminhtml/Autocompleteplus/PushController.php CHANGED
@@ -4,16 +4,11 @@ class Autocompleteplus_Autosuggest_Adminhtml_Autocompleteplus_PushController ext
4
  {
5
  public function startpushAction()
6
  {
7
- $response = $this->getResponse();
8
-
9
  $service = Mage::getModel('autocompleteplus_autosuggest/service');
10
  $service->populatePusher();
11
 
12
- $block = $this->getLayout()->createBlock('autocompleteplus_autosuggest/adminhtml_process');
13
- $block->setTemplate('autocompleteplus/process.phtml');
14
-
15
- $response->setBody($block->toHtml());
16
- $response->sendResponse();
17
  }
18
 
19
  protected function _isAllowed()
4
  {
5
  public function startpushAction()
6
  {
 
 
7
  $service = Mage::getModel('autocompleteplus_autosuggest/service');
8
  $service->populatePusher();
9
 
10
+ $this->loadLayout();
11
+ $this->renderLayout();
 
 
 
12
  }
13
 
14
  protected function _isAllowed()
app/code/local/Autocompleteplus/Autosuggest/controllers/CategoriesController.php CHANGED
@@ -63,11 +63,7 @@ class Autocompleteplus_Autosuggest_CategoriesController extends Mage_Core_Contro
63
  {
64
  $storeContext = Mage::app()->getStore()->getStoreId();
65
  $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
66
-
67
- $request = $this->getRequest();
68
- $helper = Mage::helper('autocompleteplus_autosuggest');
69
- $store = $helper->validateInput($request->getParam('store', $storeContext), 'integer', $storeContext, $storeContext);
70
-
71
  $parentId = Mage::app()->getStore($store)->getRootCategoryId();
72
 
73
  $root = $tree->getNodeById($parentId);
63
  {
64
  $storeContext = Mage::app()->getStore()->getStoreId();
65
  $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
66
+ $store = $this->getRequest()->getParam('store', $storeContext);
 
 
 
 
67
  $parentId = Mage::app()->getStore($store)->getRootCategoryId();
68
 
69
  $root = $tree->getNodeById($parentId);
app/code/local/Autocompleteplus/Autosuggest/controllers/LayeredController.php CHANGED
@@ -19,16 +19,10 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
19
  {
20
  $response = $this->getResponse();
21
  $request = $this->getRequest();
22
-
23
- $helper = Mage::helper('autocompleteplus_autosuggest');
24
  $authkey = $request->getParam('authentication_key');
25
  $uuid = $request->getParam('uuid');
26
-
27
  $scope = $request->getParam('scope', 'stores');
28
- if ($scope != 'stores' && $scope != 'default' && $scope != ''){
29
- $scope = 'stores';
30
- }
31
- $scopeId = $helper->validateInput($request->getParam('store_id', Mage::app()->getStore()->getStoreId()), 'integer', 1, null);
32
 
33
  if (!$this->valid($uuid, $authkey)) {
34
  $resp = json_encode(array('status' => 'error: '.'Authentication failed'));
@@ -60,16 +54,11 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
60
  {
61
  $request = $this->getRequest();
62
  $response = $this->getResponse();
63
- $helper = Mage::helper('autocompleteplus_autosuggest');
64
  $authkey = $request->getParam('authentication_key');
65
  $uuid = $request->getParam('uuid');
66
-
67
  $scope = $request->getParam('scope', 'stores');
68
- if ($scope != 'stores' && $scope != 'default' && $scope != ''){
69
- $scope = 'stores';
70
- }
71
- $scopeId = $helper->validateInput($request->getParam('store_id', Mage::app()->getStore()->getStoreId()), 'integer', 1, null);
72
-
73
  if (!$this->valid($uuid, $authkey)) {
74
  $resp = json_encode(array('status' => 'error: '.'Authentication failed'));
75
 
@@ -101,11 +90,10 @@ class Autocompleteplus_Autosuggest_LayeredController extends Mage_Core_Controlle
101
  {
102
  $request = $this->getRequest();
103
  $response = $this->getResponse();
104
- $helper = Mage::helper('autocompleteplus_autosuggest');
105
 
106
  $authkey = $request->getParam('authentication_key');
107
  $uuid = $request->getParam('uuid');
108
- $scopeId = $helper->validateInput($request->getParam('store_id', Mage::app()->getStore()->getStoreId()), 'integer', 1, null);
109
 
110
  if (!$this->valid($uuid, $authkey)) {
111
  $resp = json_encode(array('status' => $this->__('error: Authentication failed')));
19
  {
20
  $response = $this->getResponse();
21
  $request = $this->getRequest();
 
 
22
  $authkey = $request->getParam('authentication_key');
23
  $uuid = $request->getParam('uuid');
 
24
  $scope = $request->getParam('scope', 'stores');
25
+ $scopeId = $request->getParam('store_id', 1);
 
 
 
26
 
27
  if (!$this->valid($uuid, $authkey)) {
28
  $resp = json_encode(array('status' => 'error: '.'Authentication failed'));
54
  {
55
  $request = $this->getRequest();
56
  $response = $this->getResponse();
 
57
  $authkey = $request->getParam('authentication_key');
58
  $uuid = $request->getParam('uuid');
 
59
  $scope = $request->getParam('scope', 'stores');
60
+ $scopeId = $request->getParam('store_id', 1);
61
+
 
 
 
62
  if (!$this->valid($uuid, $authkey)) {
63
  $resp = json_encode(array('status' => 'error: '.'Authentication failed'));
64
 
90
  {
91
  $request = $this->getRequest();
92
  $response = $this->getResponse();
 
93
 
94
  $authkey = $request->getParam('authentication_key');
95
  $uuid = $request->getParam('uuid');
96
+ $scopeId = $request->getParam('store_id', 1);
97
 
98
  if (!$this->valid($uuid, $authkey)) {
99
  $resp = json_encode(array('status' => $this->__('error: Authentication failed')));
app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsController.php CHANGED
@@ -32,60 +32,38 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
32
 
33
  public function sendAction()
34
  {
 
35
  $response = $this->getResponse();
36
  $request = $this->getRequest();
37
- $helper = Mage::helper('autocompleteplus_autosuggest');
38
-
39
- $startInd = $helper->validateInput($request->getParam('offset'), 'integer', null, null);
40
- $count = $helper->validateInput($request->getParam('count'), 'integer', null, null);
41
- if ($count === null || $startInd === null){
42
- $returnArr = array(
43
- 'status' => self::STATUS_FAILURE,
44
- 'error_code' => self::MISSING_PARAMETER,
45
- 'error_details' => $this->__('The "offset" and "count" parameters are mandatory'),
46
- );
47
- $response->setHeader('Content-type', 'application/json');
48
- $response->setHttpResponseCode(400);
49
- $response->setBody(json_encode($returnArr));
50
- return;
51
- }
52
- $store = $helper->validateInput($request->getParam('store_id'), 'integer', null, null);
53
- $storeId = $helper->validateInput($request->getParam('store'), 'integer', $store, null);
54
- $orders = (string)$helper->validateInput($request->getParam('orders', ''), 'integer', '', ''); // check that input is integer if exists, if not exists we want it to be "" (string)
55
- $monthInterval = (string)$helper->validateInput($request->getParam('month_interval', ''), 'integer', '', ''); // check that input is integer if exists, if not exists we want it to be "" (string)
56
- $checksum = (string)$helper->validateInput($request->getParam('checksum', ''), 'integer', '', ''); // check that input is integer if exists, if not exists we want it to be "" (string)
57
-
58
  $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
59
 
 
 
60
  $xml = $catalogModel->renderCatalogXml($startInd, $count, $storeId, $orders, $monthInterval, $checksum);
61
 
62
  $response->setHeader('Content-type', 'text/xml');
63
  $response->setBody($xml);
 
64
  }
65
 
66
  public function sendupdatedAction()
67
  {
68
- date_default_timezone_set('Asia/Jerusalem');
69
-
70
  $request = $this->getRequest();
71
  $response = $this->getResponse();
72
- $helper = Mage::helper('autocompleteplus_autosuggest');
73
-
74
- $count = $helper->validateInput($request->getParam('count'), 'integer', null, null);
75
- $from = $helper->validateInput($request->getParam('from'), 'integer', null, null);
76
- if ($count === null || $from === null){
77
- $returnArr = array(
78
- 'status' => self::STATUS_FAILURE,
79
- 'error_code' => self::MISSING_PARAMETER,
80
- 'error_details' => $this->__('The "from" and "count" parameters are mandatory'),
81
- );
82
- $response->setHeader('Content-type', 'application/json');
83
- $response->setHttpResponseCode(400);
84
- $response->setBody(json_encode($returnArr));
85
- return;
86
- }
87
- $to = $helper->validateInput($request->getParam('to', strtotime('now')), 'integer', strtotime('now'), null);
88
- $storeId = $helper->validateInput($request->getParam('store_id'), 'integer', null, null);
89
 
90
  if (!$storeId) {
91
  $returnArr = array(
@@ -100,6 +78,8 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
100
  return;
101
  }
102
 
 
 
103
  $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
104
 
105
  $xml = $catalogModel->renderUpdatesCatalogXml($count, $from, $to, $storeId);
@@ -124,16 +104,16 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
124
  }
125
 
126
  return $this->__('no key inside');
127
- }
128
-
129
  public function versAction()
130
  {
131
  $response = $this->getResponse();
 
132
  $mage = Mage::getVersion();
133
  $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
134
  $edition = method_exists('Mage', 'getEdition') ? Mage::getEdition() : 'Community';
135
  $helper = Mage::helper('autocompleteplus_autosuggest');
136
- $get_modules = $helper->validateInput($this->getRequest()->getParam('modules'), 'integer', false, false);
137
  $uuid = $this->_getConfig()->getUUID();
138
  $site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
139
  $store_id = Mage::app()->getStore()->getStoreId();
@@ -328,9 +308,13 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
328
 
329
  $read = Mage::getSingleton('core/resource')->getConnection('core_read');
330
  $table_prefix = (string) Mage::getConfig()->getTablePrefix();
331
-
332
- $request = $this->getRequest();
333
- $store_id = $helper->validateInput($request->getParam('store_id', Mage::app()->getStore()->getStoreId()), 'integer', null, null);
 
 
 
 
334
 
335
  $sql_fetch = 'SELECT identifier FROM '.$table_prefix.'autocompleteplus_checksum WHERE store_id=?';
336
  $updates = $read->fetchPairs($sql_fetch, array($store_id)); // empty array if fails
@@ -374,13 +358,11 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
374
  $request = $this->getRequest();
375
  $response = $this->getResponse();
376
  $helper = Mage::helper('autocompleteplus_autosuggest');
377
-
378
- $store_id = $helper->validateInput($request->getParam('store_id', Mage::app()->getStore()->getStoreId()), 'integer', Mage::app()->getStore()->getStoreId(), null);
379
- $count = $helper->validateInput($request->getParam('count', self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION), 'integer', self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION, null);
380
- $start_index = $helper->validateInput($request->getParam('offset', 0), 'integer', 0, null);
381
- $php_timeout = $helper->validateInput($request->getParam('timeout', -1), 'integer', -1, null);
382
- $is_single = $helper->validateInput($request->getParam('is_single', 0), 'integer', 0, null);
383
-
384
  $uuid = $this->_getConfig()->getUUID();
385
  $checksum_server = $helper->getServerUrl();
386
  $collection = Mage::getModel('catalog/product')->getCollection();
@@ -469,106 +451,164 @@ class Autocompleteplus_Autosuggest_ProductsController extends Autocompleteplus_A
469
  $this->getResponse()->setBody(1);
470
  }
471
 
472
-
473
- public function pushbulkAction()
474
  {
 
475
  $request = $this->getRequest();
476
  $response = $this->getResponse();
 
477
  $helper = Mage::helper('autocompleteplus_autosuggest');
478
-
479
- $pushId = $helper->validateInput($request->getParam('pushid'), 'integer', null, null);
480
 
481
- $response->clearHeaders();
482
- $response->setHeader('Content-type', 'application/json');
483
- $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
484
- $count = 100;
485
- $server_url = $helper->getServerUrl();
486
- $cmd_url = $server_url.'/magento_fetch_products';
487
 
488
- if (!$pushId) {
489
- $returnArr = array(
490
- 'success' => self::MISSING_PARAMETER,
491
- 'message' => $this->__('Missing push id!'),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
  );
493
 
494
- $response->setHttpResponseCode(400);
495
- $response->setBody(json_encode($returnArr));
 
 
 
 
 
 
496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  return;
498
  }
499
 
500
- $pusher = Mage::getModel('autocompleteplus_autosuggest/pusher')->load($pushid);
501
  $sent = $pusher->getSent();
502
 
503
- switch ($sent) {
504
- case self::PUSH_IN_PROGRESS:
505
- $responseArr = array('success' => false, 'message' => $this->__('push is in process'));
506
- $response->setBody(json_encode($responseArr));
507
-
508
- return;
509
- case self::PUSH_COMPLETE:
510
- $responseArr = array('success' => false, 'message' => $this->__('push was already sent'));
511
- $response->setBody(json_encode($responseArr));
512
-
513
- return;
514
- default:
515
- $pusher->setSent(1)->save();
516
- break;
517
  }
518
 
519
- $offset = $pusher->getoffset();
520
- $storeId = $pusher->getstore_id();
521
- $to_send = $pusher->getto_send();
 
522
  $total_batches = $pusher->gettotal_batches();
523
-
524
- $xml = $catalogModel->renderCatalogXml($offset, $count, $storeId, '', '', '');
525
-
526
- $url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
527
 
528
  // setting post data and command url
529
- $data = array(
530
- 'uuid' => $this->_getConfig()->getUUID(),
531
- 'site_url' => $url,
532
- 'store_id' => $storeId,
533
- 'authentication_key' => $this->_getConfig()->getAuthenticationKey(),
534
- 'total_batches' => $total_batches,
535
- 'batch_number' => $pusher->getbatch_number(),
536
- 'products' => $xml,
537
- );
538
-
539
- if ($offset + $count > $to_send) {
540
  $data['is_last'] = 1;
541
- $count = $to_send - $offset;
542
  }
543
 
544
  // sending products
545
- $postResponseMessage = $helper->sendPostCurl($cmd_url, $data);
546
-
547
- if ($postResponseMessage != self::POST_MESSAGE_OK) {
548
- $responseArr = array(
549
- 'success' => false,
550
- 'message' => $postResponseMessage,
551
- );
552
-
553
- $response->setBody(json_encode($responseArr));
554
 
 
 
 
555
  return;
556
  }
557
 
558
- $pusher->setSent(2)->save();
559
- $nextPushId = $helper->getPushId();
 
 
 
 
 
 
 
 
560
 
561
  $totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
562
 
 
 
 
563
  $responseArr = array(
564
- 'success' => true,
565
- 'updatedStatus' => $this->__('Syncing: push %s/%s', $nextPushId, $totalPushes),
566
- 'updatedSuccessStatus' => $this->__('Successfully synced %s products', $count),
567
- 'message' => '',
568
- 'nextPushUrl' => $nextPushId ? $helper->getPushUrl($nextPushId) : '',
569
- 'count' => $count,
570
  );
571
 
572
  $response->setBody(json_encode($responseArr));
 
573
  }
574
  }
32
 
33
  public function sendAction()
34
  {
35
+ Varien_Profiler::start('Autocompleteplus_Autosuggest_Products_Send');
36
  $response = $this->getResponse();
37
  $request = $this->getRequest();
38
+ $startInd = $request->getParam('offset');
39
+ $count = $request->getParam('count');
40
+ $store = $request->getParam('store_id', '');
41
+ $storeId = $request->getParam('store', $store);
42
+ $orders = $request->getParam('orders', '');
43
+ $monthInterval = $request->getParam('month_interval', '');
44
+ $checksum = $request->getParam('checksum', '');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
46
 
47
+ Mage::app()->setCurrentStore($storeId);
48
+
49
  $xml = $catalogModel->renderCatalogXml($startInd, $count, $storeId, $orders, $monthInterval, $checksum);
50
 
51
  $response->setHeader('Content-type', 'text/xml');
52
  $response->setBody($xml);
53
+ Varien_Profiler::stop('Autocompleteplus_Autosuggest_Products_Send');
54
  }
55
 
56
  public function sendupdatedAction()
57
  {
 
 
58
  $request = $this->getRequest();
59
  $response = $this->getResponse();
60
+
61
+ $currentTime = Mage::getSingleton('core/date')->gmtTimestamp();
62
+
63
+ $count = $request->getParam('count');
64
+ $from = $request->getParam('from');
65
+ $to = $request->getParam('to', $currentTime);
66
+ $storeId = $request->getParam('store_id', false);
 
 
 
 
 
 
 
 
 
 
67
 
68
  if (!$storeId) {
69
  $returnArr = array(
78
  return;
79
  }
80
 
81
+ Mage::app()->setCurrentStore($storeId);
82
+
83
  $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
84
 
85
  $xml = $catalogModel->renderUpdatesCatalogXml($count, $from, $to, $storeId);
104
  }
105
 
106
  return $this->__('no key inside');
107
+ }
108
+
109
  public function versAction()
110
  {
111
  $response = $this->getResponse();
112
+ $get_modules = $this->getRequest()->getParam('modules', false);
113
  $mage = Mage::getVersion();
114
  $ext = Mage::helper('autocompleteplus_autosuggest')->getVersion();
115
  $edition = method_exists('Mage', 'getEdition') ? Mage::getEdition() : 'Community';
116
  $helper = Mage::helper('autocompleteplus_autosuggest');
 
117
  $uuid = $this->_getConfig()->getUUID();
118
  $site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
119
  $store_id = Mage::app()->getStore()->getStoreId();
308
 
309
  $read = Mage::getSingleton('core/resource')->getConnection('core_read');
310
  $table_prefix = (string) Mage::getConfig()->getTablePrefix();
311
+
312
+ $post = $this->getRequest()->getParams();
313
+ if (array_key_exists('store_id', $post)) {
314
+ $store_id = $post['store_id'];
315
+ } else {
316
+ $store_id = Mage::app()->getStore()->getStoreId(); // default
317
+ }
318
 
319
  $sql_fetch = 'SELECT identifier FROM '.$table_prefix.'autocompleteplus_checksum WHERE store_id=?';
320
  $updates = $read->fetchPairs($sql_fetch, array($store_id)); // empty array if fails
358
  $request = $this->getRequest();
359
  $response = $this->getResponse();
360
  $helper = Mage::helper('autocompleteplus_autosuggest');
361
+ $store_id = $request->getParam('store_id', Mage::app()->getStore()->getStoreId());
362
+ $count = $request->getParam('count', self::MAX_NUM_OF_PRODUCTS_CHECKSUM_ITERATION);
363
+ $start_index = $request->getParam('offset', 0);
364
+ $php_timeout = $request->getParam('timeout', -1);
365
+ $is_single = $request->getParam('is_single', 0);
 
 
366
  $uuid = $this->_getConfig()->getUUID();
367
  $checksum_server = $helper->getServerUrl();
368
  $collection = Mage::getModel('catalog/product')->getCollection();
451
  $this->getResponse()->setBody(1);
452
  }
453
 
454
+ public function changeSerpAction()
 
455
  {
456
+ $scope_name = 'stores';
457
  $request = $this->getRequest();
458
  $response = $this->getResponse();
459
+
460
  $helper = Mage::helper('autocompleteplus_autosuggest');
461
+ $site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
462
+ $is_new_serp = $request->getParam('new_serp', 0);
463
 
464
+ $store_id = $request->getParam('store_id', 0);
465
+ if (!$store_id) {
466
+ $scope_name = 'default';
467
+ }
 
 
468
 
469
+ define('SOAP_WSDL', $site_url.'/api/?wsdl');
470
+ define('SOAP_USER', 'instant_search');
471
+ define('SOAP_PASS', 'Rilb@kped3');
472
+
473
+ try {
474
+ $client = new SoapClient(SOAP_WSDL, array('trace' => 1, 'cache_wsdl' => 0));
475
+ $session = $client->login(SOAP_USER, SOAP_PASS);
476
+
477
+ switch ($is_new_serp) {
478
+
479
+ case 'status':
480
+ $current_state = $client->call($session, 'autocompleteplus_autosuggest.getLayeredSearchConfig', array($store_id));
481
+ $resp = array('current_status' => $current_state);
482
+ $response->setBody(json_encode($resp));
483
+
484
+ return;
485
+
486
+ case '1':
487
+ $status = $client->call($session, 'autocompleteplus_autosuggest.setLayeredSearchOn', array($scope_name, $store_id));
488
+ break;
489
+ default:
490
+ $status = $client->call($session, 'autocompleteplus_autosuggest.setLayeredSearchOff', array($scope_name, $store_id));
491
+ break;
492
+ }
493
+
494
+ $new_state = $client->call($session, 'autocompleteplus_autosuggest.getLayeredSearchConfig', array($store_id));
495
+
496
+ $resp = array(
497
+ 'request_state' => $is_new_serp,
498
+ 'new_state' => $new_state,
499
+ 'site_url' => $site_url,
500
+ 'status' => $status,
501
  );
502
 
503
+ $response->setBody(json_encode($resp));
504
+ } catch (Exception $e) {
505
+ $resp = array('status' => 'exception: '.print_r($e, true));
506
+ $response->setBody(json_encode($resp));
507
+ Mage::logException($e);
508
+ throw $e;
509
+ }
510
+ }
511
 
512
+ /**
513
+ * Bulk Push to ISP with JSON
514
+ * @return void
515
+ */
516
+ public function pushbulkAction()
517
+ {
518
+ set_time_limit(1800);
519
+ $request = $this->getRequest();
520
+ $response = $this->getResponse();
521
+
522
+ $response->clearHeaders();
523
+ $response->setHeader('Content-type', 'application/json');
524
+ $pushId = $request->getParam('pushid', null);
525
+ $helper = Mage::helper('autocompleteplus_autosuggest');
526
+ $data = array();
527
+
528
+ if(!isset($pushId)){
529
+ $responseArr = array('success'=>false,'message'=>'Missing pushid!');
530
+ $response->clearHeaders();
531
+ $response->setHeader('Content-type', 'application/json');
532
+ $response->setBody(json_encode($responseArr));
533
  return;
534
  }
535
 
536
+ $pusher = Mage::getModel('autocompleteplus_autosuggest/pusher')->load($pushId);
537
  $sent = $pusher->getSent();
538
 
539
+ if($sent==1){
540
+ $responseArr = array('success'=>false,'message'=>'push is in process');
541
+ $response->setBody(json_encode($responseArr));
542
+ return;
543
+ } elseif ($sent==2){
544
+ $responseArr = array('success'=>false,'message'=>'push was already sent');
545
+ $response->setBody(json_encode($responseArr));
546
+ return;
547
+ } else {
548
+ $pusher->setSent(1);
549
+ $pusher->save();
 
 
 
550
  }
551
 
552
+ $offset = $pusher->getoffset();
553
+ $count = 100;
554
+ $storeId = $pusher->getstore_id();
555
+ $to_send = $pusher->getto_send();
556
  $total_batches = $pusher->gettotal_batches();
557
+ $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
558
+ $url = $helper->getConfigDataByFullPath('web/unsecure/base_url');
559
+ $server_url = $helper->getServerUrl();
560
+ $cmd_url = $server_url . '/magento_fetch_products';
561
 
562
  // setting post data and command url
563
+ $data['uuid'] = $helper->getUUID();
564
+ $data['site_url'] = $url;
565
+ $data['store_id'] = $storeId;
566
+ $data['authentication_key'] = $helper->getKey();
567
+ $data['total_batches'] = $total_batches;
568
+ $data['batch_number'] = $pusher->getbatch_number();
569
+ $data['products'] = $catalogModel->renderCatalogXml($offset,$count,$storeId,'','','');
570
+
571
+ if ($offset+$count > $to_send) {
 
 
572
  $data['is_last'] = 1;
573
+ $count=$to_send-$offset;
574
  }
575
 
576
  // sending products
577
+ $res2 = $helper->sendPostCurl($cmd_url, $data);
578
+ unset($data['products']);
 
 
 
 
 
 
 
579
 
580
+ if($res2 !== 'ok') {
581
+ $responseArr = array('success'=>false,'message'=>$res2);
582
+ $response->setBody($responseArr);
583
  return;
584
  }
585
 
586
+
587
+ $pusher->setSent(2);
588
+ $pusher->save();
589
+
590
+ $nextPushId = $helper->getPushId();
591
+ $nextPushUrl = '';
592
+
593
+ if($nextPushId!=''){
594
+ $nextPushUrl=$helper->getPushUrl($nextPushId);
595
+ }
596
 
597
  $totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
598
 
599
+ $updatedStatus = 'Syncing: push ' . $nextPushId . '/' . $totalPushes;
600
+ $updatedSuccessStatus = 'Successfully synced '. $count .' products';
601
+
602
  $responseArr = array(
603
+ 'success' => true,
604
+ 'updatedStatus' => $updatedStatus,
605
+ 'updatedSuccessStatus' => $updatedSuccessStatus,
606
+ 'message' => '',
607
+ 'nextPushUrl' => $nextPushUrl,
608
+ 'count' => $count
609
  );
610
 
611
  $response->setBody(json_encode($responseArr));
612
+
613
  }
614
  }
app/code/local/Autocompleteplus/Autosuggest/controllers/ProductsbyidController.php CHANGED
@@ -19,9 +19,10 @@ class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompletepl
19
  {
20
  $request = $this->getRequest();
21
  $response = $this->getResponse();
22
- $helper = Mage::helper('autocompleteplus_autosuggest');
23
- $storeId = $helper->validateInput($request->getParam('store', Mage::app()->getStore()->getStoreId()), 'integer', 1, null);
24
- $id = $helper->validateInput($request->getParam('id'), 'integer', null, null);
 
25
 
26
  if (!$id) {
27
  $returnArr = array(
@@ -49,11 +50,11 @@ class Autocompleteplus_Autosuggest_ProductsbyidController extends Autocompletepl
49
  {
50
  $request = $this->getRequest();
51
  $response = $this->getResponse();
52
- $helper = Mage::helper('autocompleteplus_autosuggest');
53
-
54
- $fromId = $helper->validateInput($request->getParam('id', 0), 'integer', null, null);
55
- $storeId = $helper->validateInput($request->getParam('store', Mage::app()->getStore()->getStoreId()), 'integer', null, null);
56
- $count = $helper->validateInput($request->getParam('count', 100), 'integer', null, null);
57
 
58
  $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
59
  $xml = $catalogModel->renderCatalogFromIds($count, $fromId, $storeId);
19
  {
20
  $request = $this->getRequest();
21
  $response = $this->getResponse();
22
+ $storeId = $request->getParam('store', 1);
23
+ $id = $request->getParam('id');
24
+
25
+ Mage::app()->setCurrentStore($storeId);
26
 
27
  if (!$id) {
28
  $returnArr = array(
50
  {
51
  $request = $this->getRequest();
52
  $response = $this->getResponse();
53
+ $fromId = $request->getParam('id', 0);
54
+ $storeId = $request->getParam('store', 1);
55
+ $count = $request->getParam('count', 100);
56
+
57
+ Mage::app()->setCurrentStore($storeId);
58
 
59
  $catalogModel = Mage::getModel('autocompleteplus_autosuggest/catalog');
60
  $xml = $catalogModel->renderCatalogFromIds($count, $fromId, $storeId);
app/code/local/Autocompleteplus/Autosuggest/controllers/SearchesController.php CHANGED
@@ -18,18 +18,21 @@ class Autocompleteplus_Autosuggest_SearchesController extends Mage_Core_Controll
18
  public function sendAction()
19
  {
20
  set_time_limit(1800);
21
-
22
- $helper = Mage::helper('autocompleteplus_autosuggest');
23
  $post = $this->getRequest()->getParams();
24
-
25
- $startInd = $helper->validateInput($post['offset'], 'integer', 0, null);
26
- $count = $helper->validateInput($post['count'], 'integer', 0, null);
27
 
28
  // $enabled= Mage::getStoreConfig('autocompleteplus/config/enabled');
29
  // if($enabled=='0'){
30
  // die('The user has disabled autocompleteplus.');
31
  // }
32
 
 
 
 
 
 
 
 
33
  //maxim products on one page is 10000
34
  if (!$count || $count > 10000) {
35
  $count = 10000;
18
  public function sendAction()
19
  {
20
  set_time_limit(1800);
21
+
 
22
  $post = $this->getRequest()->getParams();
 
 
 
23
 
24
  // $enabled= Mage::getStoreConfig('autocompleteplus/config/enabled');
25
  // if($enabled=='0'){
26
  // die('The user has disabled autocompleteplus.');
27
  // }
28
 
29
+ $startInd = $post['offset'];
30
+ if (!$startInd) {
31
+ $startInd = 0;
32
+ }
33
+
34
+ $count = $post['count'];
35
+
36
  //maxim products on one page is 10000
37
  if (!$count || $count > 10000) {
38
  $count = 10000;
app/code/local/Autocompleteplus/Autosuggest/data/autosuggest_setup/data-install-3.0.0.5.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $batchCollection = Mage::getModel('autocompleteplus_autosuggest/batches')->getCollection();
4
+
5
+ foreach ($batchCollection as $batch) {
6
+ $currentTime = $batch->getUpdateDate();
7
+ $batch->setUpdateDate($currentTime)->save();
8
+ }
app/code/local/Autocompleteplus/Autosuggest/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Autocompleteplus_Autosuggest>
5
- <version>3.0.0.6</version>
6
  <url>http://autocompleteplus.com/</url>
7
  <modulename>Autocompleteplus_Autosuggest</modulename>
8
  </Autocompleteplus_Autosuggest>
@@ -15,6 +15,7 @@
15
  </autocompleteplus_autosuggest>
16
  <autocompleteplus_autosuggest_resource>
17
  <class>Autocompleteplus_Autosuggest_Model_Resource</class>
 
18
  <entities>
19
  <notifications>
20
  <table>autocompleteplus_notifications</table>
@@ -30,8 +31,6 @@
30
  </batches>
31
  </entities>
32
  </autocompleteplus_autosuggest_resource>
33
- <catalogsearch_mysql4>
34
- </catalogsearch_mysql4>
35
  <catalogsearch_resource>
36
  <rewrite>
37
  <fulltext_collection>Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection</fulltext_collection>
@@ -72,6 +71,15 @@
72
  </autocompleteplus_autosuggest>
73
  </observers>
74
  </catalog_product_save_before>
 
 
 
 
 
 
 
 
 
75
  <catalog_product_delete_before>
76
  <observers>
77
  <autocompleteplus_autosuggest>
@@ -177,7 +185,7 @@
177
  <adminhtml>
178
  <args>
179
  <modules>
180
- <autocompleteplus before="Mage_Adminhtml">Autocompleteplus_Autosuggest_Adminhtml</autocompleteplus>
181
  </modules>
182
  </args>
183
  </adminhtml>
@@ -198,7 +206,7 @@
198
  <imagefield>thumbnail</imagefield>
199
  <attributes>1</attributes>
200
  <layered>0</layered>
201
- <api_endpoint><![CDATA[https://acp-magento.appspot.com]]></api_endpoint>
202
  </config>
203
  </autocompleteplus>
204
  </default>
2
  <config>
3
  <modules>
4
  <Autocompleteplus_Autosuggest>
5
+ <version>3.0.0.7</version>
6
  <url>http://autocompleteplus.com/</url>
7
  <modulename>Autocompleteplus_Autosuggest</modulename>
8
  </Autocompleteplus_Autosuggest>
15
  </autocompleteplus_autosuggest>
16
  <autocompleteplus_autosuggest_resource>
17
  <class>Autocompleteplus_Autosuggest_Model_Resource</class>
18
+ <deprecatedNode>autocompleteplus_mysql4</deprecatedNode>
19
  <entities>
20
  <notifications>
21
  <table>autocompleteplus_notifications</table>
31
  </batches>
32
  </entities>
33
  </autocompleteplus_autosuggest_resource>
 
 
34
  <catalogsearch_resource>
35
  <rewrite>
36
  <fulltext_collection>Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection</fulltext_collection>
71
  </autocompleteplus_autosuggest>
72
  </observers>
73
  </catalog_product_save_before>
74
+ <catalog_product_save_after>
75
+ <observers>
76
+ <autocompleteplus_autosuggest>
77
+ <type>singleton</type>
78
+ <class>autocompleteplus_autosuggest/observer</class>
79
+ <method>catalog_product_save_after_real</method>
80
+ </autocompleteplus_autosuggest>
81
+ </observers>
82
+ </catalog_product_save_after>
83
  <catalog_product_delete_before>
84
  <observers>
85
  <autocompleteplus_autosuggest>
185
  <adminhtml>
186
  <args>
187
  <modules>
188
+ <autocompleteplus after="Mage_Adminhtml">Autocompleteplus_Autosuggest_Adminhtml</autocompleteplus>
189
  </modules>
190
  </args>
191
  </adminhtml>
206
  <imagefield>thumbnail</imagefield>
207
  <attributes>1</attributes>
208
  <layered>0</layered>
209
+ <api_endpoint><![CDATA[https://magento.instantsearchplus.com]]></api_endpoint>
210
  </config>
211
  </autocompleteplus>
212
  </default>
app/code/local/Autocompleteplus/Autosuggest/etc/config.xml.bak ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Autocompleteplus_Autosuggest>
5
+ <version>3.0.0.5</version>
6
+ <url>http://autocompleteplus.com/</url>
7
+ <modulename>Autocompleteplus_Autosuggest</modulename>
8
+ </Autocompleteplus_Autosuggest>
9
+ </modules>
10
+ <global>
11
+ <models>
12
+ <autocompleteplus_autosuggest>
13
+ <class>Autocompleteplus_Autosuggest_Model</class>
14
+ <resourceModel>autocompleteplus_autosuggest_resource</resourceModel>
15
+ </autocompleteplus_autosuggest>
16
+ <autocompleteplus_autosuggest_resource>
17
+ <class>Autocompleteplus_Autosuggest_Model_Resource</class>
18
+ <deprecatedNode>autocompleteplus_mysql4</deprecatedNode>
19
+ <entities>
20
+ <notifications>
21
+ <table>autocompleteplus_notifications</table>
22
+ </notifications>
23
+ <pusher>
24
+ <table>autocompleteplus_pusher</table>
25
+ </pusher>
26
+ <config>
27
+ <table>autocompleteplus_config</table>
28
+ </config>
29
+ <batches>
30
+ <table>autocompleteplus_batches</table>
31
+ </batches>
32
+ </entities>
33
+ </autocompleteplus_autosuggest_resource>
34
+ <catalogsearch_resource>
35
+ <rewrite>
36
+ <fulltext_collection>Autocompleteplus_Autosuggest_Model_Resource_Fulltext_Collection</fulltext_collection>
37
+ </rewrite>
38
+ </catalogsearch_resource>
39
+ </models>
40
+ <events>
41
+ <controller_action_postdispatch_checkout_cart_index>
42
+ <observers>
43
+ <autocompleteplus_autosuggest>
44
+ <class>autocompleteplus_autosuggest/observer</class>
45
+ <method>webhook_service_call</method>
46
+ </autocompleteplus_autosuggest>
47
+ </observers>
48
+ </controller_action_postdispatch_checkout_cart_index>
49
+ <controller_action_postdispatch_checkout_onepage_index>
50
+ <observers>
51
+ <autocompleteplus_autosuggest>
52
+ <class>autocompleteplus_autosuggest/observer</class>
53
+ <method>webhook_service_call</method>
54
+ </autocompleteplus_autosuggest>
55
+ </observers>
56
+ </controller_action_postdispatch_checkout_onepage_index>
57
+ <controller_action_postdispatch_checkout_onepage_success>
58
+ <observers>
59
+ <autocompleteplus_autosuggest>
60
+ <class>autocompleteplus_autosuggest/observer</class>
61
+ <method>webhook_service_call</method>
62
+ </autocompleteplus_autosuggest>
63
+ </observers>
64
+ </controller_action_postdispatch_checkout_onepage_success>
65
+ <catalog_product_save_before>
66
+ <observers>
67
+ <autocompleteplus_autosuggest>
68
+ <type>singleton</type>
69
+ <class>autocompleteplus_autosuggest/observer</class>
70
+ <method>catalog_product_save_after</method>
71
+ </autocompleteplus_autosuggest>
72
+ </observers>
73
+ </catalog_product_save_before>
74
+ <catalog_product_save_after>
75
+ <observers>
76
+ <autocompleteplus_autosuggest>
77
+ <type>singleton</type>
78
+ <class>autocompleteplus_autosuggest/observer</class>
79
+ <method>catalog_product_save_after_real</method>
80
+ </autocompleteplus_autosuggest>
81
+ </observers>
82
+ </catalog_product_save_after>
83
+ <catalog_product_delete_before>
84
+ <observers>
85
+ <autocompleteplus_autosuggest>
86
+ <type>singleton</type>
87
+ <class>autocompleteplus_autosuggest/observer</class>
88
+ <method>catalog_product_delete_before</method>
89
+ </autocompleteplus_autosuggest>
90
+ </observers>
91
+ </catalog_product_delete_before>
92
+ <adminhtml_controller_catalogrule_prepare_save>
93
+ <observers>
94
+ <autocompleteplus_autosuggest>
95
+ <type>singleton</type>
96
+ <class>autocompleteplus_autosuggest/observer</class>
97
+ <method>adminhtml_controller_catalogrule_prepare_save</method>
98
+ </autocompleteplus_autosuggest>
99
+ </observers>
100
+ </adminhtml_controller_catalogrule_prepare_save>
101
+ </events>
102
+ <resources>
103
+ <autosuggest_setup>
104
+ <setup>
105
+ <module>Autocompleteplus_Autosuggest</module>
106
+ </setup>
107
+ <connection>
108
+ <use>core_setup</use>
109
+ </connection>
110
+ </autosuggest_setup>
111
+ <autosuggest_write>
112
+ <connection>
113
+ <use>core_write</use>
114
+ </connection>
115
+ </autosuggest_write>
116
+ <autosuggest_read>
117
+ <connection>
118
+ <use>core_read</use>
119
+ </connection>
120
+ </autosuggest_read>
121
+ </resources>
122
+ <blocks>
123
+ <autocompleteplus_autosuggest>
124
+ <class>Autocompleteplus_Autosuggest_Block</class>
125
+ </autocompleteplus_autosuggest>
126
+ </blocks>
127
+ <template>
128
+ <email>
129
+ <autosuggest_status_notification module="autocompleteplus_autosuggest">
130
+ <label>Autocompleteplus status notification</label>
131
+ <file>autocompleteplus/status_notification.html</file>
132
+ <type>html</type>
133
+ </autosuggest_status_notification>
134
+ </email>
135
+ </template>
136
+ <helpers>
137
+ <autocompleteplus_autosuggest>
138
+ <class>Autocompleteplus_Autosuggest_Helper</class>
139
+ </autocompleteplus_autosuggest>
140
+ </helpers>
141
+ <sales>
142
+ <quote>
143
+ <item>
144
+ <product_attributes>
145
+ <added_from_search />
146
+ </product_attributes>
147
+ </item>
148
+ </quote>
149
+ </sales>
150
+ </global>
151
+ <frontend>
152
+ <layout>
153
+ <updates>
154
+ <autosuggest>
155
+ <file>autocompleteplus.xml</file>
156
+ </autosuggest>
157
+ </updates>
158
+ </layout>
159
+ <routers>
160
+ <instantsearchplus>
161
+ <use>standard</use>
162
+ <args>
163
+ <module>Autocompleteplus_Autosuggest</module>
164
+ <frontName>instantsearchplus</frontName>
165
+ </args>
166
+ </instantsearchplus>
167
+ <autocompleteplus>
168
+ <use>standard</use>
169
+ <args>
170
+ <module>Autocompleteplus_Autosuggest</module>
171
+ <frontName>autocompleteplus</frontName>
172
+ </args>
173
+ </autocompleteplus>
174
+ <catalogsearch>
175
+ <args>
176
+ <modules>
177
+ <Autocompleteplus_Autosuggest before="Mage_CatalogSearch">Autocompleteplus_Autosuggest_CatalogSearch</Autocompleteplus_Autosuggest>
178
+ </modules>
179
+ </args>
180
+ </catalogsearch>
181
+ </routers>
182
+ </frontend>
183
+ <admin>
184
+ <routers>
185
+ <adminhtml>
186
+ <args>
187
+ <modules>
188
+ <autocompleteplus after="Mage_Adminhtml">Autocompleteplus_Autosuggest_Adminhtml</autocompleteplus>
189
+ </modules>
190
+ </args>
191
+ </adminhtml>
192
+ </routers>
193
+ </admin>
194
+ <adminhtml>
195
+ <layout>
196
+ <updates>
197
+ <autosuggest>
198
+ <file>autocompleteplus.xml</file>
199
+ </autosuggest>
200
+ </updates>
201
+ </layout>
202
+ </adminhtml>
203
+ <default>
204
+ <autocompleteplus>
205
+ <config>
206
+ <imagefield>thumbnail</imagefield>
207
+ <attributes>1</attributes>
208
+ <layered>0</layered>
209
+ <api_endpoint><![CDATA[https://magento.instantsearchplus.com]]></api_endpoint>
210
+ </config>
211
+ </autocompleteplus>
212
+ </default>
213
+ </config>
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.5.4-2.0.5.5.php CHANGED
@@ -4,12 +4,12 @@ $installer = $this;
4
 
5
  $installer->startSetup();
6
  $fileIo = new Varien_Io_File();
7
- $fileIo->open(array('path' => Mage::getBaseDir()));
 
8
 
9
  // getEdition exist from version 1.12, LICENSE_EE.txt file only exists in EE edition, we need the condition to work on EE version less then 1.11.x.x
10
- if (!method_exists('Mage', 'getEdition') && $fileIo->isValid('LICENSE_EE.txt') && method_exists('Mage',
11
- 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true
12
- ) {
13
  $res = $installer->run("
14
 
15
  DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_pusher')};
@@ -91,8 +91,14 @@ if (!method_exists('Mage', 'getEdition') && $fileIo->isValid('LICENSE_EE.txt') &
91
 
92
  ));
93
 
94
- if ($installer->getConnection()->isTableExists($table->getName())) {
95
- $installer->getConnection()->dropTable($table->getName());
 
 
 
 
 
 
96
  }
97
 
98
  $installer->getConnection()->createTable($table);
4
 
5
  $installer->startSetup();
6
  $fileIo = new Varien_Io_File();
7
+ $baseDir = Mage::getBaseDir();
8
+ $fileIo->open(array('path' => $baseDir));
9
 
10
  // getEdition exist from version 1.12, LICENSE_EE.txt file only exists in EE edition, we need the condition to work on EE version less then 1.11.x.x
11
+ if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
12
+
 
13
  $res = $installer->run("
14
 
15
  DROP TABLE IF EXISTS {$this->getTable('autocompleteplus_pusher')};
91
 
92
  ));
93
 
94
+ if (method_exists($installer->getConnection(), 'isTableExists')) {
95
+ if ($installer->getConnection()->isTableExists($table->getName())) {
96
+ $installer->getConnection()->dropTable($table->getName());
97
+ }
98
+ } else if (method_exists($installer, 'tableExists')) {
99
+ if ($installer->tableExists($table->getName())) {
100
+ $installer->run("DROP TABLE IF EXISTS {$table->getName()};");
101
+ }
102
  }
103
 
104
  $installer->getConnection()->createTable($table);
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.7.2-2.0.7.3.php CHANGED
@@ -5,18 +5,25 @@ $tableName = $this->getTable('autocompleteplus_batches');
5
  $columnName = 'update_date';
6
  $checkColumnType = false;
7
  $fileIo = new Varien_Io_File();
8
- $fileIo->open(array('path' => Mage::getBaseDir()));
 
9
 
10
  /*
11
  * Check if getEdition method does not exist in Mage
12
  * Check if Enterprise Edition license exists in Magento root
13
  * Check if getVersion method exists in Mage
14
  * Compare versions to check if less than 1.10.0.0
 
15
  */
16
- if (!method_exists('Mage', 'getEdition') && $fileIo->isValid('LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
 
17
  $tableExists = $installer->getConnection()->showTableStatus($tableName);
18
  } else {
19
- $tableExists = $installer->getConnection()->isTableExists($tableName);
 
 
 
 
20
  }
21
 
22
  if ($tableExists) {
@@ -41,7 +48,12 @@ if ($tableExists) {
41
  if (!$checkColumnType) {
42
  $installer->startSetup();
43
 
44
- $installer->getConnection()->dropTable($tableName);
 
 
 
 
 
45
  $installer->getConnection()->newTable($tableName)
46
  ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
47
  'identity' => true,
5
  $columnName = 'update_date';
6
  $checkColumnType = false;
7
  $fileIo = new Varien_Io_File();
8
+ $baseDir = Mage::getBaseDir();
9
+ $fileIo->open(array('path' => $baseDir));
10
 
11
  /*
12
  * Check if getEdition method does not exist in Mage
13
  * Check if Enterprise Edition license exists in Magento root
14
  * Check if getVersion method exists in Mage
15
  * Compare versions to check if less than 1.10.0.0
16
+ * Required to use file_exists because Varien_Io_File isValid missing < 1.8CE
17
  */
18
+ // @codingStandardsIgnoreLine
19
+ if (!method_exists('Mage', 'getEdition') && file_exists($baseDir . DS . 'LICENSE_EE.txt') && method_exists('Mage', 'getVersion') && version_compare(Mage::getVersion(), '1.10.0.0.', '<') === true) {
20
  $tableExists = $installer->getConnection()->showTableStatus($tableName);
21
  } else {
22
+ if (method_exists($installer->getConnection(), 'isTableExists')) {
23
+ $tableExists = $installer->getConnection()->isTableExists($tableName);
24
+ } else {
25
+ $tableExists = $installer->tableExists($tableName);
26
+ }
27
  }
28
 
29
  if ($tableExists) {
48
  if (!$checkColumnType) {
49
  $installer->startSetup();
50
 
51
+ if (method_exists($installer->getConnection(), 'dropTable')) {
52
+ $installer->getConnection()->dropTable($tableName);
53
+ } else {
54
+ $installer->run("DROP TABLE IF EXISTS {$tableName};");
55
+ }
56
+
57
  $installer->getConnection()->newTable($tableName)
58
  ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
59
  'identity' => true,
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-2.0.8.8-3.0.0.0.php CHANGED
@@ -5,11 +5,24 @@ $config = Mage::getModel('autocompleteplus_autosuggest/config');
5
  $row = false;
6
  $installer->startSetup();
7
 
8
- if ($installer->getConnection()->isTableExists($installer->getTable('autocompleteplus_autosuggest/config'))) {
 
 
 
 
 
 
 
 
9
  $select = $installer->getConnection()->select()
10
- ->from(array('config' => $installer->getTable('autocompleteplus_autosuggest/config')));
11
  $row = $installer->getConnection()->fetchAll($select);
12
- $installer->getConnection()->dropTable($installer->getTable('autocompleteplus_autosuggest/config'));
 
 
 
 
 
13
  }
14
 
15
  if ($row && isset($row[0]['licensekey']) && isset($row[0]['authkey'])) {
5
  $row = false;
6
  $installer->startSetup();
7
 
8
+ $tableExists = false;
9
+ $tableName = $installer->getTable('autocompleteplus_autosuggest/config');
10
+
11
+ if (method_exists($installer->getConnection(), 'isTableExists')) {
12
+ $tableExists = $installer->getConnection()->isTableExists($tableName);
13
+ } else {
14
+ $tableExists = $installer->tableExists($tableName);
15
+ }
16
+ if ($tableExists) {
17
  $select = $installer->getConnection()->select()
18
+ ->from(array('config' => $tableName));
19
  $row = $installer->getConnection()->fetchAll($select);
20
+
21
+ if (method_exists($installer->getConnection(), 'dropTable')) {
22
+ $installer->getConnection()->dropTable($tableName);
23
+ } else {
24
+ $installer->run("DROP TABLE IF EXISTS {$tableName};");
25
+ }
26
  }
27
 
28
  if ($row && isset($row[0]['licensekey']) && isset($row[0]['authkey'])) {
app/code/local/Autocompleteplus/Autosuggest/sql/autosuggest_setup/mysql4-upgrade-3.0.0.4-3.0.0.5.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/autocompleteplus.xml CHANGED
@@ -22,4 +22,17 @@
22
  </block>
23
  </reference>
24
  </default>
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  </layout>
22
  </block>
23
  </reference>
24
  </default>
25
+ <adminhtml_autocompleteplus_push_startpush>
26
+ <remove name="root"/>
27
+ <block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
28
+ <block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
29
+ <action method="addJs"><script>prototype/prototype.js</script></action>
30
+ <action method="addJs"><script>prototype/validation.js</script></action>
31
+ <action method="addJs"><script>varien/js.js</script></action>
32
+ <action method="addJs"><script>mage/translate.js</script></action>
33
+ <action method="addJs"><script>mage/adminhtml/tools.js</script></action>
34
+ </block>
35
+ <block type="autocompleteplus_autosuggest/adminhtml_process" name="autocompleteplus_autosuggest_adminhtml_process" template="autocompleteplus/process.phtml" output="toHtml"/>
36
+ </block>
37
+ </adminhtml_autocompleteplus_push_startpush>
38
  </layout>
app/design/{frontend/base → adminhtml/default}/default/template/autocompleteplus/process.phtml RENAMED
@@ -3,23 +3,17 @@ $helper = Mage::helper('autocompleteplus_autosuggest');
3
  $pushId = $helper->getPushId();
4
  $totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
5
  $pushUrl = '';
 
6
 
7
  if ($pushId != '') {
8
  $pushUrl = $helper->getPushUrl($pushId);
9
  }
10
  ?>
11
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
12
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
13
- <head>
14
  <style type="text/css">
15
  ul { list-style-type:none; padding:0; margin:0; }
16
  li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
17
  img { margin-right:5px; }
18
  </style>
19
- <title><?php echo $this->__('Syncing data...') ?></title>
20
- </head>
21
- <body>
22
-
23
  <ul>
24
  <li>
25
  <img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif');?>" class="v-middle" style="margin-right:5px"/>
@@ -44,7 +38,8 @@ config.tpl = new Template(config.template);
44
  config.tplTxt = new Template(config.text);
45
  config.tplSccTxt = new Template(config.successText);
46
 
47
- var url= <?php echo $pushUrl; ?>;
 
48
 
49
  var count=0;
50
 
@@ -59,12 +54,14 @@ if(url!=""){
59
  function sendImportData(url) {
60
 
61
  if (!$("updatedRows")) {
62
- Element.insert($("liFinished"), {before: config.tpl.evaluate({
63
- style: "background-color: #FFD;",
64
- image: config.styles.loader,
65
- text: <?php echo $this->__('Syncing: push %s/%s', $pushId, $totalPushes); ?>,
66
- id: "updatedRows"
67
- })});
 
 
68
  }
69
 
70
  new Ajax.Request(url, {
@@ -75,47 +72,53 @@ function sendImportData(url) {
75
  var res=transport.responseText.evalJSON();
76
 
77
  if(!res){
78
- Element.insert($("updatedRows"), {before: config.tpl.evaluate({
79
- style: "background-color:"+config.styles.error.bg,
80
- image: config.styles.error.icon,
81
- text: res.message,
82
- id: "error-"+makeid()
83
- })});
84
- }else{
85
-
86
- if (!$("synced-rows")){
87
- Element.insert($("updatedRows"), {before: config.tpl.evaluate({
88
- style: "background-color:"+config.styles.message.bg,
89
- image: config.styles.message.icon,
90
- text: res.updatedSuccessStatus,
91
- id: "synced-rows"
92
- })});
93
- }else{
94
- $("synced-rows_status").update(res.updatedSuccessStatus);
95
- }
96
-
97
- url=res.nextPushUrl;
98
-
99
- count+=res.count;
100
-
101
- if(url!=""){
102
- $("updatedRows_status").update(res.updatedStatus);
103
- sendImportData(url);
104
  }else{
105
- $("liFinished").show();
106
- $("liFinished_count").update(count);
107
- $("updatedRows").hide()
108
- $("synced-rows").hide()
109
  }
110
 
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  } else {
113
- Element.insert($("updatedRows"), {before: config.tpl.evaluate({
114
- style: "background-color:"+config.styles.error.bg,
115
- image: config.styles.error.icon,
116
- text: transport.responseText.escapeHTML(),
117
- id: "error-"+makeid()
118
- })});
 
 
119
  }
120
  }
121
  });
@@ -131,6 +134,4 @@ function makeid()
131
 
132
  return text;
133
  }
134
- </script>
135
- </body>
136
- </html>
3
  $pushId = $helper->getPushId();
4
  $totalPushes = Mage::getModel('autocompleteplus_autosuggest/pusher')->getCollection()->getSize();
5
  $pushUrl = '';
6
+ $updateUrl = '';
7
 
8
  if ($pushId != '') {
9
  $pushUrl = $helper->getPushUrl($pushId);
10
  }
11
  ?>
 
 
 
12
  <style type="text/css">
13
  ul { list-style-type:none; padding:0; margin:0; }
14
  li { margin-left:0; border:1px solid #ccc; margin:2px; padding:2px 2px 2px 2px; font:normal 12px sans-serif; }
15
  img { margin-right:5px; }
16
  </style>
 
 
 
 
17
  <ul>
18
  <li>
19
  <img src="<?php echo $this->getSkinUrl('images/note_msg_icon.gif');?>" class="v-middle" style="margin-right:5px"/>
38
  config.tplTxt = new Template(config.text);
39
  config.tplSccTxt = new Template(config.successText);
40
 
41
+ var url= "<?php echo $pushUrl; ?>";
42
+ var updateUrl = "<?php echo $updateUrl; ?>";
43
 
44
  var count=0;
45
 
54
  function sendImportData(url) {
55
 
56
  if (!$("updatedRows")) {
57
+ Element.insert($("liFinished"), {
58
+ before: config.tpl.evaluate({
59
+ style: "background-color: #FFD;",
60
+ image: config.styles.loader,
61
+ text: "<?php echo $this->__('Syncing: push %s/%s', $pushId, $totalPushes); ?>",
62
+ id: "updatedRows"
63
+ })
64
+ });
65
  }
66
 
67
  new Ajax.Request(url, {
72
  var res=transport.responseText.evalJSON();
73
 
74
  if(!res){
75
+ Element.insert($("updatedRows"), {
76
+ before: config.tpl.evaluate({
77
+ style: "background-color:"+config.styles.error.bg,
78
+ image: config.styles.error.icon,
79
+ text: res.message,
80
+ id: "error-"+makeid()
81
+ })
82
+ });
83
+
84
+ } else {
85
+
86
+ if (!$("synced-rows")){
87
+ Element.insert($("updatedRows"), {
88
+ before: config.tpl.evaluate({
89
+ style: "background-color:"+config.styles.message.bg,
90
+ image: config.styles.message.icon,
91
+ text: res.updatedSuccessStatus,
92
+ id: "synced-rows"
93
+ })});
 
 
 
 
 
 
 
94
  }else{
95
+ $("synced-rows_status").update(res.updatedSuccessStatus);
 
 
 
96
  }
97
 
98
+ url=res.nextPushUrl;
99
+
100
+ count+=res.count;
101
+
102
+ if(url!=""){
103
+ $("updatedRows_status").update(res.updatedStatus);
104
+ sendImportData(url);
105
+ }else{
106
+ $("liFinished").show();
107
+ $("liFinished_count").update(count);
108
+ $("updatedRows").hide()
109
+ $("synced-rows").hide()
110
+ }
111
+
112
+ }
113
  } else {
114
+ Element.insert($("updatedRows"), {
115
+ before: config.tpl.evaluate({
116
+ style: "background-color:"+config.styles.error.bg,
117
+ image: config.styles.error.icon,
118
+ text: transport.responseText.escapeHTML(),
119
+ id: "error-"+makeid()
120
+ })
121
+ });
122
  }
123
  }
124
  });
134
 
135
  return text;
136
  }
137
+ </script>
 
 
lib/Autocompleteplus/Autosuggest/Xml/Generator.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Autocompleteplus_Autosuggest_Xml_Generator implements Autocompleteplus_Autosuggest_Xml_GeneratorInterface
4
+ {
5
+ protected $_xml;
6
+
7
+ protected $_rootElementName;
8
+
9
+ protected $_rootAttributes;
10
+
11
+ public function getRootElementName() {
12
+ return $this->_rootElementName;
13
+ }
14
+
15
+ public function setRootElementName($name) {
16
+ $this->_rootElementName = $name;
17
+ return $this;
18
+ }
19
+
20
+ public function setRootAttributes($attributes)
21
+ {
22
+ $this->_rootAttributes = $attributes;
23
+ return $this;
24
+ }
25
+
26
+ public function getRootAttributes()
27
+ {
28
+ return $this->_rootAttributes;
29
+ }
30
+
31
+ public function getSimpleXml()
32
+ {
33
+ if (!$this->_xml) {
34
+ $rootElement = sprintf('<%s/>', $this->getRootElementName());
35
+ $this->_xml = new \SimpleXMLElement($rootElement);
36
+
37
+ $rootAttributes = $this->getRootAttributes();
38
+
39
+ if ($rootAttributes) {
40
+ foreach ($rootAttributes as $attrKey => $attrValue) {
41
+ $this->_xml->addAttribute($attrKey, $attrValue);
42
+ }
43
+ }
44
+ }
45
+ return $this->_xml;
46
+ }
47
+
48
+ public function generateXml() {
49
+ $domDocument = new \DOMDocument('1.0');
50
+ $domDocument->formatOutput = true;
51
+ $simpleXmlToDom = dom_import_simplexml($this->getSimpleXml());
52
+
53
+ $simpleXmlToDom = $domDocument->importNode($simpleXmlToDom, true);
54
+ $domDocument->appendChild($simpleXmlToDom);
55
+
56
+ $output = $domDocument->saveXML($domDocument, LIBXML_NOEMPTYTAG);
57
+
58
+ return $output;
59
+ }
60
+
61
+ public function createChild($childName, $childAttributes, $childValue = false, $parent = false) {
62
+ $xml = $this->getSimpleXml();
63
+
64
+ if ($parent !== false) {
65
+ $xml = $parent;
66
+ }
67
+
68
+ if ($childValue !== false) {
69
+ $child = $xml->addChild($childName);
70
+ if ($child !== NULL) {
71
+ $node = dom_import_simplexml($child);
72
+ $doc = $node->ownerDocument;
73
+ $node->appendChild($doc->createCDATASection($childValue));
74
+ }
75
+ } else {
76
+ $child = $xml->addChild($childName);
77
+ }
78
+
79
+ if (is_array($childAttributes)) {
80
+ foreach ($childAttributes as $key => $val) {
81
+ $child->addAttribute($key, $val);
82
+ }
83
+ }
84
+
85
+ return $child;
86
+ }
87
+ }
lib/Autocompleteplus/Autosuggest/Xml/GeneratorInterface.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface Autocompleteplus_Autosuggest_Xml_GeneratorInterface
4
+ {
5
+ public function getSimpleXml();
6
+
7
+ public function getRootElementName();
8
+
9
+ public function setRootElementName($name);
10
+
11
+ public function generateXml();
12
+ }
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>autocompleteplus_autosuggest</name>
4
- <version>3.0.0.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.autocompleteplus.com/privacy">AC+</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>AutoComplete+ InstantSearch</summary>
10
  <description>AutoComplete+ InstantSearch triples visitor conversion, optimizes search, and offers promotions through state-of-the-art contextual suggestions dropdown. Since suggestions are lightning fast, accurate, and contextual - visitors find exactly what they want - faster.</description>
11
- <notes>* Fixing SQL injection security vulnerability</notes>
12
  <authors><author><name>Adar</name><user>Adar</user><email>magento@autocompleteplus.com</email></author></authors>
13
- <date>2016-06-01</date>
14
- <time>13:04:54</time>
15
- <contents><target name="magelocal"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Adminhtml"><dir name="Model"><file name="Attributes.php" hash="5e480167310365ad57785ef2a2da39be"/><file name="Button.php" hash="ad2429ce8a2c172237e41faef5fce322"/></dir></dir><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="262987c852813741a2562fe927054469"/><file name="Process.php" hash="30f02cc873ac8d6eaeaaeca5c3d328e5"/><file name="Sync.php" hash="3c668febd558dd7c2db75c314378e0d5"/></dir><file name="Autocomplete.php" hash="cc694575438fe43fc086b89f2d4826c9"/><file name="Autocorrection.php" hash="6676f140f9da260f52e59478e1af2b47"/><file name="Inject.php" hash="bc001de5e9d27bc1e41b8df80d482117"/><file name="Notifications.php" hash="3ab60946b756f093585a708185d98909"/></dir><dir name="Controller"><file name="Abstract.php" hash="84b311dbc24ca94ee7f1af655430f8ea"/></dir><dir name="Helper"><file name="Data.php" hash="d7e6f54f8285e82b125c53d18a698f44"/><file name="Data.php.bak" hash="183e152c97a13977047e950b87b3ccee"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Attributes.php" hash="8f8581590b3b2eee69704aa1715dfdd4"/></dir><dir name="Api"><file name="V2.php" hash="f764e775bf087dad35a0351ff2c04539"/></dir><file name="Api.php" hash="298fcc3db05af5fad34375457b5001d4"/><file name="Batches.php" hash="bfa0c53ff502dbb99f120a8ac7626819"/><file name="Catalog.php" hash="ee57d1ab64525318a6dc5962bd98c513"/><file name="Catalogreport.php" hash="2bfa54c42bf20418d75847a08cc114a0"/><file name="Checksum.php" hash="37550b6bd6d934f1ad2ef581dfa10eea"/><file name="Config.php" hash="42f37cd6513488738a9c97f1373d8c03"/><file name="Layer.php" hash="82538541fb58038dd308fc584454d0bd"/><file name="Notifications.php" hash="7f4037e171c63de662370aeceaeed1d6"/><file name="Observer.php" hash="216a02f7cc87e5f84d0806e48897a03d"/><file name="Pusher.php" hash="518825e11c9d8fd0b91ac78f6916c40b"/><dir name="Resource"><dir name="Batches"><file name="Collection.php" hash="5d3f333f7383f040654cfb402a089823"/></dir><file name="Batches.php" hash="c5c012179db3636e503f48d0a6de59d5"/><dir name="Checksum"><file name="Collection.php" hash="4c2c32f787763cef11ae9bf175c8813f"/></dir><file name="Checksum.php" hash="5e2d0ece6ea043e517a0c777fc165de4"/><dir name="Fulltext"><file name="Collection.php" hash="5096155efa1f4973f702778673c62507"/></dir><dir name="Notifications"><file name="Collection.php" hash="d7ef7e0ee228b48238b727de349a61b0"/></dir><file name="Notifications.php" hash="f4f1111bd0144c7bcc62ae456d7b36be"/><dir name="Pusher"><file name="Collection.php" hash="8f15379bc010d2a25bf01a8ed3f10fbb"/></dir><file name="Pusher.php" hash="e25a14c317dfe3ae1134f3afc654e8d3"/></dir><file name="Service.php" hash="4c0e98c7abfa3319768ee850ed5d8e77"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Autocompleteplus"><file name="PushController.php" hash="c708e07e9b5ae23b4d27c5df0c04cc7f"/><file name="RedirectController.php" hash="8361d1e5922d75763eb82cd916480fb1"/></dir></dir><dir name="CatalogSearch"><file name="ResultController.php" hash="8d2c03b7849b7dbeeb9a08cfa37e63ea"/></dir><file name="CatalogsearchController.php" hash="e534d0933da8a0a1deb4b0618cea5665"/><file name="CategoriesController.php" hash="4b3cd4774c37e5678bb292e4a4665c39"/><file name="LayeredController.php" hash="fa2f88699a15a36da7d6761f74ffa265"/><file name="ProductsController.php" hash="bf213973d747235a01d1f658f933e0b3"/><file name="ProductsbyidController.php" hash="467987d12edd5216ed44ba02cc3e66e1"/><file name="ResultController.php" hash="182f65ce4ccdf154aa0326512ec37140"/><file name="SearchesController.php" hash="28f023a85ecbf6e1b1151c1ea3f64058"/></dir><dir name="etc"><file name="adminhtml.xml" hash="34b9d24ddc4565311f6cc83d7e337478"/><file name="api.xml" hash="25ab859fc8312c4aa308f2e3306c6b66"/><file name="cache.xml" hash="b57472bc9410d67af3843825fba5b420"/><file name="config.xml" hash="19f0ba6f3098bfb71c297a7ada882019"/><file name="system.xml" hash="6bed22fbdfc336254126cf4a8c49aa09"/><file name="wsdl.xml" hash="97b1503c710c79376cd85e7f971c1587"/></dir><dir name="sql"><dir name="autosuggest_setup"><file name="mysql4-install-2.0.1.1.php" hash="c891e1836f3df18eba24821371c85bfa"/><file name="mysql4-upgrade-2.0.1.3-2.0.2.2.php" hash="ddc7001e761dce3b4970f3d4adac2aa3"/><file name="mysql4-upgrade-2.0.2.5-2.0.2.6.php" hash="ea94264608685c51f008382d42d499fd"/><file name="mysql4-upgrade-2.0.4.6-2.0.4.7.php" hash="8166f765780956ea87bbe62b9f709f46"/><file name="mysql4-upgrade-2.0.5.4-2.0.5.5.php" hash="00b8f4401d59f42359baec70ef2de8bb"/><file name="mysql4-upgrade-2.0.5.6-2.0.5.7.php" hash="b40aa51ca00369caa28a0030dc2490e7"/><file name="mysql4-upgrade-2.0.7.0-2.0.7.1.php" hash="3837250beee18106d0f043493dde3382"/><file name="mysql4-upgrade-2.0.7.2-2.0.7.3.php" hash="f858517837a97200e3b5c36339a0b200"/><file name="mysql4-upgrade-2.0.8.8-3.0.0.0.php" hash="bc1082a892dd8c222f2fc73917a8f6e3"/><file name="mysql4-upgrade-3.0.0.3-3.0.0.4.php" hash="9574b75e9a733be858a14588978cd21a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Autocompleteplus_Autosuggest.xml" hash="530931765807be8a21baa5e070bc4bc2"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="autocompleteplus.xml" hash="3998429f613fcc7842b7ea31cb423ec8"/></dir><dir name="template"><dir name="autocompleteplus"><dir name="catalog"><dir name="layer"><file name="view.phtml" hash="57066d2ac5fa051c15c3ed8bb43b5d08"/></dir><dir name="product"><file name="list.phtml" hash="c269d5b27302efb51cefb86a71027a0d"/></dir></dir><file name="inject.phtml" hash="e1e8e050631fe65417edb7a8f25155c8"/><file name="process.phtml" hash="2bb8f334e6d1d64c9042c10d55ac5155"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="autocompleteplus"><file name="notifications.phtml" hash="c1d08659e65020dcb9e62cf8bc28f73b"/><dir name="system"><dir name="config"><file name="button.phtml" hash="3adf3f3f4ab989cf643f2fc49719b59d"/><file name="sync.phtml" hash="e0392aac8584e98ef4260419750e1cbb"/></dir></dir></dir></dir><dir name="layout"><file name="autocompleteplus.xml" hash="939f8a52905dfef7b81a0f4552042376"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>autocompleteplus_autosuggest</name>
4
+ <version>3.0.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.autocompleteplus.com/privacy">AC+</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>AutoComplete+ InstantSearch</summary>
10
  <description>AutoComplete+ InstantSearch triples visitor conversion, optimizes search, and offers promotions through state-of-the-art contextual suggestions dropdown. Since suggestions are lightning fast, accurate, and contextual - visitors find exactly what they want - faster.</description>
11
+ <notes>ECG compatibility refactor</notes>
12
  <authors><author><name>Adar</name><user>Adar</user><email>magento@autocompleteplus.com</email></author></authors>
13
+ <date>2016-07-19</date>
14
+ <time>13:46:05</time>
15
+ <contents><target name="magelocal"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Adminhtml"><dir name="Model"><file name="Attributes.php" hash="5e480167310365ad57785ef2a2da39be"/><file name="Button.php" hash="ad2429ce8a2c172237e41faef5fce322"/></dir></dir><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="262987c852813741a2562fe927054469"/><file name="Process.php" hash="30f02cc873ac8d6eaeaaeca5c3d328e5"/><file name="Sync.php" hash="3c668febd558dd7c2db75c314378e0d5"/></dir><file name="Autocomplete.php" hash="cc694575438fe43fc086b89f2d4826c9"/><file name="Autocorrection.php" hash="6676f140f9da260f52e59478e1af2b47"/><file name="Inject.php" hash="0af946c437fda1a02098b378a142a69c"/><file name="Notifications.php" hash="3ab60946b756f093585a708185d98909"/></dir><dir name="Controller"><file name="Abstract.php" hash="84b311dbc24ca94ee7f1af655430f8ea"/></dir><dir name="Helper"><file name="Data.php" hash="0e3df8e01900dbdd8240e6facee4f159"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Attributes.php" hash="8f8581590b3b2eee69704aa1715dfdd4"/></dir><dir name="Api"><file name="V2.php" hash="f764e775bf087dad35a0351ff2c04539"/></dir><file name="Api.php" hash="298fcc3db05af5fad34375457b5001d4"/><file name="Batches.php" hash="bfa0c53ff502dbb99f120a8ac7626819"/><file name="Catalog.php" hash="790a38417bbd107334de3907a90f6e87"/><file name="Catalogreport.php" hash="110c05b050cffb2fec71973e36440702"/><file name="Checksum.php" hash="37550b6bd6d934f1ad2ef581dfa10eea"/><file name="Config.php" hash="3a19873f65c4c5485f2de7fb9baa1ca9"/><file name="Layer.php" hash="82538541fb58038dd308fc584454d0bd"/><dir name="Mysql4"><dir name="Batches"><file name="Collection.php" hash="06815b7ef6df1c09655024817f9fdc87"/></dir><file name="Batches.php" hash="f61cd3381a76f77989e5dbb35610c0fc"/><dir name="Checksum"><file name="Collection.php" hash="7879f033202d4618ad48f767dbfdd694"/></dir><file name="Checksum.php" hash="92ecf2e3990fd868f2d83fbd1f73d135"/><dir name="Fulltext"><file name="Collection.php" hash="b4b729b327d48457815a3f9c6e86e7f5"/></dir><dir name="Notifications"><file name="Collection.php" hash="9351b214c326de0a4195df88c6ef8f75"/></dir><file name="Notifications.php" hash="9f6514d2bfa7a89f2a663eaa06865d24"/><dir name="Pusher"><file name="Collection.php" hash="83bf9e00aceaa230fcdfe81ac4df344c"/></dir><file name="Pusher.php" hash="1e7ad77386c07fc060c554079a47d60f"/></dir><file name="Notifications.php" hash="7f4037e171c63de662370aeceaeed1d6"/><file name="Observer.php" hash="fc049474b276bb4c38af23e129391958"/><file name="Pusher.php" hash="518825e11c9d8fd0b91ac78f6916c40b"/><dir name="Renderer"><file name="Abstract.php" hash="e7298546a4e47a835a9b69ab873a95da"/><file name="Batches.php" hash="5d73a56a9760df0620f8c0bf28c4e4be"/><dir name="Catalog"><file name="Product.php" hash="84bedcb2c59f49835b759cec5ec7a77e"/></dir></dir><dir name="Resource"><dir name="Batches"><file name="Collection.php" hash="4cff894b990b3b80e95c4224b12050da"/></dir><file name="Batches.php" hash="bfff3c8f471bb5c19cfbc9420d7736a7"/><dir name="Checksum"><file name="Collection.php" hash="43580b863c0040783ffa59230c1fa5e2"/></dir><file name="Checksum.php" hash="e991bdba8c981fa67f46d1f06be10e11"/><dir name="Fulltext"><file name="Collection.php" hash="1a2ff4fb035bccf2424e3ecb0e0e4c93"/></dir><dir name="Notifications"><file name="Collection.php" hash="ca5fbd3f52d9fc2c575588f4d3208c69"/></dir><file name="Notifications.php" hash="5a62daeaba13c72b8f5eb40381642c8d"/><dir name="Pusher"><file name="Collection.php" hash="844299f9264313e6182816c8cbf58a37"/></dir><file name="Pusher.php" hash="fe212dffaaebc28665a3ff4244b78bcd"/></dir><file name="Service.php" hash="4c0e98c7abfa3319768ee850ed5d8e77"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Autocompleteplus"><file name="PushController.php" hash="59ca72fc498a4a190474b46706e1dd18"/><file name="RedirectController.php" hash="8361d1e5922d75763eb82cd916480fb1"/></dir></dir><dir name="CatalogSearch"><file name="ResultController.php" hash="8d2c03b7849b7dbeeb9a08cfa37e63ea"/></dir><file name="CatalogsearchController.php" hash="e534d0933da8a0a1deb4b0618cea5665"/><file name="CategoriesController.php" hash="2222f02aa99ac14c465143462e581270"/><file name="LayeredController.php" hash="444cb30c34aa499092b0007bcbb84cca"/><file name="ProductsController.php" hash="e2e1d87e0d26f37c8fd88844acf337be"/><file name="ProductsbyidController.php" hash="1589840233143b6e91fe95624638789b"/><file name="ResultController.php" hash="182f65ce4ccdf154aa0326512ec37140"/><file name="SearchesController.php" hash="7a4e94bb9456b4ac6b48c30b0cd389db"/></dir><dir name="data"><dir name="autosuggest_setup"><file name="data-install-3.0.0.5.php" hash="2b1ec2380f5c0a2d585b71eb73b8e573"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="34b9d24ddc4565311f6cc83d7e337478"/><file name="api.xml" hash="25ab859fc8312c4aa308f2e3306c6b66"/><file name="cache.xml" hash="b57472bc9410d67af3843825fba5b420"/><file name="config.xml" hash="551b19c0c8506e168fdb6fd693c4342a"/><file name="config.xml.bak" hash="51745fa3e5b736f8f03d68af5ee6f4b4"/><file name="system.xml" hash="6bed22fbdfc336254126cf4a8c49aa09"/><file name="wsdl.xml" hash="97b1503c710c79376cd85e7f971c1587"/></dir><dir name="sql"><dir name="autosuggest_setup"><file name="mysql4-install-2.0.1.1.php" hash="c891e1836f3df18eba24821371c85bfa"/><file name="mysql4-upgrade-2.0.1.3-2.0.2.2.php" hash="ddc7001e761dce3b4970f3d4adac2aa3"/><file name="mysql4-upgrade-2.0.2.5-2.0.2.6.php" hash="ea94264608685c51f008382d42d499fd"/><file name="mysql4-upgrade-2.0.4.6-2.0.4.7.php" hash="8166f765780956ea87bbe62b9f709f46"/><file name="mysql4-upgrade-2.0.5.4-2.0.5.5.php" hash="56a45f752e553280bb9242cde2aa76ce"/><file name="mysql4-upgrade-2.0.5.6-2.0.5.7.php" hash="b40aa51ca00369caa28a0030dc2490e7"/><file name="mysql4-upgrade-2.0.7.0-2.0.7.1.php" hash="3837250beee18106d0f043493dde3382"/><file name="mysql4-upgrade-2.0.7.2-2.0.7.3.php" hash="cf59ec04f2329243abac26bd79fa5818"/><file name="mysql4-upgrade-2.0.8.8-3.0.0.0.php" hash="9f60147846d67ecff6d7a28b39798f9b"/><file name="mysql4-upgrade-3.0.0.3-3.0.0.4.php" hash="9574b75e9a733be858a14588978cd21a"/><file name="mysql4-upgrade-3.0.0.4-3.0.0.5.php" hash="69094243b4af4e87a0e0186e76095099"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Autocompleteplus_Autosuggest.xml" hash="530931765807be8a21baa5e070bc4bc2"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="autocompleteplus.xml" hash="3998429f613fcc7842b7ea31cb423ec8"/></dir><dir name="template"><dir name="autocompleteplus"><dir name="catalog"><dir name="layer"><file name="view.phtml" hash="57066d2ac5fa051c15c3ed8bb43b5d08"/></dir><dir name="product"><file name="list.phtml" hash="c269d5b27302efb51cefb86a71027a0d"/></dir></dir><file name="inject.phtml" hash="e1e8e050631fe65417edb7a8f25155c8"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="autocompleteplus"><file name="notifications.phtml" hash="c1d08659e65020dcb9e62cf8bc28f73b"/><file name="process.phtml" hash="a7dd67e17a838d437fe9d9a2e9323d0c"/><dir name="system"><dir name="config"><file name="button.phtml" hash="3adf3f3f4ab989cf643f2fc49719b59d"/><file name="sync.phtml" hash="e0392aac8584e98ef4260419750e1cbb"/></dir></dir></dir></dir><dir name="layout"><file name="autocompleteplus.xml" hash="d69295113bbb7beb7b9e32cc84a9b129"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Autocompleteplus"><dir name="Autosuggest"><dir name="Xml"><file name="Generator.php" hash="c2fe75e398a73b82229999a08948f56b"/><file name="GeneratorInterface.php" hash="d3d6ea3a712fdbdb60d8994230a65f1c"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>