Springbot - Version 1.4.0.1

Version Notes

Enhanced product action logging
Prattler support

Download this release

Release Info

Developer Springbot Integrations Team
Extension Springbot
Version 1.4.0.1
Comparing to
See all releases


Code changes from version 1.3.0.10 to 1.4.0.1

Files changed (159) hide show
  1. app/code/community/Springbot/Bmbleb/Block/Adminhtml/Bmbleb/Login/Form.php +1 -2
  2. app/code/community/Springbot/Bmbleb/Block/Adminhtml/Problems.php +1 -1
  3. app/code/community/Springbot/Bmbleb/Helper/Account.php +1 -1
  4. app/code/community/Springbot/Bmbleb/Helper/PluginStatus.php +52 -141
  5. app/code/community/Springbot/Bmbleb/controllers/Adminhtml/IndexController.php +1 -1
  6. app/code/community/Springbot/Bmbleb/controllers/Adminhtml/ProblemsController.php +1 -1
  7. app/code/community/Springbot/Bmbleb/controllers/LoginController.php +7 -6
  8. app/code/community/Springbot/BoneCollector/Model/HarvestAbstract.php +0 -94
  9. app/code/community/Springbot/BoneCollector/Model/HarvestAttribute/Observer.php +0 -45
  10. app/code/community/Springbot/BoneCollector/Model/HarvestCaptureSKU/Observer.php +0 -500
  11. app/code/community/Springbot/BoneCollector/Model/HarvestCart/Observer.php +0 -161
  12. app/code/community/Springbot/BoneCollector/Model/HarvestCategory/Observer.php +0 -32
  13. app/code/community/Springbot/BoneCollector/Model/HarvestCustomer/Observer.php +0 -60
  14. app/code/community/Springbot/BoneCollector/Model/HarvestProduct/Observer.php +0 -89
  15. app/code/community/Springbot/BoneCollector/Model/HarvestPurchase/Observer.php +0 -160
  16. app/code/community/Springbot/BoneCollector/Model/HarvestRule/Observer.php +0 -77
  17. app/code/community/Springbot/BoneCollector/Model/HarvestSubscriber/Observer.php +0 -37
  18. app/code/community/Springbot/BoneCollector/etc/config.xml +0 -190
  19. app/code/community/Springbot/Boss.php +95 -118
  20. app/code/community/Springbot/Cli.php +201 -0
  21. app/code/community/Springbot/Combine/Helper/Data.php +20 -40
  22. app/code/community/Springbot/Combine/Helper/Harvest.php +4 -40
  23. app/code/community/Springbot/Combine/Helper/Parser.php +17 -9
  24. app/code/community/Springbot/Combine/Helper/Redirect.php +2 -3
  25. app/code/community/Springbot/Combine/Helper/Trackable.php +21 -25
  26. app/code/community/Springbot/Combine/Model/Action.php +62 -0
  27. app/code/community/Springbot/Combine/Model/Api.php +1 -1
  28. app/code/community/Springbot/Combine/Model/{Abstract.php → Cron.php} +9 -10
  29. app/code/community/Springbot/Combine/Model/Cron/Count.php +1 -1
  30. app/code/community/Springbot/Combine/Model/Cron/Manager/Status.php +7 -7
  31. app/code/community/Springbot/Combine/Model/Cron/Queue.php +25 -13
  32. app/code/community/Springbot/Combine/Model/Cron/Queue/Batch.php +0 -1
  33. app/code/community/Springbot/Combine/Model/Cron/Queue/Batch/Row.php +9 -9
  34. app/code/community/Springbot/Combine/Model/Cron/Worker.php +0 -10
  35. app/code/community/Springbot/Combine/Model/Harvest.php +268 -0
  36. app/code/community/Springbot/Combine/Model/Harvest/Abstract.php +0 -308
  37. app/code/community/Springbot/Combine/Model/Harvest/AttributeSets.php +39 -13
  38. app/code/community/Springbot/Combine/Model/Harvest/Carts.php +23 -14
  39. app/code/community/Springbot/Combine/Model/Harvest/Categories.php +22 -27
  40. app/code/community/Springbot/Combine/Model/Harvest/Coupons.php +27 -16
  41. app/code/community/Springbot/Combine/Model/Harvest/CustomerAttributeSets.php +42 -2
  42. app/code/community/Springbot/Combine/Model/Harvest/Customers.php +23 -11
  43. app/code/community/Springbot/Combine/Model/Harvest/Guests.php +22 -12
  44. app/code/community/Springbot/Combine/Model/Harvest/Products.php +25 -12
  45. app/code/community/Springbot/Combine/Model/Harvest/Purchases.php +23 -11
  46. app/code/community/Springbot/Combine/Model/Harvest/Rules.php +28 -16
  47. app/code/community/Springbot/Combine/Model/Harvest/Subscribers.php +26 -7
  48. app/code/community/Springbot/Combine/Model/Harvester.php +0 -11
  49. app/code/community/Springbot/Combine/Model/Mysql4/Action.php +5 -0
  50. app/code/community/Springbot/Combine/Model/Mysql4/Action/Collection.php +5 -0
  51. app/code/community/Springbot/Combine/Model/Parser.php +174 -2
  52. app/code/community/Springbot/Combine/Model/Parser/Abstract.php +0 -186
  53. app/code/community/Springbot/Combine/Model/Parser/AttributeSet.php +1 -9
  54. app/code/community/Springbot/Combine/Model/Parser/Category.php +1 -9
  55. app/code/community/Springbot/Combine/Model/Parser/Coupon.php +1 -9
  56. app/code/community/Springbot/Combine/Model/Parser/Customer.php +1 -9
  57. app/code/community/Springbot/Combine/Model/Parser/CustomerAttributeSet.php +1 -1
  58. app/code/community/Springbot/Combine/Model/Parser/Guest.php +1 -9
  59. app/code/community/Springbot/Combine/Model/Parser/Product.php +1 -9
  60. app/code/community/Springbot/Combine/Model/Parser/Purchase.php +1 -10
  61. app/code/community/Springbot/Combine/Model/Parser/Purchase/Item.php +2 -12
  62. app/code/community/Springbot/Combine/Model/Parser/Quote.php +1 -9
  63. app/code/community/Springbot/Combine/Model/Parser/Quote/Item.php +1 -12
  64. app/code/community/Springbot/Combine/Model/Parser/Rule.php +1 -9
  65. app/code/community/Springbot/Combine/Model/Parser/Subscriber.php +2 -11
  66. app/code/community/Springbot/Combine/Model/Redirect.php +18 -1
  67. app/code/community/Springbot/Combine/Model/Redirect/Order.php +18 -1
  68. app/code/community/Springbot/Combine/Model/Resource/Abstract.php +1 -1
  69. app/code/community/Springbot/Combine/Model/Resource/Action.php +72 -0
  70. app/code/community/Springbot/Combine/Model/Resource/Action/Collection.php +25 -0
  71. app/code/community/Springbot/Combine/Model/Resource/Cron/Queue.php +8 -12
  72. app/code/community/Springbot/Combine/Model/Resource/Cron/Queue/Collection.php +5 -1
  73. app/code/community/Springbot/Combine/Model/Resource/Setup.php +0 -33
  74. app/code/community/Springbot/Combine/Model/Trackable.php +68 -4
  75. app/code/community/Springbot/Combine/etc/config.xml +11 -14
  76. app/code/community/Springbot/Combine/etc/system.xml +16 -7
  77. app/code/community/Springbot/Combine/sql/combine_setup/mysql4-install-1.0.0.70.php +4 -5
  78. app/code/community/Springbot/Combine/sql/combine_setup/mysql4-upgrade-1.0.0.88-1.2.0.0.php +3 -3
  79. app/code/community/Springbot/Combine/sql/combine_setup/mysql4-upgrade-1.2.0.1-1.2.1.0.php +1 -1
  80. app/code/community/Springbot/Combine/sql/combine_setup/mysql4-upgrade-1.3.9.9-1.4.0.0.php +44 -0
  81. app/code/community/Springbot/DataServices/HarvestingManager.php +0 -447
  82. app/code/community/Springbot/Log.php +32 -9
  83. app/code/community/Springbot/{Services/Abstract.php → Services.php} +28 -22
  84. app/code/community/Springbot/Services/Cmd/Forecast.php +12 -10
  85. app/code/community/Springbot/Services/Cmd/Halt.php +4 -3
  86. app/code/community/Springbot/Services/Cmd/Harvest.php +55 -61
  87. app/code/community/Springbot/Services/Cmd/Healthcheck.php +64 -3
  88. app/code/community/Springbot/Services/Cmd/Parse.php +0 -9
  89. app/code/community/Springbot/Services/Cmd/Update.php +2 -3
  90. app/code/community/Springbot/Services/Harvest.php +16 -12
  91. app/code/community/Springbot/Services/Harvest/AttributeSets.php +22 -16
  92. app/code/community/Springbot/Services/Harvest/Carts.php +24 -20
  93. app/code/community/Springbot/Services/Harvest/Categories.php +23 -22
  94. app/code/community/Springbot/Services/Harvest/Coupons.php +14 -18
  95. app/code/community/Springbot/Services/Harvest/CustomerAttributeSets.php +7 -12
  96. app/code/community/Springbot/Services/Harvest/Customers.php +16 -18
  97. app/code/community/Springbot/Services/Harvest/Guests.php +26 -27
  98. app/code/community/Springbot/Services/Harvest/Products.php +13 -15
  99. app/code/community/Springbot/Services/Harvest/Purchases.php +15 -19
  100. app/code/community/Springbot/Services/Harvest/Rules.php +27 -29
  101. app/code/community/Springbot/Services/Harvest/Subscribers.php +17 -19
  102. app/code/community/Springbot/Services/Log/Installer.php +1 -2
  103. app/code/community/Springbot/Services/Log/Purchase.php +0 -51
  104. app/code/community/Springbot/Services/Post.php +1 -2
  105. app/code/community/Springbot/Services/Post/Attribute.php +10 -27
  106. app/code/community/Springbot/Services/Post/AttributeSet.php +7 -13
  107. app/code/community/Springbot/Services/Post/Cart.php +5 -6
  108. app/code/community/Springbot/Services/Post/Category.php +4 -2
  109. app/code/community/Springbot/Services/Post/Coupon.php +6 -2
  110. app/code/community/Springbot/Services/Post/Customer.php +6 -2
  111. app/code/community/Springbot/Services/Post/Guest.php +15 -0
  112. app/code/community/Springbot/Services/Post/Product.php +17 -10
  113. app/code/community/Springbot/Services/Post/Purchase.php +9 -4
  114. app/code/community/Springbot/Services/Post/Rule.php +9 -2
  115. app/code/community/Springbot/Services/Post/Subscriber.php +4 -1
  116. app/code/community/Springbot/Services/Priority.php +0 -11
  117. app/code/community/Springbot/Services/Store/Finalize.php +1 -1
  118. app/code/community/Springbot/Services/Store/Register.php +1 -1
  119. app/code/community/Springbot/Services/Tasks/DeliverEventLog.php +61 -0
  120. app/code/community/Springbot/Services/Tasks/Forecast.php +10 -0
  121. app/code/community/Springbot/Services/Tasks/GetLog.php +29 -0
  122. app/code/community/Springbot/Services/Tasks/KillHarvest.php +9 -0
  123. app/code/community/Springbot/Services/Tasks/LaunchFullHarvest.php +9 -0
  124. app/code/community/Springbot/Services/Tasks/LaunchPartialHarvest.php +19 -0
  125. app/code/community/Springbot/Services/Tasks/PackageUpdate.php +13 -0
  126. app/code/community/Springbot/Services/Tasks/PostItem.php +16 -0
  127. app/code/community/Springbot/Services/Tasks/ResumeHarvest.php +11 -0
  128. app/code/community/Springbot/Services/Tasks/SetVar.php +20 -0
  129. app/code/community/Springbot/Services/Tasks/SkipStoreHarvest.php +9 -0
  130. app/code/community/Springbot/Services/Update/Package.php +1 -1
  131. app/code/community/Springbot/Services/Work/Cleanup.php +1 -1
  132. app/code/community/Springbot/Services/Work/Manager.php +6 -5
  133. app/code/community/Springbot/Services/Work/Report.php +1 -1
  134. app/code/community/Springbot/Services/Work/Restart.php +2 -2
  135. app/code/community/Springbot/Services/Work/Runner.php +1 -1
  136. app/code/community/Springbot/Services/Work/Stop.php +4 -4
  137. app/code/community/Springbot/Shadow/Block/Action/View.php +20 -0
  138. app/code/community/Springbot/Shadow/Block/{Js/Boot.php → Async.php} +1 -1
  139. app/code/community/Springbot/Shadow/Controller/Action.php +33 -0
  140. app/code/community/Springbot/Shadow/Helper/Data.php +5 -0
  141. app/code/community/Springbot/Shadow/Helper/Listeners.php +0 -21
  142. app/code/community/Springbot/Shadow/Helper/Prattler.php +22 -0
  143. app/code/community/Springbot/Shadow/Model/Listeners/Observer.php +8 -210
  144. app/code/community/Springbot/Shadow/Model/Timer.php +0 -77
  145. app/code/community/Springbot/Shadow/controllers/ActionController.php +25 -0
  146. app/code/community/Springbot/Shadow/controllers/IndexController.php +83 -25
  147. app/code/community/Springbot/Shadow/etc/config.xml +3 -20
  148. app/code/community/Springbot/Util/Cache.php +63 -0
  149. app/code/community/Springbot/Util/Caller.php +0 -3
  150. app/code/community/Springbot/Util/Log/Rollover.php +2 -1
  151. app/code/community/Springbot/Util/Timer.php +68 -0
  152. app/design/adminhtml/default/default/template/bmbleb/auth.phtml +0 -1
  153. app/design/adminhtml/default/default/template/bmbleb/index.phtml +4 -3
  154. app/design/adminhtml/default/default/template/bmbleb/status.phtml +1 -1
  155. app/design/frontend/base/default/layout/shadow.xml +19 -20
  156. app/design/frontend/base/default/template/shadow/{js/boot.phtml → async.phtml} +0 -0
  157. app/design/frontend/base/default/template/shadow/emailupdate.phtml +0 -1
  158. package.xml +48 -47
  159. shell/springbot.php +24 -35
app/code/community/Springbot/Bmbleb/Block/Adminhtml/Bmbleb/Login/Form.php CHANGED
@@ -77,8 +77,7 @@ class Springbot_Bmbleb_Block_Adminhtml_Bmbleb_Login_Form extends Mage_Adminhtml_
77
  $client->setRawData($rawJSON);
78
  $req = $client->request('POST');
79
  } catch (Exception $e) {
80
- Mage::log('Remote Springbot service unavailable!');
81
- Mage::logException($e);
82
  }
83
  }
84
 
77
  $client->setRawData($rawJSON);
78
  $req = $client->request('POST');
79
  } catch (Exception $e) {
80
+ Springbot_Log::error($e);
 
81
  }
82
  }
83
 
app/code/community/Springbot/Bmbleb/Block/Adminhtml/Problems.php CHANGED
@@ -13,6 +13,6 @@ class Springbot_Bmbleb_Block_Adminhtml_Problems extends Mage_Adminhtml_Block_Tem
13
  */
14
  public function getSolutions()
15
  {
16
- return Mage::helper('bmbleb/PluginStatus')->getAllPluginProblems();
17
  }
18
  }
13
  */
14
  public function getSolutions()
15
  {
16
+ return Mage::helper('bmbleb/PluginStatus')->getPluginProblems();
17
  }
18
  }
app/code/community/Springbot/Bmbleb/Helper/Account.php CHANGED
@@ -53,7 +53,7 @@ class Springbot_Bmbleb_Helper_Account extends Mage_Core_Helper_Abstract
53
  if ($email == '' && $password == ''){
54
  return false;
55
  }
56
- $account = $this->checkCredentials($email, $password);
57
  if ($account['valid']) {
58
  $result = true;
59
  if ($saveCredentials){
53
  if ($email == '' && $password == ''){
54
  return false;
55
  }
56
+ $account = Mage::helper('combine')->checkCredentials($email, $password);
57
  if ($account['valid']) {
58
  $result = true;
59
  if ($saveCredentials){
app/code/community/Springbot/Bmbleb/Helper/PluginStatus.php CHANGED
@@ -4,51 +4,19 @@ class Springbot_Bmbleb_Helper_PluginStatus extends Mage_Core_Helper_Abstract
4
  {
5
  const REPORT_PROBLEMS_INTERVAL_SECONDS = 604800; // Seven days in seconds
6
  const TOO_MANY_HOURS = 3; // Minimum number of hours since harvest to display warning
7
- const STORE_TIMESTAMP_GLOB = 'sb-cache-healthcheck-*.dat'; // Globbing string to find all
8
-
9
- /**
10
- * Run all checks for fatal problems
11
- *
12
- * Returns any issues that would prevent a harvest that can be checked on each plugin page load, once a fatal
13
- * plugin problem is detected the user is redirected to the problems page where they are presented with a more
14
- * detailed list of problems and instructed to either login again or contact support.
15
- */
16
- public function getFatalPluginProblems()
17
- {
18
- return $this->_getPluginProblems(true, false, false);
19
- }
20
-
21
- /**
22
- * Returns a list of potential problems that should be brought to the user's attention for the magento global
23
- * notifications.
24
- */
25
- public function getGlobalPluginProblems()
26
- {
27
- return $this->_getPluginProblems(true, true, false);
28
- }
29
-
30
- /**
31
- * Returns all problems (used for the problems page) so that they can see a detailed list of problems
32
- * and possible fixes.
33
- */
34
- public function getAllPluginProblems()
35
- {
36
- return $this->_getPluginProblems(true, true, true);
37
- }
38
-
39
 
40
  /**
41
  * Check to see if its been a long time since the last checkin
42
  */
43
  public function tooLongSinceCheckin()
44
  {
45
- $fileNameGlob = $this->_getFilenameGlob();
46
  $currentTime = time();
47
- $matches = glob($fileNameGlob);
48
  $secondsSinceLastCheckin = null;
49
  $mostRecentCheckin = null;
50
- foreach ($matches as $match) {
51
- $checkinTimestap = file_get_contents($match);
 
 
52
  $secondsSinceLastCheckin = $currentTime - $checkinTimestap;
53
  if (!$mostRecentCheckin || ($secondsSinceLastCheckin < $mostRecentCheckin)) {
54
  $mostRecentCheckin = $secondsSinceLastCheckin;
@@ -71,84 +39,66 @@ class Springbot_Bmbleb_Helper_PluginStatus extends Mage_Core_Helper_Abstract
71
  * Returns a detailed list of all issues (used on the problems page) so that the user may give the support team
72
  * more information for troubleshooting what the actual issue may be.
73
  */
74
- private function _getPluginProblems($fatalProblems, $globalProblems, $possibleProblems)
75
  {
76
  $problems = array();
77
 
78
 
79
- // Fatal problems are problems that will cause the Springbot section to redirect to the problems page
80
- if ($fatalProblems) {
81
-
82
- if ($this->_emailPasswordSet() && !$this->_harvestInFlight()) {
83
- if (($missingGuids = $this->_getMissingStoreGuids())) {
84
- $problems[] = array(
85
- 'problem' => 'Missing GUIDs for the following stores: ' . $missingGuids,
86
- 'solution' => 'This problem can usually be fixed by re-logging into your Springbot account. '
87
- );
88
- }
89
- if ($this->_tokenIsInvalid()) {
90
- $problems[] = array(
91
- 'problem' => 'Security token is invalid',
92
- 'solution' => 'This problem can usually be fixed by re-logging into your Springbot account. '
93
- );
94
- }
95
- }
96
-
97
- if (!$this->_logDirIsWritable()) {
98
- $problems[] = array(
99
- 'problem' => 'Magento log directory is not writable',
100
- 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/log" in your '
101
- . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
102
- . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/log". '
103
- );
104
- }
105
- if (!$this->_tmpDirIsWritable()) {
106
  $problems[] = array(
107
- 'problem' => 'Magento tmp directory is not writable',
108
- 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/tmp" in your '
109
- . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
110
- . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/tmp". '
111
  );
112
  }
113
- if (!$this->_logDirIsReadable()) {
114
  $problems[] = array(
115
- 'problem' => 'Magento log directory is not readable',
116
- 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/log" in your '
117
- . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
118
- . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/log". '
119
  );
120
  }
121
- if (!$this->_tmpDirIsReadable()) {
122
- $problems[] = array(
123
- 'problem' => 'Magento tmp directory is not readable',
124
- 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/tmp" in your '
125
- . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
126
- . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/tmp". '
127
- );
128
- }
129
- if ($secondsSinceHarvest = $this->tooLongSinceCheckin()) {
130
- $hoursSinceHarvest = round($secondsSinceHarvest / 60 / 60);
131
- $problems[] = array(
132
- 'problem' => 'It\'s been ' . $hoursSinceHarvest . ' hours since the Springbot plugin last checked in',
133
- 'solution' => 'This problem occurs when the Springbot plugin has gone too long since it last '
134
- . 'communicated with the Springbot server. This issue can often be resolved by simply '
135
- . 're-logging in to your Springbot dashboard. '
136
- );
137
- }
138
- if (!$this->_correctPhpPath()) {
139
- $problems[] = array(
140
- 'problem' => 'Incorrect PHP executable path',
141
- 'solution' => 'This usually means that the default PHP path for your server cannot run in CLI mode. '
142
- . 'To fix this issue locate the full path of the PHP executable that you would use to run cron '
143
- . 'jobs and paste it into the "PHP Executable" setting in your Springbot configuration. '
144
- );
145
- }
146
-
147
  }
148
 
149
- // Global problems are problems that will cause a top notification on the Magento dashboard only
150
- if ($globalProblems) {
151
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  }
153
 
154
  // Report any plugin problems to the Springbot API once a week or for the very first time
@@ -162,17 +112,6 @@ class Springbot_Bmbleb_Helper_PluginStatus extends Mage_Core_Helper_Abstract
162
  }
163
  }
164
 
165
- // Possible problems include issues which might not necessarily cause a problem, but may offer insight into other problems
166
- if ($possibleProblems) {
167
- if (!$this->_mediaDirIsWritable()) {
168
- $problems[] = array(
169
- 'problem' => 'The media directory is not writable',
170
- 'solution' => 'The Magento media directory is not writable. While this should not affect the Springbot plugin '
171
- . 'it may be evidence of further permission and configuration issues. Ideally the owner of the media '
172
- . 'directory should be the same user that your webserver software runs as.'
173
- );
174
- }
175
- }
176
 
177
  return $problems;
178
  }
@@ -272,14 +211,6 @@ class Springbot_Bmbleb_Helper_PluginStatus extends Mage_Core_Helper_Abstract
272
  return is_readable(Mage::getBaseDir('log'));
273
  }
274
 
275
- /**
276
- * Check to see if Magento log directory is writable
277
- */
278
- private function _mediaDirIsWritable()
279
- {
280
- return is_writable(Mage::getBaseDir('media'));
281
- }
282
-
283
  /**
284
  * Take array of problems and post it to the Springbot API
285
  */
@@ -316,24 +247,4 @@ class Springbot_Bmbleb_Helper_PluginStatus extends Mage_Core_Helper_Abstract
316
  }
317
  return $springbotStoreIds;
318
  }
319
-
320
- private function _getFilenameGlob()
321
- {
322
- return Mage::getBaseDir('tmp') . DS . self::STORE_TIMESTAMP_GLOB;
323
- }
324
-
325
- private function _correctPhpPath()
326
- {
327
- $phpPath = Mage::helper('combine/harvest')->getPhpExec();
328
- ob_start();
329
- try {
330
- Springbot_boss::spawn("{$phpPath} -r \"echo '<!-- PHP Test -->';\"", $output);
331
- }
332
- catch (Exception $e) {
333
- // We do not know if the PHP executable path is correct or not since we cannot run spawn anyway
334
- return true;
335
- }
336
- $result = ob_get_clean();
337
- return trim($result) == '<!-- PHP Test -->';
338
- }
339
  }
4
  {
5
  const REPORT_PROBLEMS_INTERVAL_SECONDS = 604800; // Seven days in seconds
6
  const TOO_MANY_HOURS = 3; // Minimum number of hours since harvest to display warning
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  /**
9
  * Check to see if its been a long time since the last checkin
10
  */
11
  public function tooLongSinceCheckin()
12
  {
 
13
  $currentTime = time();
 
14
  $secondsSinceLastCheckin = null;
15
  $mostRecentCheckin = null;
16
+
17
+ foreach (Mage::app()->getStores() as $store) {
18
+ $checkinTimestap = Springbot_Util_Timer::lastRun('healthcheck', $store->getId());
19
+ Mage::log($checkinTimestap);
20
  $secondsSinceLastCheckin = $currentTime - $checkinTimestap;
21
  if (!$mostRecentCheckin || ($secondsSinceLastCheckin < $mostRecentCheckin)) {
22
  $mostRecentCheckin = $secondsSinceLastCheckin;
39
  * Returns a detailed list of all issues (used on the problems page) so that the user may give the support team
40
  * more information for troubleshooting what the actual issue may be.
41
  */
42
+ public function getPluginProblems()
43
  {
44
  $problems = array();
45
 
46
 
47
+ if ($this->_emailPasswordSet() && !$this->_harvestInFlight()) {
48
+ if (($missingGuids = $this->_getMissingStoreGuids())) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  $problems[] = array(
50
+ 'problem' => 'Missing GUIDs for the following stores: ' . $missingGuids,
51
+ 'solution' => 'This problem can usually be fixed by re-logging into your Springbot account. '
 
 
52
  );
53
  }
54
+ if ($this->_tokenIsInvalid()) {
55
  $problems[] = array(
56
+ 'problem' => 'Security token is invalid',
57
+ 'solution' => 'This problem can usually be fixed by re-logging into your Springbot account. '
 
 
58
  );
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
+ if (!$this->_logDirIsWritable()) {
63
+ $problems[] = array(
64
+ 'problem' => 'Magento log directory is not writable',
65
+ 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/log" in your '
66
+ . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
67
+ . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/log". '
68
+ );
69
+ }
70
+ if (!$this->_tmpDirIsWritable()) {
71
+ $problems[] = array(
72
+ 'problem' => 'Magento tmp directory is not writable',
73
+ 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/tmp" in your '
74
+ . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
75
+ . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/tmp". '
76
+ );
77
+ }
78
+ if (!$this->_logDirIsReadable()) {
79
+ $problems[] = array(
80
+ 'problem' => 'Magento log directory is not readable',
81
+ 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/log" in your '
82
+ . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
83
+ . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/log". '
84
+ );
85
+ }
86
+ if (!$this->_tmpDirIsReadable()) {
87
+ $problems[] = array(
88
+ 'problem' => 'Magento tmp directory is not readable',
89
+ 'solution' => 'This server configuration problem often occurs when the owner of the directory "var/tmp" in your '
90
+ . 'Magento root folder is different than the user your webserver runs as. To fix this issue '
91
+ . 'navigate to your Magento directory and run the command "chown &lt;your webserver user&gt; var/tmp". '
92
+ );
93
+ }
94
+ if ($secondsSinceHarvest = $this->tooLongSinceCheckin()) {
95
+ $hoursSinceHarvest = round($secondsSinceHarvest / 60 / 60);
96
+ $problems[] = array(
97
+ 'problem' => 'It\'s been ' . $hoursSinceHarvest . ' hours since the Springbot plugin last checked in',
98
+ 'solution' => 'This problem occurs when the Springbot plugin has gone too long since it last '
99
+ . 'communicated with the Springbot server. This issue can often be resolved by simply '
100
+ . 're-logging in to your Springbot dashboard. '
101
+ );
102
  }
103
 
104
  // Report any plugin problems to the Springbot API once a week or for the very first time
112
  }
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
  return $problems;
117
  }
211
  return is_readable(Mage::getBaseDir('log'));
212
  }
213
 
 
 
 
 
 
 
 
 
214
  /**
215
  * Take array of problems and post it to the Springbot API
216
  */
247
  }
248
  return $springbotStoreIds;
249
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
app/code/community/Springbot/Bmbleb/controllers/Adminhtml/IndexController.php CHANGED
@@ -16,7 +16,7 @@ class Springbot_Bmbleb_Adminhtml_IndexController extends Mage_Adminhtml_Controll
16
  } elseif($this->getRequest()->getParam('killharvest')) {
17
  Springbot_Boss::halt();
18
  $this->_redirect('*/*/status');
19
- } elseif ($problems = Mage::helper('bmbleb/PluginStatus')->getFatalPluginProblems()) {
20
  $this->_redirect('*/adminhtml_problems/index');
21
  }
22
  }
16
  } elseif($this->getRequest()->getParam('killharvest')) {
17
  Springbot_Boss::halt();
18
  $this->_redirect('*/*/status');
19
+ } elseif ($problems = Mage::helper('bmbleb/PluginStatus')->getPluginProblems()) {
20
  $this->_redirect('*/adminhtml_problems/index');
21
  }
22
  }
app/code/community/Springbot/Bmbleb/controllers/Adminhtml/ProblemsController.php CHANGED
@@ -4,7 +4,7 @@ class Springbot_Bmbleb_Adminhtml_ProblemsController extends Mage_Adminhtml_Contr
4
 
5
  public function indexAction()
6
  {
7
- if ($problems = Mage::helper('bmbleb/PluginStatus')->getAllPluginProblems()) {
8
  Mage::getSingleton('core/session')->addError('If this problem persists please contact Springbot support.');
9
  $this->loadLayout();
10
  $this->_setActiveMenu('bmbleb/adminhtml_problems/index');
4
 
5
  public function indexAction()
6
  {
7
+ if ($problems = Mage::helper('bmbleb/PluginStatus')->getPluginProblems()) {
8
  Mage::getSingleton('core/session')->addError('If this problem persists please contact Springbot support.');
9
  $this->loadLayout();
10
  $this->_setActiveMenu('bmbleb/adminhtml_problems/index');
app/code/community/Springbot/Bmbleb/controllers/LoginController.php CHANGED
@@ -45,9 +45,9 @@ class Springbot_Bmbleb_LoginController extends Mage_Adminhtml_Controller_Action
45
  $client->setRawData('{"user_id":"'.$email.'", "password":"'.$pass.'"}');
46
  $response = $client->request('POST');
47
  $result = json_decode($response->getBody(),true);
48
- } catch (Exception $e) {
49
- Mage::log('Remote Springbot service unavailable!');
50
- Mage::logException($e);
51
  Mage::getSingleton('adminhtml/session')->addError('Service unavailable from ' . $url . ' please contact support@springbot.com.');
52
  $this->_redirect('bmbleb/adminhtml_index/auth');
53
  return;
@@ -56,12 +56,13 @@ class Springbot_Bmbleb_LoginController extends Mage_Adminhtml_Controller_Action
56
  if ($result['status']=='error') {
57
  Mage::getSingleton('adminhtml/session')->addError($result['message'].' or service unavailable from '.$url);
58
  $this->_redirect('bmbleb/adminhtml_index/auth');
59
- } else {
 
60
  if ($result['token'] == '') {
61
  Mage::getSingleton('adminhtml/session')->addError('Login denied by Springbot');
62
  $this->_redirect('bmbleb/adminhtml_index/auth');
63
- } else {
64
- Mage::log('Email->' . $email.' Token->' . $result['token']);
65
  $bmblebAccount->setSavedAccountInformation($email,$pass,$result['token']);
66
  $this->_redirect('bmbleb/adminhtml_index/index');
67
  }
45
  $client->setRawData('{"user_id":"'.$email.'", "password":"'.$pass.'"}');
46
  $response = $client->request('POST');
47
  $result = json_decode($response->getBody(),true);
48
+ }
49
+ catch (Exception $e) {
50
+ Springbot_Log::error($e);
51
  Mage::getSingleton('adminhtml/session')->addError('Service unavailable from ' . $url . ' please contact support@springbot.com.');
52
  $this->_redirect('bmbleb/adminhtml_index/auth');
53
  return;
56
  if ($result['status']=='error') {
57
  Mage::getSingleton('adminhtml/session')->addError($result['message'].' or service unavailable from '.$url);
58
  $this->_redirect('bmbleb/adminhtml_index/auth');
59
+ }
60
+ else {
61
  if ($result['token'] == '') {
62
  Mage::getSingleton('adminhtml/session')->addError('Login denied by Springbot');
63
  $this->_redirect('bmbleb/adminhtml_index/auth');
64
+ }
65
+ else {
66
  $bmblebAccount->setSavedAccountInformation($email,$pass,$result['token']);
67
  $this->_redirect('bmbleb/adminhtml_index/index');
68
  }
app/code/community/Springbot/BoneCollector/Model/HarvestAbstract.php DELETED
@@ -1,94 +0,0 @@
1
- <?php
2
-
3
- class Springbot_BoneCollector_Model_HarvestAbstract
4
- {
5
- const BOT_SERVICES = 'SpringbotServices.php';
6
- const SPRINGBOT_DIRECTORY = '/app/code/community/Springbot/';
7
- const LOG_DIRECTORY = '/var/log/';
8
- const BOT_SERVICES_DIRECTORY = '/app/code/community/Springbot/DataServices/';
9
- const BACKGROUND_MODE = '&';
10
-
11
- /**
12
- * The attributes which we want to listen for changes on
13
- *
14
- * @return array
15
- */
16
- protected $_attributes = array();
17
-
18
- protected function _initObserver($observer)
19
- {
20
- if($event = $observer->getEvent()) {
21
- Springbot_Log::debug($event->getName());
22
- }
23
- }
24
-
25
- public function getPhpExec()
26
- {
27
- return Mage::helper('combine/harvest')->getPhpExec();
28
- }
29
-
30
- /**
31
- * Get top level sku
32
- *
33
- * This aims to get the top level sku. The getSku method for the product
34
- * model is overloaded providing the type instance version of the sku
35
- * meaning that it gives the simple sku for configurable or grouped products
36
- * we need to get the _data array directly and pass that sku up to ensure the
37
- * parent sku.
38
- *
39
- * @param $observer Varient_Event_Observer
40
- * @return string
41
- */
42
- public function getTopLevelSku($observer)
43
- {
44
- $product = $observer->getEvent()->getProduct();
45
- return Mage::helper('combine/parser')->getTopLevelSku($product);
46
- }
47
-
48
- public function doSend($object, $sessionKey)
49
- {
50
- $json = $object->toJson();
51
- $hash = sha1($json);
52
- $session = $this->_getSession();
53
-
54
- if ($session->getData($sessionKey) == $hash) {
55
- Springbot_Log::debug("Hash for {$sessionKey} is match, this object has already been posted, skipping");
56
- return false;
57
- } else {
58
- $session->setData($sessionKey, $hash);
59
- Springbot_Log::debug("Hash for {$sessionKey} does not match cache, sending");
60
- return true;
61
- }
62
- }
63
-
64
- protected function _getSession()
65
- {
66
- return Mage::getSingleton('core/session');
67
- }
68
-
69
- protected function _getAttributesToListenFor($extras = array())
70
- {
71
- return array_merge($this->_attributes, $extras);
72
- }
73
-
74
- protected function _entityChanged($model)
75
- {
76
- foreach($this->_getAttributesToListenFor() as $attribute) {
77
- if($attribute != 'created_at' && $attribute != 'updated_at') {
78
- if($this->_hasDataChangedFor($model, $attribute)) {
79
- return true;
80
- }
81
- }
82
- }
83
- Springbot_Log::debug('Entity unchanged');
84
- return false;
85
- }
86
-
87
- protected function _hasDataChangedFor($model, $field)
88
- {
89
- $newData = $model->getData($field);
90
- $origData = $model->getOrigData($field);
91
- return $newData!=$origData;
92
- }
93
-
94
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestAttribute/Observer.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
-
3
- class Springbot_BoneCollector_Model_HarvestAttribute_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
4
- {
5
- public function onAdminAttributeSaveAfter($observer)
6
- {
7
- try {
8
- $this->_initObserver($observer);
9
- $attribute = $observer->getEvent()->getAttribute();
10
- if($attribute->getIsUserDefined()) {
11
- if($this->doSend($attribute, 'sb_eav_entity_attribute_obs_hash')) {
12
- Springbot_Log::debug("Attempting to post parent attribute sets");
13
- Springbot_Boss::scheduleJob('post:attribute', array('i' => $attribute->getAttributeId()), Springbot_Services_Priority::LISTENER, 'listener');
14
- }
15
- } else {
16
- Springbot_Log::debug("Attribute is not user defined, skipping");
17
- }
18
- } catch (Exception $e) {
19
- Springbot_Log::error($e);
20
- }
21
- }
22
-
23
- public function onAdminAttributeSetSaveAfter($observer)
24
- {
25
- try {
26
- $attribute = $observer->getEvent()->getAttribute();
27
- $set = $this->_getAttributeSet($attribute->getAttributeSetId());
28
- if($this->doSend($set, 'sb_eav_entity_attribute_set_obs_hash')) {
29
- $this->_initObserver($observer);
30
- Springbot_Boss::scheduleJob('post:attributeSet', array('i' => $attribute->getAttributeSetId()), Springbot_Services_Priority::LISTENER, 'listener');
31
- }
32
- } catch (Exception $e) {
33
- Springbot_Log::error($e);
34
- }
35
- }
36
-
37
- protected function _getAttributeSet($id)
38
- {
39
- $helper = Mage::helper('combine/attributes');
40
-
41
- // invalidate cache as attributes are added to set
42
- $attrIds = $helper->getAttributesBySet($id)->getAllIds();
43
- return $helper->getAttributeSetById($id)->setNestedAttributeIds($attrIds);
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestCaptureSKU/Observer.php DELETED
@@ -1,500 +0,0 @@
1
- <?php
2
- /**
3
- * BoneCollector Event Listener (Capture SKU when Product Viewed)
4
- *
5
- * @category Magento Integrations
6
- * @package springbot
7
- * @author William Seitz
8
- * @division SpringBot Integration Team
9
- * @support magentosupport@springbot.com
10
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
- *
12
- */
13
- class Springbot_BoneCollector_Model_HarvestCaptureSKU_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
14
- {
15
- const VERSION = '1.2.0';
16
- const METHOD = 'getsku';
17
-
18
- public function onFrontendProductView($observer)
19
- {
20
- $controllerName = Mage::app()->getRequest()->getControllerName();
21
- $actionName = Mage::app()->getRequest()->getActionName();
22
- $routerName = Mage::app()->getRequest()->getRouteName();
23
-
24
- if ($this->_viewingProductDetailPage($controllerName,$actionName,$routerName)) {
25
- $this->_initObserver($observer);
26
- $productData = $observer->getEvent()->getProduct();
27
- $entityViewed = $productData['sku'];
28
- $eventDatetime = date("Y-m-d H:i:s");
29
- $openModeAppend = 'a';
30
- $eventHistoryFilename = Mage::getBaseDir('log') . DS . 'Springbot-EventHistory.csv';
31
- $urlViewed = Mage::helper('core/url')->getCurrentUrl();
32
- $userAgent = Mage::helper('core/http')->getHttpUserAgent();
33
-
34
- if ($this->qualifyURL($urlViewed, $userAgent)) {
35
- try {
36
- $lastCatId = $this->_getLastCategory();
37
- $visitorIP = Mage::helper('core/http')->getRemoteAddr(true);
38
- $storeId = Mage::app()->getStore()->getStoreId();
39
- $fHandle = fopen($eventHistoryFilename,$openModeAppend);
40
- $viewedMessage = array(
41
- 'view',
42
- $eventDatetime,
43
- $urlViewed,
44
- $entityViewed,
45
- $visitorIP,
46
- $storeId,
47
- $lastCatId
48
- );
49
- fputcsv($fHandle,$viewedMessage,',');
50
- fclose($fHandle);
51
- } catch (Exception $e) {
52
- Mage::log('Unknown exception opening '.$eventHistoryFilename);
53
- }
54
- }
55
- }
56
- return;
57
- }
58
-
59
- private function _viewingProductDetailPage($controllerName,$actionName,$routerName)
60
- {
61
- if ($controllerName == 'product'
62
- && $actionName == 'view'
63
- && $routerName == 'catalog') {
64
- return true;
65
- } else {
66
- return false;
67
- }
68
- }
69
-
70
- protected function _getLastCategory()
71
- {
72
- return Mage::helper('combine')->getLastCategoryId();
73
- }
74
-
75
- private function qualifyURL($url, $userAgent)
76
- {
77
- if (
78
- strpos($url,'/api') > 0 ||
79
- strpos($url,'/ajax') > 0 ||
80
- strpos($url,'/soap') > 0
81
- ) {
82
- return false;
83
- }
84
- else if ($this->is_bot($userAgent) == false && $this->urlIsIPAddress($url)== false) {
85
- return true;
86
- }
87
- else {
88
- return false;
89
- }
90
- }
91
-
92
- private function urlIsIPAddress($url)
93
- {
94
- $numericComponents = 0;
95
- $ipComponents = explode('.',$url);
96
-
97
- foreach($ipComponents as $ipVal) {
98
- if (is_numeric($ipVal)) {
99
- $numericComponents++;
100
- }
101
- }
102
- if ($numericComponents == 4) {
103
- return true;
104
- } else {
105
- return false;
106
- }
107
- }
108
-
109
- private function is_bot($user_agent) {
110
- $spiders = array(
111
- "abot",
112
- "dbot",
113
- "ebot",
114
- "hbot",
115
- "kbot",
116
- "lbot",
117
- "mbot",
118
- "nbot",
119
- "obot",
120
- "pbot",
121
- "rbot",
122
- "sbot",
123
- "tbot",
124
- "vbot",
125
- "ybot",
126
- "zbot",
127
- "bot/",
128
- "_bot",
129
- ".bot",
130
- "/bot",
131
- "-bot",
132
- ":bot",
133
- "(bot",
134
- "crawl",
135
- "slurp",
136
- "spider",
137
- "seek",
138
- "accoona",
139
- "acoon",
140
- "adressendeutschland",
141
- "ah-ha.com",
142
- "ahoy",
143
- "altavista",
144
- "ananzi",
145
- "anthill",
146
- "appie",
147
- "arachnophilia",
148
- "arale",
149
- "araneo",
150
- "aranha",
151
- "architext",
152
- "aretha",
153
- "arks",
154
- "asterias",
155
- "atlocal",
156
- "atn",
157
- "atomz",
158
- "augurfind",
159
- "backrub",
160
- "bannana_bot",
161
- "baypup",
162
- "bdfetch",
163
- "big brother",
164
- "biglotron",
165
- "bjaaland",
166
- "blackwidow",
167
- "blaiz",
168
- "blog",
169
- "blo.",
170
- "bloodhound",
171
- "boitho",
172
- "booch",
173
- "bradley",
174
- "butterfly",
175
- "calif",
176
- "cassandra",
177
- "ccubee",
178
- "cfetch",
179
- "charlotte",
180
- "churl",
181
- "cienciaficcion",
182
- "cmc",
183
- "collective",
184
- "comagent",
185
- "combine",
186
- "computingsite",
187
- "csci",
188
- "curl",
189
- "cusco",
190
- "daumoa",
191
- "deepindex",
192
- "delorie",
193
- "depspid",
194
- "deweb",
195
- "die blinde kuh",
196
- "digger",
197
- "ditto",
198
- "dmoz",
199
- "docomo",
200
- "download express",
201
- "dtaagent",
202
- "dwcp",
203
- "ebiness",
204
- "ebingbong",
205
- "e-collector",
206
- "ejupiter",
207
- "emacs-w3 search engine",
208
- "esther",
209
- "evliya celebi",
210
- "ezresult",
211
- "falcon",
212
- "felix ide",
213
- "ferret",
214
- "fetchrover",
215
- "fido",
216
- "findlinks",
217
- "fireball",
218
- "fish search",
219
- "fouineur",
220
- "funnelweb",
221
- "gazz",
222
- "gcreep",
223
- "genieknows",
224
- "getterroboplus",
225
- "geturl",
226
- "glx",
227
- "goforit",
228
- "golem",
229
- "grabber",
230
- "grapnel",
231
- "gralon",
232
- "griffon",
233
- "gromit",
234
- "grub",
235
- "gulliver",
236
- "hamahakki",
237
- "harvest",
238
- "havindex",
239
- "helix",
240
- "heritrix",
241
- "hku www octopus",
242
- "homerweb",
243
- "htdig",
244
- "html index",
245
- "html_analyzer",
246
- "htmlgobble",
247
- "hubater",
248
- "hyper-decontextualizer",
249
- "ia_archiver",
250
- "ibm_planetwide",
251
- "ichiro",
252
- "iconsurf",
253
- "iltrovatore",
254
- "image.kapsi.net",
255
- "imagelock",
256
- "incywincy",
257
- "indexer",
258
- "infobee",
259
- "informant",
260
- "ingrid",
261
- "inktomisearch.com",
262
- "inspector web",
263
- "intelliagent",
264
- "internet shinchakubin",
265
- "ip3000",
266
- "iron33",
267
- "israeli-search",
268
- "ivia",
269
- "jack",
270
- "jakarta",
271
- "javabee",
272
- "jetbot",
273
- "jumpstation",
274
- "katipo",
275
- "kdd-explorer",
276
- "kilroy",
277
- "knowledge",
278
- "kototoi",
279
- "kretrieve",
280
- "labelgrabber",
281
- "lachesis",
282
- "larbin",
283
- "legs",
284
- "libwww",
285
- "linkalarm",
286
- "link validator",
287
- "linkscan",
288
- "lockon",
289
- "lwp",
290
- "lycos",
291
- "magpie",
292
- "mantraagent",
293
- "mapoftheinternet",
294
- "marvin/",
295
- "mattie",
296
- "mediafox",
297
- "mediapartners",
298
- "mercator",
299
- "merzscope",
300
- "microsoft url control",
301
- "minirank",
302
- "miva",
303
- "mj12",
304
- "mnogosearch",
305
- "moget",
306
- "monster",
307
- "moose",
308
- "motor",
309
- "multitext",
310
- "muncher",
311
- "muscatferret",
312
- "mwd.search",
313
- "myweb",
314
- "najdi",
315
- "nameprotect",
316
- "nationaldirectory",
317
- "nazilla",
318
- "ncsa beta",
319
- "nec-meshexplorer",
320
- "nederland.zoek",
321
- "netcarta webmap engine",
322
- "netmechanic",
323
- "netresearchserver",
324
- "netscoop",
325
- "newscan-online",
326
- "nhse",
327
- "nokia6682/",
328
- "nomad",
329
- "noyona",
330
- "nutch",
331
- "nzexplorer",
332
- "objectssearch",
333
- "occam",
334
- "omni",
335
- "open text",
336
- "openfind",
337
- "openintelligencedata",
338
- "orb search",
339
- "osis-project",
340
- "pack rat",
341
- "pageboy",
342
- "pagebull",
343
- "page_verifier",
344
- "panscient",
345
- "parasite",
346
- "partnersite",
347
- "patric",
348
- "pear.",
349
- "pegasus",
350
- "peregrinator",
351
- "pgp key agent",
352
- "phantom",
353
- "phpdig",
354
- "picosearch",
355
- "piltdownman",
356
- "pimptrain",
357
- "pinpoint",
358
- "pioneer",
359
- "piranha",
360
- "plumtreewebaccessor",
361
- "pogodak",
362
- "poirot",
363
- "pompos",
364
- "poppelsdorf",
365
- "poppi",
366
- "popular iconoclast",
367
- "psycheclone",
368
- "publisher",
369
- "python",
370
- "rambler",
371
- "raven search",
372
- "roach",
373
- "road runner",
374
- "roadhouse",
375
- "robbie",
376
- "robofox",
377
- "robozilla",
378
- "rules",
379
- "salty",
380
- "sbider",
381
- "scooter",
382
- "scoutjet",
383
- "scrubby",
384
- "search.",
385
- "searchprocess",
386
- "semanticdiscovery",
387
- "senrigan",
388
- "sg-scout",
389
- "shai'hulud",
390
- "shark",
391
- "shopwiki",
392
- "sidewinder",
393
- "sift",
394
- "silk",
395
- "simmany",
396
- "site searcher",
397
- "site valet",
398
- "sitetech-rover",
399
- "skymob.com",
400
- "sleek",
401
- "smartwit",
402
- "sna-",
403
- "snappy",
404
- "snooper",
405
- "sohu",
406
- "speedfind",
407
- "sphere",
408
- "sphider",
409
- "spinner",
410
- "spyder",
411
- "steeler/",
412
- "suke",
413
- "suntek",
414
- "supersnooper",
415
- "surfnomore",
416
- "sven",
417
- "sygol",
418
- "szukacz",
419
- "tach black widow",
420
- "tarantula",
421
- "templeton",
422
- "/teoma",
423
- "t-h-u-n-d-e-r-s-t-o-n-e",
424
- "theophrastus",
425
- "titan",
426
- "titin",
427
- "tkwww",
428
- "toutatis",
429
- "t-rex",
430
- "tutorgig",
431
- "twiceler",
432
- "twisted",
433
- "ucsd",
434
- "udmsearch",
435
- "url check",
436
- "updated",
437
- "vagabondo",
438
- "valkyrie",
439
- "verticrawl",
440
- "victoria",
441
- "vision-search",
442
- "volcano",
443
- "voyager/",
444
- "voyager-hc",
445
- "w3c_validator",
446
- "w3m2",
447
- "w3mir",
448
- "walker",
449
- "wallpaper",
450
- "wanderer",
451
- "wauuu",
452
- "wavefire",
453
- "web core",
454
- "web hopper",
455
- "web wombat",
456
- "webbandit",
457
- "webcatcher",
458
- "webcopy",
459
- "webfoot",
460
- "weblayers",
461
- "weblinker",
462
- "weblog monitor",
463
- "webmirror",
464
- "webmonkey",
465
- "webquest",
466
- "webreaper",
467
- "websitepulse",
468
- "websnarf",
469
- "webstolperer",
470
- "webvac",
471
- "webwalk",
472
- "webwatch",
473
- "webwombat",
474
- "webzinger",
475
- "wget",
476
- "whizbang",
477
- "whowhere",
478
- "wild ferret",
479
- "worldlight",
480
- "wwwc",
481
- "wwwster",
482
- "xenu",
483
- "xget",
484
- "xift",
485
- "xirq",
486
- "yandex",
487
- "yanga",
488
- "yeti",
489
- "yodao",
490
- "zao/",
491
- "zippp",
492
- "zyborg"
493
- );
494
- foreach($spiders as $spider) {
495
- if (stripos($user_agent, $spider) !== false ) return true;
496
- }
497
- return false;
498
- }
499
-
500
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestCart/Observer.php DELETED
@@ -1,161 +0,0 @@
1
- <?php
2
- /**
3
- * BoneCollector Event Listener (AddToCart SKU Harvest)
4
- *
5
- * @version v1.0.0 - 4/19/2013
6
- *
7
- * @category Magento Integrations
8
- * @package springbot
9
- * @author William Seitz
10
- * @division SpringBot Integration Team
11
- * @support magentosupport@springbot.com
12
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
- *
14
- */
15
- class Springbot_BoneCollector_Model_HarvestCart_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
16
- {
17
- const ACTION_METHOD = 'atc';
18
-
19
- /**
20
- * This exists as a naive dependency injector, so we can set the
21
- * local object for testing purposes
22
- *
23
- * @param $quote Mage_Sales_Model_Quote
24
- * @return Springbot_Combine_Model_Parser_Quote
25
- */
26
- protected function _initParser($quote)
27
- {
28
- if(!isset($this->_parser)) {
29
- $this->_parser = Mage::getModel('Springbot_Combine_Model_Parser_Quote', $quote);
30
- }
31
- return $this->_parser;
32
- }
33
-
34
- /**
35
- * Push cart object to api
36
- *
37
- * @param Varien_Event_Observer $observer
38
- */
39
- public function onFrontendQuoteSaveAfter($observer)
40
- {
41
- try {
42
- $this->_initObserver($observer);
43
- $quoteObject = $observer->getQuote();
44
- $quote = $this->_initParser($quoteObject);
45
-
46
- if (
47
- $quote->getItemsCount() > 0 &&
48
- ($quote->hasCustomerData() || Mage::getStoreConfig('springbot/config/send_cart_noemail')) &&
49
- $quote->getStoreId()
50
- ) {
51
- $json = $quote->toJson();
52
-
53
- if(Mage::helper('combine')->doSendQuote($json)) {
54
-
55
- Mage::helper('combine/trackable')->addTrackable(
56
- $quote->getCustomerEmail(),
57
- 'cart_user_agent',
58
- $_SERVER['HTTP_USER_AGENT'],
59
- $quote->getQuoteId(),
60
- $quote->getCustomerId()
61
- );
62
-
63
- Springbot_Boss::scheduleJob(
64
- 'post:cart',
65
- array(
66
- 's' => Mage::app()->getStore()->getId(),
67
- 'i' => $quote->getQuoteId(),
68
- 'r' => Mage::helper('combine/redirect')->getRawEscapedCookie()
69
- ), Springbot_Services_Priority::LISTENER, 'listener'
70
- );
71
-
72
- $this->insertRedirectIds($quote);
73
- $this->createTrackables($quote);
74
- }
75
- }
76
- } catch (Exception $e) {
77
- Mage::logException($e);
78
- }
79
- }
80
-
81
- /**
82
- * Capture sku for add to cart
83
- * Inserts line into event csv to push
84
- *
85
- * @param Varien_Event_Observer $observer
86
- */
87
- public function onFrontendCartAddProduct($observer)
88
- {
89
- $this->_initObserver($observer);
90
- $quoteId = Mage::getSingleton("checkout/session")->getQuote()->getId();
91
-
92
- $eventDatetime = date("Y-m-d H:i:s");
93
- $openModeAppend = 'a';
94
- $eventHistoryFilename = Mage::getBaseDir('log') . DS . 'Springbot-EventHistory.csv';
95
-
96
- try {
97
- $storeId = Mage::app()->getStore()->getStoreId();
98
- $lastCatId = $this->_getLastCategory();
99
- $fHandle = fopen($eventHistoryFilename,$openModeAppend);
100
- $viewedMessage = array(
101
- self::ACTION_METHOD,
102
- $eventDatetime,
103
- $this->getTopLevelSku($observer),
104
- $quoteId,
105
- $storeId,
106
- Mage::helper('combine')->checkCategoryIdSanity($lastCatId, $observer->getEvent()->getProduct())
107
- );
108
- fputcsv($fHandle,$viewedMessage,',');
109
- fclose ($fHandle);
110
-
111
- } catch (Exception $e) {
112
- Mage::logException($e);
113
- Mage::log('Unknown exception opening '.$eventHistoryFilename);
114
- }
115
- return;
116
- }
117
-
118
- public function insertRedirectIds($quote)
119
- {
120
- if(Mage::helper('combine/redirect')->hasRedirectId()) {
121
- Springbot_Log::debug("Insert redirect id for customer : {$quote->getCustomerEmail()}");
122
- $params = array(
123
- 'email' => $quote->getCustomerEmail(),
124
- 'quote_id' => $quote->getQuoteId(),
125
- 'customer_id' => $quote->getCustomerId(),
126
- );
127
-
128
- Mage::helper('combine/redirect')->insertRedirectIds($params);
129
- }
130
- }
131
-
132
- public function createTrackables($quote)
133
- {
134
- $helper = Mage::helper('combine/trackable');
135
- $model = Mage::getModel('combine/trackable');
136
-
137
- if($helper->hasTrackables()) {
138
- foreach($helper->getTrackables() as $type => $value) {
139
- $model->setData(array(
140
- 'email' => $quote->getCustomerEmail(),
141
- 'type' => $type,
142
- 'value' => $value,
143
- 'quote_id' => $quote->getQuoteId(),
144
- 'customer_id' => $quote->getCustomerId(),
145
- ));
146
- $model->createOrUpdate();
147
- }
148
- }
149
- }
150
-
151
- public function setParser($parser)
152
- {
153
- $this->_parser = $parser;
154
- }
155
-
156
- protected function _getLastCategory()
157
- {
158
- return Mage::helper('combine')->getLastCategoryId();
159
- }
160
-
161
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestCategory/Observer.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
-
3
- class Springbot_BoneCollector_Model_HarvestCategory_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
4
- {
5
- public function onCategorySaveAfter($observer)
6
- {
7
- $this->_initObserver($observer);
8
- $categoryId = $observer->getEvent()->getCategory()->getEntityId();
9
- if(!empty($categoryId)) {
10
- Springbot_Boss::scheduleJob('post:category', array('i' => $categoryId), Springbot_Services_Priority::LISTENER, 'listener');
11
- }
12
- }
13
-
14
-
15
- public function onCategoryDeleteAfter($observer)
16
- {
17
- try{
18
- $category = $observer->getEvent()->getCategory();
19
- $this->_initObserver($observer);
20
- foreach(Mage::helper('combine/harvest')->mapStoreIds($category) as $mapped) {
21
- $deleted = array(
22
- 'store_id' => $mapped->getStoreId(),
23
- 'cat_id' => $category->getEntityId(),
24
- 'is_deleted' => true,
25
- );
26
- }
27
- Mage::helper('combine/harvest')->deleteRemote($deleted, 'categories');
28
- } catch (Exception $e) {
29
- Mage::logException($e);
30
- }
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestCustomer/Observer.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
-
3
- class Springbot_BoneCollector_Model_HarvestCustomer_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
4
- {
5
- protected $_customer;
6
-
7
- public function onCustomerSaveAfter($observer)
8
- {
9
- try {
10
- $this->_initObserver($observer);
11
- $this->_customer = $observer->getEvent()->getCustomer();
12
-
13
- if ($this->_entityChanged($this->_customer)) {
14
- $customerId = $this->_customer->getId();
15
- Springbot_Boss::scheduleJob('post:customer', array('i' => $customerId), Springbot_Services_Priority::LISTENER, 'listener');
16
- }
17
- } catch (Exception $e) {
18
- Springbot_Log::error($e);
19
- }
20
- }
21
-
22
- public function onCustomerDeleteBefore($observer)
23
- {
24
- try {
25
- // Runs blocking in session to guarantee record existence
26
- $customer = $observer->getEvent()->getCustomer();
27
- $this->_initObserver($observer);
28
- Mage::getModel('Springbot_Services_Post_Customer')->setData(array(
29
- 'start_id' => $customer->getId(),
30
- 'delete' => true,
31
- ))->run();
32
-
33
- } catch (Exception $e) {
34
- Springbot_Log::error($e);
35
- }
36
- }
37
-
38
- protected function _getAttributesToListenFor($extras = array())
39
- {
40
- $codes = array();
41
- $h = Mage::helper('combine/attributes');
42
- $attributes = $h->getCustomerCustomAttributes($h->getCustomerAttributeSet());
43
-
44
- try {
45
- foreach($attributes as $attribute) {
46
- $codes[] = $attribute->getAttributeCode();
47
- }
48
- }
49
- catch (Exception $e) {
50
- Springbot_Log::debug('Exception caught during attribute iteration for customer observer');
51
- }
52
-
53
-
54
- // Ensure we test for change in group
55
- $codes[] = 'group_id';
56
-
57
- return parent::_getAttributesToListenFor($codes);
58
- }
59
- }
60
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestProduct/Observer.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * BoneCollector Event Listener (Product Harvest)
4
- *
5
- * @version v1.0.0 - 12/28/2012
6
- *
7
- * @category Magento Integrations
8
- * @package springbot
9
- * @author William Seitz
10
- * @division SpringBot Integration Team
11
- * @support magentosupport@springbot.com
12
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
- *
14
- */
15
- class Springbot_BoneCollector_Model_HarvestProduct_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
16
- {
17
- protected $_product;
18
-
19
- protected $_attributes = array(
20
- 'entity_id',
21
- 'sku',
22
- 'attribute_set_id',
23
- 'description',
24
- 'full_description',
25
- 'short_description',
26
- 'image',
27
- 'url_key',
28
- 'small_image',
29
- 'thumbnail',
30
- 'status',
31
- 'visibility',
32
- 'price',
33
- 'special_price',
34
- 'image_label',
35
- );
36
-
37
- public function onProductSaveAfter($observer)
38
- {
39
- try {
40
- $this->_product = $observer->getEvent()->getProduct();
41
-
42
- if ($this->_entityChanged($this->_product)) {
43
- $this->_initObserver($observer);
44
- Springbot_Boss::scheduleJob('post:product', array('i' => $this->_product->getId()), Springbot_Services_Priority::LISTENER, 'listener');
45
- }
46
-
47
- } catch (Exception $e) {
48
- Mage::logException($e);
49
- }
50
- }
51
-
52
- public function onProductDeleteBefore($observer)
53
- {
54
- $this->_initObserver($observer);
55
- try{
56
- $this->_product = $observer->getEvent()->getProduct();
57
- $entity_id = $this->_product->getId();
58
- foreach(Mage::helper('combine/harvest')->mapStoreIds($this->_product) as $mapped) {
59
- $post[] = array(
60
- 'store_id' => $mapped->getStoreId(),
61
- 'entity_id' => $entity_id,
62
- 'sku' => $this->_getSkuFailsafe($this->_product),
63
- 'is_deleted' => true,
64
- );
65
- }
66
- Mage::helper('combine/harvest')->deleteRemote($post, 'products');
67
- } catch (Exception $e) {
68
- Mage::logException($e);
69
- }
70
- }
71
-
72
- protected function _getSkuFailsafe($product)
73
- {
74
- if ($sku = $product->getSku()) {
75
- return $sku;
76
- }
77
- else {
78
- return Springbot_Boss::NO_SKU_PREFIX . $product->getEntityId();
79
- }
80
- }
81
-
82
- protected function _getAttributesToListenFor($extras = array())
83
- {
84
- return parent::_getAttributesToListenFor(
85
- Mage::helper('combine/parser')->getCustomAttributeNames($this->_product)
86
- );
87
-
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestPurchase/Observer.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * Visitor BoneCollector Event Listener
4
- *
5
- * @version v1.0.0 - 12/28/2012
6
- *
7
- * @category Magento Integrations
8
- * @package springbot
9
- * @author William Seitz
10
- * @division SpringBot Integration Team
11
- * @support magentosupport@springbot.com
12
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
- *
14
- */
15
- class Springbot_BoneCollector_Model_HarvestPurchase_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
16
- {
17
- const METHOD = 'purchase';
18
- const COOKIE_NAME = 'springbot_redirect_queue';
19
- const STDLIST_BASENAME = 'SpringbotServices-BoneCollector-Purchase';
20
-
21
- protected $_order;
22
-
23
- public function onFrontendOrderSaveAfter($observer)
24
- {
25
- if($this->_getCheckoutSession()->getSpringbotLogPurchaseAction() === true) {
26
- $this->callPurchaseLogAction($observer);
27
- $this->_getCheckoutSession()->unsSpringbotLogPurchaseAction();
28
- }
29
-
30
- if($this->_doSendPurchase($observer)) {
31
- $this->_purchaseHarvest($observer, true);
32
- }
33
- }
34
-
35
- public function onAdminOrderSaveAfter($observer)
36
- {
37
- $this->_purchaseHarvest($observer, false);
38
- }
39
-
40
- public function onFrontendOrderPlaceAfter($observer)
41
- {
42
- $this->_initObserver($observer);
43
- $this->_getCheckoutSession()->setSpringbotLogPurchaseAction(true);
44
- }
45
-
46
- public function callPurchaseLogAction($observer)
47
- {
48
- try {
49
- $this->_initObserver($observer);
50
- $this->_order = $observer->getEvent()->getOrder();
51
-
52
- Springbot_Boss::scheduleJob(
53
- 'log:purchase',
54
- array(
55
- 'i' => $this->_order->getId(),
56
- 'c' => $this->_getLastCategory(),
57
- ),
58
- Springbot_Services_Priority::LISTENER, 'listener'
59
- );
60
-
61
- } catch (Exception $e) {
62
- Mage::logException($e);
63
- }
64
- }
65
-
66
- protected function _purchaseHarvest($observer, $frontend = true)
67
- {
68
- try {
69
- $this->_initObserver($observer);
70
- $this->_order = $observer->getEvent()->getOrder();
71
- $this->updateTrackables();
72
-
73
- if($frontend) {
74
- $this->_logUserAgent();
75
- }
76
- Springbot_Boss::scheduleJob('post:purchase',
77
- array(
78
- 'i' => $this->_order->getEntityId(),
79
- 'c' => $this->_getLastCategory(),
80
- 'r' => $this->getRedirectIds($frontend),
81
- ),
82
- Springbot_Services_Priority::LISTENER, 'listener'
83
- );
84
-
85
- } catch (Exception $e) {
86
- Mage::logException($e);
87
- }
88
- }
89
-
90
- protected function _logUserAgent() {
91
- Mage::helper('combine/trackable')->addTrackable(
92
- $this->_order->getCustomerEmail(),
93
- 'purchase_user_agent',
94
- $_SERVER['HTTP_USER_AGENT'],
95
- $this->_order->getQuoteId(),
96
- $this->_order->getCustomerId()
97
- );
98
- }
99
-
100
- public function updateTrackables()
101
- {
102
- $helper = Mage::helper('combine/trackable');
103
- $params = $helper->getTrackables();
104
- $quoteId = $this->_order->getQuoteId();
105
-
106
- foreach($this->getTrackablesForQuote($quoteId) as $trackable) {
107
- $trackable->setOrderId($this->_order->getId())
108
- ->setCustomerId($this->_order->getCustomerId())
109
- ->save();
110
- }
111
- }
112
-
113
- public function getTrackablesForQuote($quoteId)
114
- {
115
- return Mage::getModel('combine/trackable')->getCollection()
116
- ->addFieldToFilter('quote_id', $quoteId);
117
- }
118
-
119
- protected function _doSendPurchase($observer)
120
- {
121
- $order = $observer->getEvent()->getOrder();
122
- $hash = sha1($order->toJson());
123
- $session = $this->_getCheckoutSession();
124
-
125
- if($session->getSpringbotOrderHash() == $hash) {
126
- Springbot_Log::debug("Purchase hash is match, this object has already been posted, skipping");
127
- return false;
128
- } else {
129
- $session->setSpringbotOrderHash($hash);
130
- Springbot_Log::debug("Purchase hash does not match cache, sending purchase");
131
- return true;
132
- }
133
- }
134
-
135
- protected function _getCustomerEmail()
136
- {
137
- return $this->_order->getCustomerEmail();
138
- }
139
-
140
- protected function _getLastCategory()
141
- {
142
- return Mage::helper('combine')->getLastCategoryId();
143
- }
144
-
145
- protected function _getCheckoutSession()
146
- {
147
- return Mage::getSingleton('checkout/session');
148
- }
149
-
150
- public function getRedirectIds($frontend = true)
151
- {
152
- $redirects = $frontend ? Mage::helper('combine/redirect')->getRedirectIds() : array();
153
-
154
- if($dbRedirects = Mage::helper('combine/redirect')->getRedirectsByEmail($this->_getCustomerEmail(), $this->_order->getCreatedAt())) {
155
- $redirects = array_unique(array_merge($redirects, $dbRedirects));
156
- }
157
-
158
- return array_values($redirects);
159
- }
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestRule/Observer.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- class Springbot_BoneCollector_Model_HarvestRule_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
4
- {
5
- protected $_coupon;
6
- protected $_attributes = array(
7
- 'is_active',
8
- 'name' ,
9
- 'coupon_code',
10
- 'description',
11
- 'conditions',
12
- 'actions',
13
- 'from_date',
14
- 'to_date',
15
- 'uses_per_coupon',
16
- 'uses_per_customer',
17
- 'stop_rules_processing',
18
- 'is_advanced',
19
- 'product_ids',
20
- 'sort_order',
21
- 'simple_action',
22
- 'discount_amount',
23
- 'discount_qty',
24
- 'discount_step',
25
- 'simple_free_shipping',
26
- 'apply_to_shipping',
27
- 'times_used',
28
- 'is_rss',
29
- 'website_ids',
30
- 'customer_group_ids',
31
- );
32
-
33
- public function onSalesruleRuleSaveAfter($observer)
34
- {
35
- try {
36
- $this->_initObserver($observer);
37
- $this->_rule = $observer->getEvent()->getRule();
38
-
39
- if ($this->_entityChanged($this->_rule)) {
40
- $ruleId = $this->_rule->getId();
41
- $websiteIds = explode(',', $this->_rule->getWebsiteIds());
42
- foreach ($websiteIds as $websiteId) {
43
- if ($website = Mage::app()->getWebsite($websiteId)) {
44
- foreach ($website->getGroups() as $group) {
45
- $stores = $group->getStores();
46
- foreach ($stores as $store) {
47
- Springbot_Boss::scheduleJob('post:rule', array('i' => $ruleId, 's' => $store->getId()), Springbot_Services_Priority::LISTENER, 'listener');
48
- }
49
- }
50
- }
51
- }
52
- }
53
-
54
- } catch (Exception $e) {
55
- Springbot_Log::error($e);
56
- }
57
-
58
- }
59
-
60
- public function onSalesruleRuleDeleteBefore($observer)
61
- {
62
- try {
63
- // Runs blocking in session to guarantee record existence
64
- $rule = $observer->getEvent()->getRule()->getPrimaryCoupon();
65
- $this->_initObserver($observer);
66
- Mage::getModel('Springbot_Services_Post_Rule')->setData(array(
67
- 'start_id' => $rule->getId(),
68
- 'delete' => true,
69
- ))->run();
70
-
71
- } catch (Exception $e) {
72
- Springbot_Log::error($e);
73
- }
74
- }
75
-
76
- }
77
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/Model/HarvestSubscriber/Observer.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- class Springbot_BoneCollector_Model_HarvestSubscriber_Observer extends Springbot_BoneCollector_Model_HarvestAbstract
4
- {
5
- public function onSubscriberSaveAfter($observer)
6
- {
7
- try {
8
- $this->_initObserver($observer);
9
- $subscriberId = $observer->getEvent()->getSubscriber()->getId();
10
-
11
- Springbot_Boss::scheduleJob(
12
- 'post:subscriber',
13
- array('i' => $subscriberId),
14
- Springbot_Services_Priority::LISTENER,
15
- 'listener'
16
- );
17
-
18
- } catch (Exception $e) {
19
- Springbot_Log::error($e);
20
- }
21
- }
22
-
23
- public function onSubscriberDeleteBefore($observer)
24
- {
25
- try {
26
- // Runs blocking in session to guarantee record existence
27
- $this->_initObserver($observer);
28
- Mage::getModel('Springbot_Services_Post_Subscriber')->setData(array(
29
- 'start_id' => $observer->getEvent()->getSubscriber()->getId(),
30
- 'delete' => true,
31
- ))->run();
32
- } catch (Exception $e) {
33
- Springbot_Log::error($e);
34
- }
35
- }
36
- }
37
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/BoneCollector/etc/config.xml DELETED
@@ -1,190 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category springbot
5
- * @package springbot_BoneCollector
6
- * @author springbot integration team
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- -->
10
- <config>
11
- <global>
12
- <models>
13
- <bonecollector>
14
- <class>Springbot_BoneCollector_Model</class>
15
- </bonecollector>
16
- </models>
17
- <events>
18
- <catalog_product_save_after>
19
- <observers>
20
- <springbot_bonecollector_product_observer>
21
- <type>singleton</type>
22
- <class>Springbot_BoneCollector_Model_HarvestProduct_Observer</class>
23
- <method>onProductSaveAfter</method>
24
- </springbot_bonecollector_product_observer>
25
- </observers>
26
- </catalog_product_save_after>
27
- <catalog_product_delete_before>
28
- <observers>
29
- <springbot_bonecollector_productdelete_observer>
30
- <type>singleton</type>
31
- <class>Springbot_BoneCollector_Model_HarvestProduct_Observer</class>
32
- <method>onProductDeleteBefore</method>
33
- </springbot_bonecollector_productdelete_observer>
34
- </observers>
35
- </catalog_product_delete_before>
36
- <catalog_category_save_after>
37
- <observers>
38
- <springbot_bonecollector_categorysave_observer>
39
- <type>singleton</type>
40
- <class>Springbot_BoneCollector_Model_HarvestCategory_Observer</class>
41
- <method>onCategorySaveAfter</method>
42
- </springbot_bonecollector_categorysave_observer>
43
- </observers>
44
- </catalog_category_save_after>
45
- <catalog_category_delete_after>
46
- <observers>
47
- <springbot_bonecollector_categorydelete_observer>
48
- <type>singleton</type>
49
- <class>Springbot_BoneCollector_Model_HarvestCategory_Observer</class>
50
- <method>onCategoryDeleteAfter</method>
51
- </springbot_bonecollector_categorydelete_observer>
52
- </observers>
53
- </catalog_category_delete_after>
54
- <customer_save_after>
55
- <observers>
56
- <springbot_bonecollector_customersave_observer>
57
- <type>singleton</type>
58
- <class>Springbot_BoneCollector_Model_HarvestCustomer_Observer</class>
59
- <method>onCustomerSaveAfter</method>
60
- </springbot_bonecollector_customersave_observer>
61
- </observers>
62
- </customer_save_after>
63
- <customer_delete_before>
64
- <observers>
65
- <springbot_bonecollector_customerdelete_observer>
66
- <type>singleton</type>
67
- <class>Springbot_BoneCollector_Model_HarvestCustomer_Observer</class>
68
- <method>onCustomerDeleteBefore</method>
69
- </springbot_bonecollector_customerdelete_observer>
70
- </observers>
71
- </customer_delete_before>
72
- <newsletter_subscriber_save_after>
73
- <observers>
74
- <springbot_bonecollector_customersave_observer>
75
- <type>singleton</type>
76
- <class>Springbot_BoneCollector_Model_HarvestSubscriber_Observer</class>
77
- <method>onSubscriberSaveAfter</method>
78
- </springbot_bonecollector_customersave_observer>
79
- </observers>
80
- </newsletter_subscriber_save_after>
81
- <newsletter_subscriber_delete_before>
82
- <observers>
83
- <springbot_bonecollector_customerdelete_observer>
84
- <type>singleton</type>
85
- <class>Springbot_BoneCollector_Model_HarvestSubscriber_Observer</class>
86
- <method>onSubscriberDeleteBefore</method>
87
- </springbot_bonecollector_customerdelete_observer>
88
- </observers>
89
- </newsletter_subscriber_delete_before>
90
- </events>
91
- </global>
92
- <frontend>
93
- <events>
94
- <sales_order_place_after>
95
- <observers>
96
- <springbot_bonecollector_purchase_log_observer>
97
- <type>singleton</type>
98
- <class>Springbot_BoneCollector_Model_HarvestPurchase_Observer</class>
99
- <method>onFrontendOrderPlaceAfter</method>
100
- </springbot_bonecollector_purchase_log_observer>
101
- </observers>
102
- </sales_order_place_after>
103
- <sales_order_save_after>
104
- <observers>
105
- <springbot_bonecollector_purchase_observer>
106
- <type>singleton</type>
107
- <class>Springbot_BoneCollector_Model_HarvestPurchase_Observer</class>
108
- <method>onFrontendOrderSaveAfter</method>
109
- </springbot_bonecollector_purchase_observer>
110
- </observers>
111
- </sales_order_save_after>
112
- <sales_quote_save_after>
113
- <observers>
114
- <springbot_bonecollector_addtocart_observer>
115
- <type>singleton</type>
116
- <class>Springbot_BoneCollector_Model_HarvestCart_Observer</class>
117
- <method>onFrontendQuoteSaveAfter</method>
118
- </springbot_bonecollector_addtocart_observer>
119
- </observers>
120
- </sales_quote_save_after>
121
- <catalog_controller_product_view>
122
- <observers>
123
- <springbot_bonecollector_capturesku_observer>
124
- <type>singleton</type>
125
- <class>Springbot_BoneCollector_Model_HarvestCaptureSKU_Observer</class>
126
- <method>onFrontendProductView</method>
127
- </springbot_bonecollector_capturesku_observer>
128
- </observers>
129
- </catalog_controller_product_view>
130
- <checkout_cart_add_product_complete>
131
- <observers>
132
- <springbot_bonecollector_addskutocart_observer>
133
- <type>singleton</type>
134
- <class>Springbot_BoneCollector_Model_HarvestCart_Observer</class>
135
- <method>onFrontendCartAddProduct</method>
136
- </springbot_bonecollector_addskutocart_observer>
137
- </observers>
138
- </checkout_cart_add_product_complete>
139
- </events>
140
- </frontend>
141
- <adminhtml>
142
- <events>
143
- <sales_order_save_after>
144
- <observers>
145
- <springbot_bonecollector_purchase_admin_observer>
146
- <type>singleton</type>
147
- <class>Springbot_BoneCollector_Model_HarvestPurchase_Observer</class>
148
- <method>onAdminOrderSaveAfter</method>
149
- </springbot_bonecollector_purchase_admin_observer>
150
- </observers>
151
- </sales_order_save_after>
152
- <catalog_entity_attribute_save_commit_after>
153
- <observers>
154
- <springbot_bonecollector_attribute_observer>
155
- <type>singleton</type>
156
- <class>Springbot_BoneCollector_Model_HarvestAttribute_Observer</class>
157
- <method>onAdminAttributeSaveAfter</method>
158
- </springbot_bonecollector_attribute_observer>
159
- </observers>
160
- </catalog_entity_attribute_save_commit_after>
161
- <eav_entity_attribute_save_commit_after>
162
- <observers>
163
- <springbot_bonecollector_attribute_set_observer>
164
- <type>singleton</type>
165
- <class>Springbot_BoneCollector_Model_HarvestAttribute_Observer</class>
166
- <method>onAdminAttributeSetSaveAfter</method>
167
- </springbot_bonecollector_attribute_set_observer>
168
- </observers>
169
- </eav_entity_attribute_save_commit_after>
170
- <salesrule_rule_save_after>
171
- <observers>
172
- <springbot_bonecollector_rulesave_observer>
173
- <type>singleton</type>
174
- <class>Springbot_BoneCollector_Model_HarvestRule_Observer</class>
175
- <method>onSalesruleRuleSaveAfter</method>
176
- </springbot_bonecollector_rulesave_observer>
177
- </observers>
178
- </salesrule_rule_save_after>
179
- <salesrule_rule_delete_before>
180
- <observers>
181
- <springbot_bonecollector_coupondelete_observer>
182
- <type>singleton</type>
183
- <class>Springbot_BoneCollector_Model_HarvestCoupon_Observer</class>
184
- <method>onSalesruleRuleDeleteBefore</method>
185
- </springbot_bonecollector_coupondelete_observer>
186
- </observers>
187
- </salesrule_rule_delete_before>
188
- </events>
189
- </adminhtml>
190
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Boss.php CHANGED
@@ -1,15 +1,22 @@
1
  <?php
2
 
 
 
 
 
 
 
 
3
  class Springbot_Boss
4
  {
5
- private static $_currentStore;
6
-
7
- const EVENT_FILENAME = 'Springbot-EventHistory.csv';
8
- const SOURCE_BULK_HARVEST = 'BH';
9
- const SOURCE_OBSERVER = 'OB';
10
- const DATE_FORMAT = 'Y-m-d H:i:s';
11
- const NO_SKU_PREFIX = '_sbentity-';
12
-
13
 
14
  /**
15
  * Schedule cron job
@@ -21,141 +28,103 @@ class Springbot_Boss
21
  * @param int $storeId
22
  * @param bool $requiresAuth
23
  */
24
- public static function scheduleJob($method, $args, $priority, $queue = 'default', $storeId = null, $requiresAuth = true)
25
  {
26
- if($requiresAuth && !self::storeIdsExist()) {
27
- Springbot_Log::debug('Not authenticated, job not queued');
28
- }
29
- else {
30
- $cronner = Mage::getModel('combine/cron_queue');
31
- $cronner->setData(array(
32
- 'method' => $method,
33
- 'args' => json_encode($args),
34
- 'priority' => $priority,
35
- 'command_hash' => sha1($method . json_encode($args)),
36
- 'queue' => $queue,
37
- 'store_id' => $storeId
38
- ));
39
-
40
- $cronner->insertIgnore();
 
41
  self::startWorkManager();
 
42
  }
43
  }
44
 
45
- public static function startWorkManager()
46
  {
47
- $status = Mage::getModel('combine/cron_manager_status');
48
- if(
49
- !$status->isBlocked() &&
50
- !$status->isActive()
51
- ) {
52
- Springbot_Boss::internalCallback('work:manager');
53
- }
54
- }
 
 
 
55
 
56
- /**
57
- *
58
- * @param string $method
59
- * @param array $args
60
- * @param bool $background
61
- */
62
- public static function internalCallback($method, $args = array(), $background = true)
63
- {
64
- $bkg = $background ? '&' : '';
65
- $fmt = self::buildFlags($args);
66
- $php = Mage::helper('combine/harvest')->getPhpExec();
67
- $dir = Mage::getBaseDir();
68
- $err = Mage::helper('combine')->getSpringbotErrorLog();
69
- $log = Mage::helper('combine')->getSpringbotLog();
70
- $nohup = Mage::helper('combine')->nohup();
71
- $nice = Mage::helper('combine')->nice();
72
- $cmd = "{$nohup} {$nice} {$php} {$dir}/shell/springbot.php {$fmt} {$method} >> {$log} 2>> {$err} {$bkg}";
73
 
74
- try {
75
- $ret = self::spawn($cmd);
76
- }
77
- catch (Exception $e) {
78
- $ret = null;
79
  }
80
- return $ret;
81
  }
82
 
83
- /**
84
- * Build cli flags from arg array
85
- *
86
- * @param array $args
87
- * @return string
88
- */
89
- public static function buildFlags($args)
90
  {
91
- $fmt = array();
92
-
93
- foreach($args as $flag => $arg) {
94
- if(is_int($flag)) {
95
- $flag = $arg;
96
- $arg = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
- $fmt[] = "-$flag $arg";
99
  }
100
- return implode(' ', $fmt);
101
  }
102
 
103
- /**
104
- * Spawn system callback with any available system command
105
- *
106
- * @param string $command
107
- * @param int $return_var
108
- */
109
- public static function spawn($command, &$return_var = 0)
110
  {
111
- Springbot_Log::debug($command);
112
- if(function_exists('system')) {
113
- $ret = system($command, $return_var);
114
- } else if(function_exists('exec')) {
115
- $ret = exec($command, $return_var);
116
- } else if(function_exists('passthru')) {
117
- $ret = passthru($command, $return_var);
118
- } else if(function_exists('shell_exec')) {
119
- $ret = shell_exec($command);
120
- } else {
121
- throw new Exception('Program execution function not found!');
122
  }
123
- Springbot_Log::debug($ret);
124
- return $ret;
125
- }
126
-
127
- public static function launchHarvest()
128
- {
129
- Mage::helper('combine/harvest')->truncateEngineLogs();
130
- Springbot_Boss::internalCallback('cmd:harvest');
131
  }
132
 
133
  /**
134
- * This method kills all processes which contain 'Harvest' in the command by default.
135
- * Use carefully!
136
  *
137
- * @param string $toHalt
138
  */
139
- public static function halt()
140
- {
141
- $queueDb = new Springbot_Combine_Model_Mysql4_Cron_Queue;
142
- $queueDb->removeHarvestRows();
143
- }
144
-
145
- public static function haltStore($storeId)
146
  {
147
  $queueDb = new Springbot_Combine_Model_Mysql4_Cron_Queue;
148
- $queueDb->removeStoreHarvestRows($storeId);
149
- }
150
-
151
- public static function setActive($storeId)
152
- {
153
- self::$_currentStore = $storeId;
154
- }
155
-
156
- public static function getEventHistoryFilename()
157
- {
158
- return Mage::getBaseDir('log') . DS . self::EVENT_FILENAME;
159
  }
160
 
161
  public static function isCron()
@@ -173,4 +142,12 @@ class Springbot_Boss
173
  return true;
174
  }
175
 
 
 
 
 
 
 
 
 
176
  }
1
  <?php
2
 
3
+ /**
4
+ * Class: Springbot_Boss
5
+ *
6
+ * @author Springbot Magento Integration Team <magento@springbot.com>
7
+ * @version 1.4.0.0
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
  class Springbot_Boss
11
  {
12
+ const SOURCE_BULK_HARVEST = 'BH';
13
+ const SOURCE_OBSERVER = 'OB';
14
+ const DATE_FORMAT = 'Y-m-d H:i:s';
15
+ const NO_SKU_PREFIX = '_sbentity-';
16
+ const TOKEN_DELIMITER = '%7';
17
+ const COOKIE_NAME = 'springbot_redirect_queue';
18
+ const SB_TRACKABLES_COOKIE = '_sbtk';
19
+ const MAXIMUM_IDS_SAVED = 32;
20
 
21
  /**
22
  * Schedule cron job
28
  * @param int $storeId
29
  * @param bool $requiresAuth
30
  */
31
+ public static function scheduleJob($method, array $args, $priority, $queue = 'default', $storeId = null, $requiresAuth = true)
32
  {
33
+ if(self::active() && !empty($method)) {
34
+ if ($requiresAuth && !self::storeIdsExist()) {
35
+ Springbot_Log::debug('Not authenticated, job not queued');
36
+ }
37
+ else {
38
+ $cronModel = Mage::getModel('combine/cron_queue');
39
+ $cronModel->setData(array(
40
+ 'method' => $method,
41
+ 'args' => json_encode($args),
42
+ 'priority' => $priority,
43
+ 'command_hash' => sha1($method . json_encode($args)),
44
+ 'queue' => $queue,
45
+ 'store_id' => $storeId
46
+ ));
47
+ $cronModel->insertIgnore();
48
+ }
49
  self::startWorkManager();
50
+ Springbot_Cli::runHealthcheck($storeId);
51
  }
52
  }
53
 
54
+ public static function insertEvent($data, $runHealthcheck = false)
55
  {
56
+ if(self::active()) {
57
+ if(!isset($data['type']) || !isset($data['store_id'])) {
58
+ Springbot_Log::error(new Exception("Invalid action attempted to log"));
59
+ return;
60
+ } else {
61
+ $storeId = $data['store_id'];
62
+ }
63
+ $event = Mage::getModel('combine/action');
64
+ $event->setData($data);
65
+ $event->setVisitorIp(Mage::helper('core/http')->getRemoteAddr(true));
66
+ $event->save();
67
 
68
+ Springbot_Log::debug($event->getData());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ if($runHealthcheck) {
71
+ Springbot_Cli::runHealthcheck($storeId);
72
+ }
 
 
73
  }
 
74
  }
75
 
76
+ public static function addTrackable($type, $value, $quoteId, $customerId, $customerEmail = '', $orderId = null)
 
 
 
 
 
 
77
  {
78
+ if(self::active()) {
79
+ $trackableModel = Mage::getModel('combine/trackable');
80
+ $trackableModel->setData(array(
81
+ 'type' => $type,
82
+ 'value' => $value,
83
+ 'quote_id' => $quoteId,
84
+ 'customer_id' => $customerId,
85
+ 'email' => $customerEmail,
86
+ 'order_id' => $orderId
87
+ ));
88
+ $trackableModel->createOrUpdate();
89
+
90
+ // Ensure that trackables in cookie are processed
91
+ foreach($trackableModel->getTrackables() as $type => $value) {
92
+ Springbot_Log::debug("Ensure trackable $type => $value");
93
+ $trackableModel->setData(array(
94
+ 'type' => $type,
95
+ 'value' => $value,
96
+ 'quote_id' => $quoteId,
97
+ 'customer_id' => $customerId,
98
+ 'email' => $customerEmail,
99
+ 'order_id' => $orderId
100
+ ));
101
+ $trackableModel->createOrUpdate();
102
  }
 
103
  }
 
104
  }
105
 
106
+ public static function startWorkManager()
 
 
 
 
 
 
107
  {
108
+ if(self::active() && !self::isCron()) {
109
+ $status = Mage::getModel('combine/cron_manager_status');
110
+ if(
111
+ !$status->isBlocked() &&
112
+ !$status->isActive()
113
+ ) {
114
+ Springbot_Cli::internalCallback('work:manager');
115
+ }
 
 
 
116
  }
 
 
 
 
 
 
 
 
117
  }
118
 
119
  /**
120
+ * Removes all harvest jobs from the queue
 
121
  *
122
+ * @param integer $storeId
123
  */
124
+ public static function halt($storeId = null)
 
 
 
 
 
 
125
  {
126
  $queueDb = new Springbot_Combine_Model_Mysql4_Cron_Queue;
127
+ $queueDb->removeHarvestRows($storeId);
 
 
 
 
 
 
 
 
 
 
128
  }
129
 
130
  public static function isCron()
142
  return true;
143
  }
144
 
145
+ /**
146
+ * Check if plugin is active and should function properly
147
+ */
148
+ public static function active()
149
+ {
150
+ $token = Mage::getStoreConfig('springbot/config/security_token');
151
+ return !empty($token);
152
+ }
153
  }
app/code/community/Springbot/Cli.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class: Springbot_Cli
5
+ *
6
+ * @author Springbot Magento Integration Team <magento@springbot.com>
7
+ * @version 1.4.0.0
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Springbot_Cli
11
+ {
12
+
13
+ private static $_phpExec;
14
+
15
+ /**
16
+ * Intended to be a wrapper for interalCallback to route cronned
17
+ * instances to the cron queue. We do not want to send jobs in
18
+ * the work service here, as they wind up in a loop.
19
+ *
20
+ * @param string $method
21
+ * @param array $args
22
+ */
23
+ public static function async($method, $args = array())
24
+ {
25
+ if(Springbot_Boss::isCron()) {
26
+ Springbot_Boss::scheduleJob($method, $args, 1);
27
+ } else {
28
+ self::internalCallback($method, $args, true);
29
+ }
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @param string $method
35
+ * @param array $args
36
+ * @param bool $background
37
+ */
38
+ public static function internalCallback($method, $args = array(), $background = true)
39
+ {
40
+ $bkg = $background ? '&' : '';
41
+ $fmt = self::buildFlags($args);
42
+ $php = self::getPhpExec();
43
+ $dir = Mage::getBaseDir();
44
+ $err = Springbot_Log::getSpringbotErrorLog();
45
+ $log = Springbot_Log::getSpringbotLog();
46
+ $nohup = self::nohup();
47
+ $nice = self::nice();
48
+
49
+ $cmd = "{$nohup} {$nice} {$php} {$dir}/shell/springbot.php {$fmt} {$method} >> {$log} 2>> {$err} {$bkg}";
50
+ return self::spawn($cmd);
51
+ }
52
+
53
+ public static function nohup()
54
+ {
55
+ return Mage::getStoreConfig('springbot/advanced/nohup') ? 'nohup' : '';
56
+ }
57
+
58
+ public static function nice()
59
+ {
60
+ return Mage::getStoreConfig('springbot/advanced/nice') ? 'nice' : '';
61
+ }
62
+
63
+ /**
64
+ * Build cli flags from arg array
65
+ *
66
+ * @param array $args
67
+ * @return string
68
+ */
69
+ public static function buildFlags($args)
70
+ {
71
+ $fmt = array();
72
+
73
+ foreach($args as $flag => $arg) {
74
+ if(is_int($flag)) {
75
+ $flag = $arg;
76
+ $arg = '';
77
+ }
78
+ $fmt[] = "-$flag $arg";
79
+ }
80
+ return implode(' ', $fmt);
81
+ }
82
+
83
+ /**
84
+ * Spawn system callback with any available system command
85
+ *
86
+ * @param string $command
87
+ * @param int $return_var
88
+ */
89
+ public static function spawn($command, &$return_var = 0)
90
+ {
91
+ Springbot_Log::debug($command);
92
+ if(function_exists('system')) {
93
+ $ret = system($command, $return_var);
94
+ } else if(function_exists('exec')) {
95
+ $ret = exec($command, $return_var);
96
+ } else if(function_exists('passthru')) {
97
+ $ret = passthru($command, $return_var);
98
+ } else if(function_exists('shell_exec')) {
99
+ $ret = shell_exec($command);
100
+ } else {
101
+ throw new Exception('Program execution function not found!');
102
+ }
103
+ Springbot_Log::debug($ret);
104
+ return $ret;
105
+ }
106
+
107
+ public static function launchHarvest()
108
+ {
109
+ Mage::helper('combine/harvest')->truncateEngineLogs();
110
+ self::async('cmd:harvest');
111
+ }
112
+
113
+ public static function runHealthcheck($storeId = null, $force = false)
114
+ {
115
+ if(is_null($storeId)) {
116
+ $storeId = Mage::app()->getStore()->getStoreId();
117
+ }
118
+
119
+ // Healthcheck uses default query interval
120
+ if(Springbot_Util_Timer::fire('healthcheck', $storeId) || $force) {
121
+ self::async('cmd:healthcheck', array('s' => $storeId));
122
+ }
123
+
124
+ // Send event log every minute
125
+ if(Springbot_Util_Timer::fire('event_log', $storeId, 1)) {
126
+ Springbot_Boss::scheduleJob(
127
+ 'tasks:deliverEventLog',
128
+ array('s' => $storeId),
129
+ 5,
130
+ 'default',
131
+ $storeId
132
+ );
133
+ }
134
+
135
+ // Run this in real time, but only every 30 min
136
+ if(Springbot_Util_Timer::fire('cleanup', $storeId, 30)) {
137
+ $cleanup = new Springbot_Services_Work_Cleanup();
138
+ $cleanup->run();
139
+ }
140
+ }
141
+
142
+ public static function startWorkManager()
143
+ {
144
+ $status = Mage::getModel('combine/cron_manager_status');
145
+ if (!$status->isBlocked() && !$status->isActive()) {
146
+ self::internalCallback('work:manager');
147
+ }
148
+ }
149
+
150
+ public static function haltManager($pid)
151
+ {
152
+ self::internalCallback('work:stop', array('p' => $pid));
153
+ }
154
+
155
+ public static function postItem($type, $id)
156
+ {
157
+ self::async(
158
+ "post:$id",
159
+ array('i' => $id)
160
+ );
161
+ }
162
+
163
+ public static function resumeHarvest()
164
+ {
165
+ self::async('work:manager');
166
+ }
167
+
168
+ /**
169
+ * Get PHP executable path
170
+ *
171
+ * @return string
172
+ */
173
+ public static function getPhpExec()
174
+ {
175
+ if(!isset(self::$_phpExec)) {
176
+ try {
177
+ $php = Mage::getStoreConfig('springbot/config/php_exec');
178
+
179
+ if((empty($php))) {
180
+ // This prevents the system command from outputting to apache
181
+ ob_start();
182
+ if(empty($php) || !file_exists($php)) {
183
+ $php = self::spawn('which php5 2> /dev/null');
184
+ }
185
+ if(empty($php) || !file_exists($php)) {
186
+ $php = self::spawn('which php 2> /dev/null');
187
+ }
188
+ if(empty($php) || !file_exists($php)) {
189
+ $php = 'php';
190
+ }
191
+ ob_end_clean();
192
+ }
193
+ self::$_phpExec = $php;
194
+ }
195
+ catch (Exception $e) {
196
+ return '';
197
+ }
198
+ }
199
+ return self::$_phpExec;
200
+ }
201
+ }
app/code/community/Springbot/Combine/Helper/Data.php CHANGED
@@ -45,12 +45,12 @@ class Springbot_Combine_Helper_Data extends Mage_Core_Helper_Abstract
45
 
46
  public function checkCredentials($email = null, $password = null)
47
  {
48
- $return = array('valid' => false);
49
-
50
  try {
 
51
  $this->requestSecurityToken($email, $password, true);
52
  $return['valid'] = true;
53
- } catch (Exception $e) {
 
54
  $return['message'] = $e->getMessage();
55
  }
56
  return $return;
@@ -75,12 +75,13 @@ class Springbot_Combine_Helper_Data extends Mage_Core_Helper_Abstract
75
 
76
  protected function _resolvePassword($email = null, $password = null)
77
  {
78
- if(is_null($email) || is_null($password)) {
79
  $payload = array(
80
  'user_id' => Mage::getStoreConfig('springbot/config/account_email'),
81
  'password' => Mage::helper('core')->decrypt(Mage::getStoreConfig('springbot/config/account_password')),
82
  );
83
- } else {
 
84
  $payload = array(
85
  'user_id' => $email,
86
  'password' => $password,
@@ -203,53 +204,32 @@ class Springbot_Combine_Helper_Data extends Mage_Core_Helper_Abstract
203
  );
204
  }
205
 
206
- public function getSpringbotErrorLog()
207
- {
208
- return Mage::getBaseDir('log') . DS . Springbot_Log::ERRFILE;
209
- }
210
-
211
- public function getSpringbotLog()
212
- {
213
- return Mage::getBaseDir('log') . DS . Springbot_Log::LOGFILE;
214
- }
215
-
216
- public function isEmpty($obj)
217
- {
218
- return count((array) $obj) == 0;
219
- }
220
-
221
- public function nohup()
222
- {
223
- return Mage::getStoreConfig('springbot/advanced/nohup') ? 'nohup' : '';
224
- }
225
-
226
- public function nice()
227
- {
228
- return Mage::getStoreConfig('springbot/advanced/nice') ? 'nice' : '';
229
- }
230
-
231
  public function getLogContents($logName)
232
  {
233
  $maxRecSize = 65536;
234
- if (empty($logName)) {
235
- $fullFilename = Mage::getBaseDir('log') . DS . Springbot_Log::LOGFILE;
236
- } else {
237
- $fullFilename = Mage::getBaseDir('log') . DS . str_replace('../', '', $logName);
238
- }
 
 
 
239
 
240
  $buffer = '';
241
- if(file_exists($fullFilename)) {
242
  if (($fHandle = fopen($fullFilename, 'r')) !== FALSE) {
243
- $fSize = filesize($fullFilename)/1024;
244
  if ($fSize > 32) {
245
  fseek($fHandle, 1024*($fSize-32));
246
  }
247
  while (!feof($fHandle)) {
248
  $buffer .= fgets($fHandle,$maxRecSize) . ' ';
249
  }
250
- fclose ($fHandle);
251
- } else {
252
- $buffer='Open failed on '.$fullFilename;
 
253
  }
254
  }
255
  return $buffer;
45
 
46
  public function checkCredentials($email = null, $password = null)
47
  {
 
 
48
  try {
49
+ $return = array('valid' => false);
50
  $this->requestSecurityToken($email, $password, true);
51
  $return['valid'] = true;
52
+ }
53
+ catch (Exception $e) {
54
  $return['message'] = $e->getMessage();
55
  }
56
  return $return;
75
 
76
  protected function _resolvePassword($email = null, $password = null)
77
  {
78
+ if (is_null($email) || is_null($password)) {
79
  $payload = array(
80
  'user_id' => Mage::getStoreConfig('springbot/config/account_email'),
81
  'password' => Mage::helper('core')->decrypt(Mage::getStoreConfig('springbot/config/account_password')),
82
  );
83
+ }
84
+ else {
85
  $payload = array(
86
  'user_id' => $email,
87
  'password' => $password,
204
  );
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  public function getLogContents($logName)
208
  {
209
  $maxRecSize = 65536;
210
+
211
+ if (empty($logName)) {
212
+ $fullFilename = Springbot_Log::getSpringbotLog();
213
+ }
214
+ else {
215
+ // Remove directory traversals for security
216
+ $fullFilename = Mage::getBaseDir('log') . DS . str_replace('../', '', $logName);
217
+ }
218
 
219
  $buffer = '';
220
+ if (file_exists($fullFilename)) {
221
  if (($fHandle = fopen($fullFilename, 'r')) !== FALSE) {
222
+ $fSize = filesize($fullFilename) / 1024;
223
  if ($fSize > 32) {
224
  fseek($fHandle, 1024*($fSize-32));
225
  }
226
  while (!feof($fHandle)) {
227
  $buffer .= fgets($fHandle,$maxRecSize) . ' ';
228
  }
229
+ fclose($fHandle);
230
+ }
231
+ else {
232
+ $buffer = 'Open failed on '.$fullFilename;
233
  }
234
  }
235
  return $buffer;
app/code/community/Springbot/Combine/Helper/Harvest.php CHANGED
@@ -5,7 +5,6 @@ class Springbot_Combine_Helper_Harvest extends Mage_Core_Helper_Abstract
5
  protected $_ignores;
6
  protected $_defines;
7
  protected $_rulesBuilt = false;
8
- protected $_phpExec;
9
  protected $_harvestId;
10
 
11
  public function initRemoteHarvest($id)
@@ -63,39 +62,6 @@ class Springbot_Combine_Helper_Harvest extends Mage_Core_Helper_Abstract
63
  return !empty($output) ? $output : array($model);
64
  }
65
 
66
- /**
67
- * Get PHP executable
68
- *
69
- * @return string
70
- */
71
- public function getPhpExec()
72
- {
73
- if(!isset($this->_phpExec)) {
74
- try {
75
- $php = Mage::getStoreConfig('springbot/config/php_exec');
76
-
77
- if((empty($php))) {
78
- // This prevents the system command from outputting to apache
79
- ob_start();
80
- if(empty($php) || !file_exists($php)) {
81
- $php = Springbot_Boss::spawn('which php5 2> /dev/null');
82
- }
83
- if(empty($php) || !file_exists($php)) {
84
- $php = Springbot_Boss::spawn('which php 2> /dev/null');
85
- }
86
- if(empty($php) || !file_exists($php)) {
87
- $php = 'php';
88
- }
89
- ob_end_clean();
90
- }
91
- $this->_phpExec = $php;
92
- }
93
- catch (Exception $e) {
94
- return '';
95
- }
96
- }
97
- return $this->_phpExec;
98
- }
99
 
100
  /**
101
  * Get last collection primary id
@@ -124,7 +90,7 @@ class Springbot_Combine_Helper_Harvest extends Mage_Core_Helper_Abstract
124
  /**
125
  * Get id field name for collection
126
  *
127
- * Attepmt to get id field name (sql primary key) for collection through
128
  * existing methods, then failing over to inspecting an the resource itself.
129
  * Mainly done this way for subscribers.
130
  *
@@ -176,7 +142,7 @@ class Springbot_Combine_Helper_Harvest extends Mage_Core_Helper_Abstract
176
  $sampleSize = self::getSampleSize();
177
  $reverseSample = self::getReverseSample();
178
 
179
- $size = is_null($segmentSize) ? $this->_getMaxSegmentSize() : $segmentSize;
180
  $segments = array();
181
 
182
  // If getting just a sample of each entity, get the $sampleSize most recent entities
@@ -306,9 +272,7 @@ class Springbot_Combine_Helper_Harvest extends Mage_Core_Helper_Abstract
306
  array(
307
  'n' => $file->getBaseFilename(),
308
  'm' => $method,
309
- ),
310
- 0,
311
- 'listener'
312
  );
313
  }
314
 
@@ -427,7 +391,7 @@ class Springbot_Combine_Helper_Harvest extends Mage_Core_Helper_Abstract
427
  $this->_rulesBuilt = true;
428
  }
429
 
430
- protected function _getMaxSegmentSize()
431
  {
432
  $size = Mage::getStoreConfig('springbot/config/segment_size');
433
  return $size ? $size : 100;
5
  protected $_ignores;
6
  protected $_defines;
7
  protected $_rulesBuilt = false;
 
8
  protected $_harvestId;
9
 
10
  public function initRemoteHarvest($id)
62
  return !empty($output) ? $output : array($model);
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  /**
67
  * Get last collection primary id
90
  /**
91
  * Get id field name for collection
92
  *
93
+ * Attempt to get id field name (sql primary key) for collection through
94
  * existing methods, then failing over to inspecting an the resource itself.
95
  * Mainly done this way for subscribers.
96
  *
142
  $sampleSize = self::getSampleSize();
143
  $reverseSample = self::getReverseSample();
144
 
145
+ $size = is_null($segmentSize) ? $this->getSegmentSize() : $segmentSize;
146
  $segments = array();
147
 
148
  // If getting just a sample of each entity, get the $sampleSize most recent entities
272
  array(
273
  'n' => $file->getBaseFilename(),
274
  'm' => $method,
275
+ ), 0, 'listener'
 
 
276
  );
277
  }
278
 
391
  $this->_rulesBuilt = true;
392
  }
393
 
394
+ protected function getSegmentSize()
395
  {
396
  $size = Mage::getStoreConfig('springbot/config/segment_size');
397
  return $size ? $size : 100;
app/code/community/Springbot/Combine/Helper/Parser.php CHANGED
@@ -76,10 +76,9 @@ class Springbot_Combine_Helper_Parser extends Mage_Core_Helper_Abstract
76
  }
77
  }
78
 
79
- public function isAccessible($product)
80
  {
81
  return
82
- ($product instanceof Mage_Catalog_Model_Product) &&
83
  !(
84
  $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ||
85
  $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
@@ -138,7 +137,11 @@ class Springbot_Combine_Helper_Parser extends Mage_Core_Helper_Abstract
138
  $code = $attribute->getAttributeCode();
139
 
140
  if($attribute->usesSource()) {
141
- $value = $product->getAttributeText($code);
 
 
 
 
142
  } else {
143
  $value = $product->getData($code);
144
  }
@@ -198,16 +201,21 @@ class Springbot_Combine_Helper_Parser extends Mage_Core_Helper_Abstract
198
  $img->resize($size);
199
  }
200
  return (string) $img;
201
- } else if(($image = $product->getImage()) != 'no_selection' && $image ) {
 
202
  // main
203
- } else if(($image = $product->getSmallImage()) != 'no_selection' && $image ) {
 
204
  // small
205
- } else if(($image = $product->getThumbnail()) != 'no_selection' && $image ) {
 
206
  // thumbnail
207
- } else if ($product->getMediaGalleryImages() && $product->getMediaGalleryImages()->getSize() > 0) {
 
208
  // First item from gallery
209
- $image = $product->getMediaGalleryImages()->getFirstItem()->getUrl();
210
- } else {
 
211
  // if all else fails, build cached image
212
  return null;
213
  }
76
  }
77
  }
78
 
79
+ public function isAccessible(Mage_Catalog_Model_Product $product)
80
  {
81
  return
 
82
  !(
83
  $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ||
84
  $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
137
  $code = $attribute->getAttributeCode();
138
 
139
  if($attribute->usesSource()) {
140
+ try {
141
+ $value = $product->getAttributeText($code);
142
+ } catch (Mage_Eav $e) {
143
+ Springbot_Log::debug($e->getMessage());
144
+ }
145
  } else {
146
  $value = $product->getData($code);
147
  }
201
  $img->resize($size);
202
  }
203
  return (string) $img;
204
+ }
205
+ else if(($image = $product->getImage()) != 'no_selection' && $image ) {
206
  // main
207
+ }
208
+ else if(($image = $product->getSmallImage()) != 'no_selection' && $image ) {
209
  // small
210
+ }
211
+ else if(($image = $product->getThumbnail()) != 'no_selection' && $image ) {
212
  // thumbnail
213
+ }
214
+ else if ($product->getMediaGalleryImages() && $product->getMediaGalleryImages()->getSize() > 0) {
215
  // First item from gallery
216
+ return $product->getMediaGalleryImages()->getFirstItem()->getUrl();
217
+ }
218
+ else {
219
  // if all else fails, build cached image
220
  return null;
221
  }
app/code/community/Springbot/Combine/Helper/Redirect.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class Springbot_Combine_Helper_Redirect extends Mage_Core_Helper_Abstract
4
  {
5
- const COOKIE_NAME = 'springbot_redirect_queue';
6
 
7
  public function insertRedirectIds($params, $ids = null)
8
  {
@@ -40,7 +39,7 @@ class Springbot_Combine_Helper_Redirect extends Mage_Core_Helper_Abstract
40
  public function checkTable($table)
41
  {
42
  if(!Mage::getSingleton('core/resource')->getConnection('core_read')->showTableStatus($table)) {
43
- Mage::logException(new Exception("{$table} table does not exist. Rerunning Springbot update 1.0.0.70->1.2.0.0."));
44
  $setup = new Springbot_Combine_Model_Resource_Setup('combine_setup');
45
  $setup->reinstallSetupScript('1.0.0.70', '1.2.0.0');
46
  return true;
@@ -113,7 +112,7 @@ class Springbot_Combine_Helper_Redirect extends Mage_Core_Helper_Abstract
113
 
114
  public function getRawCookie()
115
  {
116
- return Mage::getModel('core/cookie')->get(self::COOKIE_NAME);
117
  }
118
 
119
  public function hasRedirectId()
2
 
3
  class Springbot_Combine_Helper_Redirect extends Mage_Core_Helper_Abstract
4
  {
 
5
 
6
  public function insertRedirectIds($params, $ids = null)
7
  {
39
  public function checkTable($table)
40
  {
41
  if(!Mage::getSingleton('core/resource')->getConnection('core_read')->showTableStatus($table)) {
42
+ Springbot_Log::error("{$table} table does not exist. Rerunning Springbot update 1.0.0.70->1.2.0.0.");
43
  $setup = new Springbot_Combine_Model_Resource_Setup('combine_setup');
44
  $setup->reinstallSetupScript('1.0.0.70', '1.2.0.0');
45
  return true;
112
 
113
  public function getRawCookie()
114
  {
115
+ return Mage::getModel('core/cookie')->get(Springbot_Boss::COOKIE_NAME);
116
  }
117
 
118
  public function hasRedirectId()
app/code/community/Springbot/Combine/Helper/Trackable.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class Springbot_Combine_Helper_Trackable extends Mage_Core_Helper_Abstract
4
  {
5
- const SB_COOKIE = '_sbtk';
6
 
7
  public function getTrackables()
8
  {
@@ -10,9 +9,15 @@ class Springbot_Combine_Helper_Trackable extends Mage_Core_Helper_Abstract
10
  return json_decode(base64_decode($sbCookie));
11
  }
12
 
13
- public function getCookie()
14
  {
15
- return Mage::getModel('core/cookie')->get(self::SB_COOKIE);
 
 
 
 
 
 
16
  }
17
 
18
  public function hasTrackables()
@@ -21,45 +26,36 @@ class Springbot_Combine_Helper_Trackable extends Mage_Core_Helper_Abstract
21
  return !empty($sb);
22
  }
23
 
24
- public function addTrackable($customerEmail, $type, $value, $quoteId, $customerId) {
25
- $model = Mage::getModel('combine/trackable');
26
- $model->setData(
27
- array(
28
- 'email' => $customerEmail,
29
- 'type' => $type,
30
- 'value' => $value,
31
- 'quote_id' => $quoteId,
32
- 'customer_id' => $customerId
33
- )
34
- );
35
- $model->createOrUpdate();
36
  }
37
 
38
  public function getTrackablesHashByOrder($orderId)
39
  {
40
- $collection = Mage::getModel('combine/trackable')->getCollection()
41
- ->addFieldToFilter('order_id', $orderId);
42
-
43
  return $this->_buildHash($collection);
44
  }
45
 
46
  public function getTrackablesHashByQuote($quoteId)
47
  {
48
- $collection = Mage::getModel('combine/trackable')->getCollection()
49
- ->addFieldToFilter('quote_id', $quoteId);
50
-
51
  return $this->_buildHash($collection);
52
  }
53
 
 
 
 
 
 
 
54
  protected function _buildHash($collection)
55
  {
56
  $hash = new stdClass();
57
-
58
- foreach($collection as $item) {
59
  $hash->{$item->getType()} = $item->getValue();
60
  }
61
-
62
- if(!Mage::helper('combine')->isEmpty($hash)) {
63
  return $hash;
64
  }
65
  }
2
 
3
  class Springbot_Combine_Helper_Trackable extends Mage_Core_Helper_Abstract
4
  {
 
5
 
6
  public function getTrackables()
7
  {
9
  return json_decode(base64_decode($sbCookie));
10
  }
11
 
12
+ public function updateTrackables($order)
13
  {
14
+ $quoteId = $order->getQuoteId();
15
+
16
+ foreach($this->getTrackablesForQuote($quoteId) as $trackable) {
17
+ $trackable->setOrderId($order->getId())
18
+ ->setCustomerId($order->getCustomerId())
19
+ ->save();
20
+ }
21
  }
22
 
23
  public function hasTrackables()
26
  return !empty($sb);
27
  }
28
 
29
+ public function getCookie()
30
+ {
31
+ return Mage::getModel('core/cookie')->get(Springbot_Boss::SB_TRACKABLES_COOKIE);
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  public function getTrackablesHashByOrder($orderId)
35
  {
36
+ $collection = $this->getTrackablesForQuote($order->getQuote->getId());
 
 
37
  return $this->_buildHash($collection);
38
  }
39
 
40
  public function getTrackablesHashByQuote($quoteId)
41
  {
42
+ $collection = $this->getTrackablesForQuote($quoteId);
 
 
43
  return $this->_buildHash($collection);
44
  }
45
 
46
+ public function getTrackablesForQuote($quoteId)
47
+ {
48
+ return Mage::getModel('combine/trackable')->getCollection()
49
+ ->addFieldToFilter('quote_id', $quoteId);
50
+ }
51
+
52
  protected function _buildHash($collection)
53
  {
54
  $hash = new stdClass();
55
+ foreach ($collection as $item) {
 
56
  $hash->{$item->getType()} = $item->getValue();
57
  }
58
+ if (count((array) $hash) > 0) {
 
59
  return $hash;
60
  }
61
  }
app/code/community/Springbot/Combine/Model/Action.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Combine_Model_Action extends Springbot_Combine_Model_Cron
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('combine/action');
8
+ }
9
+
10
+ public function toAction()
11
+ {
12
+ $actionMethod = "_{$this->getType()}ToAction";
13
+ return $this->{$actionMethod}();
14
+ }
15
+
16
+ public function isValidView()
17
+ {
18
+ return ($this->getType() == 'view') && $this->hasSku();
19
+ }
20
+
21
+ protected function _viewToAction()
22
+ {
23
+ return array(
24
+ 'action' => $this->getType(),
25
+ 'page_url' => $this->getPageUrl(),
26
+ 'sku' => $this->getSku(),
27
+ 'visitor_ip' => $this->getVisitorIp(),
28
+ 'category_id' => $this->getCategoryId(),
29
+ 'store_id' => $this->getStoreId(),
30
+ 'quantity' => $this->getQuantity(),
31
+ 'datetime' => $this->getCreatedAt(),
32
+ );
33
+ }
34
+
35
+ protected function _atcToAction()
36
+ {
37
+ return array(
38
+ 'action' => $this->getType(),
39
+ 'sku' => $this->getSku(),
40
+ 'sku_fulfillment' => $this->getSkuFulfillment(),
41
+ 'quote_id' => $this->getQuoteId(),
42
+ 'category_id' => $this->getCategoryId(),
43
+ 'store_id' => $this->getStoreId(),
44
+ 'quantity' => $this->getQuantity(),
45
+ 'datetime' => $this->getCreatedAt(),
46
+ );
47
+ }
48
+
49
+ protected function _purchaseToAction()
50
+ {
51
+ return array(
52
+ 'action' => $this->getType(),
53
+ 'sku' => $this->getSku(),
54
+ 'sku_fulfillment' => $this->getSkuFulfillment(),
55
+ 'purchase_id' => $this->getPurchaseId(),
56
+ 'category_id' => $this->getCategoryId(),
57
+ 'store_id' => $this->getStoreId(),
58
+ 'quantity' => $this->getQuantity(),
59
+ 'datetime' => $this->getCreatedAt(),
60
+ );
61
+ }
62
+ }
app/code/community/Springbot/Combine/Model/Api.php CHANGED
@@ -14,7 +14,7 @@ class Springbot_Combine_Model_Api extends Varien_Object
14
  protected $_retries = 0;
15
  protected $_requestStart;
16
 
17
- public function wrap($model, array $data)
18
  {
19
  $transport = new stdClass();
20
  $transport->$model = $data;
14
  protected $_retries = 0;
15
  protected $_requestStart;
16
 
17
+ public function wrap($model, $data)
18
  {
19
  $transport = new stdClass();
20
  $transport->$model = $data;
app/code/community/Springbot/Combine/Model/{Abstract.php → Cron.php} RENAMED
@@ -1,26 +1,25 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Abstract extends Mage_Core_Model_Abstract
4
  {
5
- /**
6
- * Insert ignore into collection
7
- */
 
 
8
  public function insertIgnore()
9
  {
10
  try {
11
  if($this->_validate()) {
12
  $this->_getResource()->insertIgnore($this);
13
  }
14
- } catch(Exception $e) {
 
15
  $this->_getResource()->rollBack();
16
  Springbot_Log::error($e);
17
  }
18
-
19
  return $this;
20
  }
21
 
22
- protected function _validate()
23
- {
24
- return true;
25
- }
26
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Cron extends Mage_Core_Model_Abstract
4
  {
5
+ protected function _validate()
6
+ {
7
+ return true;
8
+ }
9
+
10
  public function insertIgnore()
11
  {
12
  try {
13
  if($this->_validate()) {
14
  $this->_getResource()->insertIgnore($this);
15
  }
16
+ }
17
+ catch(Exception $e) {
18
  $this->_getResource()->rollBack();
19
  Springbot_Log::error($e);
20
  }
 
21
  return $this;
22
  }
23
 
24
+
 
 
 
25
  }
app/code/community/Springbot/Combine/Model/Cron/Count.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Cron_Count extends Springbot_Combine_Model_Abstract
4
  {
5
  public function _construct()
6
  {
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Cron_Count extends Springbot_Combine_Model_Cron
4
  {
5
  public function _construct()
6
  {
app/code/community/Springbot/Combine/Model/Cron/Manager/Status.php CHANGED
@@ -14,8 +14,12 @@ class Springbot_Combine_Model_Cron_Manager_Status extends Varien_Object
14
  }
15
  else {
16
  $filename = Mage::getBaseDir('tmp') . DS . Springbot_Services_Work_Manager::WORKMANAGER_FILENAME;
17
- list($pid, $startTime) = explode('-', file_get_contents($filename));
18
- return ((time() - $startTime) < Springbot_Services_Work_Manager::WORKER_TIMEOUT);
 
 
 
 
19
  }
20
  }
21
 
@@ -24,7 +28,7 @@ class Springbot_Combine_Model_Cron_Manager_Status extends Varien_Object
24
  if($this->isActive()) {
25
  Springbot_Log::debug('Work manager active, halting');
26
  $this->issueWorkBlocker();
27
- $this->haltManager();
28
  } else {
29
  Springbot_Log::debug('Work manager inactive, starting');
30
  $this->removeWorkBlocker();
@@ -37,10 +41,6 @@ class Springbot_Combine_Model_Cron_Manager_Status extends Varien_Object
37
  return file_exists($this->_getBlockFile());
38
  }
39
 
40
- public function haltManager()
41
- {
42
- Springbot_Boss::internalCallback('work:stop', array('p' => $this->getPid()));
43
- }
44
 
45
  public function issueWorkBlocker()
46
  {
14
  }
15
  else {
16
  $filename = Mage::getBaseDir('tmp') . DS . Springbot_Services_Work_Manager::WORKMANAGER_FILENAME;
17
+ if(file_exists($filename)) {
18
+ list($pid, $startTime) = explode('-', file_get_contents($filename));
19
+ return ((time() - $startTime) < Springbot_Services_Work_Manager::WORKER_TIMEOUT);
20
+ } else {
21
+ return false;
22
+ }
23
  }
24
  }
25
 
28
  if($this->isActive()) {
29
  Springbot_Log::debug('Work manager active, halting');
30
  $this->issueWorkBlocker();
31
+ $this->haltManager($this->getPid());
32
  } else {
33
  Springbot_Log::debug('Work manager inactive, starting');
34
  $this->removeWorkBlocker();
41
  return file_exists($this->_getBlockFile());
42
  }
43
 
 
 
 
 
44
 
45
  public function issueWorkBlocker()
46
  {
app/code/community/Springbot/Combine/Model/Cron/Queue.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Cron_Queue extends Springbot_Combine_Model_Abstract
4
  {
5
  const FAILED_JOB_PRIORITY = 9;
6
 
@@ -30,26 +30,28 @@ class Springbot_Combine_Model_Cron_Queue extends Springbot_Combine_Model_Abstrac
30
  'attempts' => $this->getAttempts() + 1,
31
  'run_at' => now(),
32
  'locked_at' => now(),
33
- 'locked_by' => getmypid(),
34
- 'error' => null
 
35
  ));
36
  $this->save();
37
  }
38
 
39
  public function run()
40
  {
41
- Springbot_Log::debug("Running ".__CLASS__);
42
- $return = true;
43
- $class = $this->getInstance();
44
- $class->setData($this->getParsedArgs());
45
- $this->_pre();
46
-
47
  try {
 
 
 
 
 
48
  $class->run();
49
- } catch (Exception $e) {
 
50
  $this->setError($e->getMessage());
51
  // Lower priority for failed job - keeping order intact
52
- $this->setPriority($this->getPriority() + Springbot_Services_Priority::FAILED);
 
53
  $return = false;
54
  if ($this->getAttempts() >= Springbot_Combine_Model_Resource_Cron_Queue_Collection::ATTEMPT_LIMIT) {
55
  Springbot_Log::remote(
@@ -63,11 +65,22 @@ class Springbot_Combine_Model_Cron_Queue extends Springbot_Combine_Model_Abstrac
63
  return $return;
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
66
  protected function _post()
67
  {
68
  if(!$this->hasError()) {
69
  $this->delete();
70
- } else {
 
71
  $this->addData(array(
72
  'locked_at' => null,
73
  'locked_by' => null,
@@ -85,5 +98,4 @@ class Springbot_Combine_Model_Cron_Queue extends Springbot_Combine_Model_Abstrac
85
  $args = (array) json_decode($this->getArgs());
86
  return Springbot_Services_Registry::parseOpts($args);
87
  }
88
-
89
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Cron_Queue extends Springbot_Combine_Model_Cron
4
  {
5
  const FAILED_JOB_PRIORITY = 9;
6
 
30
  'attempts' => $this->getAttempts() + 1,
31
  'run_at' => now(),
32
  'locked_at' => now(),
33
+ 'locked_by' => getmypid(),
34
+ 'next_run_at' => null,
35
+ 'error' => null
36
  ));
37
  $this->save();
38
  }
39
 
40
  public function run()
41
  {
 
 
 
 
 
 
42
  try {
43
+ Springbot_Log::debug("Running ".__CLASS__);
44
+ $return = true;
45
+ $class = $this->getInstance();
46
+ $class->setData($this->getParsedArgs());
47
+ $this->_pre();
48
  $class->run();
49
+ }
50
+ catch (Exception $e) {
51
  $this->setError($e->getMessage());
52
  // Lower priority for failed job - keeping order intact
53
+ $this->setPriority($this->getPriority() + Springbot_Services::FAILED);
54
+ $this->setNextRunAt($this->_calculateNextRunAt());
55
  $return = false;
56
  if ($this->getAttempts() >= Springbot_Combine_Model_Resource_Cron_Queue_Collection::ATTEMPT_LIMIT) {
57
  Springbot_Log::remote(
65
  return $return;
66
  }
67
 
68
+ protected function _calculateNextRunAt()
69
+ {
70
+ $attempts = $this->getAttempts();
71
+ $expMinutes = pow(2, $attempts);
72
+ $nextRun = date("Y-m-d H:i:s", strtotime("+$expMinutes minutes"));
73
+
74
+ Springbot_Log::debug('Next run at: ' . $nextRun);
75
+ return $nextRun;
76
+ }
77
+
78
  protected function _post()
79
  {
80
  if(!$this->hasError()) {
81
  $this->delete();
82
+ }
83
+ else {
84
  $this->addData(array(
85
  'locked_at' => null,
86
  'locked_by' => null,
98
  $args = (array) json_decode($this->getArgs());
99
  return Springbot_Services_Registry::parseOpts($args);
100
  }
 
101
  }
app/code/community/Springbot/Combine/Model/Cron/Queue/Batch.php CHANGED
@@ -26,7 +26,6 @@ class Springbot_Combine_Model_Cron_Queue_Batch extends Varien_Object
26
  $rows = $this->_getWriter()->exec($sql);
27
  }
28
  Springbot_Log::info("{$rows} rows inserted");
29
- Springbot_Boss::startWorkManager();
30
  }
31
 
32
  public function push($args)
26
  $rows = $this->_getWriter()->exec($sql);
27
  }
28
  Springbot_Log::info("{$rows} rows inserted");
 
29
  }
30
 
31
  public function push($args)
app/code/community/Springbot/Combine/Model/Cron/Queue/Batch/Row.php CHANGED
@@ -3,13 +3,13 @@
3
  class Springbot_Combine_Model_Cron_Queue_Batch_Row extends Varien_Object
4
  {
5
  protected $_schema = array(
6
- 'method',
7
- 'args',
8
- 'priority',
9
- 'command_hash',
10
- 'queue',
11
- 'store_id',
12
- );
13
 
14
  public function getSchema()
15
  {
@@ -24,8 +24,8 @@ class Springbot_Combine_Model_Cron_Queue_Batch_Row extends Varien_Object
24
  public function __toString()
25
  {
26
  $res = $this->_getResource();
27
-
28
- foreach($this->getSchema() as $column) {
29
  $value = $this->getData($column);
30
  $quoted[] = !empty($value) ? $res->quote($value) : 'NULL';
31
  }
3
  class Springbot_Combine_Model_Cron_Queue_Batch_Row extends Varien_Object
4
  {
5
  protected $_schema = array(
6
+ 'method',
7
+ 'args',
8
+ 'priority',
9
+ 'command_hash',
10
+ 'queue',
11
+ 'store_id',
12
+ );
13
 
14
  public function getSchema()
15
  {
24
  public function __toString()
25
  {
26
  $res = $this->_getResource();
27
+ $quoted = array();
28
+ foreach ($this->getSchema() as $column) {
29
  $value = $this->getData($column);
30
  $quoted[] = !empty($value) ? $res->quote($value) : 'NULL';
31
  }
app/code/community/Springbot/Combine/Model/Cron/Worker.php CHANGED
@@ -15,14 +15,12 @@ class Springbot_Combine_Model_Cron_Worker extends Mage_Core_Model_Abstract
15
  }
16
  else {
17
  $count = 0;
18
- $sleepInterval = $this->getSleepInterval();
19
  $maxJobs = $this->getMaxJobs();
20
  do {
21
  if($job = $this->getNextJob($isForeman)) {
22
  Springbot_Log::debug("Running job #$count for pid => " . getmypid());
23
  $job->run();
24
  $count++;
25
- sleep($sleepInterval);
26
  } else {
27
  Springbot_Log::debug("No more jobs found");
28
  }
@@ -43,14 +41,6 @@ class Springbot_Combine_Model_Cron_Worker extends Mage_Core_Model_Abstract
43
  }
44
  }
45
 
46
- public function getSleepInterval()
47
- {
48
- if (!$sleepInterval = Mage::getStoreConfig('springbot/advanced/sleep_interval')) {
49
- $sleepInterval = 1;
50
- }
51
- return $sleepInterval;
52
- }
53
-
54
  public function getMaxJobs()
55
  {
56
  if (!$maxJobs = Mage::getStoreConfig('springbot/cron/max_jobs')) {
15
  }
16
  else {
17
  $count = 0;
 
18
  $maxJobs = $this->getMaxJobs();
19
  do {
20
  if($job = $this->getNextJob($isForeman)) {
21
  Springbot_Log::debug("Running job #$count for pid => " . getmypid());
22
  $job->run();
23
  $count++;
 
24
  } else {
25
  Springbot_Log::debug("No more jobs found");
26
  }
41
  }
42
  }
43
 
 
 
 
 
 
 
 
 
44
  public function getMaxJobs()
45
  {
46
  if (!$maxJobs = Mage::getStoreConfig('springbot/cron/max_jobs')) {
app/code/community/Springbot/Combine/Model/Harvest.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Springbot_Combine_Model_Harvest
4
+ {
5
+ abstract public function getMageModel();
6
+ abstract public function getParserModel();
7
+ abstract public function getApiController();
8
+ abstract public function getApiModel();
9
+
10
+ private $_api;
11
+ private $_collection;
12
+ private $_model;
13
+ private $_total = 0;
14
+ private $_segmentQueue = array();
15
+ private $_segmentSize = 250;
16
+ private $_segmentMin = 0;
17
+ private $_segmentMax = 0;
18
+ private $_delete = false;
19
+ private $_storeId = null;
20
+ private $_dataSource;
21
+
22
+
23
+ public function __construct(Springbot_Combine_Model_Api $api, Varien_Data_Collection $collection, $dataSource)
24
+ {
25
+ $this->_api = $api;
26
+ $this->_collection = $collection;
27
+ $this->_dataSource = $dataSource;
28
+ }
29
+
30
+ /**
31
+ * Return the row name for the given
32
+ *
33
+ * @return string the name of the unique id column for the entity
34
+ */
35
+ public function getRowId()
36
+ {
37
+ return 'entity_id';
38
+ }
39
+
40
+ /**
41
+ * Iterate through all entities inn the collection and call the step() method
42
+ * which will post the JSON entities to the API.
43
+ *
44
+ * @return Springbot_Combine_Model_Harvest
45
+ */
46
+ public function harvest()
47
+ {
48
+ //if ($this->getCollection()->getCount()) {
49
+ Mage::getSingleton('core/resource_iterator')->walk(
50
+ $this->getCollection()->getSelect(),
51
+ array(array($this, 'step'))
52
+ );
53
+
54
+ // Post leftover segment
55
+ $this->_total += count($this->_segmentQueue);
56
+ $this->postSegment();
57
+ //}
58
+
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Set delete param for all records
64
+ *
65
+ * @return Springbot_Combine_Model_Harvest
66
+ */
67
+ public function delete()
68
+ {
69
+ $this->_delete = true;
70
+ return $this->harvest();
71
+ }
72
+
73
+ /**
74
+ * Post single defined model
75
+ *
76
+ * We must post as a single element in array to handle downstream
77
+ * formatting concerns.
78
+ *
79
+ * @param Mage_Core_Model_Abstract $model
80
+ */
81
+ public function post($model)
82
+ {
83
+ $parsed = array($this->parse($model)->getData());
84
+ $payload = $this->getApi()->wrap($this->getApiModel(), $parsed);
85
+ $this->getApi()->reinit()->call($this->getApiController(), $payload);
86
+ }
87
+
88
+ /**
89
+ * Push a model onto the segment queue
90
+ *
91
+ * @param Mage_Core_Model_Abstract $model
92
+ * @return Springbot_Combine_Model_Harvest_Abstract
93
+ */
94
+ public function push(Mage_Core_Model_Abstract $model)
95
+ {
96
+ $this->_segmentQueue[] = $this->parse($model);
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * Step callback referenced in harvester. Posts the segment (limited by the
102
+ * defined segment size)
103
+ *
104
+ * @param array $args
105
+ */
106
+ public function step($args)
107
+ {
108
+ if (count($this->_segmentQueue) >= $this->getSegmentSize()) {
109
+ $this->_total += $this->getSegmentSize();
110
+ $this->postSegment();
111
+ }
112
+
113
+ try {
114
+ if (isset($args['row'])) {
115
+ $id = $this->_getRowId($args['row']);
116
+ $model = $this->loadMageModel($id);
117
+ $this->_segmentQueue[] = $this->parse($model);
118
+ }
119
+ }
120
+ catch (Exception $e) {
121
+ Springbot_Log::error($e);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Parse caller for dependent parser method
127
+ *
128
+ * @param Mage_Core_Model_Abstract $model
129
+ * @return Zend_Json_Expr
130
+ */
131
+ public function parse($model)
132
+ {
133
+ $parser = Mage::getModel($this->getParserModel(), $model);
134
+ if ($this->getStoreId()) {
135
+ $parser->setMageStoreId($this->getStoreId());
136
+ }
137
+ $parser->setDataSource($this->getDataSource());
138
+ if($this->_delete) {
139
+ $parser->setIsDeleted(true);
140
+ }
141
+ return $parser->getData();
142
+ }
143
+
144
+ /**
145
+ * Loads mage model to parse
146
+ *
147
+ * @param int $entityId
148
+ * @return Mage_Core_Model_Abstract
149
+ */
150
+ public function loadMageModel($entityId)
151
+ {
152
+ if(!isset($this->_model)) {
153
+ $this->_model = Mage::getModel($this->getMageModel());
154
+ }
155
+ return $this->_model->load($entityId);
156
+ }
157
+
158
+ /**
159
+ * Post segment to api
160
+ *
161
+ */
162
+ public function postSegment()
163
+ {
164
+ if (count($this->_segmentQueue) > 0) {
165
+ $payload = $this->getApi()->wrap($this->getApiModel(), $this->_segmentQueue);
166
+ $this->getApi()->reinit()->call($this->getApiController(), $payload);
167
+ $this->_segmentQueue = array();
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Set the current store id
173
+ *
174
+ * @param int $id
175
+ */
176
+ public function setStoreId($id)
177
+ {
178
+ $this->_storeId = $id;
179
+ return $this;
180
+ }
181
+
182
+ public function getDataSource()
183
+ {
184
+ return $this->_dataSource;
185
+ }
186
+
187
+ public function setDelete($bool)
188
+ {
189
+ $this->_delete = $bool;
190
+ return $this;
191
+ }
192
+
193
+ public function getDelete()
194
+ {
195
+ return $this->_delete;
196
+ }
197
+
198
+ public function getHarvesterName()
199
+ {
200
+ return ucfirst($this->getHarvesterName());
201
+ }
202
+
203
+ public function getCollection()
204
+ {
205
+ return $this->_collection;
206
+ }
207
+
208
+ public function getProcessedCount()
209
+ {
210
+ return $this->_total;
211
+ }
212
+
213
+ public function getSegmentMin()
214
+ {
215
+ return $this->_segmentMin;
216
+ }
217
+
218
+ public function getSegmentMax()
219
+ {
220
+ return $this->_segmentMax;
221
+ }
222
+
223
+ public function getSegmentSize()
224
+ {
225
+ return $this->_segmentSize;
226
+ }
227
+
228
+ public function getApi()
229
+ {
230
+ return $this->_api;
231
+ }
232
+
233
+ public function getStoreId()
234
+ {
235
+ return $this->_storeId;
236
+ }
237
+
238
+ /**
239
+ * Gets row id based on class config
240
+ *
241
+ * @param array $row
242
+ * @return int
243
+ */
244
+ private function _getRowId($row)
245
+ {
246
+ $id = null;
247
+ if(isset($row[$this->getRowId()])) {
248
+ $id = $row[$this->getRowId()];
249
+ $this->_setSegmentMinMax($id);
250
+ }
251
+ return $id;
252
+ }
253
+
254
+ /**
255
+ * Set min/max for current segment
256
+ *
257
+ * @param int $id
258
+ */
259
+ private function _setSegmentMinMax($id)
260
+ {
261
+ if($id < $this->_segmentMin || !$this->_segmentMin) {
262
+ $this->_segmentMin = $id;
263
+ }
264
+ if($id > $this->_segmentMax) {
265
+ $this->_segmentMax = $id;
266
+ }
267
+ }
268
+ }
app/code/community/Springbot/Combine/Model/Harvest/Abstract.php DELETED
@@ -1,308 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Combine_Model_Harvest_Abstract
4
- {
5
- protected $_collection;
6
- protected $_iterator;
7
- protected $_https;
8
- protected $_model;
9
- protected $_parser;
10
- protected $_parserModel;
11
- protected $_segmentQueue = array();
12
- protected $_total = 0;
13
- protected $_apiController;
14
- protected $_apiModel;
15
- protected $_mageModel;
16
- protected $_rowId = 'entity_id';
17
- protected $_segmentSize = 250;
18
- protected $_segmentMin = 0;
19
- protected $_segmentMax = 0;
20
- protected $_delete = false;
21
- protected $_storeId;
22
- protected $_dataSource;
23
-
24
- /**
25
- * Central controller for harvest
26
- *
27
- * @return Springbot_Combine_Model_Harvest_Abstract
28
- */
29
- public function harvest()
30
- {
31
- if($this->getCount()) {
32
- $this->_getIterator()->walk(
33
- $this->getSelect(),
34
- array(array($this, 'step'))
35
- );
36
- // Post leftover segment
37
- $this->_total += count($this->_segmentQueue);
38
- $this->postSegment();
39
- }
40
- return $this;
41
- }
42
-
43
- /**
44
- * Set delete param for all records
45
- *
46
- * @return Springbot_Combine_Model_Harvest_Abstract
47
- */
48
- public function delete()
49
- {
50
- $this->_delete = true;
51
- return $this->harvest();
52
- }
53
-
54
- /**
55
- * Post single defined model
56
- *
57
- * We must post as a single element in array to handle downstream
58
- * formatting concerns.
59
- *
60
- * @param Mage_Core_Model_Abstract $model
61
- */
62
- public function post($model)
63
- {
64
- $parsed = array($this->parse($model));
65
- $payload = $this->_getApi()->wrap($this->_getApiModel(), $parsed);
66
- $this->_getApi()->reinit()->call($this->_getApiController(), $payload);
67
- }
68
-
69
- /**
70
- * Push a model onto the segment queue
71
- *
72
- * @param Mage_Core_Model_Abstract $model
73
- * @return Springbot_Combine_Model_Harvest_Abstract
74
- */
75
- public function push($model)
76
- {
77
- unset($this->_parser); //reinit
78
- $this->setDataSource(Springbot_Boss::SOURCE_OBSERVER);
79
- $this->_segmentQueue[] = $this->parse($model);
80
- return $this;
81
- }
82
-
83
- /**
84
- * Gets row id based on class config
85
- *
86
- * @param array $row
87
- * @return int
88
- */
89
- protected function _getRowId($row)
90
- {
91
- $id = null;
92
- if(isset($row[$this->_rowId])) {
93
- $id = $row[$this->_rowId];
94
- $this->_setSegmentMinMax($id);
95
- }
96
- return $id;
97
- }
98
-
99
- /**
100
- * Set min/max for current segment
101
- *
102
- * @param int $id
103
- */
104
- protected function _setSegmentMinMax($id)
105
- {
106
- if($id < $this->_segmentMin || !$this->_segmentMin) {
107
- $this->_segmentMin = $id;
108
- }
109
- if($id > $this->_segmentMax) {
110
- $this->_segmentMax = $id;
111
- }
112
- }
113
-
114
- /**
115
- * Step callback referenced in harvester
116
- *
117
- * @param array $args
118
- */
119
- public function step($args)
120
- {
121
- if(count($this->_segmentQueue) >= $this->_getMaxSegmentSize()) {
122
- $this->_total += $this->_getMaxSegmentSize();
123
- $this->postSegment();
124
- }
125
-
126
- try {
127
- if(isset($args['row'])) {
128
- $id = $this->_getRowId($args['row']);
129
- $model = $this->loadMageModel($id);
130
- $this->_segmentQueue[] = $this->parse($model);
131
- }
132
- } catch (Exception $e) {
133
- Springbot_Log::error($e);
134
- }
135
- }
136
-
137
- /**
138
- * Parse caller for dependent parser method
139
- *
140
- * @param Mage_Core_Model_Abstract $model
141
- * @return Zend_Json_Expr
142
- */
143
- public function parse($model)
144
- {
145
- $parsed = $this->_getParser($model)->parse($model);
146
- if($this->_delete) {
147
- $parsed->setIsDeleted(true);
148
- }
149
- $parsed->setDataSource($this->getDataSource());
150
- $json = $parsed->toJson();
151
- return $parsed->getData();
152
- }
153
-
154
- /**
155
- * Loads mage model to parse
156
- *
157
- * @param int $entityId
158
- * @return Mage_Core_Model_Abstract
159
- */
160
- public function loadMageModel($entityId)
161
- {
162
- if(!isset($this->_model)) {
163
- $this->_model = Mage::getModel($this->_getMageModel());
164
- }
165
- return $this->_model->load($entityId);
166
- }
167
-
168
- /**
169
- * Post segment to api
170
- */
171
- public function postSegment()
172
- {
173
- if(count($this->_segmentQueue) > 0) {
174
- $payload = $this->_getApi()->wrap($this->_getApiModel(), $this->_segmentQueue);
175
- $this->_getApi()->reinit()->call($this->_getApiController(), $payload);
176
-
177
- $this->_clearSegment();
178
- }
179
- }
180
-
181
- protected function _clearSegment()
182
- {
183
- unset($this->_segmentQueue);
184
- }
185
-
186
- public function setStoreId($id)
187
- {
188
- $this->_storeId = $id;
189
- return $this;
190
- }
191
-
192
- public function setDataSource($source)
193
- {
194
- $this->_dataSource = $source;
195
- return $this;
196
- }
197
-
198
- public function setDelete($bool)
199
- {
200
- $this->_delete = $bool;
201
- return $this;
202
- }
203
-
204
- public function getHarvesterName()
205
- {
206
- return ucfirst($this->_apiModel);
207
- }
208
-
209
- public function getCollection()
210
- {
211
- if(!isset($this->_collection)) {
212
- throw new Exception("Collection not found!");
213
- }
214
- return $this->_collection;
215
- }
216
-
217
- public function setCollection(Varien_Data_Collection $collection)
218
- {
219
- $this->_collection = $collection;
220
- return $this;
221
- }
222
-
223
- public function getSelect()
224
- {
225
- return $this->getCollection()->getSelect();
226
- }
227
-
228
- public function getCount()
229
- {
230
- return $this->getCollection()->getSize();
231
- }
232
-
233
- public function getProcessedCount()
234
- {
235
- return $this->_total;
236
- }
237
-
238
- public function getSegmentMin()
239
- {
240
- return $this->_segmentMin;
241
- }
242
-
243
- public function getSegmentMax()
244
- {
245
- return $this->_segmentMax;
246
- }
247
-
248
- public function getDataSource()
249
- {
250
- return $this->_dataSource;
251
- }
252
-
253
- protected function _getMageModel()
254
- {
255
- if(!isset($this->_mageModel)) {
256
- throw new Exception('Please set Magento model to parse!');
257
- }
258
- return $this->_mageModel;
259
- }
260
-
261
- protected function _getParser($model)
262
- {
263
- if(!isset($this->_parserModel)) {
264
- throw new Exception('Please set parser type.');
265
- }
266
- if(!isset($this->_parser)) {
267
- $this->_parser = Mage::getModel($this->_parserModel, $model);
268
- }
269
- return $this->_parser;
270
- }
271
-
272
- protected function _getApiController()
273
- {
274
- if(!isset($this->_apiController)) {
275
- throw new Exception('Please set api controller to send to.');
276
- }
277
- return $this->_apiController;
278
- }
279
-
280
- protected function _getApiModel()
281
- {
282
- if(!isset($this->_apiModel)) {
283
- throw new Exception('Please set remote model to send to.');
284
- }
285
- return $this->_apiModel;
286
- }
287
-
288
- protected function _getMaxSegmentSize()
289
- {
290
- return $this->_segmentSize;
291
- }
292
-
293
- protected function _getApi()
294
- {
295
- if(!isset($this->_api)) {
296
- $this->_api = Mage::getModel('combine/api');
297
- }
298
- return $this->_api;
299
- }
300
-
301
- protected function _getIterator()
302
- {
303
- if(!isset($this->_iterator)) {
304
- $this->_iterator = Mage::getSingleton('core/resource_iterator');
305
- }
306
- return $this->_iterator;
307
- }
308
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Combine/Model/Harvest/AttributeSets.php CHANGED
@@ -1,24 +1,50 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_AttributeSets extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_parserModel = 'combine/parser_attributeSet';
6
- protected $_apiController = 'attribute_sets';
7
- protected $_apiModel = 'attribute_sets';
8
- protected $_rowId = 'attribute_set_id';
9
  protected $_helper;
10
 
11
- public function parse($model)
 
 
 
 
 
 
12
  {
13
- $parser = $this->_getParser($model)->setMageStoreId($this->_storeId);
14
- $parsed = $parser->parse($model);
 
 
 
 
 
15
 
16
- if($this->_delete) {
17
- $parsed->setIsDeleted(true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
- $parsed->setDataSource($this->getDataSource());
20
- $json = $parsed->toJson();
21
- return $parsed->getData();
22
  }
23
 
24
  public function loadMageModel($id)
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_AttributeSets extends Springbot_Combine_Model_Harvest
4
  {
 
 
 
 
5
  protected $_helper;
6
 
7
+
8
+ public function getMageModel()
9
+ {
10
+ return 'eav/entity_attribute_set';
11
+ }
12
+
13
+ public function getParserModel()
14
  {
15
+ return 'combine/parser_attributeSet';
16
+ }
17
+
18
+ public function getApiController()
19
+ {
20
+ return 'attribute_sets';
21
+ }
22
 
23
+ public function getApiModel()
24
+ {
25
+ return 'attribute_sets';
26
+ }
27
+
28
+ public function getRowId()
29
+ {
30
+ return 'attribute_set_id';
31
+ }
32
+
33
+ /**
34
+ * Parse caller for dependent parser method
35
+ *
36
+ * @param Mage_Core_Model_Abstract $model
37
+ * @return Zend_Json_Expr
38
+ */
39
+ public function parse($model)
40
+ {
41
+ $parser = Mage::getModel($this->getParserModel(), $model);
42
+ $parser->setMageStoreId($this->getStoreId());
43
+ $parser->setStoreId($this->getStoreId());
44
+ if ($this->getDelete()) {
45
+ $parser->setIsDeleted(true);
46
  }
47
+ return $parser->getData();
 
 
48
  }
49
 
50
  public function loadMageModel($id)
app/code/community/Springbot/Combine/Model/Harvest/Carts.php CHANGED
@@ -1,27 +1,36 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Carts extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'sales/quote';
6
- protected $_parserModel = 'combine/parser_quote';
7
- protected $_apiController = 'carts';
8
- protected $_apiModel = 'carts';
9
 
 
 
 
 
10
 
11
- public function loadMageModel($entityId)
12
  {
13
- $this->_model = Mage::getModel($this->_getMageModel());
14
- $this->_model->setStoreId($this->_storeId);
15
- $this->_model->load($entityId);
16
- return $this->_model;
17
  }
18
 
19
- public function parse($model)
20
  {
21
- $parser = $this->_getParser($model)->parse($model);
22
- $parser->setDataSource($this->getDataSource());
23
- return $parser->getData();
24
  }
25
 
26
 
 
 
 
 
 
 
 
 
 
 
27
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Carts extends Springbot_Combine_Model_Harvest
4
  {
5
+ public function getMageModel()
6
+ {
7
+ return 'sales/quote';
8
+ }
9
 
10
+ public function getParserModel()
11
+ {
12
+ return 'combine/parser_quote';
13
+ }
14
 
15
+ public function getApiController()
16
  {
17
+ return 'carts';
 
 
 
18
  }
19
 
20
+ public function getApiModel()
21
  {
22
+ return 'carts';
 
 
23
  }
24
 
25
 
26
+ public function loadMageModel($entityId)
27
+ {
28
+ $model = Mage::getModel($this->getMageModel());
29
+ $model->setStoreId($this->getStoreId());
30
+ $model->load($entityId);
31
+ return $model;
32
+ }
33
+
34
+
35
+
36
  }
app/code/community/Springbot/Combine/Model/Harvest/Categories.php CHANGED
@@ -1,39 +1,34 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Categories extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'catalog/category';
6
- protected $_parserModel = 'combine/parser_category';
7
- protected $_apiController = 'categories';
8
- protected $_apiModel = 'categories';
9
 
10
- /**
11
- * Parse caller for dependent parser method
12
- *
13
- * @param Mage_Core_Model_Abstract $model
14
- * @return Zend_Json_Expr
15
- */
16
- public function parse($model)
17
  {
18
- $parsed = $this->_getParser($model)
19
- ->setMageStoreId($this->_storeId)
20
- ->parse($model);
21
 
22
- if($this->_delete) {
23
- $parsed->setIsDeleted(true);
24
- }
25
- $parsed->setDataSource($this->getDataSource());
26
- $json = $parsed->toJson();
27
- return $parsed->getData();
 
 
28
  }
29
 
 
 
 
 
 
 
30
  public function loadMageModel($entityId)
31
  {
32
- if(!isset($this->_model)) {
33
- $this->_model = Mage::getModel($this->_getMageModel());
34
- }
35
- $this->_model->setStoreId($this->_storeId);
36
- $this->_model->load($entityId);
37
- return $this->_model;
38
  }
39
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Categories extends Springbot_Combine_Model_Harvest
4
  {
 
 
 
 
5
 
6
+ public function getMageModel()
 
 
 
 
 
 
7
  {
8
+ return 'catalog/category';
9
+ }
 
10
 
11
+ public function getParserModel()
12
+ {
13
+ return 'combine/parser_category';
14
+ }
15
+
16
+ public function getApiController()
17
+ {
18
+ return 'categories';
19
  }
20
 
21
+ public function getApiModel()
22
+ {
23
+ return 'categories';
24
+ }
25
+
26
+
27
  public function loadMageModel($entityId)
28
  {
29
+ $model = Mage::getModel($this->getMageModel());
30
+ $model->setStoreId($this->getStoreId());
31
+ $model->load($entityId);
32
+ return $model;
 
 
33
  }
34
  }
app/code/community/Springbot/Combine/Model/Harvest/Coupons.php CHANGED
@@ -1,27 +1,38 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Coupons extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'salesrule/coupon';
6
- protected $_parserModel = 'combine/parser_coupon';
7
- protected $_apiController = 'coupons';
8
- protected $_apiModel = 'coupons';
9
- protected $_rowId = 'coupon_id';
10
 
11
- public function loadMageModel($entityId)
 
 
 
 
 
 
 
 
 
 
12
  {
13
- $this->_model = Mage::getModel($this->_getMageModel());
14
- $this->_model->setStoreId($this->_storeId);
15
- $this->_model->load($entityId);
16
- return $this->_model;
17
  }
18
 
19
- public function parse($model)
20
  {
21
- $model->setStoreId($this->_storeId);
22
- $parser = $this->_getParser($model)->parse($model);
23
- $parser->setDataSource($this->getDataSource());
24
- return $parser->getData();
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Coupons extends Springbot_Combine_Model_Harvest
4
  {
 
 
 
 
 
5
 
6
+ public function getMageModel()
7
+ {
8
+ return 'salesrule/coupon';
9
+ }
10
+
11
+ public function getParserModel()
12
+ {
13
+ return 'combine/parser_coupon';
14
+ }
15
+
16
+ public function getApiController()
17
  {
18
+ return 'coupons';
 
 
 
19
  }
20
 
21
+ public function getApiModel()
22
  {
23
+ return 'coupons';
 
 
 
24
  }
25
 
26
+ public function getRowId()
27
+ {
28
+ return 'coupon_id';
29
+ }
30
+
31
+ public function loadMageModel($entityId)
32
+ {
33
+ $model = Mage::getModel($this->getMageModel());
34
+ $model->setStoreId($this->getStoreId());
35
+ $model->load($entityId);
36
+ return $model;
37
+ }
38
  }
app/code/community/Springbot/Combine/Model/Harvest/CustomerAttributeSets.php CHANGED
@@ -1,6 +1,46 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_CustomerAttributeSets extends Springbot_Combine_Model_Harvest_AttributeSets implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_parserModel = 'combine/parser_customerAttributeSet';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_CustomerAttributeSets extends Springbot_Combine_Model_Harvest
4
  {
5
+ protected $_helper;
6
+
7
+ public function getMageModel()
8
+ {
9
+ return 'eav/entity_attribute_set';
10
+ }
11
+
12
+ public function getParserModel()
13
+ {
14
+ return 'combine/parser_customerAttributeSet';
15
+ }
16
+
17
+ public function getApiController()
18
+ {
19
+ return 'attribute_sets';
20
+ }
21
+
22
+ public function getApiModel()
23
+ {
24
+ return 'attribute_sets';
25
+ }
26
+
27
+ public function getRowId()
28
+ {
29
+ return 'attribute_set_id';
30
+ }
31
+
32
+
33
+ public function loadMageModel($id)
34
+ {
35
+ return $this->_getHelper()->getAttributeSetById($id);
36
+ }
37
+
38
+ protected function _getHelper()
39
+ {
40
+ if(!isset($this->_helper)) {
41
+ $this->_helper = Mage::helper('combine/attributes');
42
+ }
43
+ return $this->_helper;
44
+ }
45
+
46
  }
app/code/community/Springbot/Combine/Model/Harvest/Customers.php CHANGED
@@ -1,19 +1,31 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Customers extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'customer/customer';
6
- protected $_parserModel = 'combine/parser_customer';
7
- protected $_apiController = 'customers';
8
- protected $_apiModel = 'customers';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  public function loadMageModel($entityId)
11
  {
12
- if(!isset($this->_model)) {
13
- $this->_model = Mage::getModel('customer/customer');
14
- }
15
- // This unsets addresses so we can reuse this model
16
- $this->_model->cleanAllAddresses();
17
- return $this->_model->load($entityId);
18
  }
19
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Customers extends Springbot_Combine_Model_Harvest
4
  {
5
+ public function getMageModel()
6
+ {
7
+ return 'customer/customer';
8
+ }
9
+
10
+ public function getParserModel()
11
+ {
12
+ return 'combine/parser_customer';
13
+ }
14
+
15
+ public function getApiController()
16
+ {
17
+ return 'customers';
18
+ }
19
+
20
+ public function getApiModel()
21
+ {
22
+ return 'customers';
23
+ }
24
+
25
 
26
  public function loadMageModel($entityId)
27
  {
28
+ $model = Mage::getModel('customer/customer');
29
+ return $model->load($entityId);
 
 
 
 
30
  }
31
  }
app/code/community/Springbot/Combine/Model/Harvest/Guests.php CHANGED
@@ -1,20 +1,30 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Guests extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'sales/order';
6
- protected $_parserModel = 'combine/parser_guest';
7
- protected $_apiController = 'customers';
8
- protected $_apiModel = 'customers';
9
 
10
- public function loadMageModel($entityId)
 
 
 
 
 
11
  {
12
- if(!isset($this->_model)) {
13
- $this->_model = Mage::getModel('sales/order');
14
- }
15
- $this->_model->unsetData();
16
- $this->_model->reset();
 
 
17
 
18
- return $this->_model->load($entityId);
 
 
 
19
  }
20
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Guests extends Springbot_Combine_Model_Harvest
4
  {
5
+ public function getMageModel()
6
+ {
7
+ return 'sales/order';
8
+ }
9
 
10
+ public function getParserModel()
11
+ {
12
+ return 'combine/parser_guest';
13
+ }
14
+
15
+ public function getApiController()
16
  {
17
+ return 'customers';
18
+ }
19
+
20
+ public function getApiModel()
21
+ {
22
+ return 'customers';
23
+ }
24
 
25
+ public function loadMageModel($entityId)
26
+ {
27
+ $model = Mage::getModel('sales/order');
28
+ return $model->load($entityId);
29
  }
30
  }
app/code/community/Springbot/Combine/Model/Harvest/Products.php CHANGED
@@ -1,22 +1,35 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Products extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'catalog/product';
6
- protected $_parserModel = 'combine/parser_product';
7
- protected $_apiController = 'products';
8
- protected $_apiModel = 'products';
9
  protected $_segmentSize = 100;
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  public function loadMageModel($entityId)
13
  {
14
- if(!isset($this->_model)) {
15
- $this->_model = Mage::getModel($this->_getMageModel());
16
- }
17
- $this->_model->cleanCache()->reset();
18
- $this->_model->setStoreId($this->_storeId);
19
- $this->_model->load($entityId);
20
- return $this->_model;
21
  }
22
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Products extends Springbot_Combine_Model_Harvest
4
  {
 
 
 
 
5
  protected $_segmentSize = 100;
6
 
7
+ public function getMageModel()
8
+ {
9
+ return 'catalog/product';
10
+ }
11
+
12
+ public function getParserModel()
13
+ {
14
+ return 'combine/parser_product';
15
+ }
16
+
17
+ public function getApiController()
18
+ {
19
+ return 'products';
20
+ }
21
+
22
+ public function getApiModel()
23
+ {
24
+ return 'products';
25
+ }
26
+
27
 
28
  public function loadMageModel($entityId)
29
  {
30
+ $model = Mage::getModel($this->getMageModel());
31
+ $model->setStoreId($this->getStoreId());
32
+ $model->load($entityId);
33
+ return $model;
 
 
 
34
  }
35
  }
app/code/community/Springbot/Combine/Model/Harvest/Purchases.php CHANGED
@@ -1,20 +1,32 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Purchases extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'sales/order';
6
- protected $_parserModel = 'combine/parser_purchase';
7
- protected $_apiController = 'purchases';
8
- protected $_apiModel = 'purchases';
9
  protected $_segmentSize = 100;
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  public function loadMageModel($entityId)
12
  {
13
- if(!isset($this->_model)) {
14
- $this->_model = Mage::getModel($this->_getMageModel());
15
- }
16
- $this->_model->unsetData();
17
- $this->_model->reset();
18
- return $this->_model->load($entityId);
19
  }
20
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Purchases extends Springbot_Combine_Model_Harvest
4
  {
 
 
 
 
5
  protected $_segmentSize = 100;
6
 
7
+ public function getMageModel()
8
+ {
9
+ return 'sales/order';
10
+ }
11
+
12
+ public function getParserModel()
13
+ {
14
+ return 'combine/parser_purchase';
15
+ }
16
+
17
+ public function getApiController()
18
+ {
19
+ return 'purchases';
20
+ }
21
+
22
+ public function getApiModel()
23
+ {
24
+ return 'purchases';
25
+ }
26
+
27
  public function loadMageModel($entityId)
28
  {
29
+ $model = Mage::getModel($this->getMageModel());
30
+ return $model->load($entityId);
 
 
 
 
31
  }
32
  }
app/code/community/Springbot/Combine/Model/Harvest/Rules.php CHANGED
@@ -1,27 +1,39 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Rules extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'salesrule/rule';
6
- protected $_parserModel = 'combine/parser_rule';
7
- protected $_apiController = 'promotions';
8
- protected $_apiModel = 'promotions';
9
- protected $_rowId = 'rule_id';
10
 
11
- public function loadMageModel($entityId)
 
 
 
 
 
 
 
 
 
 
12
  {
13
- $this->_model = Mage::getModel($this->_getMageModel());
14
- $this->_model->setStoreId($this->_storeId);
15
- $this->_model->load($entityId);
16
- return $this->_model;
17
  }
18
 
19
- public function parse($model)
20
  {
21
- $model->setStoreId($this->_storeId);
22
- $parser = $this->_getParser($model)->parse($model);
23
- $parser->setDataSource($this->getDataSource());
24
- return $parser->getData();
25
  }
26
 
 
 
 
 
 
 
 
 
 
27
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Rules extends Springbot_Combine_Model_Harvest
4
  {
5
+ public function getMageModel()
6
+ {
7
+ return 'salesrule/rule';
8
+ }
 
9
 
10
+ public function getParserModel()
11
+ {
12
+ return 'combine/parser_rule';
13
+ }
14
+
15
+ public function getApiController()
16
+ {
17
+ return 'promotions';
18
+ }
19
+
20
+ public function getApiModel()
21
  {
22
+ return 'promotions';
 
 
 
23
  }
24
 
25
+ public function getRowId()
26
  {
27
+ return 'rule_id';
 
 
 
28
  }
29
 
30
+ public function loadMageModel($entityId)
31
+ {
32
+ $model = Mage::getModel($this->getMageModel());
33
+ $model->setStoreId($this->getStoreId());
34
+ $model->load($entityId);
35
+ return $model;
36
+ }
37
+
38
+
39
  }
app/code/community/Springbot/Combine/Model/Harvest/Subscribers.php CHANGED
@@ -1,16 +1,35 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Harvest_Subscribers extends Springbot_Combine_Model_Harvest_Abstract implements Springbot_Combine_Model_Harvester
4
  {
5
- protected $_mageModel = 'newsletter/subscriber';
6
- protected $_parserModel = 'combine/parser_subscriber';
7
- protected $_apiController = 'customers';
8
- protected $_apiModel = 'customers';
9
- protected $_rowId = 'subscriber_id';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  public function parse($model)
12
  {
13
- if($this->_delete) {
14
  $model->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
15
  }
16
  return parent::parse($model);
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Harvest_Subscribers extends Springbot_Combine_Model_Harvest
4
  {
5
+ public function getMageModel()
6
+ {
7
+ return 'newsletter/subscriber';
8
+ }
9
+
10
+ public function getParserModel()
11
+ {
12
+ return 'combine/parser_subscriber';
13
+ }
14
+
15
+ public function getApiController()
16
+ {
17
+ return 'customers';
18
+ }
19
+
20
+ public function getApiModel()
21
+ {
22
+ return 'customers';
23
+ }
24
+
25
+ public function getRowId()
26
+ {
27
+ return 'subscriber_id';
28
+ }
29
 
30
  public function parse($model)
31
  {
32
+ if ($this->getDelete()) {
33
  $model->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
34
  }
35
  return parent::parse($model);
app/code/community/Springbot/Combine/Model/Harvester.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- interface Springbot_Combine_Model_Harvester
4
- {
5
- public function getCollection();
6
- public function setCollection(Varien_Data_Collection $collection);
7
- public function harvest();
8
- public function step($args);
9
- public function parse($model);
10
- public function loadMageModel($entityId);
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Combine/Model/Mysql4/Action.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Combine_Model_Mysql4_Action extends Springbot_Combine_Model_Resource_Cron_Events
4
+ {
5
+ }
app/code/community/Springbot/Combine/Model/Mysql4/Action/Collection.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Combine_Model_Mysql4_Action_Collection extends Springbot_Combine_Model_Resource_Action_Collection
4
+ {
5
+ }
app/code/community/Springbot/Combine/Model/Parser.php CHANGED
@@ -1,6 +1,178 @@
1
  <?php
2
 
3
- interface Springbot_Combine_Model_Parser
4
  {
5
- public function parse($parsable);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  }
1
  <?php
2
 
3
+ abstract class Springbot_Combine_Model_Parser extends Varien_Object
4
  {
5
+ protected $_parsed = false;
6
+ protected $_attrProtected = array();
7
+
8
+ /**
9
+ * Redeclaration of Varien_Object::toJson
10
+ *
11
+ * @array $attributes array of attributes to include
12
+ * @return string
13
+ */
14
+ public function toJson(array $arrAttributes = array())
15
+ {
16
+ if(!$this->isParsed()) {
17
+ $this->_parse();
18
+ }
19
+ $this->prune();
20
+ return parent::toJson($arrAttributes);
21
+ }
22
+
23
+ public function reinit()
24
+ {
25
+ unset($this->_storeId);
26
+ }
27
+
28
+ public function prune()
29
+ {
30
+ $this->_data = $this->_prune($this->_data);
31
+ return $this;
32
+ }
33
+
34
+ protected function _prune($array)
35
+ {
36
+ if(is_array($array)) {
37
+ foreach($array as $key => $value) {
38
+ if(is_array($value)) {
39
+ $array[$key] = $this->_prune($value);
40
+ }
41
+ if(empty($value)) {
42
+ unset($array[$key]);
43
+ } else if(is_string($value)) {
44
+ $array[$key] = trim($array[$key]);
45
+ }
46
+ }
47
+ }
48
+ return $array;
49
+ }
50
+
51
+ public function getCustomAttributes()
52
+ {
53
+ $return = array();
54
+ $helper = Mage::helper('combine/attributes');
55
+ $model = $this->_getAccessor();
56
+ $attributes = $helper->getAttributesBySet($model->getAttributeSetId());
57
+
58
+ foreach($attributes as $attribute) {
59
+ $code = $attribute->getAttributeCode();
60
+
61
+ if(!$this->_isProtected($code) && $model->hasData($code)) {
62
+ if($attribute->usesSource()) {
63
+ $value = $helper->getOptionText($attribute, $model->getData($code));
64
+ } else {
65
+ $value = $model->getData($code);
66
+ }
67
+
68
+ $return[$code] = $value;
69
+ }
70
+ }
71
+
72
+ return $return;
73
+ }
74
+
75
+ public function setIsParsed()
76
+ {
77
+ $this->_parsed = true;
78
+ return $this;
79
+ }
80
+
81
+ public function isParsed()
82
+ {
83
+ return $this->_parsed;
84
+ }
85
+
86
+ public function getAccessibleSku($item)
87
+ {
88
+ if($product = $item->getProduct()) {
89
+ if(
90
+ $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ||
91
+ $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
92
+ ) {
93
+ Springbot_Log::debug('Product not visible - attempt to find parent');
94
+ $product = $this->getParentProduct($item);
95
+ }
96
+ return $this->_getHelper()->getTopLevelSku($product);
97
+ }
98
+ }
99
+
100
+ protected function _getLandingUrl($product)
101
+ {
102
+ return $this->_getHelper()->getLandingUrl($product);
103
+ }
104
+
105
+ protected function _getHelper()
106
+ {
107
+ return Mage::helper('combine/parser');
108
+ }
109
+
110
+ protected function _parse()
111
+ {
112
+ return $this->setIsParsed();
113
+ }
114
+
115
+ protected function _formatDateTime($date)
116
+ {
117
+ $_date = new DateTime($date, new DateTimeZone('UTC'));
118
+ return $_date->format(DateTime::ATOM);
119
+ }
120
+
121
+ protected function _getAccessor()
122
+ {
123
+ if(!isset($this->_accessor)) {
124
+ throw new Exception('Please set _accessor in Class ' . __CLASS__);
125
+ }
126
+ return $this->{$this->_accessor};
127
+ }
128
+
129
+ public function getMageStoreId()
130
+ {
131
+ if(!isset($this->_storeId)) {
132
+ $this->_storeId = $this->_getAccessor()->getStoreId();
133
+ }
134
+ return $this->_storeId;
135
+ }
136
+
137
+ public function setMageStoreId($storeId)
138
+ {
139
+ $this->_storeId = $storeId;
140
+ return $this;
141
+ }
142
+
143
+ public function getSpringbotStoreId()
144
+ {
145
+ return $this->_getSpringbotStoreId($this->getMageStoreId());
146
+ }
147
+
148
+ protected function _getSpringbotStoreId($id)
149
+ {
150
+ return Mage::helper('combine/harvest')->getSpringbotStoreId($id);
151
+ }
152
+
153
+ protected function _isProtected($attrCode)
154
+ {
155
+ return in_array($attrCode, $this->_attrProtected);
156
+ }
157
+
158
+ protected function _getBaseAmt($field, $model = null)
159
+ {
160
+ if(is_null($model)) {
161
+ $model = $this->_getAccessor();
162
+ }
163
+ return ($amt = $model->getData("base_{$field}")) ? $amt : $model->getData($field);
164
+ }
165
+
166
+ protected function _getSkuFailsafe($product)
167
+ {
168
+ // Use array accessor here because getSku method
169
+ // use the type instance's sku (i.e. the child sku)
170
+ if ($sku = $product['sku']) {
171
+ return $sku;
172
+ }
173
+ else {
174
+ return Springbot_Boss::NO_SKU_PREFIX .$product->getEntityId();
175
+ }
176
+ }
177
+
178
  }
app/code/community/Springbot/Combine/Model/Parser/Abstract.php DELETED
@@ -1,186 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Combine_Model_Parser_Abstract extends Varien_Object
4
- {
5
- protected $_parsed = false;
6
- protected $_attrProtected = array();
7
-
8
- /**
9
- * Redeclaration of Varien_Object::toJson
10
- *
11
- * @array $attributes array of attributes to include
12
- * @return string
13
- */
14
- public function toJson(array $arrAttributes = array())
15
- {
16
- if(!$this->isParsed()) {
17
- $this->_parse();
18
- }
19
- $this->prune();
20
- return parent::toJson($arrAttributes);
21
- }
22
-
23
- public function reinit()
24
- {
25
- unset($this->_storeId);
26
- }
27
-
28
- public function prune()
29
- {
30
- $this->_data = $this->_prune($this->_data);
31
- return $this;
32
- }
33
-
34
- protected function _prune($array)
35
- {
36
- if(is_array($array)) {
37
- foreach($array as $key => $value) {
38
- if(is_array($value)) {
39
- $array[$key] = $this->_prune($value);
40
- }
41
- if(empty($value)) {
42
- unset($array[$key]);
43
- } else if(is_string($value)) {
44
- $array[$key] = trim($array[$key]);
45
- }
46
- }
47
- }
48
- return $array;
49
- }
50
-
51
- public function getCustomAttributes()
52
- {
53
- $return = array();
54
- $helper = Mage::helper('combine/attributes');
55
- $model = $this->_getAccessor();
56
- $attributes = $helper->getAttributesBySet($model->getAttributeSetId());
57
-
58
- foreach($attributes as $attribute) {
59
- $code = $attribute->getAttributeCode();
60
-
61
- if(!$this->_isProtected($code) && $model->hasData($code)) {
62
- if($attribute->usesSource()) {
63
- $value = $helper->getOptionText($attribute, $model->getData($code));
64
- } else {
65
- $value = $model->getData($code);
66
- }
67
-
68
- $return[$code] = $value;
69
- }
70
- }
71
-
72
- return $return;
73
- }
74
-
75
- public function setIsParsed()
76
- {
77
- $this->_parsed = true;
78
- return $this;
79
- }
80
-
81
- public function isParsed()
82
- {
83
- return $this->_parsed;
84
- }
85
-
86
- public function getAccessibleSku($item)
87
- {
88
- if($product = $item->getProduct()) {
89
- if(
90
- $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ||
91
- $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
92
- ) {
93
- Springbot_Log::debug('Product not visible - attempt to find parent');
94
- $product = $this->getParentProduct($item);
95
- }
96
- return $this->_getHelper()->getTopLevelSku($product);
97
- }
98
- }
99
-
100
- protected function _getLandingUrl($product)
101
- {
102
- return $this->_getHelper()->getLandingUrl($product);
103
- }
104
-
105
- protected function _parse()
106
- {
107
- return $this->setIsParsed();
108
- }
109
-
110
- protected function _formatDateTime($date)
111
- {
112
- $_date = new DateTime($date, new DateTimeZone('UTC'));
113
- return $_date->format(DateTime::ATOM);
114
- }
115
-
116
- protected function _getAccessor()
117
- {
118
- if(!isset($this->_accessor)) {
119
- throw new Exception('Please set _accessor in Class ' . __CLASS__);
120
- }
121
- return $this->{$this->_accessor};
122
- }
123
-
124
- public function getMageStoreId()
125
- {
126
- if(!isset($this->_storeId)) {
127
- $this->_storeId = $this->_getAccessor()->getStoreId();
128
- }
129
- return $this->_storeId;
130
- }
131
-
132
- public function setMageStoreId($storeId)
133
- {
134
- $this->_storeId = $storeId;
135
- return $this;
136
- }
137
-
138
- public function getSpringbotStoreId()
139
- {
140
- return $this->_getSpringbotStoreId($this->getMageStoreId());
141
- }
142
-
143
- protected function _getSpringbotStoreId($id)
144
- {
145
- return Mage::helper('combine/harvest')->getSpringbotStoreId($id);
146
- }
147
-
148
- protected function _isProtected($attrCode)
149
- {
150
- return in_array($attrCode, $this->_attrProtected);
151
- }
152
-
153
- protected function _getHelper()
154
- {
155
- return Mage::helper('combine/parser');
156
- }
157
-
158
- protected function _getBaseAmt($field, $model = null)
159
- {
160
- if(is_null($model)) {
161
- $model = $this->_getAccessor();
162
- }
163
- return ($amt = $model->getData("base_{$field}")) ? $amt : $model->getData($field);
164
- }
165
-
166
- protected function _getProduct($id)
167
- {
168
- return Mage::getModel('catalog/product')->load($id);
169
- }
170
-
171
-
172
- protected function _getSkuFailsafe($product)
173
- {
174
- if($product instanceof Mage_Catalog_Model_Product) {
175
- // Use array accessor here because getSku method
176
- // use the type instance's sku (i.e. the child sku)
177
- if ($sku = $product['sku']) {
178
- return $sku;
179
- }
180
- else {
181
- return Springbot_Boss::NO_SKU_PREFIX . $product->getEntityId();
182
- }
183
- }
184
- }
185
-
186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Combine/Model/Parser/AttributeSet.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_AttributeSet extends Springbot_Combine_Model_Parser_Abstract implements Springbot_Combine_Model_Parser
4
  {
5
  protected $_helper;
6
  protected $_set;
@@ -14,14 +14,6 @@ class Springbot_Combine_Model_Parser_AttributeSet extends Springbot_Combine_Mode
14
  $this->_parse();
15
  }
16
 
17
- public function parse($set)
18
- {
19
- $this->_set = $set;
20
- $this->_parse();
21
-
22
- return $this;
23
- }
24
-
25
  protected function _parse()
26
  {
27
  $this->_data = array(
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_AttributeSet extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_helper;
6
  protected $_set;
14
  $this->_parse();
15
  }
16
 
 
 
 
 
 
 
 
 
17
  protected function _parse()
18
  {
19
  $this->_data = array(
app/code/community/Springbot/Combine/Model/Parser/Category.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Category extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  protected $_accessor = '_category';
6
  protected $_category;
@@ -12,14 +12,6 @@ class Springbot_Combine_Model_Parser_Category extends Springbot_Combine_Model_Pa
12
  $this->_parse();
13
  }
14
 
15
- public function parse($category)
16
- {
17
- $this->_category = $category;
18
- $this->_parse();
19
-
20
- return $this;
21
- }
22
-
23
  protected function _parse()
24
  {
25
  $this->setData(array(
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Category extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_accessor = '_category';
6
  protected $_category;
12
  $this->_parse();
13
  }
14
 
 
 
 
 
 
 
 
 
15
  protected function _parse()
16
  {
17
  $this->setData(array(
app/code/community/Springbot/Combine/Model/Parser/Coupon.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Coupon extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  protected $_coupon;
6
  protected $_accessor = '_coupon';
@@ -11,14 +11,6 @@ class Springbot_Combine_Model_Parser_Coupon extends Springbot_Combine_Model_Pars
11
  $this->_parse();
12
  }
13
 
14
- public function parse($coupon)
15
- {
16
- $this->_coupon = $coupon;
17
- $this->_parse();
18
-
19
- return $this;
20
- }
21
-
22
  protected function _parse()
23
  {
24
  $this->setData(array(
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Coupon extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_coupon;
6
  protected $_accessor = '_coupon';
11
  $this->_parse();
12
  }
13
 
 
 
 
 
 
 
 
 
14
  protected function _parse()
15
  {
16
  $this->setData(array(
app/code/community/Springbot/Combine/Model/Parser/Customer.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Customer extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  const TYPE = 'REGISTERED';
6
 
@@ -34,14 +34,6 @@ class Springbot_Combine_Model_Parser_Customer extends Springbot_Combine_Model_Pa
34
  return $this->_getCustomerOrderCollection()->getSize() > 0;
35
  }
36
 
37
- public function parse($customer)
38
- {
39
- $this->_customer = $customer;
40
- $this->_parse();
41
-
42
- return $this;
43
- }
44
-
45
  protected function _parse()
46
  {
47
  $this->setData(array(
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Customer extends Springbot_Combine_Model_Parser
4
  {
5
  const TYPE = 'REGISTERED';
6
 
34
  return $this->_getCustomerOrderCollection()->getSize() > 0;
35
  }
36
 
 
 
 
 
 
 
 
 
37
  protected function _parse()
38
  {
39
  $this->setData(array(
app/code/community/Springbot/Combine/Model/Parser/CustomerAttributeSet.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_CustomerAttributeSet extends Springbot_Combine_Model_Parser_AttributeSet implements Springbot_Combine_Model_Parser
4
  {
5
  protected $_type = 'customer';
6
 
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_CustomerAttributeSet extends Springbot_Combine_Model_Parser_AttributeSet
4
  {
5
  protected $_type = 'customer';
6
 
app/code/community/Springbot/Combine/Model/Parser/Guest.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Guest extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  const TYPE = 'GUEST';
6
  const OFFSET = 100000000;
@@ -14,14 +14,6 @@ class Springbot_Combine_Model_Parser_Guest extends Springbot_Combine_Model_Parse
14
  $this->_parse();
15
  }
16
 
17
- public function parse($order)
18
- {
19
- $this->_order = $order;
20
- $this->_address = $this->_order->getShippingAddress();
21
- $this->_parse();
22
- return $this;
23
- }
24
-
25
  protected function _parse()
26
  {
27
  if(!is_object($this->_address)) { return false; }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Guest extends Springbot_Combine_Model_Parser
4
  {
5
  const TYPE = 'GUEST';
6
  const OFFSET = 100000000;
14
  $this->_parse();
15
  }
16
 
 
 
 
 
 
 
 
 
17
  protected function _parse()
18
  {
19
  if(!is_object($this->_address)) { return false; }
app/code/community/Springbot/Combine/Model/Parser/Product.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Product extends Springbot_Combine_Model_Parser_Abstract implements Springbot_Combine_Model_Parser
4
  {
5
  protected $_accessor = '_product';
6
  protected $_product;
@@ -11,14 +11,6 @@ class Springbot_Combine_Model_Parser_Product extends Springbot_Combine_Model_Par
11
  $this->_parse();
12
  }
13
 
14
- public function parse($product)
15
- {
16
- $this->_product = $product;
17
- $this->_parse();
18
-
19
- return $this;
20
- }
21
-
22
  public function _parse()
23
  {
24
  $p = $this->_product;
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Product extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_accessor = '_product';
6
  protected $_product;
11
  $this->_parse();
12
  }
13
 
 
 
 
 
 
 
 
 
14
  public function _parse()
15
  {
16
  $p = $this->_product;
app/code/community/Springbot/Combine/Model/Parser/Purchase.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Purchase extends Springbot_Combine_Model_Parser_Abstract implements Springbot_Combine_Model_Parser
4
  {
5
  protected $_accessor = '_purchase';
6
  protected $_purchase;
@@ -13,15 +13,6 @@ class Springbot_Combine_Model_Parser_Purchase extends Springbot_Combine_Model_Pa
13
  $this->_parse();
14
  }
15
 
16
- public function parse($purchase)
17
- {
18
- $this->_lineItems = null;
19
- $this->_purchase = $purchase;
20
- $this->_parse();
21
-
22
- return $this;
23
- }
24
-
25
  protected function _parse()
26
  {
27
  $model = $this->_purchase;
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Purchase extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_accessor = '_purchase';
6
  protected $_purchase;
13
  $this->_parse();
14
  }
15
 
 
 
 
 
 
 
 
 
 
16
  protected function _parse()
17
  {
18
  $model = $this->_purchase;
app/code/community/Springbot/Combine/Model/Parser/Purchase/Item.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Purchase_Item extends Springbot_Combine_Model_Parser_Abstract implements Springbot_Combine_Model_Parser
4
  {
5
  protected $_item;
6
  protected $_accessor = '_item';
@@ -15,15 +15,6 @@ class Springbot_Combine_Model_Parser_Purchase_Item extends Springbot_Combine_Mod
15
  $this->_parse();
16
  }
17
 
18
- public function parse($item)
19
- {
20
- $this->_item = $item;
21
- $this->_actualProduct = null;
22
- $this->_parentProduct = null;
23
- $this->_parse();
24
- return $this;
25
- }
26
-
27
  public function _parse()
28
  {
29
  $item = $this->_item;
@@ -68,7 +59,7 @@ class Springbot_Combine_Model_Parser_Purchase_Item extends Springbot_Combine_Mod
68
  if(!isset($parentProductId)) {
69
  $parentProductId = $item->getProductId();
70
  }
71
- $this->_parentProduct = $this->_getProduct($parentProductId);
72
  }
73
  return $this->_parentProduct;
74
  }
@@ -96,7 +87,6 @@ class Springbot_Combine_Model_Parser_Purchase_Item extends Springbot_Combine_Mod
96
 
97
  protected function _getProductAttributes()
98
  {
99
- $collection = array();
100
  return $this->_getHelper()->getCustomAttributes($this->getActualProduct(), 50);
101
  }
102
 
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Purchase_Item extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_item;
6
  protected $_accessor = '_item';
15
  $this->_parse();
16
  }
17
 
 
 
 
 
 
 
 
 
 
18
  public function _parse()
19
  {
20
  $item = $this->_item;
59
  if(!isset($parentProductId)) {
60
  $parentProductId = $item->getProductId();
61
  }
62
+ $this->_parentProduct = Mage::getModel('catalog/product')->load($parentProductId);
63
  }
64
  return $this->_parentProduct;
65
  }
87
 
88
  protected function _getProductAttributes()
89
  {
 
90
  return $this->_getHelper()->getCustomAttributes($this->getActualProduct(), 50);
91
  }
92
 
app/code/community/Springbot/Combine/Model/Parser/Quote.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Quote extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  protected $_quote;
6
  protected $_accessor = '_quote';
@@ -13,14 +13,6 @@ class Springbot_Combine_Model_Parser_Quote extends Springbot_Combine_Model_Parse
13
  $this->_parse();
14
  }
15
 
16
- public function parse(Mage_Sales_Model_Quote $quote)
17
- {
18
- $this->_items = array();
19
- $this->_quote = $quote;
20
- $this->_parse();
21
- return $this;
22
- }
23
-
24
  public function getItemsCount()
25
  {
26
  return count($this->_items);
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Quote extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_quote;
6
  protected $_accessor = '_quote';
13
  $this->_parse();
14
  }
15
 
 
 
 
 
 
 
 
 
16
  public function getItemsCount()
17
  {
18
  return count($this->_items);
app/code/community/Springbot/Combine/Model/Parser/Quote/Item.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Quote_Item extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  protected $_item;
6
  protected $_accessor = '_item';
@@ -15,21 +15,10 @@ class Springbot_Combine_Model_Parser_Quote_Item extends Springbot_Combine_Model_
15
  $this->_parse();
16
  }
17
 
18
- public function parse(Mage_Sales_Model_Quote_Item $item)
19
- {
20
- $this->_item = $item;
21
- $this->_parentProduct = null;
22
- $this->_actualProduct = null;
23
- $this->_parse();
24
- return $this;
25
- }
26
-
27
  protected function _parse()
28
  {
29
  $item = $this->_item;
30
-
31
  $parent = $this->getParentProduct();
32
- $actual = $this->getActualProduct();
33
 
34
  $this->_data = array(
35
  'sku' => $this->_getSkuFailsafe($parent),
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Quote_Item extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_item;
6
  protected $_accessor = '_item';
15
  $this->_parse();
16
  }
17
 
 
 
 
 
 
 
 
 
 
18
  protected function _parse()
19
  {
20
  $item = $this->_item;
 
21
  $parent = $this->getParentProduct();
 
22
 
23
  $this->_data = array(
24
  'sku' => $this->_getSkuFailsafe($parent),
app/code/community/Springbot/Combine/Model/Parser/Rule.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Rule extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  protected $_rule;
6
  protected $_accessor = '_rule';
@@ -11,14 +11,6 @@ class Springbot_Combine_Model_Parser_Rule extends Springbot_Combine_Model_Parser
11
  $this->_parse();
12
  }
13
 
14
- public function parse($rule)
15
- {
16
- $this->_rule = $rule;
17
- $this->_parse();
18
-
19
- return $this;
20
- }
21
-
22
  protected function _parse()
23
  {
24
  $this->setData(array(
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Rule extends Springbot_Combine_Model_Parser
4
  {
5
  protected $_rule;
6
  protected $_accessor = '_rule';
11
  $this->_parse();
12
  }
13
 
 
 
 
 
 
 
 
 
14
  protected function _parse()
15
  {
16
  $this->setData(array(
app/code/community/Springbot/Combine/Model/Parser/Subscriber.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Parser_Subscriber extends Springbot_Combine_Model_Parser_Abstract
4
  {
5
  const TYPE = 'SUBSCRIBER';
6
  const SUBSCRIBER_MODE = 'NL';
@@ -19,14 +19,6 @@ class Springbot_Combine_Model_Parser_Subscriber extends Springbot_Combine_Model_
19
  return !empty($customerId);
20
  }
21
 
22
- public function parse($subscriber)
23
- {
24
- $this->_subscriber = $subscriber;
25
- $this->_parse();
26
-
27
- return $this;
28
- }
29
-
30
  protected function _parse()
31
  {
32
  $this->setCustomerId($this->_buildCustomerId())
@@ -35,8 +27,7 @@ class Springbot_Combine_Model_Parser_Subscriber extends Springbot_Combine_Model_
35
  ->setEmail($this->_subscriber->getSubscriberEmail())
36
  ->setOptinStatus($this->_subscriber->getSubscriberStatus())
37
  ->setSubscriberMode(self::SUBSCRIBER_MODE)
38
- ->setCustomerType(self::TYPE)
39
- ;
40
  return parent::_parse();
41
  }
42
 
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Parser_Subscriber extends Springbot_Combine_Model_Parser
4
  {
5
  const TYPE = 'SUBSCRIBER';
6
  const SUBSCRIBER_MODE = 'NL';
19
  return !empty($customerId);
20
  }
21
 
 
 
 
 
 
 
 
 
22
  protected function _parse()
23
  {
24
  $this->setCustomerId($this->_buildCustomerId())
27
  ->setEmail($this->_subscriber->getSubscriberEmail())
28
  ->setOptinStatus($this->_subscriber->getSubscriberStatus())
29
  ->setSubscriberMode(self::SUBSCRIBER_MODE)
30
+ ->setCustomerType(self::TYPE);
 
31
  return parent::_parse();
32
  }
33
 
app/code/community/Springbot/Combine/Model/Redirect.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Redirect extends Springbot_Combine_Model_Abstract
4
  {
5
  public function _construct()
6
  {
@@ -27,4 +27,21 @@ class Springbot_Combine_Model_Redirect extends Springbot_Combine_Model_Abstract
27
  $ids = $collection->getAllIds();
28
  return $ids;
29
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Redirect extends Mage_Core_Model_Abstract
4
  {
5
  public function _construct()
6
  {
27
  $ids = $collection->getAllIds();
28
  return $ids;
29
  }
30
+
31
+ /**
32
+ * Insert ignore into collection
33
+ */
34
+ public function insertIgnore()
35
+ {
36
+ try {
37
+ if($this->_validate()) {
38
+ $this->_getResource()->insertIgnore($this);
39
+ }
40
+ } catch(Exception $e) {
41
+ $this->_getResource()->rollBack();
42
+ Springbot_Log::error($e);
43
+ }
44
+
45
+ return $this;
46
+ }
47
  }
app/code/community/Springbot/Combine/Model/Redirect/Order.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Combine_Model_Redirect_Order extends Springbot_Combine_Model_Abstract
4
  {
5
  public function _construct()
6
  {
@@ -14,4 +14,21 @@ class Springbot_Combine_Model_Redirect_Order extends Springbot_Combine_Model_Abs
14
  $orderId = $this->getOrderId();
15
  return !(empty($entity) || empty($orderId));
16
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
1
  <?php
2
 
3
+ class Springbot_Combine_Model_Redirect_Order extends Mage_Core_Model_Abstract
4
  {
5
  public function _construct()
6
  {
14
  $orderId = $this->getOrderId();
15
  return !(empty($entity) || empty($orderId));
16
  }
17
+
18
+ /**
19
+ * Insert ignore into collection
20
+ */
21
+ public function insertIgnore()
22
+ {
23
+ try {
24
+ if($this->_validate()) {
25
+ $this->_getResource()->insertIgnore($this);
26
+ }
27
+ } catch(Exception $e) {
28
+ $this->_getResource()->rollBack();
29
+ Springbot_Log::error($e);
30
+ }
31
+
32
+ return $this;
33
+ }
34
  }
app/code/community/Springbot/Combine/Model/Resource/Abstract.php CHANGED
@@ -9,7 +9,7 @@ abstract class Springbot_Combine_Model_Resource_Abstract extends Mage_Core_Model
9
  $bind = $this->_prepareDataForSave($object);
10
  $this->_insertIgnore($table, $bind);
11
  } catch (Exception $e) {
12
- Mage::logException($e);
13
  }
14
  }
15
 
9
  $bind = $this->_prepareDataForSave($object);
10
  $this->_insertIgnore($table, $bind);
11
  } catch (Exception $e) {
12
+ Springbot_Log::error($e);
13
  }
14
  }
15
 
app/code/community/Springbot/Combine/Model/Resource/Action.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Combine_Model_Resource_Action extends Springbot_Combine_Model_Resource_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('combine/action', 'id');
8
+ }
9
+
10
+ public function lockEvents($pid, $storeId, $count)
11
+ {
12
+ $count = (int) $count;
13
+ $vars = array(
14
+ 'pid' => $pid,
15
+ 'store_id' => $storeId,
16
+ );
17
+ $cronEventsTable = Mage::getSingleton('core/resource')->getTableName('springbot_actions');
18
+ $write = $this->_getWriter();
19
+ $write->query(
20
+ "UPDATE `{$cronEventsTable}`
21
+ SET `locked_by` = :pid, `locked_at` = NOW()
22
+ WHERE `store_id` = :store_id
23
+ ORDER BY `id`
24
+ LIMIT $count",
25
+ $vars
26
+ );
27
+ }
28
+
29
+ public function removeEvents($pid = null)
30
+ {
31
+ $cronEventsTable = Mage::getSingleton('core/resource')->getTableName('springbot_actions');
32
+ $write = $this->_getWriter();
33
+ $sql = $write->quoteInto("DELETE FROM `{$cronEventsTable}` WHERE `locked_by` = ?;", $pid);
34
+ $write->query($sql);
35
+ }
36
+
37
+ public function removeStoreEventRows($storeId, $pid = null)
38
+ {
39
+ if (is_numeric($storeId) && is_numeric($limit)) {
40
+ $cronEventsTable = Mage::getSingleton('core/resource')->getTableName('springbot_actions');
41
+ $write = $this->_getWriter();
42
+ $sql = $write->quoteInto("DELETE FROM `{$cronEventsTable}` WHERE `store_id` = ?", $storeId);
43
+
44
+ if($pid) {
45
+ $sql .= " AND `locked_by` = $pid";
46
+ }
47
+
48
+ $write->query($sql);
49
+ }
50
+ }
51
+
52
+ public function releaseLocksForPid($pid)
53
+ {
54
+ $cronEventsTable = Mage::getSingleton('core/resource')->getTableName('springbot_actions');
55
+ $write = $this->_getWriter();
56
+ $sql = $write->quoteInto("UPDATE `{$cronEventsTable}` SET `locked_by` = NULL, `locked_at` = NULL WHERE `locked_by`", $pid);
57
+ $write->query($sql);
58
+ }
59
+
60
+ public function releaseOldLocks($hoursOld)
61
+ {
62
+ $cronEventsTable = Mage::getSingleton('core/resource')->getTableName('springbot_actions');
63
+ $write = $this->_getWriter();
64
+ $sql = $write->quoteInto("UPDATE `{$cronEventsTable}` SET `locked_by` = NULL, `locked_at` = NULL WHERE `locked_at` < DATE_SUB(NOW(), INTERVAL ? HOUR)", $hoursOld);
65
+ $write->query($sql);
66
+ }
67
+
68
+ protected function _getWriter()
69
+ {
70
+ return Mage::getSingleton('core/resource')->getConnection('core_write');
71
+ }
72
+ }
app/code/community/Springbot/Combine/Model/Resource/Action/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Combine_Model_Resource_Action_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('combine/action');
8
+ }
9
+
10
+ public function getEvents($storeId, $limit = 200)
11
+ {
12
+ $this->addFieldToFilter('store_id', $storeId)
13
+ ->setPage(1, $limit);
14
+ return $this;
15
+ }
16
+
17
+ public function getLockedEvents($storeId, $pid = null)
18
+ {
19
+ if($pid) {
20
+ $this->addFieldToFilter('locked_by', $pid);
21
+ }
22
+ $this->addFieldToFilter('store_id', $storeId);
23
+ return $this;
24
+ }
25
+ }
app/code/community/Springbot/Combine/Model/Resource/Cron/Queue.php CHANGED
@@ -7,19 +7,18 @@ class Springbot_Combine_Model_Resource_Cron_Queue extends Springbot_Combine_Mode
7
  $this->_init('combine/cron_queue', 'id');
8
  }
9
 
10
- public function removeHarvestRows()
11
  {
12
  $cronQueueTable = Mage::getSingleton('core/resource')->getTableName('springbot_cron_queue');
13
  $write = $this->_getWriter();
14
- $write->query("DELETE FROM `{$cronQueueTable}` WHERE `queue` != 'listener';");
15
- }
 
 
 
 
 
16
 
17
- public function removeStoreHarvestRows($storeId)
18
- {
19
- $cronQueueTable = Mage::getSingleton('core/resource')->getTableName('springbot_cron_queue');
20
- $write = $this->_getWriter();
21
- $sql = $write->quoteInto("DELETE FROM `{$cronQueueTable}` WHERE `store_id` = ?", $storeId);
22
- $write->query($sql);
23
  }
24
 
25
  public function lockRows($rowIds)
@@ -44,13 +43,10 @@ class Springbot_Combine_Model_Resource_Cron_Queue extends Springbot_Combine_Mode
44
  $cronQueueTable = Mage::getSingleton('core/resource')->getTableName('springbot_cron_queue');
45
  $write = $this->_getWriter($cronQueueTable);
46
  $sql = "UPDATE `{$cronQueueTable}` SET `locked_at` = NULL, `locked_by` = NULL WHERE `locked_by` IS NOT NULL AND `locked_by` ";
47
-
48
  if(count($activeIds)) {
49
  $sql = $write->quoteInto($sql . " NOT IN (?)", $activeIds);
50
  }
51
-
52
  Springbot_Log::debug($sql);
53
-
54
  $write->query($sql);
55
  }
56
 
7
  $this->_init('combine/cron_queue', 'id');
8
  }
9
 
10
+ public function removeHarvestRows($storeId = null)
11
  {
12
  $cronQueueTable = Mage::getSingleton('core/resource')->getTableName('springbot_cron_queue');
13
  $write = $this->_getWriter();
14
+ if (is_null($storeId)) {
15
+ $write->query("DELETE FROM `{$cronQueueTable}` WHERE `queue` != 'listener';");
16
+ }
17
+ else {
18
+ $sql = $write->quoteInto("DELETE FROM `{$cronQueueTable}` WHERE `store_id` = ?", $storeId);
19
+ $write->query($sql);
20
+ }
21
 
 
 
 
 
 
 
22
  }
23
 
24
  public function lockRows($rowIds)
43
  $cronQueueTable = Mage::getSingleton('core/resource')->getTableName('springbot_cron_queue');
44
  $write = $this->_getWriter($cronQueueTable);
45
  $sql = "UPDATE `{$cronQueueTable}` SET `locked_at` = NULL, `locked_by` = NULL WHERE `locked_by` IS NOT NULL AND `locked_by` ";
 
46
  if(count($activeIds)) {
47
  $sql = $write->quoteInto($sql . " NOT IN (?)", $activeIds);
48
  }
 
49
  Springbot_Log::debug($sql);
 
50
  $write->query($sql);
51
  }
52
 
app/code/community/Springbot/Combine/Model/Resource/Cron/Queue/Collection.php CHANGED
@@ -19,7 +19,11 @@ class Springbot_Combine_Model_Resource_Cron_Queue_Collection extends Mage_Core_M
19
  {
20
  $this->getSelect()
21
  ->where('locked_at IS NULL')
22
- ->where('attempts < ?', $this->getAttemptLimit());
 
 
 
 
23
 
24
  // Only foreman can process the default queue
25
  if(!$isForeman) {
19
  {
20
  $this->getSelect()
21
  ->where('locked_at IS NULL')
22
+ ->where('attempts < ?', $this->getAttemptLimit())
23
+ ->where(
24
+ "(next_run_at IS NULL OR next_run_at < ?)",
25
+ date("Y-m-d H:i:s")
26
+ );
27
 
28
  // Only foreman can process the default queue
29
  if(!$isForeman) {
app/code/community/Springbot/Combine/Model/Resource/Setup.php CHANGED
@@ -34,7 +34,6 @@ class Springbot_Combine_Model_Resource_Setup extends Mage_Core_Model_Resource_Se
34
  public function resendInstallLog()
35
  {
36
  $this->getSiteDetails();
37
- $this->setDefaultPhpPath();
38
  $this->submit();
39
  }
40
 
@@ -43,11 +42,6 @@ class Springbot_Combine_Model_Resource_Setup extends Mage_Core_Model_Resource_Se
43
  return $this->_data;
44
  }
45
 
46
- public function bugOut()
47
- {
48
- echo Zend_Json::prettyPrint($this->toJson());
49
- }
50
-
51
  public function getSiteDetails()
52
  {
53
  try{
@@ -60,19 +54,6 @@ class Springbot_Combine_Model_Resource_Setup extends Mage_Core_Model_Resource_Se
60
  return true;
61
  }
62
 
63
- public function setDefaultPhpPath()
64
- {
65
- $phpPaths = $this->_getPhpExecutablePaths();
66
- if(isset($phpPaths['php-cli']) && ($phpPaths['php-cli'])) {
67
- Springbot_Log::debug('Setting default php path to ' . $phpPaths['php-cli']);
68
- Mage::getModel('core/config')->saveConfig('springbot/config/php_exec', $phpPaths['php-cli'] );
69
- }
70
- elseif(isset($phpPaths['php5']) && ($phpPaths['php5'])) {
71
- Springbot_Log::debug('Setting default php path to ' . $phpPaths['php5']);
72
- Mage::getModel('core/config')->saveConfig('springbot/config/php_exec', $phpPaths['php5'] );
73
- }
74
- }
75
-
76
  public function fetchConfig()
77
  {
78
  $this->_getApp()->reinitStores();
@@ -167,7 +148,6 @@ class Springbot_Combine_Model_Resource_Setup extends Mage_Core_Model_Resource_Se
167
  )
168
  ),
169
  'phpinfo' => $this->_phpinfoArray(true),
170
- 'php_executable_paths' => $this->_getPhpExecutablePaths(),
171
  );
172
  }
173
 
@@ -233,19 +213,6 @@ class Springbot_Combine_Model_Resource_Setup extends Mage_Core_Model_Resource_Se
233
  return $check == "ok" ? "ok" : "could not execute php as shell";
234
  }
235
 
236
- protected function _getPhpExecutablePaths()
237
- {
238
- $returnVar = null;
239
- ob_start();
240
- $outputs = array(
241
- 'php' => Springbot_Boss::spawn("which -a php", $returnVar),
242
- 'php5' => Springbot_Boss::spawn("which -a php5", $returnVar),
243
- 'php-cli' => Springbot_Boss::spawn("which -a php-cli", $returnVar),
244
- );
245
- ob_end_clean();
246
- return $outputs;
247
- }
248
-
249
  protected function _phpinfoArray($return=false){
250
  /* Andale! Andale! Yee-Hah! */
251
  ob_start();
34
  public function resendInstallLog()
35
  {
36
  $this->getSiteDetails();
 
37
  $this->submit();
38
  }
39
 
42
  return $this->_data;
43
  }
44
 
 
 
 
 
 
45
  public function getSiteDetails()
46
  {
47
  try{
54
  return true;
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  public function fetchConfig()
58
  {
59
  $this->_getApp()->reinitStores();
148
  )
149
  ),
150
  'phpinfo' => $this->_phpinfoArray(true),
 
151
  );
152
  }
153
 
213
  return $check == "ok" ? "ok" : "could not execute php as shell";
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  protected function _phpinfoArray($return=false){
217
  /* Andale! Andale! Yee-Hah! */
218
  ob_start();
app/code/community/Springbot/Combine/Model/Trackable.php CHANGED
@@ -10,19 +10,83 @@ class Springbot_Combine_Model_Trackable extends Mage_Core_Model_Abstract
10
  public function createOrUpdate()
11
  {
12
  if($this->_validate()) {
13
- if($this->getResource()->create($this)) {
14
- } else {
15
  $this->save();
16
  }
17
  }
 
 
18
  return $this;
19
  }
20
 
21
  protected function _validate()
22
  {
23
- return !empty($this->_data['email']) &&
24
- !empty($this->_data['type']) &&
25
  !empty($this->_data['value']) &&
26
  !empty($this->_data['quote_id']);
27
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
10
  public function createOrUpdate()
11
  {
12
  if($this->_validate()) {
13
+ if (!$this->getResource()->create($this)) {
 
14
  $this->save();
15
  }
16
  }
17
+ $trackables = $this->getTrackables();
18
+ $this->_setSbTrackablesCookie($trackables);
19
  return $this;
20
  }
21
 
22
  protected function _validate()
23
  {
24
+ return !empty($this->_data['type']) &&
 
25
  !empty($this->_data['value']) &&
26
  !empty($this->_data['quote_id']);
27
  }
28
+
29
+ public function updateTrackables($order)
30
+ {
31
+ foreach ($this->getTrackablesForQuote($order->getId()) as $trackable) {
32
+ $trackable->setOrderId($order->getId())
33
+ ->setCustomerId($order->getCustomerId())
34
+ ->save();
35
+ }
36
+ }
37
+
38
+ public function getTrackablesForQuote($quoteId)
39
+ {
40
+ return Mage::getModel('combine/trackable')->getCollection()
41
+ ->addFieldToFilter('quote_id', $quoteId);
42
+ }
43
+
44
+ public function isObjectEmpty($obj)
45
+ {
46
+ return count((array) $obj) == 0;
47
+ }
48
+
49
+ private function _setSbTrackablesCookie($params)
50
+ {
51
+ if (!$this->isObjectEmpty($params)) {
52
+ $encoded = base64_encode(json_encode($params));
53
+ $this->_setCookie(Springbot_Boss::SB_TRACKABLES_COOKIE, $encoded);
54
+ }
55
+ }
56
+
57
+ public function getTrackables()
58
+ {
59
+ $params = Mage::app()->getRequest()->getParams();
60
+ $origParams = Mage::helper('combine/trackable')->getTrackables();
61
+ if ($origParams) {
62
+ $sbParams = clone $origParams;
63
+ }
64
+ else {
65
+ $sbParams = new stdClass();
66
+ }
67
+ foreach ($params as $param => $value) {
68
+ if (preg_match('/^sb_/', $param)) {
69
+ Springbot_Log::debug("Assigning $param from url with $value");
70
+ $sbParams->$param = $value;
71
+ }
72
+ }
73
+ return !$this->isObjectEmpty($sbParams) ? $sbParams : new stdClass();
74
+ }
75
+
76
+ protected function _setCookie($name, $value)
77
+ {
78
+ Springbot_Log::debug("Saving cookie $name : $value");
79
+
80
+ Mage::getModel('core/cookie')->set(
81
+ $name,
82
+ $value,
83
+ strtotime('+365 days'),
84
+ '/', // path
85
+ null, // domain
86
+ null, // secure
87
+ false // httpOnly
88
+ );
89
+ }
90
+
91
+
92
  }
app/code/community/Springbot/Combine/etc/config.xml CHANGED
@@ -1,16 +1,8 @@
1
  <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category springbot
5
- * @package springbot_Combine
6
- * @author springbot integration team
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- -->
10
  <config>
11
  <modules>
12
  <Springbot_Combine>
13
- <version>1.3.0.8</version>
14
  </Springbot_Combine>
15
  </modules>
16
  <global>
@@ -32,6 +24,9 @@
32
  <trackable>
33
  <table>springbot_trackable</table>
34
  </trackable>
 
 
 
35
  <cron_queue>
36
  <table>springbot_cron_queue</table>
37
  </cron_queue>
@@ -85,17 +80,19 @@
85
  <debug>
86
  <log_format>default</log_format>
87
  <log_level>6</log_level>
88
- <expire_time_days>30</expire_time_days>
89
- <filesize_limit>104857600</filesize_limit>
 
90
  </debug>
91
  <advanced>
92
  <nice>0</nice>
93
  <nohup>0</nohup>
94
- <worker_count>5</worker_count>
95
  <sleep_interval>1</sleep_interval>
96
  <extended_config>0</extended_config>
97
  <product_url_type>default</product_url_type>
98
- <assets_domain>assets.springbot.com</assets_domain>
 
99
  </advanced>
100
  <cart_restore>
101
  <do_restore>1</do_restore>
@@ -103,7 +100,7 @@
103
  </cart_restore>
104
  <cron>
105
  <enabled>0</enabled>
106
- <max_jobs>10</max_jobs>
107
  </cron>
108
  </springbot>
109
  </default>
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
 
2
  <config>
3
  <modules>
4
  <Springbot_Combine>
5
+ <version>1.4.0.1</version>
6
  </Springbot_Combine>
7
  </modules>
8
  <global>
24
  <trackable>
25
  <table>springbot_trackable</table>
26
  </trackable>
27
+ <action>
28
+ <table>springbot_actions</table>
29
+ </action>
30
  <cron_queue>
31
  <table>springbot_cron_queue</table>
32
  </cron_queue>
80
  <debug>
81
  <log_format>default</log_format>
82
  <log_level>6</log_level>
83
+ <pretty_print>0</pretty_print>
84
+ <expire_time_days>10</expire_time_days>
85
+ <filesize_limit>10000000</filesize_limit>
86
  </debug>
87
  <advanced>
88
  <nice>0</nice>
89
  <nohup>0</nohup>
90
+ <worker_count>2</worker_count>
91
  <sleep_interval>1</sleep_interval>
92
  <extended_config>0</extended_config>
93
  <product_url_type>default</product_url_type>
94
+ <assets_domain>d2z0bn1jv8xwtk.cloudfront.net</assets_domain>
95
+ <scrape_coupons>0</scrape_coupons>
96
  </advanced>
97
  <cart_restore>
98
  <do_restore>1</do_restore>
100
  </cart_restore>
101
  <cron>
102
  <enabled>0</enabled>
103
+ <max_jobs>1</max_jobs>
104
  </cron>
105
  </springbot>
106
  </default>
app/code/community/Springbot/Combine/etc/system.xml CHANGED
@@ -124,14 +124,13 @@
124
  <comment>Comma separated list of Classes for the frontend field where a user enters their email address.</comment>
125
  </email_selector>
126
  <security_token translate="label">
127
- <label>Security Token</label>
128
- <frontend_type>text</frontend_type>
129
- <sort_order>110</sort_order>
130
- <show_in_default>1</show_in_default>
131
- <show_in_website>0</show_in_website>
132
- <comment>Springbot supplied security token.</comment>
133
  </security_token>
134
-
135
  </fields>
136
  </config>
137
  <images translate="label">
@@ -183,6 +182,16 @@
183
  <show_in_store>0</show_in_store>
184
  <comment>&lt;strong style="color:red"&gt;Warning!&lt;/strong&gt; Please monitor disk space if setting to Debug level, filesize may grow rapidly.</comment>
185
  </log_http>
 
 
 
 
 
 
 
 
 
 
186
  <log_level translate="label">
187
  <label>Log Level</label>
188
  <frontend_type>select</frontend_type>
124
  <comment>Comma separated list of Classes for the frontend field where a user enters their email address.</comment>
125
  </email_selector>
126
  <security_token translate="label">
127
+ <label>Security Token</label>
128
+ <frontend_type>text</frontend_type>
129
+ <sort_order>110</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>0</show_in_website>
132
+ <comment>Springbot supplied security token.</comment>
133
  </security_token>
 
134
  </fields>
135
  </config>
136
  <images translate="label">
182
  <show_in_store>0</show_in_store>
183
  <comment>&lt;strong style="color:red"&gt;Warning!&lt;/strong&gt; Please monitor disk space if setting to Debug level, filesize may grow rapidly.</comment>
184
  </log_http>
185
+ <pretty_print translate="label">
186
+ <label>Pretty Print HTTP Requests in Log</label>
187
+ <frontend_type>select</frontend_type>
188
+ <source_model>adminhtml/system_config_source_yesno</source_model>
189
+ <sort_order>15</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>0</show_in_website>
192
+ <show_in_store>0</show_in_store>
193
+ <depends><log_http>1</log_http></depends>
194
+ </pretty_print>
195
  <log_level translate="label">
196
  <label>Log Level</label>
197
  <frontend_type>select</frontend_type>
app/code/community/Springbot/Combine/sql/combine_setup/mysql4-install-1.0.0.70.php CHANGED
@@ -5,14 +5,13 @@ $installer = $this;
5
 
6
  $installer->startSetup();
7
 
8
- try
9
- {
10
  $installer->getSiteDetails();
11
- $installer->setDefaultPhpPath();
12
  if(!Mage::getStoreConfig('springbot/debug/skip_install_log')) {
13
  $installer->submit();
14
  }
15
- } catch (Exception $e) {
16
- Mage::logException($e);
 
17
  }
18
  $installer->endSetup();
5
 
6
  $installer->startSetup();
7
 
8
+ try {
 
9
  $installer->getSiteDetails();
 
10
  if(!Mage::getStoreConfig('springbot/debug/skip_install_log')) {
11
  $installer->submit();
12
  }
13
+ }
14
+ catch (Exception $e) {
15
+ Springbot_Log::error($e);
16
  }
17
  $installer->endSetup();
app/code/community/Springbot/Combine/sql/combine_setup/mysql4-upgrade-1.0.0.88-1.2.0.0.php CHANGED
@@ -10,7 +10,7 @@ $installer->getConnection()->beginTransaction();
10
  $session = Mage::getSingleton('core/session');
11
 
12
  try {
13
- $installer->run("
14
  CREATE TABLE IF NOT EXISTS `{$installer->getTable('combine/trackable')}`
15
  (
16
  `id` INT(11) unsigned NOT NULL auto_increment,
@@ -28,8 +28,8 @@ $installer->run("
28
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29
  ");
30
  } catch (Exception $e) {
31
- Mage::log('Install failed clear and retry');
32
- if(!$session->getSbReinstall()) {
33
  $session->setSbReinstall(true);
34
  $installer->reinstallSetupScript('1.0.0.70', '1.2.0.0');
35
  }
10
  $session = Mage::getSingleton('core/session');
11
 
12
  try {
13
+ $installer->run("
14
  CREATE TABLE IF NOT EXISTS `{$installer->getTable('combine/trackable')}`
15
  (
16
  `id` INT(11) unsigned NOT NULL auto_increment,
28
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29
  ");
30
  } catch (Exception $e) {
31
+ Springbot_Log::error(new Exception('Install failed clear and retry'));
32
+ if (!$session->getSbReinstall()) {
33
  $session->setSbReinstall(true);
34
  $installer->reinstallSetupScript('1.0.0.70', '1.2.0.0');
35
  }
app/code/community/Springbot/Combine/sql/combine_setup/mysql4-upgrade-1.2.0.1-1.2.1.0.php CHANGED
@@ -41,7 +41,7 @@ $installer->run("
41
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
42
  ");
43
  } catch (Exception $e) {
44
- Mage::log('Springbot 1.2.0.0-1.2.1.0 update failed!');
45
  }
46
 
47
  $installer->endSetup();
41
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
42
  ");
43
  } catch (Exception $e) {
44
+ Springbot_Log::error('Springbot 1.2.0.0-1.2.1.0 update failed!');
45
  }
46
 
47
  $installer->endSetup();
app/code/community/Springbot/Combine/sql/combine_setup/mysql4-upgrade-1.3.9.9-1.4.0.0.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Springbot_Combine_Model_Resource_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ $installer->getConnection()->beginTransaction();
9
+
10
+ $session = Mage::getSingleton('core/session');
11
+
12
+ try {
13
+ $installer->run("
14
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('combine/action')}`
15
+ (
16
+ `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
17
+ `type` ENUM('atc', 'view', 'purchase') NOT NULL,
18
+ `store_id` INT NOT NULL,
19
+ `visitor_ip` VARCHAR(100) NOT NULL,
20
+ `page_url` TEXT NULL,
21
+ `sku` VARCHAR(255) NOT NULL,
22
+ `sku_fulfillment` VARCHAR(255) NOT NULL,
23
+ `quantity` INT UNSIGNED DEFAULT 1,
24
+ `purchase_id` INT UNSIGNED NULL,
25
+ `quote_id` INT UNSIGNED NULL,
26
+ `category_id` INT UNSIGNED NULL,
27
+ `locked_by` VARCHAR(255) NULL,
28
+ `locked_at` DATETIME NULL,
29
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
30
+ PRIMARY KEY (`id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32
+ ");
33
+
34
+ $installer->run("ALTER TABLE `{$installer->getTable('combine/cron_queue')}` ADD COLUMN `next_run_at` DATETIME NULL AFTER `error`;");
35
+ } catch (Exception $e) {
36
+ Springbot_Log::error('Springbot 1.2.1.0-1.4.0.0 update failed!');
37
+ Springbot_Log::error(new Exception('Install failed clear and retry'));
38
+ if (!$session->getSbReinstall()) {
39
+ $session->setSbReinstall(true);
40
+ $installer->reinstallSetupScript('1.2.1.0', '1.4.0.0');
41
+ }
42
+ }
43
+
44
+ $installer->endSetup();
app/code/community/Springbot/DataServices/HarvestingManager.php DELETED
@@ -1,447 +0,0 @@
1
- <?php
2
- /**
3
- * Harvesting Manager
4
- *
5
- * @version v1.0.45 - 12/26/2012
6
- *
7
- * @category Magento Integrations
8
- * @package springbot
9
- * @author William Seitz
10
- * @division SpringBot Integration Team
11
- * @support magentosupport@springbot.com
12
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
- *
14
- */
15
-
16
- class Springbot_DataServices_HarvestingManager
17
- {
18
- const MAGENTO_PACKAGE_VERSION = '1.3.0.10';
19
- const SUCCESSFUL_RESPONSE = 'ok';
20
- const DATE_FORMAT = 'Y-m-d H:i:s';
21
-
22
- private $rootAppPath = '';
23
- private $eventHistoryFilename = '';
24
-
25
- public function __construct()
26
- {
27
- $this->rootAppPath = Mage::getBaseDir();
28
- $this->eventHistoryFilename = $this->rootAppPath . '/var/log/Springbot-EventHistory.csv';
29
- }
30
-
31
- public function harvestHealthCheck($storeId)
32
- {
33
- $this->springbotStoreID = Mage::helper('combine/harvest')->getSpringbotStoreId($storeId);
34
- $result = Mage::getModel('combine/api')->call('harvest_master', '{"store_id":"'.$this->springbotStoreID.'","version":"'.self::MAGENTO_PACKAGE_VERSION.'"}');
35
-
36
- echo "Harvest HealthCheck store: {$storeId}/{$this->springbotStoreID}" . PHP_EOL;
37
-
38
- if ($result['status']==self::SUCCESSFUL_RESPONSE) {
39
-
40
- foreach ($result['commands'] as $cmd) {
41
- $this->showMessage('Command->'.$cmd['command'].' is being processed.');
42
- switch (trim(strtolower($cmd['command']))) {
43
- case 'get_log':
44
- if (isset($cmd['data']['log_name'])) {
45
- $this->getlog($cmd['data']['log_name']);
46
- } else {
47
- $this->getlog();
48
- }
49
- break;
50
-
51
- case 'setvar':
52
- case 'set_var':
53
- $this->setConfigVar($cmd['data']['var_name'], $cmd['data']['var_value']);
54
- Mage::getConfig()->cleanCache();
55
- break;
56
-
57
- case 'post':
58
- $type = isset($cmd['data']['type']) ? $cmd['data']['type'] : null;
59
- $id = isset($cmd['data']['entity_id']) ? $cmd['data']['entity_id'] : null;
60
- $this->postItem($type, $id);
61
-
62
- case 'package_update':
63
- $version = isset($cmd['data']['package_version']) ? $cmd['data']['package_version'] : null;
64
- $this->updatePackage($version);
65
- break;
66
-
67
- case 'full_harvest':
68
- case 'launch_full_harvest':
69
- Springbot_Boss::launchHarvest();
70
- break;
71
-
72
- case 'partial_harvest':
73
- $type = isset($cmd['data']['type']) ? $cmd['data']['type'] : null;
74
- $this->launchPartialHarvest($storeId, $type);
75
- break;
76
-
77
- case 'resume_harvest':
78
- Mage::getConfig()->cleanCache();
79
- Mage::getConfig()->reinit();
80
- $this->resumeHarvest();
81
- break;
82
-
83
- case 'file_replace':
84
- $this->fileReplace($cmd['data']['target_dir'],$cmd['data']['source']);
85
- break;
86
-
87
- case 'adroll_turn_on':
88
- $this->setAdrollFeature($cmd['store_id'],$cmd,true);
89
- break;
90
-
91
- case 'adroll_turn_off':
92
- $this->setAdrollFeature($cmd['store_id'],$cmd,false);
93
- break;
94
-
95
- case 'kill_harvest':
96
- Springbot_Boss::halt();
97
- break;
98
-
99
- case 'table_data':
100
- $this->logTableData();
101
- break;
102
-
103
- case 'forecast':
104
- Springbot_Services_Cmd_Forecast::forecastAllStores();
105
- break;
106
-
107
- case 'skip_store_harvest':
108
- Springbot_Boss::haltStore($cmd['store_id']);
109
- break;
110
-
111
- }
112
- }
113
- $this->deliverEventLog();
114
- }
115
- return;
116
- }
117
-
118
- public function getlog($logName = '')
119
- {
120
- $buffer = Mage::helper('combine')->getLogContents($logName);
121
-
122
- $logData = array(
123
- 'logs' => array(
124
- array(
125
- 'store_id' => $this->springbotStoreID,
126
- 'description' => $buffer,
127
- ),
128
- ),
129
- );
130
-
131
- $method = 'logs';
132
-
133
- Mage::getModel('combine/api')->call($method, json_encode($logData), false);
134
-
135
- if (isset($result['status'])) {
136
- if ($result['status']==self::SUCCESSFUL_RESPONSE) {
137
- $error_msg='was successfully delivered';
138
- } else {
139
- $error_msg='delivery failed ->'.$result['status'];
140
- }
141
- }
142
- $this->showMessage('['.__METHOD__.'] '.' '.$error_msg);
143
- }
144
-
145
- private function setConfigVar($varName, $varValue)
146
- {
147
- $varName = trim($varName);
148
- if(!preg_match('/.*\/.*\/.*/', $varName)) {
149
- $varName = 'springbot/config/' . $varName;
150
- }
151
- if (!empty($varName) && ($varName != 'springbot/config/php_exec')) {
152
- $this->set_config($varName, $varValue);
153
- }
154
- return;
155
- }
156
-
157
- private function deliverEventLog()
158
- {
159
- $maxRecord = 8192;
160
- $delimiter = ',';
161
- $eventHistoryArchiveFilename = $this->rootAppPath.'/var/log/Springbot-EventHistory-Archive.csv';
162
-
163
- if (file_exists($eventHistoryArchiveFilename)) {
164
- $this->showMessage('Purge existing archive '.$eventHistoryArchiveFilename);
165
- unlink ($eventHistoryArchiveFilename);
166
- }
167
- $this->showMessage('Snapshot '.$this->eventHistoryFilename.' -> '.$eventHistoryArchiveFilename);
168
- copy($this->eventHistoryFilename, $eventHistoryArchiveFilename);
169
- $handle = fopen($this->eventHistoryFilename, 'w');
170
- if ($handle) {
171
- $this->showMessage('Erasing '.$this->eventHistoryFilename);
172
- fclose($handle);
173
- } else {
174
- $this->showMessage('Open/Erase failed on '.$this->eventHistoryFilename);
175
- }
176
-
177
- /* Get Unique Store Number */
178
- $store_number_list=array();
179
- if (($handle = fopen($eventHistoryArchiveFilename, 'r')) !== FALSE) {
180
- while (($rawRow = fgetcsv($handle, $maxRecord, $delimiter)) !== FALSE) {
181
- $data = array();
182
- $storeNumber = '';
183
- switch ($this->captureValue(0,$rawRow)) {
184
- case 'view':
185
- $storeNumber = $this->captureValue(5,$rawRow);
186
- break;
187
- case 'purchase':
188
- $storeNumber = $this->captureValue(5,$rawRow);
189
- break;
190
- case 'atc':
191
- $storeNumber = $this->captureValue(4,$rawRow);
192
- break;
193
- }
194
- if (!empty($storeNumber) && !in_array($storeNumber, $store_number_list)) {$store_number_list[]=$storeNumber;}
195
- }
196
- fclose($handle);
197
- }
198
- foreach ($store_number_list as $storeNumber) {
199
- if ($storeNumber=='' || empty($storeNumber)) {
200
- } else {
201
-
202
- $springbotStoreID = Mage::helper('combine/harvest')->getSpringbotStoreId($storeNumber);
203
-
204
- $logData = array();
205
- if (($handle = fopen($eventHistoryArchiveFilename, 'r')) !== FALSE) {
206
- $this->showMessage('Formatting'.$eventHistoryArchiveFilename);
207
- $actionCount=0;
208
- while (($rawRow = fgetcsv($handle, $maxRecord, $delimiter)) !== FALSE) {
209
- $actionCount++;
210
- $row = array();
211
- $data = array();
212
- foreach ($rawRow as $val) {
213
- $row[]=preg_replace('/[^(\x20-\x7F)]*/','', $val);
214
- }
215
- $data['action'] = $this->captureValue(0,$row);
216
- $data['datetime'] = $this->captureValue(1,$row);
217
-
218
- switch ($data['action']) {
219
- case 'view':
220
- $currentURL = $this->captureValue(2,$row);
221
- $currentIP = $this->captureValue(4,$row);
222
- $data['page_url'] = $currentURL;
223
- $data['sku'] = $this->captureValue(3,$row);
224
- $data['sku_fulfillment'] = $this->captureValue(3,$row);
225
- $data['visitor_ip'] = $currentIP;
226
- $data['category_id'] = $this->captureValue(6,$row);
227
- $eventStoreNumber = $this->captureValue(5,$row);
228
- break;
229
-
230
- case 'purchase':
231
- $data['sku'] = $this->captureValue(2,$row);
232
- $data['sku_fulfillment'] = $this->captureValue(3,$row);
233
- $data['purchase_id'] = $this->captureValue(4,$row);
234
- $data['category_id'] = $this->captureValue(6,$row);
235
- $eventStoreNumber = $this->captureValue(5,$row);
236
- break;
237
-
238
- case 'atc':
239
- $data['sku'] = $this->captureValue(2,$row);
240
- $data['sku_fulfillment'] = $this->captureValue(2,$row);
241
- $data['quote_id'] = $this->captureValue(3,$row);
242
- $eventStoreNumber = $this->captureValue(4,$row);
243
- $data['category_id'] = $this->captureValue(5,$row);
244
- break;
245
-
246
- default:
247
- $data['sku'] = '';
248
- $eventStoreNumber = '';
249
-
250
- }
251
- if ($eventStoreNumber==$storeNumber && !empty($data['sku'])) { array_push($logData, $data); }
252
-
253
- }
254
- $this->showMessage('Store->'.$storeNumber.' had '.$actionCount.' actions extracted from '.$eventHistoryArchiveFilename);
255
- fclose($handle);
256
- }
257
- if (sizeof($logData) == 0) {
258
- $this->showMessage('Empty '.$eventHistoryArchiveFilename);
259
- } else {
260
- $this->showMessage('Delivering '.$eventHistoryArchiveFilename);
261
- $method = 'stores/'.$springbotStoreID.'/products/actions/create';
262
- $result = Mage::getModel('combine/api')->call($method, json_encode($logData));
263
-
264
- if (isset($result['status'])) {
265
- if ($result['status']==self::SUCCESSFUL_RESPONSE) {
266
- $error_msg='was successfully delivered';
267
- } else {
268
- $error_msg='delivery failed ->'.$result['status'];
269
- }
270
- } else {
271
- $error_msg=' delivery failed (No status array) ->'.$result;
272
- }
273
- $this->showMessage('['.$method.'] '.$eventHistoryArchiveFilename.' '.$error_msg);
274
- }
275
- } // end foreach
276
- }
277
- return;
278
- }
279
-
280
- private function captureValue($ix,$rowArray)
281
- {
282
- if (isset($rowArray[$ix])) {
283
- return $rowArray[$ix];
284
- } else {
285
- return '';
286
- }
287
- }
288
-
289
- public function updatePackage($version)
290
- {
291
- $updater = new Springbot_Services_Cmd_Update();
292
- $updater->setVersion($version);
293
- $updater->run();
294
- return true;
295
- }
296
-
297
- private function fileReplace($target,$source)
298
- {
299
- $openModeOutput = 'w';
300
- $origSize = 0;
301
-
302
- $magentoRootDir = $this->rootAppPath;
303
- if (substr($target,0,1) != '/') {
304
- $qualifiedFilename = $magentoRootDir.'/'.$target;
305
- } else {
306
- $qualifiedFilename = $magentoRootDir.$target;
307
- }
308
-
309
- /* If file exists make a backup copy */
310
-
311
- if (file_exists($qualifiedFilename)) {
312
- $origSize=filesize($qualifiedFilename);
313
- copy($qualifiedFilename, $qualifiedFilename.'.backup');
314
- }
315
-
316
- $fHandle = fopen($qualifiedFilename,$openModeOutput);
317
- fwrite($fHandle, $source);
318
- fclose($fHandle);
319
- $newSize=filesize($qualifiedFilename);
320
-
321
- $this->showMessage('File Updated->'.$qualifiedFilename.' Original Size:'.$origSize.'; New Size:'.$newSize);
322
-
323
- return;
324
- }
325
-
326
- public function postItem($type, $id)
327
- {
328
- Springbot_Boss::internalCallback(
329
- "post:$id",
330
- array('i' => $id)
331
- );
332
- }
333
-
334
- private function resumeHarvest()
335
- {
336
- Springbot_Boss::internalCallback('work:manager');
337
- }
338
-
339
- private function launchPartialHarvest($storeId, $type)
340
- {
341
- Mage::helper('combine/harvest')->truncateEngineLogs();
342
- Springbot_Boss::scheduleJob(
343
- 'cmd:harvest',
344
- array(
345
- 's' => $storeId,
346
- 'c' => $type,
347
- ),
348
- Springbot_Services_Priority::HARVEST,
349
- 'default',
350
- $storeId
351
- );
352
- }
353
-
354
- private function setAdrollFeature($storeId, $data, $enable)
355
- {
356
- $configPath = 'design/footer/absolute_footer';
357
- $pixel_code = html_entity_decode($data['data']['pixel_script'], ENT_QUOTES);
358
- $new_footer = '';
359
- $existing=$this->RemoveAdRoll($this->get_config($configPath));
360
-
361
- if ($enable) {
362
- if (strlen($pixel_code)>self::ZERO) {
363
- $new_footer = $this->InsertAdrollScript($existing,$pixel_code);
364
- }
365
- } else {
366
- $new_footer = $existing;
367
- }
368
-
369
- // Only set adroll for current store!
370
- $scope_id = Mage::app()->getStore()->getStoreId();
371
- $this->set_config($configPath, $new_footer, 'stores', $storeId);
372
- $this->showMessage($configPath.' is now ['.$new_footer.']');
373
-
374
- return;
375
- }
376
-
377
- private function RemoveAdRoll($existing)
378
- {
379
- $footerLength = strlen($existing);
380
- $bannerPrefix = "<!-- Springbot: Begin Adroll Script ";
381
- $endScriptMarker = "<!-- Springbot: End Adroll Script -->";
382
-
383
- $beginPointer = strpos($existing, $bannerPrefix);
384
- $endPointer = strpos($existing, $endScriptMarker);
385
-
386
- if ($endPointer>self::ZERO) {
387
- return $this->EraseScript($existing,$beginPointer,$endPointer);
388
- } else {
389
- return $existing;
390
- }
391
- return;
392
- }
393
-
394
- private function EraseScript($scriptCode,$begLoc,$endLoc)
395
- {
396
- $strLEN = strlen($scriptCode);
397
- $newScript = '';
398
- for ($c=self::ZERO;$c<$strLEN;$c++) {
399
- if ($c<$begLoc || $c>$endLoc) {
400
- $newScript=$newScript.substr($scriptCode,$c,self::ZERO);
401
- }
402
- }
403
- return $newScript;
404
- }
405
-
406
- private function InsertAdrollScript($currentFooterCode,$ad_pixelCode)
407
- {
408
- $now = date(self::DATE_FORMAT);
409
-
410
- $newFooter = $currentFooterCode
411
- ."<!-- Springbot: Begin Adroll Script ".$now.' -->'."\n"
412
- .$ad_pixelCode
413
- ."<!-- Springbot: End Adroll Script -->";
414
-
415
- return $newFooter;
416
- }
417
-
418
- private function get_config($path)
419
- {
420
- return Mage::getStoreConfig($path);
421
- }
422
-
423
- private function set_config($path, $value, $scope = 'default', $scope_id = 0)
424
- {
425
- return Mage::getModel('core/config')->saveConfig($path, $value, $scope, $scope_id);
426
- }
427
-
428
- private function showMessage($msg, $abort=false, $ignoreMessage=true)
429
- {
430
- Springbot_Log::debug($msg);
431
- if ($ignoreMessage==false) {
432
- Springbot_Log::harvest($msg);
433
- }
434
- if ($abort) {
435
- Springbot_Log::harvest($msg);
436
- Springbot_Log::harvest('Process Abort requested');
437
- exit;
438
- }
439
- return;
440
- }
441
-
442
- public function logTableData() {
443
- $count = Mage::getModel('combine/cron_queue')->getCollection()->count();
444
- Springbot_Log::remote('Cron queue table size: ' . $count);
445
- }
446
-
447
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Log.php CHANGED
@@ -1,15 +1,22 @@
1
  <?php
2
 
 
 
 
 
 
 
 
3
  class Springbot_Log
4
  {
5
- const EMERG = 0; // Emergency: system is unusable
6
- const ALERT = 1; // Alert: action must be taken immediately
7
- const CRIT = 2; // Critical: critical conditions
8
- const ERR = 3; // Error: error conditions
9
- const WARN = 4; // Warning: warning conditions
10
- const NOTICE = 5; // Notice: normal but significant condition
11
- const INFO = 6; // Informational: informational messages
12
- const DEBUG = 7; // Debug: debug messages
13
 
14
  const LOGFILE = 'Springbot.log';
15
  const ERRFILE = 'Springbot.err';
@@ -80,8 +87,22 @@ class Springbot_Log
80
  self::_log($message, Zend_Log::INFO);
81
  }
82
 
83
- public static function error(Exception $e)
 
 
 
 
 
 
 
 
 
 
 
84
  {
 
 
 
85
  self::_log("\n" . $e->__toString(), Zend_Log::ERR, 'default', self::ERRFILE);
86
  }
87
 
@@ -134,4 +155,6 @@ class Springbot_Log
134
  Springbot_Log::harvest('--------------------------------------------------------------------------------', $remote);
135
  }
136
 
 
 
137
  }
1
  <?php
2
 
3
+ /**
4
+ * Class: Springbot_Log
5
+ *
6
+ * @author Springbot Magento Integration Team <magento@springbot.com>
7
+ * @version 1.4.0.0
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
  class Springbot_Log
11
  {
12
+ const EMERG = 0; // Emergency: system is unusable
13
+ const ALERT = 1; // Alert: action must be taken immediately
14
+ const CRIT = 2; // Critical: critical conditions
15
+ const ERR = 3; // Error: error conditions
16
+ const WARN = 4; // Warning: warning conditions
17
+ const NOTICE = 5; // Notice: normal but significant condition
18
+ const INFO = 6; // Informational: informational messages
19
+ const DEBUG = 7; // Debug: debug messages
20
 
21
  const LOGFILE = 'Springbot.log';
22
  const ERRFILE = 'Springbot.err';
87
  self::_log($message, Zend_Log::INFO);
88
  }
89
 
90
+ public static function getSpringbotErrorLog()
91
+ {
92
+ return Mage::getBaseDir('log') . DS . Springbot_Log::ERRFILE;
93
+ }
94
+
95
+ public static function getSpringbotLog()
96
+ {
97
+ return Mage::getBaseDir('log') . DS . Springbot_Log::LOGFILE;
98
+ }
99
+
100
+
101
+ public static function error(Exception $e)
102
  {
103
+ if(is_string($e)) {
104
+ $e = new Exception($e);
105
+ }
106
  self::_log("\n" . $e->__toString(), Zend_Log::ERR, 'default', self::ERRFILE);
107
  }
108
 
155
  Springbot_Log::harvest('--------------------------------------------------------------------------------', $remote);
156
  }
157
 
158
+
159
+
160
  }
app/code/community/Springbot/{Services/Abstract.php → Services.php} RENAMED
@@ -1,9 +1,23 @@
1
  <?php
2
 
3
- abstract class Springbot_Services_Abstract extends Varien_Object
 
 
 
 
 
 
 
 
4
  {
 
 
 
 
 
 
 
5
  protected $_type = 'items';
6
- protected $_harvester;
7
  protected $_startTime;
8
 
9
  protected function _construct()
@@ -18,7 +32,8 @@ abstract class Springbot_Services_Abstract extends Varien_Object
18
  $val = parent::getData($key);
19
 
20
  if(!(isset($val) || is_array($val))) {
21
- throw new Exception($this->_humanize($key) . ' required for harvest!');
 
22
  } else {
23
  return $val;
24
  }
@@ -43,6 +58,12 @@ abstract class Springbot_Services_Abstract extends Varien_Object
43
  }
44
  }
45
 
 
 
 
 
 
 
46
  public function getStartId()
47
  {
48
  return parent::getData('start_id');
@@ -78,29 +99,14 @@ abstract class Springbot_Services_Abstract extends Varien_Object
78
  return isset($this->_data['force']) && $this->_data['force'] === true;
79
  }
80
 
81
- public function getProcessedCount()
82
- {
83
- return $this->getHarvester()->getProcessedCount();
84
- }
85
-
86
- public function getHarvesterName()
87
- {
88
- return $this->getHarvester()->getHarvesterName();
89
- }
90
-
91
- public function getHarvester()
92
- {
93
- return $this->_harvester;
94
- }
95
-
96
- public function getSegmentMin()
97
  {
98
- return $this->getHarvester()->getSegmentMin();
99
  }
100
 
101
- public function getSegmentMax()
102
  {
103
- return $this->getHarvester()->getSegmentMax();
104
  }
105
 
106
  public function getType()
1
  <?php
2
 
3
+ /**
4
+ * Class: Springbot_Services
5
+ *
6
+ * @author Springbot Magento Integration Team <magento@springbot.com>
7
+ * @version 1.4.0.0
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ * @abstract
10
+ */
11
+ abstract class Springbot_Services extends Varien_Object
12
  {
13
+ const HARVEST = 0;
14
+ const PARTITION = 1;
15
+ const SEGMENT = 2;
16
+ const CATEGORY = 3;
17
+ const LISTENER = 5;
18
+ const FAILED = 8;
19
+
20
  protected $_type = 'items';
 
21
  protected $_startTime;
22
 
23
  protected function _construct()
32
  $val = parent::getData($key);
33
 
34
  if(!(isset($val) || is_array($val))) {
35
+ //throw new Exception($this->_humanize($key) . ' required for harvest!');
36
+ return null;
37
  } else {
38
  return $val;
39
  }
58
  }
59
  }
60
 
61
+ public function getSpringbotStoreId()
62
+ {
63
+ return Mage::helper('combine/harvest')
64
+ ->getSpringbotStoreId($this->getStoreId());
65
+ }
66
+
67
  public function getStartId()
68
  {
69
  return parent::getData('start_id');
99
  return isset($this->_data['force']) && $this->_data['force'] === true;
100
  }
101
 
102
+ public function getSegmentMin($harvester)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  {
104
+ return $harvester->getSegmentMin();
105
  }
106
 
107
+ public function getSegmentMax($harvester)
108
  {
109
+ return $harvester->getSegmentMax();
110
  }
111
 
112
  public function getType()
app/code/community/Springbot/Services/Cmd/Forecast.php CHANGED
@@ -1,30 +1,32 @@
1
  <?php
2
 
3
- class Springbot_Services_Cmd_Forecast extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
7
- if($storeId = $this->getStoreId()) {
8
  $harvestId = Mage::helper('combine/harvest')->initRemoteHarvest($storeId);
9
- self::forecastStore($storeId, $harvestId);
10
  }
11
  else {
12
- self::forecastAllStores();
13
  }
14
  }
15
 
16
- public static function forecastAllStores() {
17
- foreach(Mage::helper('combine/harvest')->getStoresToHarvest() as $store) {
18
  $harvestId = Mage::helper('combine/harvest')->initRemoteHarvest($store->getStoreId());
19
- self::forecastStore($store->getStoreId(), $harvestId);
20
  }
21
  }
22
 
23
- public static function forecastStore($storeId, $harvestId)
24
  {
25
- foreach(Springbot_Services_Cmd_Harvest::getClasses() as $key) {
26
  $keyUpper = ucwords($key);
27
- $collection = call_user_func(array('Springbot_Services_Harvest_' . $keyUpper, 'getCollection'), $storeId);
 
 
28
  Mage::helper('combine/harvest')->forecast($collection, $storeId, $keyUpper, $harvestId);
29
  }
30
  }
1
  <?php
2
 
3
+ class Springbot_Services_Cmd_Forecast extends Springbot_Services
4
  {
5
  public function run()
6
  {
7
+ if ($storeId = $this->getStoreId()) {
8
  $harvestId = Mage::helper('combine/harvest')->initRemoteHarvest($storeId);
9
+ $this->forecastStore($storeId, $harvestId);
10
  }
11
  else {
12
+ $this->forecastAllStores();
13
  }
14
  }
15
 
16
+ public function forecastAllStores() {
17
+ foreach (Mage::helper('combine/harvest')->getStoresToHarvest() as $store) {
18
  $harvestId = Mage::helper('combine/harvest')->initRemoteHarvest($store->getStoreId());
19
+ $this->forecastStore($store->getStoreId(), $harvestId);
20
  }
21
  }
22
 
23
+ public function forecastStore($storeId, $harvestId)
24
  {
25
+ foreach (Springbot_Services_Cmd_Harvest::getClasses() as $key) {
26
  $keyUpper = ucwords($key);
27
+ $harvestClassName = 'Springbot_Services_Harvest_' . $keyUpper;
28
+ $harvestObject = new $harvestClassName;
29
+ $collection = $harvestObject->getCollection($storeId);
30
  Mage::helper('combine/harvest')->forecast($collection, $storeId, $keyUpper, $harvestId);
31
  }
32
  }
app/code/community/Springbot/Services/Cmd/Halt.php CHANGED
@@ -1,12 +1,13 @@
1
  <?php
2
 
3
- class Springbot_Services_Cmd_Halt extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
7
- if(isset($this->_data['halt_command'])) {
8
  $out = Springbot_Boss::halt($this->getHaltCommand());
9
- } else {
 
10
  $out = Springbot_Boss::halt();
11
  }
12
  print $out . PHP_EOL;
1
  <?php
2
 
3
+ class Springbot_Services_Cmd_Halt extends Springbot_Services
4
  {
5
  public function run()
6
  {
7
+ if (isset($this->_data['halt_command'])) {
8
  $out = Springbot_Boss::halt($this->getHaltCommand());
9
+ }
10
+ else {
11
  $out = Springbot_Boss::halt();
12
  }
13
  print $out . PHP_EOL;
app/code/community/Springbot/Services/Cmd/Harvest.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
- class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
3
  {
4
  const SEGMENT_SIZE = 2000;
5
 
6
  protected $_harvestId;
7
 
8
- // Defines order when all
9
  protected static $_classes = array(
10
  'categories',
11
  'attributeSets',
@@ -20,12 +20,18 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
20
  //'carts',
21
  );
22
 
 
 
 
 
 
 
23
  protected function _init()
24
  {
25
  $service = new Springbot_Services_Store_Register;
26
 
27
  // Init all stores upfront
28
- foreach($this->getHelper()->getStoresToHarvest() as $store) {
29
  $service->setStoreId($store->getStoreId())->run();
30
  }
31
 
@@ -38,13 +44,13 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
38
  {
39
  Springbot_Log::debug(__METHOD__);
40
 
41
- if($this->getIsResume()) {
42
  $this->_resumeHarvest();
43
  }
44
- else if($this->hasClass() && $this->hasRange()) {
45
  $this->_harvest($this->getClass(), $this->getStoreId());
46
  }
47
- else if($this->hasClass()) {
48
  $this->_segmentHarvest($this->getClass(), $this->getStoreId());
49
  }
50
  else {
@@ -54,13 +60,16 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
54
 
55
  protected function _fullHarvest()
56
  {
57
- if(!$this->getHelper()->isHarvestRunning()) {
58
- $this->_init();
59
- //Iterate all stores
60
- foreach($this->getHelper()->getStoresToHarvest() as $store) {
61
- $this->_harvestId = Mage::helper('combine/harvest')->initRemoteHarvest($store->getStoreId());
62
- $this->_harvestStore($store, self::$_classes, $this->_harvestId);
63
- }
 
 
 
64
  }
65
  }
66
 
@@ -89,9 +98,9 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
89
  }
90
  }
91
 
92
- protected function _partialHarvestClass($store, $class, $partition, $harvestId)
93
  {
94
- Springbot_Log::debug("Partial harvest started {$store->getStoreId()} | $lastClassCompleted | $lastFailedPartition | $harvestId");
95
  Springbot_Boss::scheduleJob(
96
  'cmd:harvest',
97
  array(
@@ -100,17 +109,17 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
100
  'v' => $harvestId,
101
  'i' => $partition,
102
  ),
103
- Springbot_Services_Priority::CATEGORY,
104
  'default',
105
  $store->getStoreId()
106
  );
107
  }
108
 
109
- protected function _harvestStore($store, $classes, $harvestId) {
110
- $this->_setActive($store->getStoreId());
111
  $this->_logStoreHeader($store);
112
 
113
- Springbot_Services_Cmd_Forecast::forecastStore($store->getStoreId(), $this->_harvestId);
 
114
 
115
  foreach ($classes as $class) {
116
  Springbot_Boss::scheduleJob(
@@ -120,7 +129,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
120
  'c' => $class,
121
  'v' => $harvestId,
122
  ),
123
- Springbot_Services_Priority::CATEGORY,
124
  'default',
125
  $store->getStoreId()
126
  );
@@ -131,7 +140,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
131
  'c' => $class,
132
  'v' => $harvestId,
133
  ),
134
- Springbot_Services_Priority::CATEGORY,
135
  'default',
136
  $store->getStoreId()
137
  );
@@ -139,7 +148,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
139
  Springbot_Boss::scheduleJob(
140
  'store:finalize',
141
  array('s' => $store->getStoreId()),
142
- Springbot_Services_Priority::CATEGORY,
143
  'default',
144
  $store->getStoreId()
145
  );
@@ -181,7 +190,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
181
  'c' => $key,
182
  'v' => $this->getHarvestId(),
183
  ),
184
- Springbot_Services_Priority::PARTITION,
185
  'partition', // Partition queue
186
  $storeId
187
  );
@@ -213,7 +222,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
213
  'i' => (string) $partition,
214
  'v' => $this->getHarvestId(),
215
  ),
216
- Springbot_Services_Priority::SEGMENT,
217
  'default',
218
  $storeId
219
  );
@@ -224,7 +233,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
224
 
225
  private function _reportHarvestStartTime($harvestId, $storeId, $type)
226
  {
227
- $cronCount =Mage::getModel('combine/cron_count');
228
 
229
  // Create the cron count row for the entity if it doesn't exist already.
230
  $cronCount->increaseCount($storeId, $harvestId, $type, 0);
@@ -237,7 +246,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
237
  );
238
  $api = Mage::getModel('combine/api');
239
  $payload = $api->wrap('harvest_segments', array($params));
240
- if(!is_null($harvestId)) {
241
  return $api->put("harvests/{$harvestId}", $payload);
242
  }
243
  }
@@ -248,10 +257,25 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
248
  protected function _getCollection($type, $storeId)
249
  {
250
  Springbot_Log::debug("Building collection $type for partition => {$this->getPartition()}");
251
- return call_user_func_array(
252
- array('Springbot_Services_Harvest_' . $type, 'getCollection'),
253
- array($storeId, $this->getPartition())
254
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  }
256
 
257
  /**
@@ -274,33 +298,7 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
274
  return $classesLeft;
275
  }
276
 
277
- public function getPartition()
278
- {
279
- return new Springbot_Util_Partition($this->getStartId(), $this->getStopId());
280
- }
281
-
282
- public function getHarvestId()
283
- {
284
- return isset($this->_harvestId) ? $this->_harvestId : $this->_data['harvest_id'];
285
- }
286
-
287
- public function getHelper()
288
- {
289
- return Mage::helper('combine/harvest');
290
- }
291
-
292
- protected function _setActive($storeId)
293
- {
294
- Springbot_Boss::setActive($storeId);
295
- return $this;
296
- }
297
-
298
- protected function _getDate()
299
- {
300
- return date("Y-m-d H:i:s");
301
- }
302
-
303
- protected function _logStoreHeader($store)
304
  {
305
  $helper = Mage::helper('combine/store')->setStore($store);
306
 
@@ -310,8 +308,4 @@ class Springbot_Services_Cmd_Harvest extends Springbot_Services_Abstract
310
  Springbot_Log::printLine(true);
311
  }
312
 
313
- public static function getClasses()
314
- {
315
- return self::$_classes;
316
- }
317
  }
1
  <?php
2
+ class Springbot_Services_Cmd_Harvest extends Springbot_Services
3
  {
4
  const SEGMENT_SIZE = 2000;
5
 
6
  protected $_harvestId;
7
 
8
+ // Defines order which entities are harvested during a full harvest
9
  protected static $_classes = array(
10
  'categories',
11
  'attributeSets',
20
  //'carts',
21
  );
22
 
23
+
24
+ public static function getClasses()
25
+ {
26
+ return self::$_classes;
27
+ }
28
+
29
  protected function _init()
30
  {
31
  $service = new Springbot_Services_Store_Register;
32
 
33
  // Init all stores upfront
34
+ foreach ($this->getHelper()->getStoresToHarvest() as $store) {
35
  $service->setStoreId($store->getStoreId())->run();
36
  }
37
 
44
  {
45
  Springbot_Log::debug(__METHOD__);
46
 
47
+ if ($this->getIsResume()) {
48
  $this->_resumeHarvest();
49
  }
50
+ else if ($this->hasClass() && $this->hasRange()) {
51
  $this->_harvest($this->getClass(), $this->getStoreId());
52
  }
53
+ else if ($this->hasClass()) {
54
  $this->_segmentHarvest($this->getClass(), $this->getStoreId());
55
  }
56
  else {
60
 
61
  protected function _fullHarvest()
62
  {
63
+ if($this->getHelper()->isHarvestRunning()) {
64
+ throw new Exception('Harvest is running already!');
65
+ }
66
+
67
+ $this->_init();
68
+
69
+ //Iterate all stores
70
+ foreach ($this->getHelper()->getStoresToHarvest() as $store) {
71
+ $this->_harvestId = Mage::helper('combine/harvest')->initRemoteHarvest($store->getStoreId());
72
+ $this->_harvestStore($store, self::$_classes, $this->_harvestId);
73
  }
74
  }
75
 
98
  }
99
  }
100
 
101
+ protected function _partialHarvestClass(Mage_Core_Model_Store $store, $class, $partition, $harvestId)
102
  {
103
+ Springbot_Log::debug("Partial harvest started {$store->getStoreId()} | $class | {$harvestId}");
104
  Springbot_Boss::scheduleJob(
105
  'cmd:harvest',
106
  array(
109
  'v' => $harvestId,
110
  'i' => $partition,
111
  ),
112
+ Springbot_Services::CATEGORY,
113
  'default',
114
  $store->getStoreId()
115
  );
116
  }
117
 
118
+ protected function _harvestStore(Mage_Core_Model_Store $store, array $classes, $harvestId) {
 
119
  $this->_logStoreHeader($store);
120
 
121
+ $forecastService = new Springbot_Services_Cmd_Forecast;
122
+ $forecastService->forecastStore($store->getStoreId(), $this->_harvestId);
123
 
124
  foreach ($classes as $class) {
125
  Springbot_Boss::scheduleJob(
129
  'c' => $class,
130
  'v' => $harvestId,
131
  ),
132
+ Springbot_Services::CATEGORY,
133
  'default',
134
  $store->getStoreId()
135
  );
140
  'c' => $class,
141
  'v' => $harvestId,
142
  ),
143
+ Springbot_Services::CATEGORY,
144
  'default',
145
  $store->getStoreId()
146
  );
148
  Springbot_Boss::scheduleJob(
149
  'store:finalize',
150
  array('s' => $store->getStoreId()),
151
+ Springbot_Services::CATEGORY,
152
  'default',
153
  $store->getStoreId()
154
  );
190
  'c' => $key,
191
  'v' => $this->getHarvestId(),
192
  ),
193
+ Springbot_Services::PARTITION,
194
  'partition', // Partition queue
195
  $storeId
196
  );
222
  'i' => (string) $partition,
223
  'v' => $this->getHarvestId(),
224
  ),
225
+ Springbot_Services::SEGMENT,
226
  'default',
227
  $storeId
228
  );
233
 
234
  private function _reportHarvestStartTime($harvestId, $storeId, $type)
235
  {
236
+ $cronCount = Mage::getModel('combine/cron_count');
237
 
238
  // Create the cron count row for the entity if it doesn't exist already.
239
  $cronCount->increaseCount($storeId, $harvestId, $type, 0);
246
  );
247
  $api = Mage::getModel('combine/api');
248
  $payload = $api->wrap('harvest_segments', array($params));
249
+ if (!is_null($harvestId)) {
250
  return $api->put("harvests/{$harvestId}", $payload);
251
  }
252
  }
257
  protected function _getCollection($type, $storeId)
258
  {
259
  Springbot_Log::debug("Building collection $type for partition => {$this->getPartition()}");
260
+ $harvestServiceClassName = 'Springbot_Services_Harvest_' . $type;
261
+ $harvestServiceObject = new $harvestServiceClassName;
262
+ return $harvestServiceObject->getCollection($storeId, $this->getPartition());
263
+ }
264
+
265
+
266
+ public function getPartition()
267
+ {
268
+ return new Springbot_Util_Partition($this->getStartId(), $this->getStopId());
269
+ }
270
+
271
+ public function getHarvestId()
272
+ {
273
+ return isset($this->_harvestId) ? $this->_harvestId : $this->_data['harvest_id'];
274
+ }
275
+
276
+ public function getHelper()
277
+ {
278
+ return Mage::helper('combine/harvest');
279
  }
280
 
281
  /**
298
  return $classesLeft;
299
  }
300
 
301
+ private function _logStoreHeader(Mage_Core_Model_Store $store)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  {
303
  $helper = Mage::helper('combine/store')->setStore($store);
304
 
308
  Springbot_Log::printLine(true);
309
  }
310
 
 
 
 
 
311
  }
app/code/community/Springbot/Services/Cmd/Healthcheck.php CHANGED
@@ -1,12 +1,18 @@
1
  <?php
2
 
3
- class Springbot_Services_Cmd_Healthcheck extends Springbot_Services_Abstract
4
  {
 
 
5
  public function run()
6
  {
7
  // Run checkin process
8
- $harvestingManager = new Springbot_DataServices_HarvestingManager();
9
- $harvestingManager->harvestHealthCheck($this->getStoreId());
 
 
 
 
10
 
11
  // Inspect, rollover and delete logs
12
  $rollover = new Springbot_Util_Log_Rollover();
@@ -14,6 +20,61 @@ class Springbot_Services_Cmd_Healthcheck extends Springbot_Services_Abstract
14
  $rollover->ensureLogSize();
15
  $rollover->reset();
16
 
 
 
 
 
17
  Springbot_Log::debug("Healthcheck job complete");
18
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
1
  <?php
2
 
3
+ class Springbot_Services_Cmd_Healthcheck extends Springbot_Services
4
  {
5
+ const SUCCESSFUL_RESPONSE = 'ok';
6
+
7
  public function run()
8
  {
9
  // Run checkin process
10
+ $this->healthcheck($this->getStoreId());
11
+
12
+ // Scrape coupons
13
+ if(Mage::getStoreConfig('springbot/advanced/scrape_coupons')) {
14
+ $this->_scrapeEntities();
15
+ }
16
 
17
  // Inspect, rollover and delete logs
18
  $rollover = new Springbot_Util_Log_Rollover();
20
  $rollover->ensureLogSize();
21
  $rollover->reset();
22
 
23
+ // Clean orphaned jobs
24
+ $cleanup = new Springbot_Services_Work_Cleanup();
25
+ $cleanup->run();
26
+
27
  Springbot_Log::debug("Healthcheck job complete");
28
  }
29
+
30
+ public function healthcheck($storeId)
31
+ {
32
+ if ($storeId) {
33
+ $springbotStoreId = Mage::helper('combine/harvest')->getSpringbotStoreId($storeId);
34
+ $packageVersion = Mage::getConfig()->getModuleConfig("Springbot_Combine")->version;
35
+
36
+ $result = Mage::getModel('combine/api')
37
+ ->call(
38
+ 'harvest_master',
39
+ '{"store_id":"'.$springbotStoreId.'","version":"'. $packageVersion .'"}'
40
+ );
41
+
42
+ if ($result['status'] == self::SUCCESSFUL_RESPONSE) {
43
+ foreach ($result['commands'] as $cmd) {
44
+ $task = $this->_makeTaskInstance($cmd);
45
+ $task->run();
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ private function _scrapeEntities()
52
+ {
53
+ $lastPostedCouponId = Mage::getStoreConfig('springbot/tmp/last_coupon_id');
54
+ if (!$lastPostedCouponId) {
55
+ $lastPostedCouponId = 0;
56
+ }
57
+ $couponsToPost = Mage::getModel('salesrule/coupon')->getCollection()
58
+ ->addFieldToFilter('coupon_id', array('gt' => $lastPostedCouponId));
59
+
60
+ $couponsToPost->getSelect()->order('coupon_id', 'ASC');
61
+ $lastFoundCouponId = null;
62
+ foreach ($couponsToPost as $couponToPost) {
63
+ Springbot_Boss::scheduleJob('post:coupon', array('i' => $couponToPost->getId()), Springbot_Services::LISTENER, 'listener');
64
+ $lastFoundCouponId = $couponToPost->getId();
65
+ }
66
+ if (($lastFoundCouponId) && ($lastPostedCouponId != $lastFoundCouponId)) {
67
+ Mage::getModel('core/config')->saveConfig('springbot/tmp/last_coupon_id', $lastFoundCouponId, 'default', 0);
68
+ Mage::getConfig()->cleanCache();
69
+ }
70
+ }
71
+
72
+ private function _makeTaskInstance($cmd)
73
+ {
74
+ $taskname = ucfirst($cmd['command']);
75
+ $classname = "Springbot_Services_Task_{$taskname}";
76
+ $task = new $class();
77
+ $task->setData($cmd['data']);
78
+ return $task;
79
+ }
80
  }
app/code/community/Springbot/Services/Cmd/Parse.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Services_Cmd_Parse extends Springbot_Services_Abstract
4
- {
5
- public function run()
6
- {
7
- print_r($this->_data);
8
- }
9
- }
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Services/Cmd/Update.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
 
3
- class Springbot_Services_Cmd_Update extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
7
- if(Mage::getStoreConfig('springbot/config/remote_update') || $this->getForce()) {
8
  try {
9
  Springbot_Log::info("Updating Springbot extension");
10
 
@@ -32,7 +32,6 @@ class Springbot_Services_Cmd_Update extends Springbot_Services_Abstract
32
  Mage::app()->cleanCache();
33
  } catch (Exception $e) {
34
  Springbot_Log::error($e);
35
- die($e->getMessage() . PHP_EOL);
36
  }
37
  $msg = "Updated to version $version successfully!";
38
  Springbot_Log::remote($msg);
1
  <?php
2
 
3
+ class Springbot_Services_Cmd_Update extends Springbot_Services
4
  {
5
  public function run()
6
  {
7
+ if (Mage::getStoreConfig('springbot/config/remote_update') || $this->getForce()) {
8
  try {
9
  Springbot_Log::info("Updating Springbot extension");
10
 
32
  Mage::app()->cleanCache();
33
  } catch (Exception $e) {
34
  Springbot_Log::error($e);
 
35
  }
36
  $msg = "Updated to version $version successfully!";
37
  Springbot_Log::remote($msg);
app/code/community/Springbot/Services/Harvest.php CHANGED
@@ -1,20 +1,24 @@
1
  <?php
2
 
3
- abstract class Springbot_Services_Harvest extends Springbot_Services_Abstract
4
  {
5
- public function run()
 
6
  {
7
  $mb = round(memory_get_peak_usage(true) / pow(1024, 2), 2);
8
 
9
- $msg = "{$this->getHarvesterName()} block {$this->getSegmentMin()} : {$this->getSegmentMax()} posted [{$this->getProcessedCount()} overall]";
10
- $msg .= " | " . $mb . ' MB';
11
- $msg .= " | {$this->getRuntime()} sec";
 
 
 
12
 
13
  Springbot_Log::harvest($msg);
14
  $countObject = Mage::getModel('combine/cron_count');
15
- $countObject->increaseCount($this->getStoreId(), $this->getHarvestId(), $this->getClass(), $this->getProcessedCount());
16
 
17
- return $this->getProcessedCount();
18
  }
19
 
20
  public function getDataSource()
@@ -22,14 +26,14 @@ abstract class Springbot_Services_Harvest extends Springbot_Services_Abstract
22
  return Springbot_Boss::SOURCE_BULK_HARVEST;
23
  }
24
 
25
- public static function limitCollection($collection, Springbot_Util_Partition $partition, $id = 'entity_id')
26
  {
27
- if($partition->start) {
28
- $collection->addFieldToFilter($id, array('gteq' => $partition->start));
29
  }
30
 
31
- if($partition->stop) {
32
- $collection->addFieldToFilter($id, array('lteq' => $partition->stop));
33
  }
34
  return $collection;
35
  }
1
  <?php
2
 
3
+ abstract class Springbot_Services_Harvest extends Springbot_Services
4
  {
5
+
6
+ public function reportCount($harvester)
7
  {
8
  $mb = round(memory_get_peak_usage(true) / pow(1024, 2), 2);
9
 
10
+ $processedCount = $harvester->getProcessedCount();
11
+ $segmentMin = $harvester->getSegmentMin();
12
+ $segmentMax = $harvester->getSegmentMax();
13
+ $apiModel = $harvester->getApiModel();
14
+
15
+ $msg = "{$apiModel} block {$segmentMin}:{$segmentMax} posted [{$processedCount} overall] | {$mb}MB | {$this->getRuntime()} sec";
16
 
17
  Springbot_Log::harvest($msg);
18
  $countObject = Mage::getModel('combine/cron_count');
19
+ $countObject->increaseCount($this->getStoreId(), $this->getHarvestId(), $harvester->getApiModel(), $harvester->getProcessedCount());
20
 
21
+ return $harvester->getProcessedCount();
22
  }
23
 
24
  public function getDataSource()
26
  return Springbot_Boss::SOURCE_BULK_HARVEST;
27
  }
28
 
29
+ public static function limitCollection($collection, Springbot_Util_Partition $partition, $idColumn = 'entity_id')
30
  {
31
+ if ($partition->start) {
32
+ $collection->addFieldToFilter($idColumn, array('gteq' => $partition->start));
33
  }
34
 
35
+ if ($partition->stop) {
36
+ $collection->addFieldToFilter($idColumn, array('lteq' => $partition->stop));
37
  }
38
  return $collection;
39
  }
app/code/community/Springbot/Services/Harvest/AttributeSets.php CHANGED
@@ -2,28 +2,34 @@
2
 
3
  class Springbot_Services_Harvest_AttributeSets extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'attributes';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('attribute_set_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('attribute_set_id', array('lteq' => $this->getStopId()));
 
 
 
 
 
14
  }
15
 
16
- $this->_harvester = Mage::getModel('combine/harvest_attributeSets')
17
- ->setDataSource($this->getDataSource())
18
- ->setStoreId($this->getStoreId())
19
- ->setCollection($collection)
20
- ->harvest();
21
-
22
- return parent::run();
23
  }
24
 
25
- public static function getCollection()
26
  {
27
- return Mage::helper('combine/attributes')->getAttributeSets();
 
 
 
 
 
 
 
 
 
28
  }
 
29
  }
2
 
3
  class Springbot_Services_Harvest_AttributeSets extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ if ($this->getStoreId()) {
8
+ $collection = $this->getCollection($this->getStoreId());
9
+ $api = Mage::getModel('combine/api');
10
+ $harvester = new Springbot_Combine_Model_Harvest_AttributeSets($api, $collection, $this->getDataSource());
11
+ $harvester->setStoreId($this->getStoreId());
12
+ $harvester->harvest();
13
+ $this->reportCount($harvester);
14
+ }
15
+ else {
16
+ throw new Exception("Missing store id for Attribute Sets harvest");
17
  }
18
 
 
 
 
 
 
 
 
19
  }
20
 
21
+ public function getCollection($storeId, $partition = null)
22
  {
23
+ $collection = Mage::helper('combine/attributes')->getAttributeSets();
24
+ //self::getCollection($this->getStoreId())
25
+
26
+ $collection->addFieldToFilter('attribute_set_id', array('gt' => $this->getStartId()));
27
+
28
+ if ($this->getStopId() !== null) {
29
+ $collection->addFieldToFilter('attribute_set_id', array('lteq' => $this->getStopId()));
30
+ }
31
+
32
+ return $collection;
33
  }
34
+
35
  }
app/code/community/Springbot/Services/Harvest/Carts.php CHANGED
@@ -2,34 +2,38 @@
2
 
3
  class Springbot_Services_Harvest_Carts extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'carts';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('entity_id', array('gt' => $this->getStartId()))
11
- ->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
12
-
13
- $this->_harvester = Mage::getModel('combine/harvest_carts')
14
- ->setDataSource($this->getDataSource())
15
- ->setStoreId($this->getStoreId())
16
- ->setCollection($collection)
17
- ->harvest();
18
-
19
- return parent::run();
20
  }
21
 
22
- public static function getCollection($storeId, $partition = null)
23
  {
24
- $collection = Mage::getModel('sales/quote')
25
- ->getCollection()
26
- ->addFieldToFilter('customer_email', array('notnull' => true))
27
- ->addFieldToFilter('store_id', $storeId)
28
- ->addFieldToFilter('is_active', 1);
29
 
30
- if($partition) {
 
 
 
 
 
 
31
  $collection = parent::limitCollection($collection, $partition);
32
  }
 
33
  return $collection;
34
  }
35
  }
2
 
3
  class Springbot_Services_Harvest_Carts extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ if ($this->getStoreId()) {
8
+ $collection = $this->getCollection($this->getStoreId());
9
+ $api = Mage::getModel('combine/api');
10
+ $harvester = new Springbot_Combine_Model_Harvest_Carts($api, $collection, $this->getDataSource());
11
+ $harvester->setStoreId($this->getStoreId());
12
+ $harvester->harvest();
13
+ return $this->reportCount($harvester);
14
+ }
15
+ else {
16
+ throw new exception("Store id missing for carts harvest");
17
+ }
18
  }
19
 
20
+ public function getCollection($storeId, $partition = null)
21
  {
22
+ $collection = Mage::getModel('sales/quote')->getCollection();
23
+ $collection->addFieldToFilter('customer_email', array('notnull' => true));
24
+ $collection->addFieldToFilter('store_id', $storeId);
25
+ $collection->addFieldToFilter('is_active', 1);
 
26
 
27
+ if ($this->getStartId() !== null) {
28
+ $collection->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
29
+ }
30
+ if ($this->getStopId()) {
31
+ $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
32
+ }
33
+ if ($partition) {
34
  $collection = parent::limitCollection($collection, $partition);
35
  }
36
+
37
  return $collection;
38
  }
39
  }
app/code/community/Springbot/Services/Harvest/Categories.php CHANGED
@@ -2,33 +2,32 @@
2
 
3
  class Springbot_Services_Harvest_Categories extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'categories';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
 
 
 
 
14
  }
15
-
16
- $this->_harvester = Mage::getModel('combine/harvest_categories')
17
- ->setCollection($collection)
18
- ->setStoreId($this->getStoreId())
19
- ->setDataSource($this->getDataSource())
20
- ->harvest();
21
-
22
- return parent::run();
23
  }
24
 
25
- public static function getCollection($storeId, $partition = null)
26
  {
27
  $rootCategory = Mage::app()->getStore($storeId)->getRootCategoryId();
28
-
29
- $collection = Mage::getModel('catalog/category')
30
- ->getCollection()
31
- ->addAttributeToFilter(array(
 
 
 
 
 
32
  array(
33
  'attribute' => 'entity_id',
34
  'eq' => $rootCategory
@@ -37,11 +36,13 @@ class Springbot_Services_Harvest_Categories extends Springbot_Services_Harvest
37
  'attribute' => 'path',
38
  'like' => "1/{$rootCategory}/%"
39
  ),
40
- ));
 
41
 
42
- if($partition) {
43
  $collection = parent::limitCollection($collection, $partition);
44
  }
 
45
  return $collection;
46
  }
47
  }
2
 
3
  class Springbot_Services_Harvest_Categories extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ if ($this->getStoreId()) {
8
+ $collection = $this->getCollection($this->getStoreId());
9
+ $api = Mage::getModel('combine/api');
10
+ $harvester = new Springbot_Combine_Model_Harvest_Categories($api, $collection, $this->getDataSource());
11
+ $harvester->harvest();
12
+ return $this->reportCount($harvester);
13
+ }
14
+ else {
15
+ throw new Exception('Store id missing for category harvest');
16
  }
 
 
 
 
 
 
 
 
17
  }
18
 
19
+ public function getCollection($storeId, $partition = null)
20
  {
21
  $rootCategory = Mage::app()->getStore($storeId)->getRootCategoryId();
22
+ $collection = Mage::getModel('catalog/category')->getCollection();
23
+ if ($this->getStopId() !== null) {
24
+ $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
25
+ }
26
+ if ($this->getStartId() !== null) {
27
+ $collection->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
28
+ }
29
+ $collection->addAttributeToFilter(
30
+ array(
31
  array(
32
  'attribute' => 'entity_id',
33
  'eq' => $rootCategory
36
  'attribute' => 'path',
37
  'like' => "1/{$rootCategory}/%"
38
  ),
39
+ )
40
+ );
41
 
42
+ if ($partition) {
43
  $collection = parent::limitCollection($collection, $partition);
44
  }
45
+
46
  return $collection;
47
  }
48
  }
app/code/community/Springbot/Services/Harvest/Coupons.php CHANGED
@@ -2,34 +2,30 @@
2
 
3
  class Springbot_Services_Harvest_Coupons extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'coupons';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('coupon_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('coupon_id', array('lteq' => $this->getStopId()));
14
- }
15
-
16
- $this->_harvester = Mage::getModel('combine/harvest_coupons')
17
- ->setStoreId($this->getStoreId())
18
- ->setDataSource($this->getDataSource())
19
- ->setCollection($collection)
20
- ->harvest();
21
-
22
- return parent::run();
23
  }
24
 
25
- public static function getCollection($storeId, $partition = null)
26
  {
27
  // Filter based on the website_ids string
28
  $collection = Mage::getModel('salesrule/coupon')->getCollection();
29
 
30
- if($partition) {
31
  $collection = parent::limitCollection($collection, $partition, 'coupon_id');
32
  }
 
 
 
 
 
 
 
33
  return $collection;
34
  }
35
  }
2
 
3
  class Springbot_Services_Harvest_Coupons extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = $this->getCollection($this->getStoreId());
8
+ $api = Mage::getModel('combine/api');
9
+ $harvester = new Springbot_Combine_Model_Harvest_Coupons($api, $collection, $this->getDataSource());
10
+ $harvester->harvest();
11
+ $this->reportCount($harvester);
 
 
 
 
 
 
 
 
 
12
  }
13
 
14
+ public function getCollection($storeId, $partition = null)
15
  {
16
  // Filter based on the website_ids string
17
  $collection = Mage::getModel('salesrule/coupon')->getCollection();
18
 
19
+ if ($partition) {
20
  $collection = parent::limitCollection($collection, $partition, 'coupon_id');
21
  }
22
+ if ($this->getStartId() !== null) {
23
+ $collection->addFieldToFilter('coupon_id', array('gt' => $this->getStartId()));
24
+ }
25
+ if ($this->getStopId()) {
26
+ $collection->addFieldToFilter('coupon_id', array('lteq' => $this->getStopId()));
27
+ }
28
+
29
  return $collection;
30
  }
31
  }
app/code/community/Springbot/Services/Harvest/CustomerAttributeSets.php CHANGED
@@ -2,22 +2,17 @@
2
 
3
  class Springbot_Services_Harvest_CustomerAttributeSets extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'attributes';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection();
10
-
11
- $this->_harvester = Mage::getModel('combine/harvest_customerAttributeSets')
12
- ->setDataSource($this->getDataSource())
13
- ->setStoreId($this->getStoreId())
14
- ->setCollection($collection)
15
- ->harvest();
16
-
17
- return parent::run();
18
  }
19
 
20
- public static function getCollection()
21
  {
22
  return Mage::helper('combine/attributes')->getCustomerAttributeSets();
23
  }
2
 
3
  class Springbot_Services_Harvest_CustomerAttributeSets extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = $this->getCollection();
8
+ $api = Mage::getModel('combine/api');
9
+ $harvester = new Springbot_Combine_Model_Harvest_CustomerAttributeSets($api, $collection, $this->getDataSource());
10
+ $harvester->setStoreId($this->getStoreId());
11
+ $harvester->harvest();
12
+ $this->reportCount($harvester);
 
 
 
13
  }
14
 
15
+ public function getCollection()
16
  {
17
  return Mage::helper('combine/attributes')->getCustomerAttributeSets();
18
  }
app/code/community/Springbot/Services/Harvest/Customers.php CHANGED
@@ -2,29 +2,27 @@
2
 
3
  class Springbot_Services_Harvest_Customers extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'customers';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
14
- }
15
- $this->_harvester = Mage::getModel('combine/harvest_customers')
16
- ->setCollection($collection)
17
- ->setDataSource($this->getDataSource())
18
- ->harvest();
19
-
20
- return parent::run();
21
  }
22
 
23
- public static function getCollection($storeId, $partition = null)
24
  {
25
- $collection = Mage::getModel('customer/customer')
26
- ->getCollection()
27
- ->addFieldToFilter('store_id', $storeId);
 
 
 
 
 
 
 
28
 
29
  if($partition) {
30
  $collection = parent::limitCollection($collection, $partition);
2
 
3
  class Springbot_Services_Harvest_Customers extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = $this->getCollection($this->getStoreId());
9
+ $harvester = new Springbot_Combine_Model_Harvest_Customers($api, $collection, $this->getDataSource());
10
+ $harvester->harvest();
11
+ return $this->reportCount($harvester);
 
 
 
 
 
 
 
12
  }
13
 
14
+ public function getCollection($storeId, $partition = null)
15
  {
16
+ $collection = Mage::getModel('customer/customer')->getCollection();
17
+ $collection->addFieldToFilter('store_id', $storeId);
18
+
19
+ if ($this->getStartId() !== null) {
20
+ $collection->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
21
+ }
22
+
23
+ if ($this->getStopId()) {
24
+ $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
25
+ }
26
 
27
  if($partition) {
28
  $collection = parent::limitCollection($collection, $partition);
app/code/community/Springbot/Services/Harvest/Guests.php CHANGED
@@ -2,45 +2,44 @@
2
 
3
  class Springbot_Services_Harvest_Guests extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'guests';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
14
  }
 
 
 
15
 
16
- if(method_exists($collection, 'groupByAttribute')) {
17
  // Magento 1.3.*
18
  $collection->groupByAttribute('customer_email');
19
- } else if($collection->getSelect() instanceof Zend_Db_Select) {
 
20
  // Deduplicate by customer email
21
  try {
22
  $collection->getSelect()->order('increment_id')->group('customer_email');
23
- } catch (Exception $e) { }
 
24
  }
25
 
26
- $this->_harvester = Mage::getModel('combine/harvest_guests')
27
- ->setCollection($collection)
28
- ->setDataSource($this->getDataSource())
29
- ->harvest();
30
-
31
- return parent::run();
32
- }
33
-
34
- public static function getCollection($storeId, $partition = null)
35
- {
36
- $collection = Mage::getModel('sales/order')
37
- ->getCollection()
38
- ->addFieldToFilter('store_id', $storeId)
39
- ->addFieldToFilter('customer_is_guest', true);
40
-
41
- if($partition) {
42
- $collection = parent::limitCollection($collection, $partition);
43
- }
44
  return $collection;
45
  }
46
  }
2
 
3
  class Springbot_Services_Harvest_Guests extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = $this->getCollection($this->getStoreId());
8
+ $api = Mage::getModel('combine/api');
9
+ $harvester = new Springbot_Combine_Model_Harvest_Guests($api, $collection, $this->getDataSource());
10
+ $harvester->harvest();
11
+
12
+ return $this->reportCount($harvester);
13
+ }
14
+
15
+ public function getCollection($storeId, $partition = null)
16
+ {
17
+ $collection = Mage::getModel('sales/order')->getCollection();
18
+ $collection->addFieldToFilter('store_id', $storeId);
19
+ $collection->addFieldToFilter('customer_is_guest', true);
20
+
21
+ if ($this->getStartId() !== null) {
22
+ $collection->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
23
+ }
24
+ if ($this->getStopId()) {
25
  $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
26
  }
27
+ if ($partition) {
28
+ $collection = parent::limitCollection($collection, $partition);
29
+ }
30
 
31
+ if (method_exists($collection, 'groupByAttribute')) {
32
  // Magento 1.3.*
33
  $collection->groupByAttribute('customer_email');
34
+ }
35
+ else if($collection->getSelect() instanceof Zend_Db_Select) {
36
  // Deduplicate by customer email
37
  try {
38
  $collection->getSelect()->order('increment_id')->group('customer_email');
39
+ }
40
+ catch (Exception $e) { }
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  return $collection;
44
  }
45
  }
app/code/community/Springbot/Services/Harvest/Products.php CHANGED
@@ -2,32 +2,30 @@
2
 
3
  class Springbot_Services_Harvest_Products extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'products';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
14
- }
15
 
16
- $this->_harvester = Mage::getModel('combine/harvest_products')
17
- ->setStoreId($this->getStoreId())
18
- ->setDataSource($this->getDataSource())
19
- ->setCollection($collection)
20
- ->harvest();
21
 
22
- return parent::run();
23
  }
24
 
25
- public static function getCollection($storeId, $partition = null)
26
  {
27
  $collection = Mage::getModel('catalog/product')
28
  ->getCollection()
29
  ->addStoreFilter($storeId);
30
 
 
 
 
 
 
 
31
  if($partition) {
32
  $collection = parent::limitCollection($collection, $partition);
33
  }
2
 
3
  class Springbot_Services_Harvest_Products extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = $this->getCollection($this->getStoreId());
 
 
 
 
 
8
 
9
+ $api = Mage::getModel('combine/api');
10
+ $harvester = new Springbot_Combine_Model_Harvest_Products($api, $collection, $this->getDataSource());
11
+ $harvester->setStoreId($this->getStoreId());
12
+ $harvester->harvest();
 
13
 
14
+ return $this->reportCount($harvester);
15
  }
16
 
17
+ public function getCollection($storeId, $partition = null)
18
  {
19
  $collection = Mage::getModel('catalog/product')
20
  ->getCollection()
21
  ->addStoreFilter($storeId);
22
 
23
+ $collection->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
24
+ $stopId = $this->getStopId();
25
+ if ($stopId !== null) {
26
+ $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
27
+ }
28
+
29
  if($partition) {
30
  $collection = parent::limitCollection($collection, $partition);
31
  }
app/code/community/Springbot/Services/Harvest/Purchases.php CHANGED
@@ -2,32 +2,28 @@
2
 
3
  class Springbot_Services_Harvest_Purchases extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'purchases';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
14
- }
15
-
16
- $this->_harvester = Mage::getModel('combine/harvest_purchases')
17
- ->setCollection($collection)
18
- ->setDataSource($this->getDataSource())
19
- ->harvest();
20
 
21
- return parent::run();
22
  }
23
 
24
- public static function getCollection($storeId, $partition = null)
25
  {
26
- $collection = Mage::getModel('sales/order')
27
- ->getCollection()
28
- ->addFieldToFilter('store_id', $storeId);
 
 
 
 
 
29
 
30
- if($partition) {
31
  $collection = parent::limitCollection($collection, $partition);
32
  }
33
  return $collection;
2
 
3
  class Springbot_Services_Harvest_Purchases extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = self::getCollection($this->getStoreId());
8
+ $api = Mage::getModel('combine/api');
9
+ $harvester = new Springbot_Combine_Model_Harvest_Purchases($api, $collection, $this->getDataSource());
10
+ $harvester->harvest();
 
 
 
 
 
 
 
11
 
12
+ return $this->reportCount($harvester);
13
  }
14
 
15
+ public function getCollection($storeId, $partition = null)
16
  {
17
+ $collection = Mage::getModel('sales/order')->getCollection();
18
+ $collection->addFieldToFilter('store_id', $storeId);
19
+ if ($this->getStartId() !== null) {
20
+ $collection->addFieldToFilter('entity_id', array('gt' => $this->getStartId()));
21
+ }
22
+ if ($this->getStopId()) {
23
+ $collection->addFieldToFilter('entity_id', array('lteq' => $this->getStopId()));
24
+ }
25
 
26
+ if ($partition) {
27
  $collection = parent::limitCollection($collection, $partition);
28
  }
29
  return $collection;
app/code/community/Springbot/Services/Harvest/Rules.php CHANGED
@@ -2,45 +2,43 @@
2
 
3
  class Springbot_Services_Harvest_Rules extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'rules';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('rule_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('rule_id', array('lteq' => $this->getStopId()));
14
- }
15
 
16
- $this->_harvester = Mage::getModel('combine/harvest_rules')
17
- ->setStoreId($this->getStoreId())
18
- ->setDataSource($this->getDataSource())
19
- ->setCollection($collection)
20
- ->harvest();
21
-
22
- return parent::run();
23
  }
24
 
25
- public static function getCollection($storeId, $partition = null)
26
  {
27
  $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
28
 
29
- // Filter based on the website_ids string
30
- $collection = Mage::getModel('salesrule/rule')
31
- ->getCollection()
32
- ->addFieldToFilter('website_ids',
33
- array(
34
- array('like' => "%,{$websiteId},%"),
35
- array('like' => "{$websiteId},%"),
36
- array('like' => "%,{$websiteId}"),
37
- array('like' => "{$websiteId}"),
38
- )
39
- );
40
-
41
- if($partition) {
42
  $collection = parent::limitCollection($collection, $partition, 'rule_id');
43
  }
 
 
 
 
 
 
 
 
 
44
  return $collection;
45
  }
46
  }
2
 
3
  class Springbot_Services_Harvest_Rules extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = $this->getCollection($this->getStoreId());
8
+ $api = Mage::getModel('combine/api');
9
+ $harvester = new Springbot_Combine_Model_Harvest_Rules($api, $collection, $this->getDataSource());
10
+ $harvester->harvest();
 
 
11
 
12
+ return $this->reportCount($harvester);
 
 
 
 
 
 
13
  }
14
 
15
+ public function getCollection($storeId, $partition = null)
16
  {
17
  $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
18
 
19
+ // Find all rules for the given storeId
20
+ $collection = Mage::getModel('salesrule/rule')->getCollection();
21
+ $collection->addFieldToFilter('website_ids',
22
+ array(
23
+ array('like' => "%,{$websiteId},%"),
24
+ array('like' => "{$websiteId},%"),
25
+ array('like' => "%,{$websiteId}"),
26
+ array('like' => "{$websiteId}"),
27
+ )
28
+ );
29
+
30
+ if ($partition) {
 
31
  $collection = parent::limitCollection($collection, $partition, 'rule_id');
32
  }
33
+
34
+ if ($this->getStartId() !== null) {
35
+ $collection->addFieldToFilter('rule_id', array('gt' => $this->getStartId()));
36
+ }
37
+
38
+ if ($this->getStopId()) {
39
+ $collection->addFieldToFilter('rule_id', array('lteq' => $this->getStopId()));
40
+ }
41
+
42
  return $collection;
43
  }
44
  }
app/code/community/Springbot/Services/Harvest/Subscribers.php CHANGED
@@ -2,33 +2,31 @@
2
 
3
  class Springbot_Services_Harvest_Subscribers extends Springbot_Services_Harvest
4
  {
5
- protected $_type = 'subscribers';
6
-
7
  public function run()
8
  {
9
- $collection = self::getCollection($this->getStoreId())
10
- ->addFieldToFilter('subscriber_id', array('gt' => $this->getStartId()));
11
- $stopId = $this->getStopId();
12
- if ($stopId !== null) {
13
- $collection->addFieldToFilter('subscriber_id', array('lteq' => $this->getStopId()));
14
- }
15
-
16
- $this->_harvester = Mage::getModel('combine/harvest_subscribers')
17
- ->setCollection($collection)
18
- ->setDataSource($this->getDataSource())
19
- ->harvest();
20
-
21
- return parent::run();
22
  }
23
 
24
- public static function getCollection($storeId, $partition = null)
25
  {
26
- $collection = Mage::getResourceSingleton('newsletter/subscriber_collection')
27
- ->addFieldToFilter('store_id', $storeId);
28
 
29
- if($partition) {
 
 
 
 
 
 
 
30
  $collection = parent::limitCollection($collection, $partition, 'subscriber_id');
31
  }
 
32
  return $collection;
33
  }
34
  }
2
 
3
  class Springbot_Services_Harvest_Subscribers extends Springbot_Services_Harvest
4
  {
 
 
5
  public function run()
6
  {
7
+ $collection = $this->getCollection($this->getStoreId());
8
+ $api = Mage::getModel('combine/api');
9
+ $harvester = new Springbot_Combine_Model_Harvest_Subscribers($api, $collection, $this->getDataSource());
10
+ $harvester->harvest();
11
+ return $this->reportCount($harvester);
 
 
 
 
 
 
 
 
12
  }
13
 
14
+ public function getCollection($storeId, $partition = null)
15
  {
16
+ $collection = Mage::getModel('newsletter/subscriber')->getCollection();
17
+ $collection->addFieldToFilter('store_id', $storeId);
18
 
19
+ if ($this->getStartId() !== null) {
20
+ $collection->addFieldToFilter('subscriber_id', array('gt' => $this->getStartId()));
21
+ }
22
+ if ($this->getStopId()) {
23
+ $collection->addFieldToFilter('subscriber_id', array('lteq' => $this->getStopId()));
24
+ }
25
+
26
+ if ($partition) {
27
  $collection = parent::limitCollection($collection, $partition, 'subscriber_id');
28
  }
29
+
30
  return $collection;
31
  }
32
  }
app/code/community/Springbot/Services/Log/Installer.php CHANGED
@@ -1,11 +1,10 @@
1
  <?php
2
 
3
- class Springbot_Services_Log_Installer extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
7
  $setupModel = Mage::getModel('Springbot_Combine_Model_Resource_Setup');
8
-
9
  $setupModel->resendInstallLog();
10
  }
11
  }
1
  <?php
2
 
3
+ class Springbot_Services_Log_Installer extends Springbot_Services
4
  {
5
  public function run()
6
  {
7
  $setupModel = Mage::getModel('Springbot_Combine_Model_Resource_Setup');
 
8
  $setupModel->resendInstallLog();
9
  }
10
  }
app/code/community/Springbot/Services/Log/Purchase.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Services_Log_Purchase extends Springbot_Services_Abstract
4
- {
5
- public function run()
6
- {
7
- $orderId = $this->getEntityId();
8
- Springbot_Log::debug("Log purchase action for order_id : $orderId");
9
- $purchase = Mage::getModel('sales/order')->load($orderId);
10
-
11
- if(!$purchase->getId()) {
12
- // @TODO create remote error logger?
13
- throw new Exception("Purchase record not available in database!");
14
- }
15
-
16
- foreach($purchase->getAllVisibleItems() as $item) {
17
- $this->_logEvent('purchase', array(
18
- $this->_getAccessibleSku($item),
19
- $item->getSku(),
20
- $purchase->getIncrementId(),
21
- $purchase->getStoreId(),
22
- Mage::helper('combine')->checkCategoryIdSanity($this->_getCategoryId(), $item->getProductId()),
23
- ));
24
- }
25
- return;
26
- }
27
-
28
- protected function _logEvent($action, $content)
29
- {
30
- $eventDatetime = date(Springbot_Boss::DATE_FORMAT);
31
- $logContent = array($action, $eventDatetime);
32
- $fHandle = fopen(Springbot_Boss::getEventHistoryFilename(), 'a');
33
-
34
- fputcsv($fHandle, array_merge($logContent, $content));
35
- fclose ($fHandle);
36
- }
37
-
38
-
39
- protected function _getCategoryId()
40
- {
41
- if($this->hasCategoryId()) {
42
- return $this->getCategoryId();
43
- }
44
- return null;
45
- }
46
-
47
- protected function _getAccessibleSku($item)
48
- {
49
- return Mage::helper('combine/parser')->getAccessibleSkuFromSalesItem($item);
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Services/Post.php CHANGED
@@ -1,8 +1,7 @@
1
  <?php
2
 
3
- abstract class Springbot_Services_Post extends Springbot_Services_Abstract
4
  {
5
-
6
  public function getDataSource()
7
  {
8
  return Springbot_Boss::SOURCE_OBSERVER;
1
  <?php
2
 
3
+ abstract class Springbot_Services_Post extends Springbot_Services
4
  {
 
5
  public function getDataSource()
6
  {
7
  return Springbot_Boss::SOURCE_OBSERVER;
app/code/community/Springbot/Services/Post/Attribute.php CHANGED
@@ -4,20 +4,22 @@ class Springbot_Services_Post_Attribute extends Springbot_Services_Post
4
  {
5
  public function run()
6
  {
7
- $attribute = $this->loadAttribute();
8
- $harvester = $this->_getAttributeSetHarvester();
9
- $ids = $this->getAllAttributeSetIds();
10
 
11
- if(($count = count($ids)) > 0) {
 
12
  Springbot_Log::debug("{$count} related attribute sets found, saving!");
13
- foreach($ids as $setId) {
14
- $set = $this->loadAttributeSet($setId);
15
- foreach($this->_getStoreIds() as $id) {
16
  $harvester->setStoreId($id);
17
  $harvester->push($set);
18
  }
19
  }
20
- } else {
 
21
  Springbot_Log::debug("No related attribute sets found");
22
  }
23
  $harvester->postSegment();
@@ -33,23 +35,4 @@ class Springbot_Services_Post_Attribute extends Springbot_Services_Post
33
  return $ids;
34
  }
35
 
36
- protected function _getAttributeSetHarvester()
37
- {
38
- return Mage::getModel('combine/harvest_attributeSets');
39
- }
40
-
41
- public function loadAttributeSet($setId)
42
- {
43
- return Mage::getModel('eav/entity_attribute_set')->load($setId);
44
- }
45
-
46
- public function getAllAttributeSetIds()
47
- {
48
- return Mage::helper('combine/attributes')->getAllSetsForAttribute($this->getEntityId());
49
- }
50
-
51
- public function loadAttribute()
52
- {
53
- return Mage::getModel('eav/entity_attribute')->load($this->getEntityId());
54
- }
55
  }
4
  {
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_AttributeSets($api, $collection, $this->getDataSource());
10
 
11
+ $ids = Mage::helper('combine/attributes')->getAllSetsForAttribute($this->getEntityId());
12
+ if (($count = count($ids)) > 0) {
13
  Springbot_Log::debug("{$count} related attribute sets found, saving!");
14
+ foreach ($ids as $setId) {
15
+ $set = Mage::getModel('eav/entity_attribute_set')->load($setId);
16
+ foreach ($this->_getStoreIds() as $id) {
17
  $harvester->setStoreId($id);
18
  $harvester->push($set);
19
  }
20
  }
21
+ }
22
+ else {
23
  Springbot_Log::debug("No related attribute sets found");
24
  }
25
  $harvester->postSegment();
35
  return $ids;
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
app/code/community/Springbot/Services/Post/AttributeSet.php CHANGED
@@ -4,22 +4,16 @@ class Springbot_Services_Post_AttributeSet extends Springbot_Services_Post
4
  {
5
  public function run()
6
  {
7
- $harvester = Mage::getModel('combine/harvest_attributeSets');
 
 
8
 
9
- foreach($this->_getStoreIds() as $id) {
10
- $harvester->setStoreId($id);
11
- $harvester->push(Mage::getModel('eav/entity_attribute_set')->load($this->getEntityId()));
 
12
  }
13
  $harvester->postSegment();
14
  }
15
 
16
- protected function _getStoreIds()
17
- {
18
- $stores = Mage::helper('combine/harvest')->getStoresToHarvest();
19
- $ids = array();
20
- foreach($stores as $store) {
21
- $ids[] = $store->getStoreId();
22
- }
23
- return $ids;
24
- }
25
  }
4
  {
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_AttributeSets($api, $collection, $this->getDataSource());
10
 
11
+ foreach (Mage::helper('combine/harvest')->getStoresToHarvest() as $store) {
12
+ $harvester->setStoreId($store->getStoreId());
13
+ $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($this->getEntityId());
14
+ $harvester->push($attributeSet);
15
  }
16
  $harvester->postSegment();
17
  }
18
 
 
 
 
 
 
 
 
 
 
19
  }
app/code/community/Springbot/Services/Post/Cart.php CHANGED
@@ -5,18 +5,17 @@ class Springbot_Services_Post_Cart extends Springbot_Services_Post
5
  public function run()
6
  {
7
  $quoteId = $this->getEntityId();
8
-
9
  Springbot_Log::debug("Posting quote $quoteId");
10
 
11
- $store = Mage::getModel('core/store')->load($this->getStoreId());
12
 
13
- // For some reason you have to set the store to load
14
- // a quote, why??? Varien knows...
15
- $quote = Mage::getModel('sales/quote')->setStore($store)->load($quoteId);
16
 
17
  $parser = Mage::getModel('combine/parser_quote', $quote);
18
  $quoteJson = $parser->toJson();
19
-
20
  Mage::helper('combine')->apiPostWrapped('carts', json_decode($quoteJson), true);
21
  }
 
22
  }
5
  public function run()
6
  {
7
  $quoteId = $this->getEntityId();
 
8
  Springbot_Log::debug("Posting quote $quoteId");
9
 
10
+ $quote = Mage::getModel('sales/quote');
11
 
12
+ // For some reason you have to set the store to load a quote, why??? Varien knows...
13
+ $store = Mage::getModel('core/store')->load($this->getStoreId());
14
+ $quote->setStore($store)->load($quoteId);
15
 
16
  $parser = Mage::getModel('combine/parser_quote', $quote);
17
  $quoteJson = $parser->toJson();
 
18
  Mage::helper('combine')->apiPostWrapped('carts', json_decode($quoteJson), true);
19
  }
20
+
21
  }
app/code/community/Springbot/Services/Post/Category.php CHANGED
@@ -5,9 +5,11 @@ class Springbot_Services_Post_Category extends Springbot_Services_Post
5
  public function run()
6
  {
7
  $category = Mage::getModel('catalog/category')->load($this->getEntityId());
8
- $harvester = Mage::getModel('combine/harvest_categories');
 
 
9
 
10
- foreach(Mage::helper('combine/harvest')->mapStoreIds($category) as $mapped) {
11
  $harvester->push($mapped);
12
  }
13
 
5
  public function run()
6
  {
7
  $category = Mage::getModel('catalog/category')->load($this->getEntityId());
8
+ $api = Mage::getModel('combine/api');
9
+ $collection = new Varien_Data_Collection;
10
+ $harvester = new Springbot_Combine_Model_Harvest_Categories($api, $collection, $this->getDataSource());
11
 
12
+ foreach (Mage::helper('combine/harvest')->mapStoreIds($category) as $mapped) {
13
  $harvester->push($mapped);
14
  }
15
 
app/code/community/Springbot/Services/Post/Coupon.php CHANGED
@@ -4,9 +4,13 @@ class Springbot_Services_Post_Coupon extends Springbot_Services_Post
4
  {
5
  public function run()
6
  {
7
- $coupon = Mage::getModel('salesrule/coupon')->load($this->getEntityId());
 
8
  $coupon->setStoreId($this->getStoreId());
9
- $harvester = Mage::getModel('combine/harvest_coupons');
 
 
 
10
  $harvester->push($coupon);
11
  $harvester->postSegment();
12
  }
4
  {
5
  public function run()
6
  {
7
+ $coupon = Mage::getModel('salesrule/coupon');
8
+ $coupon->load($this->getEntityId());
9
  $coupon->setStoreId($this->getStoreId());
10
+
11
+ $api = Mage::getModel('combine/api');
12
+ $collection = new Varien_Data_Collection;
13
+ $harvester = new Springbot_Combine_Model_Harvest_Coupons($api, $collection, $this->getDataSource());
14
  $harvester->push($coupon);
15
  $harvester->postSegment();
16
  }
app/code/community/Springbot/Services/Post/Customer.php CHANGED
@@ -4,8 +4,12 @@ class Springbot_Services_Post_Customer extends Springbot_Services_Post
4
  {
5
  public function run()
6
  {
7
- $harvester = Mage::getModel('combine/harvest_customers')->setDelete($this->getDelete());
8
- $harvester->push(Mage::getModel('customer/customer')->load($this->getStartId()));
 
 
 
 
9
  $harvester->postSegment();
10
  }
11
  }
4
  {
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_Customers($api, $collection, $this->getDataSource());
10
+ $harvester->setDelete($this->getDelete());
11
+ $customer = Mage::getModel('customer/customer')->load($this->getStartId());
12
+ $harvester->push($customer);
13
  $harvester->postSegment();
14
  }
15
  }
app/code/community/Springbot/Services/Post/Guest.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Post_Guest extends Springbot_Services_Post
4
+ {
5
+ public function run()
6
+ {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_Guests($api, $collection, $this->getDataSource());
10
+ $harvester->setDelete($this->getDelete());
11
+ $purchase = Mage::getModel('sales/order')->load($this->getStartId());
12
+ $harvester->push($purchase);
13
+ $harvester->postSegment();
14
+ }
15
+ }
app/code/community/Springbot/Services/Post/Product.php CHANGED
@@ -2,30 +2,37 @@
2
 
3
  class Springbot_Services_Post_Product extends Springbot_Services_Post
4
  {
5
- protected $_harvester;
6
-
7
  public function run()
8
  {
9
- $this->_harvester = Mage::getModel('combine/harvest_products');
10
-
11
- $this->_aggregateProduct($this->getEntityId());
12
-
13
- $this->_harvester->postSegment();
14
  }
15
 
16
- protected function _aggregateProduct($entityId)
 
 
 
 
 
 
 
 
17
  {
18
  $product = Mage::getModel('catalog/product')->load($entityId);
19
 
20
  foreach(Mage::helper('combine/harvest')->mapStoreIds($product) as $mapped) {
21
- $this->_harvester->push($mapped);
22
  }
23
 
24
  if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
25
  Springbot_Log::debug('Executing configurable callback save');
26
  foreach(Mage::helper('combine/parser')->getChildProductIds($product) as $childId) {
27
- $this->_aggregateProduct($childId);
28
  }
29
  }
30
  }
 
31
  }
2
 
3
  class Springbot_Services_Post_Product extends Springbot_Services_Post
4
  {
 
 
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_Products($api, $collection, $this->getDataSource());
10
+ $this->_aggregateProduct($this->getEntityId(), $harvester);
11
+ $harvester->postSegment();
12
  }
13
 
14
+ /**
15
+ * Map store ids to given model
16
+ *
17
+ * This method will push all products that are children of the supplied product if they're
18
+ * a configurable as well as the same product for all stores it is associated to.
19
+ *
20
+ * @param integer $entityId
21
+ */
22
+ protected function _aggregateProduct($entityId, $harvester)
23
  {
24
  $product = Mage::getModel('catalog/product')->load($entityId);
25
 
26
  foreach(Mage::helper('combine/harvest')->mapStoreIds($product) as $mapped) {
27
+ $harvester->push($mapped);
28
  }
29
 
30
  if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
31
  Springbot_Log::debug('Executing configurable callback save');
32
  foreach(Mage::helper('combine/parser')->getChildProductIds($product) as $childId) {
33
+ $this->_aggregateProduct($childId, $harvester);
34
  }
35
  }
36
  }
37
+
38
  }
app/code/community/Springbot/Services/Post/Purchase.php CHANGED
@@ -19,15 +19,20 @@ class Springbot_Services_Post_Purchase extends Springbot_Services_Post
19
  ->setRedirectMongoIds($redirectIds);
20
  }
21
 
22
- $harvester = Mage::getModel('combine/harvest_purchases');
 
 
23
 
24
  $harvester->push($this->_purchase);
25
  $harvester->postSegment();
26
 
27
  if($this->_purchase->getCustomerIsGuest()) {
28
- Mage::getModel('combine/harvest_guests')
29
- ->push($this->_purchase)
30
- ->postSegment();
 
 
 
31
  }
32
  }
33
 
19
  ->setRedirectMongoIds($redirectIds);
20
  }
21
 
22
+ $api = Mage::getModel('combine/api');
23
+ $collection = new Varien_Data_Collection;
24
+ $harvester = new Springbot_Combine_Model_Harvest_Purchases($api, $collection, $this->getDataSource());
25
 
26
  $harvester->push($this->_purchase);
27
  $harvester->postSegment();
28
 
29
  if($this->_purchase->getCustomerIsGuest()) {
30
+ Springbot_Boss::scheduleJob(
31
+ 'post:guest',
32
+ array('i' => $orderId),
33
+ Springbot_Services::LISTENER,
34
+ 'listener'
35
+ );
36
  }
37
  }
38
 
app/code/community/Springbot/Services/Post/Rule.php CHANGED
@@ -4,9 +4,16 @@ class Springbot_Services_Post_Rule extends Springbot_Services_Post
4
  {
5
  public function run()
6
  {
7
- $rule = Mage::getModel('salesrule/rule')->load($this->getEntityId());
 
 
 
 
 
 
 
8
  $rule->setStoreId($this->getStoreId());
9
- $harvester = Mage::getModel('combine/harvest_rules');
10
  $harvester->push($rule);
11
  $harvester->postSegment();
12
  }
4
  {
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_Rules($api, $collection, $this->getDataSource());
10
+
11
+ $rule = Mage::getModel('salesrule/rule');
12
+ $rule->load($this->getEntityId());
13
+
14
+ // Since rules do not have store ids, we go by the store_id passed from the command line
15
  $rule->setStoreId($this->getStoreId());
16
+
17
  $harvester->push($rule);
18
  $harvester->postSegment();
19
  }
app/code/community/Springbot/Services/Post/Subscriber.php CHANGED
@@ -4,7 +4,10 @@ class Springbot_Services_Post_Subscriber extends Springbot_Services_Post
4
  {
5
  public function run()
6
  {
7
- $harvester = Mage::getModel('combine/harvest_subscribers')->setDelete($this->getDelete());
 
 
 
8
  $harvester->push(Mage::getModel('newsletter/subscriber')->load($this->getStartId()));
9
  $harvester->postSegment();
10
  }
4
  {
5
  public function run()
6
  {
7
+ $api = Mage::getModel('combine/api');
8
+ $collection = new Varien_Data_Collection;
9
+ $harvester = new Springbot_Combine_Model_Harvest_Subscribers($api, $collection, $this->getDataSource());
10
+ $harvester->setDelete($this->getDelete());
11
  $harvester->push(Mage::getModel('newsletter/subscriber')->load($this->getStartId()));
12
  $harvester->postSegment();
13
  }
app/code/community/Springbot/Services/Priority.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Services_Priority
4
- {
5
- const HARVEST = 0;
6
- const PARTITION = 1;
7
- const SEGMENT = 2;
8
- const CATEGORY = 3;
9
- const LISTENER = 5;
10
- const FAILED = 8;
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Services/Store/Finalize.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Store_Finalize extends Springbot_Services_Abstract
4
  {
5
 
6
  public function run()
1
  <?php
2
 
3
+ class Springbot_Services_Store_Finalize extends Springbot_Services
4
  {
5
 
6
  public function run()
app/code/community/Springbot/Services/Store/Register.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Store_Register extends Springbot_Services_Abstract
4
  {
5
  const API_CLASS = 'stores';
6
 
1
  <?php
2
 
3
+ class Springbot_Services_Store_Register extends Springbot_Services
4
  {
5
  const API_CLASS = 'stores';
6
 
app/code/community/Springbot/Services/Tasks/DeliverEventLog.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_DeliverEventLog extends Springbot_Services
4
+ {
5
+ const EVENT_MAX = 200;
6
+
7
+ public function run()
8
+ {
9
+ $ssid = $this->getSpringbotStoreId();
10
+ $method = "stores/{$ssid}/products/actions/create";
11
+ $eventItems = array();
12
+ try{
13
+ $this->_lockEvents();
14
+ foreach($this->_getLockedEvents() as $event) {
15
+ $eventItems[] = $event->toAction();
16
+ }
17
+ if ($eventItems) {
18
+ $result = Mage::getModel('combine/api')
19
+ ->call($method, json_encode($eventItems));
20
+ }
21
+ $this->_removeEvents();
22
+ } catch (Exception $e) {
23
+ // We can capture this here and keep if from bubbling up.
24
+ // This api call will fail and get recreated on the next check in
25
+ Springbot_Log::error($e);
26
+ }
27
+ $this->_releaseLocks();
28
+ }
29
+
30
+ private function _removeEvents()
31
+ {
32
+ $this->_getEventsResource()->removeEvents(getmypid());
33
+ }
34
+
35
+ private function _getLockedEvents()
36
+ {
37
+ return $this->_getEventsCollection()
38
+ ->getLockedEvents($this->getStoreId(), getmypid());
39
+ }
40
+
41
+ private function _lockEvents()
42
+ {
43
+ $this->_getEventsResource()
44
+ ->lockEvents(getmypid(), $this->getStoreId(), self::EVENT_MAX);
45
+ }
46
+
47
+ private function _releaseLocks()
48
+ {
49
+ $this->_getEventsResource()->releaseLocksForPid(getmypid());
50
+ }
51
+
52
+ private function _getEventsCollection()
53
+ {
54
+ return Mage::getModel('combine/action')->getCollection();
55
+ }
56
+
57
+ private function _getEventsResource()
58
+ {
59
+ return Mage::getResourceModel('combine/action');
60
+ }
61
+ }
app/code/community/Springbot/Services/Tasks/Forecast.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_Forecast extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ $instance = new Springbot_Services_Cmd_Forecast();
8
+ $instance->forecastAllStores();
9
+ }
10
+ }
app/code/community/Springbot/Services/Tasks/GetLog.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_GetLog extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ $buffer = Mage::helper('combine')->getLogContents($this->getLogName());
8
+
9
+ $logData = array(
10
+ 'logs' => array(
11
+ array(
12
+ 'store_id' => $this->getSpringbotStoreId(),
13
+ 'description' => $buffer,
14
+ ),
15
+ ),
16
+ );
17
+
18
+ Mage::getModel('combine/api')->call('logs', json_encode($logData), false);
19
+
20
+ if (isset($result['status'])) {
21
+ if ($result['status']==self::SUCCESSFUL_RESPONSE) {
22
+ Springbot_Log::harvest('['.__METHOD__.'] was successfully delivered');
23
+ }
24
+ else {
25
+ Springbot_Log::harvest('['.__METHOD__.'] delivery failed ->'.$result['status']);
26
+ }
27
+ }
28
+ }
29
+ }
app/code/community/Springbot/Services/Tasks/KillHarvest.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_KillHarvest extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ Springbot_Boss::halt();
8
+ }
9
+ }
app/code/community/Springbot/Services/Tasks/LaunchFullHarvest.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_LaunchFullHarvest extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ Springbot_Cli::launchHarvest();
8
+ }
9
+ }
app/code/community/Springbot/Services/Tasks/LaunchPartialHarvest.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_LaunchPartialHarvest extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ Mage::helper('combine/harvest')->truncateEngineLogs();
8
+ Springbot_Boss::scheduleJob(
9
+ 'cmd:harvest',
10
+ array(
11
+ 's' => $this->getStoreId(),
12
+ 'c' => $this->getType,
13
+ ),
14
+ Springbot_Services::HARVEST,
15
+ 'default',
16
+ $this->getStoreId()
17
+ );
18
+ }
19
+ }
app/code/community/Springbot/Services/Tasks/PackageUpdate.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_UpdatePackage extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ $version = $this->getPackageVersion();
8
+ $updater = new Springbot_Services_Cmd_Update();
9
+ $updater->setVersion($version);
10
+ $updater->run();
11
+ return true;
12
+ }
13
+ }
app/code/community/Springbot/Services/Tasks/PostItem.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_PostItem extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ if($type = ucfirst($this->getType())) {
8
+ $classname = 'Springbot_Services_Post_' . $type;
9
+ $instance = new $classname();
10
+ $instance->setEntityId($this->getEntityId());
11
+ $instance->run();
12
+ } else {
13
+ throw new Exception("Type not supplied for " . __CLASS__);
14
+ }
15
+ }
16
+ }
app/code/community/Springbot/Services/Tasks/ResumeHarvest.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_ResumeHarvest extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ Mage::getConfig()->cleanCache();
8
+ Mage::getConfig()->reinit();
9
+ Springbot_Cli::resumeHarvest();
10
+ }
11
+ }
app/code/community/Springbot/Services/Tasks/SetVar.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_SetVar extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ $varName = $this->getVarName();
8
+ $varValue = $this->getVarValue();
9
+
10
+ if (!preg_match('/.*\/.*\/.*/', $varName)) {
11
+ $varName = 'springbot/config/' . $varName;
12
+ }
13
+
14
+ if (!empty($varName) && ($varName != 'springbot/config/php_exec')) {
15
+ Mage::getModel('core/config')->saveConfig($varName, $varValue, 'default', 0);
16
+ }
17
+
18
+ Mage::getConfig()->cleanCache();
19
+ }
20
+ }
app/code/community/Springbot/Services/Tasks/SkipStoreHarvest.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Services_Tasks_SkipStoreHarvest extends Springbot_Services
4
+ {
5
+ public function run()
6
+ {
7
+ Springbot_Boss::haltStore($this->getStoreId());
8
+ }
9
+ }
app/code/community/Springbot/Services/Update/Package.php CHANGED
@@ -129,7 +129,7 @@ class Springbot_Services_Update_Package extends Springbot_Services_Update_Abstra
129
 
130
  protected function _cmdTar($file, $out)
131
  {
132
- Springbot_Boss::spawn("tar -zxf $file -C $out");
133
  if($this->_empty($out)) {
134
  throw new Exception('Tar empty!');
135
  }
129
 
130
  protected function _cmdTar($file, $out)
131
  {
132
+ Springbot_Cli::spawn("tar -zxf $file -C $out");
133
  if($this->_empty($out)) {
134
  throw new Exception('Tar empty!');
135
  }
app/code/community/Springbot/Services/Work/Cleanup.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Work_Cleanup extends Springbot_Services_Abstract
4
  {
5
  const UNLOCK_AFTER_X_HOURS = 24;
6
 
1
  <?php
2
 
3
+ class Springbot_Services_Work_Cleanup extends Springbot_Services
4
  {
5
  const UNLOCK_AFTER_X_HOURS = 24;
6
 
app/code/community/Springbot/Services/Work/Manager.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Work_Manager extends Springbot_Services_Abstract
4
  {
5
  const WORKMANAGER_FILENAME = 'springbot-workmanager';
6
  const WORKER_PREFIX = 'springbotworker-';
@@ -28,10 +28,10 @@ class Springbot_Services_Work_Manager extends Springbot_Services_Abstract
28
  $currentWorkerCount = $this->_getWorkerCount();
29
  if(!$this->_foremanRunning()) {
30
  $this->_foremanQueued = true;
31
- Springbot_Boss::internalCallback('work:runner', array('o' => true));
32
  }
33
  else if($currentWorkerCount < $maxWorkers) {
34
- Springbot_Boss::internalCallback('work:runner');
35
  }
36
  sleep(self::SPAWN_WORKER_SECONDS);
37
  $this->_verifyWorkersRunning();
@@ -43,7 +43,7 @@ class Springbot_Services_Work_Manager extends Springbot_Services_Abstract
43
 
44
  if($this->_hasJobs()) {
45
  Springbot_Log::debug("Jobs still queued, restarting manager");
46
- Springbot_Boss::startWorkManager();
47
  } else {
48
  Springbot_Log::debug("No more jobs found. Exiting. Manager will restart on next checkin.");
49
  }
@@ -112,7 +112,8 @@ class Springbot_Services_Work_Manager extends Springbot_Services_Abstract
112
 
113
  private function _getWorkerFiles()
114
  {
115
- return glob(Mage::getBaseDir('tmp') . DS . 'springbotworker*');
 
116
  }
117
 
118
  private function _hasJobs()
1
  <?php
2
 
3
+ class Springbot_Services_Work_Manager extends Springbot_Services
4
  {
5
  const WORKMANAGER_FILENAME = 'springbot-workmanager';
6
  const WORKER_PREFIX = 'springbotworker-';
28
  $currentWorkerCount = $this->_getWorkerCount();
29
  if(!$this->_foremanRunning()) {
30
  $this->_foremanQueued = true;
31
+ Springbot_Cli::internalCallback('work:runner', array('o' => true));
32
  }
33
  else if($currentWorkerCount < $maxWorkers) {
34
+ Springbot_Cli::internalCallback('work:runner');
35
  }
36
  sleep(self::SPAWN_WORKER_SECONDS);
37
  $this->_verifyWorkersRunning();
43
 
44
  if($this->_hasJobs()) {
45
  Springbot_Log::debug("Jobs still queued, restarting manager");
46
+ Springbot_Cli::startWorkManager();
47
  } else {
48
  Springbot_Log::debug("No more jobs found. Exiting. Manager will restart on next checkin.");
49
  }
112
 
113
  private function _getWorkerFiles()
114
  {
115
+ $glob = glob(Mage::getBaseDir('tmp') . DS . 'springbotworker*');
116
+ return $glob ? $glob : array();
117
  }
118
 
119
  private function _hasJobs()
app/code/community/Springbot/Services/Work/Report.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Work_Report extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
1
  <?php
2
 
3
+ class Springbot_Services_Work_Report extends Springbot_Services
4
  {
5
  public function run()
6
  {
app/code/community/Springbot/Services/Work/Restart.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Work_Restart extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
@@ -13,7 +13,7 @@ class Springbot_Services_Work_Restart extends Springbot_Services_Abstract
13
  if($status->isActive()) {
14
  $status->haltManager();
15
  }
16
- Springbot_Boss::startWorkManager();
17
  }
18
 
19
  }
1
  <?php
2
 
3
+ class Springbot_Services_Work_Restart extends Springbot_Services
4
  {
5
  public function run()
6
  {
13
  if($status->isActive()) {
14
  $status->haltManager();
15
  }
16
+ Springbot_Cli::startWorkManager();
17
  }
18
 
19
  }
app/code/community/Springbot/Services/Work/Runner.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Work_Runner extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
1
  <?php
2
 
3
+ class Springbot_Services_Work_Runner extends Springbot_Services
4
  {
5
  public function run()
6
  {
app/code/community/Springbot/Services/Work/Stop.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Services_Work_Stop extends Springbot_Services_Abstract
4
  {
5
  public function run()
6
  {
@@ -11,15 +11,15 @@ class Springbot_Services_Work_Stop extends Springbot_Services_Abstract
11
  do{
12
  if($pid = $this->getPid()) {
13
  Springbot_Log::debug("Issuing kill command for manager pid: {$pid}");
14
- Springbot_Boss::spawn('kill ' . $pid);
15
  } else {
16
  Springbot_Log::debug("No active manager found, skipping");
17
  }
18
 
19
  if($pids = $this->_getStatus()->getActiveWorkerPids()) {
20
- foreach($pids as $pid) {
21
  Springbot_Log::debug("Issuing kill command for worker pid: {$pid}");
22
- Springbot_Boss::spawn('kill ' . $pid);
23
  }
24
  } else {
25
  Springbot_Log::debug("No active workers found, skipping");
1
  <?php
2
 
3
+ class Springbot_Services_Work_Stop extends Springbot_Services
4
  {
5
  public function run()
6
  {
11
  do{
12
  if($pid = $this->getPid()) {
13
  Springbot_Log::debug("Issuing kill command for manager pid: {$pid}");
14
+ Springbot_Cli::spawn('kill ' . $pid);
15
  } else {
16
  Springbot_Log::debug("No active manager found, skipping");
17
  }
18
 
19
  if($pids = $this->_getStatus()->getActiveWorkerPids()) {
20
+ foreach ($pids as $pid) {
21
  Springbot_Log::debug("Issuing kill command for worker pid: {$pid}");
22
+ Springbot_Cli::spawn('kill ' . $pid);
23
  }
24
  } else {
25
  Springbot_Log::debug("No active workers found, skipping");
app/code/community/Springbot/Shadow/Block/Action/View.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Shadow_Block_Action_View extends Mage_Core_Block_Template
4
+ {
5
+ protected function _toHtml()
6
+ {
7
+ return '<img src="' . $this->_getPixelUrl() . '"style="position:absolute; visibility:hidden">';
8
+ }
9
+
10
+ private function _getPixelUrl()
11
+ {
12
+ $params = array(
13
+ 'store_id' => Mage::app()->getStore()->getStoreId(),
14
+ 'sku' => Mage::registry('current_product')->getSku(),
15
+ 'page_url' => Mage::helper('core/url')->getCurrentUrl(),
16
+ 'category_id' => Mage::helper('combine')->getLastCategoryId(),
17
+ );
18
+ return Mage::getUrl('springbot_update/action/view', array('_query' => $params));
19
+ }
20
+ }
app/code/community/Springbot/Shadow/Block/{Js/Boot.php → Async.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Springbot_Shadow_Block_Js_Boot extends Mage_Core_Block_Template
4
  {
5
  public function getSpringbotStoreId()
6
  {
1
  <?php
2
 
3
+ class Springbot_Shadow_Block_Async extends Mage_Core_Block_Template
4
  {
5
  public function getSpringbotStoreId()
6
  {
app/code/community/Springbot/Shadow/Controller/Action.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Shadow_Controller_Action extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ $this->setFlag('', self::FLAG_NO_PRE_DISPATCH, 1);
8
+ $this->setFlag('', self::FLAG_NO_POST_DISPATCH, 1);
9
+ parent::preDispatch();
10
+ return $this;
11
+ }
12
+
13
+ /**
14
+ * Return whether or not the current request is authenticated by a
15
+ * Springbot token in the header
16
+ *
17
+ * @return boolean
18
+ */
19
+ public function hasSbAuthToken()
20
+ {
21
+ $helper = Mage::helper('shadow/prattler');
22
+ $token = $helper->getPrattlerToken();
23
+ if (!$token) {
24
+ Springbot_Log::debug('Could not load security token to authenticated jobs endpoint');
25
+ }
26
+ else if ($this->getRequest()->getHeader('Springbot-Security-Token') != $token) {
27
+ Springbot_Log::debug('Supplied security token hash does not match');
28
+ } else {
29
+ return true;
30
+ }
31
+ return false;
32
+ }
33
+ }
app/code/community/Springbot/Shadow/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Shadow_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ }
app/code/community/Springbot/Shadow/Helper/Listeners.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Shadow_Helper_Listeners extends Mage_Core_Helper_Abstract
4
- {
5
- public function getListenerIds()
6
- {
7
- return explode(',', Mage::getStoreConfig('springbot/config/email_selector'));
8
- }
9
-
10
- public function getListenerClasses()
11
- {
12
- return explode(',', Mage::getStoreConfig('springbot/config/email_selector_classes'));
13
- }
14
-
15
- public function getBaseUrlNoProtocol()
16
- {
17
- return preg_replace('/https?:/','', Mage::getBaseUrl());
18
- }
19
- }
20
-
21
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Shadow/Helper/Prattler.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Shadow_Helper_Prattler extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getPrattlerToken()
6
+ {
7
+ $storeId = Mage::app()->getStore()->getStoreId();
8
+ $token = Mage::helper('bmbleb/account')->getSavedSecurityToken();
9
+ $guid = Mage::getStoreConfig('springbot/config/store_guid_' . $storeId);
10
+ return sha1($token . $guid);
11
+ }
12
+
13
+ public function getPrattlerJsonResponse()
14
+ {
15
+ $jobs = Mage::getModel('combine/cron_queue')->getCollection();
16
+ $response = array(
17
+ 'success' => 'ok',
18
+ 'jobs' => $jobs->getSize(),
19
+ );
20
+ return json_encode($response);
21
+ }
22
+ }
app/code/community/Springbot/Shadow/Model/Listeners/Observer.php CHANGED
@@ -1,221 +1,19 @@
1
  <?php
2
- /**
3
- * Visitor Shadow Event Listener
4
- *
5
- * @version v1.0.1 - 12/28/2012
6
- *
7
- * @category Magento Intergations
8
- * @package springbot
9
- * @author William Seitz
10
- * @division SpringBot Integration Team
11
- * @support magentosupport@springbot.com
12
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13
- *
14
- */
15
- class Springbot_Shadow_Model_Listeners_Observer {
16
-
17
- const TOKEN_DELIMITER = '%7';
18
- const COOKIE_NAME = 'springbot_redirect_queue';
19
- const SB_TRACKABLES_COOKIE = '_sbtk';
20
- const MAXIMUM_IDS_SAVED = 32;
21
-
22
- /**
23
- * Order of priority desc - "there can only be one!"
24
- */
25
- protected $_redirectIds = array(
26
- 'sb',
27
- 'redirect_mongo_id',
28
- );
29
 
30
- public function post($observer)
31
- {
32
- try {
33
- Mage::helper('combine')->setLastCategoryId();
34
- } catch (Exception $e) {
35
- Mage::logException($e);
36
- }
37
- }
38
 
39
- public function escort($observer)
40
  {
41
- if ($quoteId = Mage::app()->getRequest()->getParam('quote_id')) {
42
- $suppliedSecurityHash = Mage::app()->getRequest()->getParam('sec_key');
43
- Mage::helper('combine/cart')->setQuote($quoteId, $suppliedSecurityHash);
44
- }
45
-
46
  try {
47
- // Set springbot redirect queue
48
- if($param = $this->_getParam()) {
49
- $this->_setSpringbotRedirectQueueCookie($param);
50
- }
51
-
52
- // Set sb trackables cookie
53
- if($trackables = $this->getTrackables()) {
54
- $this->_setSbTrackablesCookie($trackables);
55
- }
56
-
57
- $storeId = Mage::app()->getStore()->getStoreId();
58
-
59
- $this->runHealthcheck($storeId);
60
- $this->scrapeEntities($storeId);
61
-
62
- $this->runQueueCleanup();
63
-
64
- } catch (Exception $e) {
65
- Mage::logException($e);
66
- }
67
- return;
68
- }
69
-
70
- public function runQueueCleanup()
71
- {
72
- // global scope, no need for store_id, run every hour
73
- if (Springbot_Shadow_Model_Timer::fire('cleanup', 0, 60)) {
74
- Springbot_Boss::internalCallback('work:cleanup');
75
- }
76
- }
77
-
78
- public function runHealthcheck($storeId)
79
- {
80
- if (Springbot_Shadow_Model_Timer::fire('healthcheck', $storeId)) {
81
- $this->querySpringbot($storeId);
82
- if (!Springbot_Boss::isCron()) {
83
- Springbot_Boss::startWorkManager();
84
- }
85
- }
86
- }
87
-
88
- public function scrapeEntities($storeId)
89
- {
90
- if (Springbot_Shadow_Model_Timer::fire('scrape', $storeId, 10)) {
91
- $lastPostedCouponId = Mage::getStoreConfig('springbot/tmp/last_coupon_id');
92
- if (!$lastPostedCouponId) {
93
- $lastPostedCouponId = 0;
94
- }
95
- $couponsToPost = Mage::getModel('salesrule/coupon')->getCollection()
96
- ->addFieldToFilter('coupon_id', array('gt' => $lastPostedCouponId));
97
-
98
- $couponsToPost->getSelect()->order('coupon_id', 'ASC');
99
- $lastFoundCouponId = null;
100
- foreach ($couponsToPost as $couponToPost) {
101
- Springbot_Boss::scheduleJob('post:coupon', array('i' => $couponToPost->getId()), Springbot_Services_Priority::LISTENER, 'listener');
102
- $lastFoundCouponId = $couponToPost->getId();
103
- }
104
- if (($lastFoundCouponId) && ($lastPostedCouponId != $lastFoundCouponId)) {
105
- Mage::getModel('core/config')->saveConfig('springbot/tmp/last_coupon_id', $lastFoundCouponId, 'default', 0);
106
- Mage::getConfig()->cleanCache();
107
- }
108
- }
109
- }
110
-
111
- public function getTrackables()
112
- {
113
- $params = $this->_getParams();
114
- $origParams = Mage::helper('combine/trackable')->getTrackables();
115
- $sbParams = $origParams ? clone $origParams : new stdClass();
116
-
117
- foreach($params as $param => $value) {
118
- if(preg_match('/^sb_/', $param)) {
119
- Springbot_Log::debug("Assigning $param from url with $value");
120
- $sbParams->$param = $value;
121
  }
122
  }
123
- $this->_ensureHttpReferer($sbParams);
124
- return !Mage::helper('combine')->isEmpty($sbParams) && $sbParams != $origParams ? $sbParams : false;
125
- }
126
-
127
- protected function _getParam()
128
- {
129
- $params = Mage::app()->getRequest()->getParams();
130
- foreach($this->_redirectIds as $id) {
131
- if(isset($params[$id])) {
132
- return $params[$id];
133
- }
134
- }
135
- }
136
-
137
- protected function _setSbTrackablesCookie($params)
138
- {
139
- if(!Mage::helper('combine')->isEmpty($params)) {
140
- $encoded = base64_encode(json_encode($params));
141
- $this->_setCookie(self::SB_TRACKABLES_COOKIE, $encoded);
142
- }
143
- }
144
-
145
- protected function _ensureHttpReferer(&$params)
146
- {
147
- if(!isset($params->sb_referer_host) && !$this->_hasSbReferHost()) {
148
- if(isset($_SERVER['HTTP_REFERER']) && isset($_SERVER['HTTP_HOST'])) {
149
- $host = $_SERVER['HTTP_HOST'];
150
- $parsed = parse_url($_SERVER['HTTP_REFERER']);
151
- $referer = isset($parsed['host']) ? $parsed['host'] : null;
152
-
153
- if($referer != $host) {
154
- Springbot_Log::debug("refered by $referer"); if($host) {
155
- $params->sb_referer_host = $referer;
156
- }
157
- }
158
- }
159
- }
160
- }
161
-
162
- protected function _hasSbReferHost()
163
- {
164
- $params = Mage::helper('combine/trackable')->getTrackables();
165
- return isset($params->sb_referer_host);
166
- }
167
-
168
- protected function _setSpringbotRedirectQueueCookie($param)
169
- {
170
- $redirectQueue = Mage::getModel('core/cookie')->get(self::COOKIE_NAME);
171
-
172
- if(!empty($redirectQueue)) {
173
- $cookieValues = explode(self::TOKEN_DELIMITER, $redirectQueue);
174
-
175
- if (count($cookieValues) >= self::MAXIMUM_IDS_SAVED) {
176
- $oldestValue = array_shift($cookieValues);
177
- }
178
-
179
- if (end($cookieValues) != $param) {
180
- $cookieValues[] = $param;
181
- }
182
-
183
- $redirectQueue = implode(self::TOKEN_DELIMITER, $cookieValues);
184
- $this->_setCookie(self::COOKIE_NAME, $redirectQueue);
185
  }
 
186
  }
187
 
188
- protected function _setCookie($name, $value)
189
- {
190
- Springbot_Log::debug("Saving cookie $name : $value");
191
-
192
- Mage::getModel('core/cookie')->set(
193
- $name,
194
- $value,
195
- strtotime('+365 days'),
196
- '/', // path
197
- null, // domain
198
- null, // secure
199
- false // httpOnly
200
- );
201
- }
202
-
203
- /**
204
- * Query Springbot api healthcheck when running
205
- * in standard / not cron mode.
206
- */
207
- private function querySpringbot($storeId)
208
- {
209
- Springbot_Boss::internalCallback('cmd:healthcheck', array('s' => $storeId));
210
- }
211
-
212
- protected function _getParams()
213
- {
214
- return Mage::app()->getRequest()->getParams();
215
- }
216
-
217
- protected function _isCron()
218
- {
219
- return Springbot_Boss::isCron();
220
- }
221
  }
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ class Springbot_Shadow_Model_Listeners_Observer {
 
 
 
 
 
 
 
4
 
5
+ public function reconstituteCart($observer)
6
  {
 
 
 
 
 
7
  try {
8
+ if ($quoteId = Mage::app()->getRequest()->getParam('quote_id')) {
9
+ $suppliedSecurityHash = Mage::app()->getRequest()->getParam('sec_key');
10
+ Mage::helper('combine/cart')->setQuote($quoteId, $suppliedSecurityHash);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
  }
13
+ catch (Exception $e) {
14
+ Springbot_Log::error($e);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
+ return;
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
app/code/community/Springbot/Shadow/Model/Timer.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- class Springbot_Shadow_Model_Timer
4
- {
5
- const DEFAULT_POLLING_INTERVAL = 5; // minutes
6
-
7
- protected $_task;
8
- protected $_storeId;
9
- protected $_interval;
10
-
11
- public function __construct($task, $storeId, $interval)
12
- {
13
- $this->_task = $task;
14
- $this->_storeId = $storeId;
15
- $this->_interval = is_null($interval) ? $this->_getQueryInterval() : $interval;
16
- }
17
-
18
- public static function fire($task, $storeId, $interval = null)
19
- {
20
- $ins = new Springbot_Shadow_Model_Timer($task, $storeId, $interval);
21
- if($ins->doRunTask()) {
22
- Springbot_Log::debug("Firing $task for store_id: $storeId");
23
- $ins->_setCache(time());
24
- return true;
25
- } else {
26
- return false;
27
- }
28
- }
29
-
30
- public function doRunTask()
31
- {
32
- $intervalDiff = (time() - $this->_getCache()) / 60;
33
- return $intervalDiff > $this->_interval;
34
- }
35
-
36
- protected function _getQueryInterval()
37
- {
38
- $interval = Mage::getStoreConfig('springbot/config/query_interval');
39
- if(empty($interval) || !isset($interval)) {
40
- $interval = self::DEFAULT_POLLING_INTERVAL;
41
- }
42
- return $interval;
43
- }
44
-
45
- protected function _getCache()
46
- {
47
- $fname = $this->_getFilename();
48
- $lastFired = 0;
49
-
50
- if(file_exists($fname)) {
51
- if($fHandle = $this->_openCacheWithLock($fname,'r')) {
52
- $lastFired = trim(fread($fHandle, 128));
53
- fclose($fHandle);
54
- }
55
- }
56
- return $lastFired;
57
- }
58
-
59
- protected function _setCache($value)
60
- {
61
- if ($fHandle = $this->_openCacheWithLock($this->_getFilename(),'w')) {
62
- fwrite($fHandle, $value."\n");
63
- fclose($fHandle);
64
- }
65
- return $this;
66
- }
67
-
68
- protected function _getFilename()
69
- {
70
- return Mage::getBaseDir('tmp') . DS . 'sb-cache-' . $this->_task . '-' . $this->_storeId . '.dat';
71
- }
72
-
73
- private function _openCacheWithLock($fileName, $mode = 'w')
74
- {
75
- return fopen($fileName, $mode);
76
- }
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Springbot/Shadow/controllers/ActionController.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Springbot_Shadow_ActionController extends Springbot_Shadow_Controller_Action
3
+ {
4
+ public function viewAction()
5
+ {
6
+ $params = $this->getRequest()->getParams();
7
+
8
+ $params['type'] = 'view';
9
+ $params['visitor_ip'] = Mage::helper('core/http')->getRemoteAddr(true);
10
+
11
+ Springbot_Boss::insertEvent($params);
12
+
13
+ Springbot_Cli::runHealthcheck();
14
+
15
+ // return 1x1 pixel transparent gif
16
+ $this->getResponse()->setHeader('Content-type', 'image/gif');
17
+ // needed to avoid cache time on browser side
18
+ $this->getResponse()->setHeader('Content-Length', '42');
19
+ $this->getResponse()->setHeader('Cache-Control', 'private, no-cache, no-cache=Set-Cookie, proxy-revalidate');
20
+ $this->getResponse()->setHeader('Expires', 'Wed, 11 Jan 2000 12:59:00 GMT');
21
+ $this->getResponse()->setHeader('Last-Modified', 'Wed, 11 Jan 2006 12:59:00 GMT');
22
+ $this->getResponse()->setHeader('Pragma', 'no-cache');
23
+ $this->getResponse()->setBody(sprintf('%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%',71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59));
24
+ }
25
+ }
app/code/community/Springbot/Shadow/controllers/IndexController.php CHANGED
@@ -1,38 +1,96 @@
1
  <?php
2
- class Springbot_Shadow_IndexController extends Mage_Core_Controller_Front_Action
3
  {
4
- private $_acceptedParams = array('email');
 
 
 
 
 
 
5
 
6
  public function indexAction()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  {
8
  if ($quote = Mage::getSingleton('checkout/session')->getQuote()) {
9
- $params = $this->getRequest()->getParams();
10
- foreach ($params as $paramName => $paramValue) {
11
- if ($this->_isValidParam($paramName)) {
12
- if ($paramName == 'email') {
13
- $sessionQuoteExists = $quote->hasEntityId();
14
- if ($quote = Mage::getModel('checkout/session')->getQuote()) {
15
- // If there is no email address associated with the quote, check to see if one exists from our js listener
16
- if (!$quote->getCustomerEmail()) {
17
- $quote->setCustomerEmail($paramValue);
18
- $quote->save();
19
- }
20
- }
21
- if (!$sessionQuoteExists) {
22
- Mage::getSingleton('checkout/session')->setQuoteId($quote->getId());
23
- }
24
- }
25
- }
26
  }
27
- }
28
 
29
- $this->loadLayout()->getLayout()->getBlock('root')->setTemplate('shadow/emailupdate.phtml');
30
- $this->_initLayoutMessages('core/session');
31
- $this->renderLayout();
 
 
 
 
32
  }
33
 
34
- private function _isValidParam($paramName) {
35
- return in_array($paramName, $this->_acceptedParams);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
 
 
 
 
 
 
 
 
 
38
  }
1
  <?php
2
+ class Springbot_Shadow_IndexController extends Springbot_Shadow_Controller_Action
3
  {
4
+ /**
5
+ * Order of priority desc - "there can only be one!"
6
+ */
7
+ private $_redirectIds = array(
8
+ 'sb',
9
+ 'redirect_mongo_id',
10
+ );
11
 
12
  public function indexAction()
13
+ {
14
+ $params = $this->getRequest()->getParams();
15
+ if (isset($params['run'])) {
16
+ $this->runCaller();
17
+ }
18
+ else if (isset($params['email'])) {
19
+ $this->emailCaller();
20
+ }
21
+ else if (isset($params['trackable']) && isset($params['type'])) {
22
+ $this->trackableCaller();
23
+ }
24
+ else if (isset($params['healthcheck'])) {
25
+ $this->healthcheckCaller();
26
+ }
27
+ }
28
+
29
+ private function runCaller()
30
+ {
31
+ $helper = Mage::helper('shadow/prattler');
32
+
33
+ if ($this->hasSbAuthToken()) {
34
+ $cronWorker = Mage::getModel('combine/cron_worker');
35
+ $cronWorker->run();
36
+
37
+ $this->getResponse()->setHeader('Content-type', 'application/json');
38
+ $this->getResponse()->setBody($helper->getPrattlerJsonResponse());
39
+ }
40
+ }
41
+
42
+ private function emailCaller()
43
  {
44
  if ($quote = Mage::getSingleton('checkout/session')->getQuote()) {
45
+ $sessionQuoteExists = $quote->hasEntityId();
46
+
47
+ // If there is no email address associated with the quote, check to see if one exists from our js listener
48
+ if (!$quote->getCustomerEmail()) {
49
+ $quote->setCustomerEmail($this->getRequest()->getParam('email'));
50
+ $quote->save();
 
 
 
 
 
 
 
 
 
 
 
51
  }
 
52
 
53
+ if (!$sessionQuoteExists) {
54
+ Mage::getSingleton('checkout/session')->setQuoteId($quote->getId());
55
+ }
56
+
57
+ $this->getResponse()->setHeader('Content-type', 'application/json');
58
+ $this->getResponse()->setBody('{}');
59
+ }
60
  }
61
 
62
+ private function trackableCaller()
63
+ {
64
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
65
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
66
+ $customerId = $customerData->getId();
67
+ }
68
+ else {
69
+ $customerId = null;
70
+ }
71
+
72
+ if ($quote = Mage::getModel('checkout/session')->getQuote()) {
73
+ $quoteId = $quote->getId();
74
+ }
75
+ else {
76
+ $quoteId = null;
77
+ }
78
+
79
+ Springbot_Boss::addTrackable(
80
+ $this->getRequest()->getParam('type'),
81
+ $this->getRequest()->getParam('trackable'),
82
+ $quoteId,
83
+ $customerId
84
+ );
85
  }
86
 
87
+ private function healthcheckCaller()
88
+ {
89
+ if ($this->hasSbAuthToken()) {
90
+ Springbot_Cli::runHealthcheck(null, true);
91
+
92
+ $this->getResponse()->setHeader('Content-type', 'application/json');
93
+ $this->getResponse()->setBody('{"success":"ok"}');
94
+ }
95
+ }
96
  }
app/code/community/Springbot/Shadow/etc/config.xml CHANGED
@@ -1,12 +1,4 @@
1
  <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category springbot
5
- * @package springbot_Shadow
6
- * @author springbot integration team
7
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
- */
9
- -->
10
  <config>
11
  <modules>
12
  <Springbot_Shadow>
@@ -48,24 +40,15 @@
48
  </updates>
49
  </layout>
50
  <events>
51
- <controller_action_predispatch>
52
  <observers>
53
  <springbot_shadow_observer>
54
  <type>singleton</type>
55
  <class>shadow/listeners_observer</class>
56
- <method>escort</method>
57
  </springbot_shadow_observer>
58
  </observers>
59
- </controller_action_predispatch>
60
- <controller_action_postdispatch>
61
- <observers>
62
- <springbot_shadow_observer>
63
- <type>singleton</type>
64
- <class>shadow/listeners_observer</class>
65
- <method>post</method>
66
- </springbot_shadow_observer>
67
- </observers>
68
- </controller_action_postdispatch>
69
  </events>
70
  </frontend>
71
  </config>
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
 
2
  <config>
3
  <modules>
4
  <Springbot_Shadow>
40
  </updates>
41
  </layout>
42
  <events>
43
+ <controller_action_predispatch_checkout_cart_index>
44
  <observers>
45
  <springbot_shadow_observer>
46
  <type>singleton</type>
47
  <class>shadow/listeners_observer</class>
48
+ <method>reconstituteCart</method>
49
  </springbot_shadow_observer>
50
  </observers>
51
+ </controller_action_predispatch_checkout_cart_index>
 
 
 
 
 
 
 
 
 
52
  </events>
53
  </frontend>
54
  </config>
app/code/community/Springbot/Util/Cache.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class: Springbot_Util_Cache
5
+ *
6
+ * @author Springbot Magento Integration Team <magento@springbot.com>
7
+ * @version 1.4.0.0
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Springbot_Util_Cache
11
+ {
12
+ const CACHE_TAG = 'springbot_cache';
13
+
14
+ public function __construct($appCache = null)
15
+ {
16
+ $this->_appCache = $appCache;
17
+ }
18
+
19
+ public static function set($key, $value)
20
+ {
21
+ $instance = new Springbot_Util_Cache();
22
+ $instance->_save($key, $value);
23
+ }
24
+
25
+ public static function get($key)
26
+ {
27
+ $instance = new Springbot_Util_Cache();
28
+ return $instance->_load($key);
29
+ }
30
+
31
+ public static function clean()
32
+ {
33
+ $instance = new Springbot_Util_Cache();
34
+ $instance->_clean();
35
+ }
36
+
37
+ protected function _save($key, $value)
38
+ {
39
+ $this->_getAppCache()->save($value, $key, array(self::CACHE_TAG));
40
+ }
41
+
42
+ protected function _load($key)
43
+ {
44
+ return $this->_getAppCache()->load($key);
45
+ }
46
+
47
+ protected function _clean()
48
+ {
49
+ return $this->_getAppCache()->clean(
50
+ Zend_Cache::CLEANING_MODE_MATCHING_TAG,
51
+ array(self::CACHE_TAG)
52
+ );
53
+ }
54
+
55
+ private function _getAppCache()
56
+ {
57
+ if(!isset($this->_appCache)) {
58
+ $this->_appCache = Mage::app()->getCache();
59
+ }
60
+ return $this->_appCache;
61
+ }
62
+
63
+ }
app/code/community/Springbot/Util/Caller.php CHANGED
@@ -50,7 +50,4 @@ class Springbot_Util_Caller
50
  return self::_safeGet(self::$_trace, $depth - 1);
51
  }
52
 
53
- private static function _getCaller($depth)
54
- {
55
- }
56
  }
50
  return self::_safeGet(self::$_trace, $depth - 1);
51
  }
52
 
 
 
 
53
  }
app/code/community/Springbot/Util/Log/Rollover.php CHANGED
@@ -49,7 +49,8 @@ class Springbot_Util_Log_Rollover
49
  if(!isset($this->_globbed[$filename])) {
50
  $filename = $this->_qualify($filename);
51
  $pattern = $filename . '.*';
52
- $this->_globbed[$filename] = glob($pattern);
 
53
  Springbot_Log::debug("Checking glob for $pattern, returns " . count($this->_globbed[$filename]) . " results");
54
  }
55
  return $this->_globbed[$filename];
49
  if(!isset($this->_globbed[$filename])) {
50
  $filename = $this->_qualify($filename);
51
  $pattern = $filename . '.*';
52
+ $glob = glob($pattern);
53
+ $this->_globbed[$filename] = isset($glob) ? $glob : array();
54
  Springbot_Log::debug("Checking glob for $pattern, returns " . count($this->_globbed[$filename]) . " results");
55
  }
56
  return $this->_globbed[$filename];
app/code/community/Springbot/Util/Timer.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Springbot_Util_Timer
4
+ {
5
+ const DEFAULT_POLLING_INTERVAL = 5; // minutes
6
+
7
+ protected $_task;
8
+ protected $_storeId;
9
+ protected $_interval;
10
+
11
+ public function __construct($task, $storeId, $interval = null)
12
+ {
13
+ $this->_task = $task;
14
+ $this->_storeId = $storeId;
15
+ $this->_interval = is_null($interval) ? $this->_getQueryInterval() : $interval;
16
+ }
17
+
18
+ public static function fire($task, $storeId, $interval = null)
19
+ {
20
+ $ins = new Springbot_Util_Timer($task, $storeId, $interval);
21
+ if($ins->doRunTask()) {
22
+ Springbot_Log::debug("Firing $task for store_id: $storeId");
23
+ $ins->_setLastRunAt();
24
+ return true;
25
+ } else {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ public static function lastRun($task, $storeId)
31
+ {
32
+ $ins = new Springbot_Util_Timer($task, $storeId);
33
+ return $ins->_getLastRunAt();
34
+ }
35
+
36
+ public function doRunTask()
37
+ {
38
+ $intervalDiff = (time() - $this->_getLastRunAt()) / 60;
39
+ return $intervalDiff > $this->_interval;
40
+ }
41
+
42
+ public function _getKey()
43
+ {
44
+ return $this->_task . '-' . $this->_storeId;
45
+ }
46
+
47
+ protected function _getLastRunAt()
48
+ {
49
+ Springbot_Log::debug('Getting: ' . $this->_getKey());
50
+ return Springbot_Util_Cache::get($this->_getKey());
51
+ }
52
+
53
+ protected function _setLastRunAt()
54
+ {
55
+ $time = (string) time();
56
+ Springbot_Log::debug('Setting: ' . $this->_getKey() . ' => ' . $time);
57
+ Springbot_Util_Cache::set($this->_getKey(), $time);
58
+ }
59
+
60
+ protected function _getQueryInterval()
61
+ {
62
+ $interval = Mage::getStoreConfig('springbot/config/query_interval');
63
+ if(empty($interval) || !isset($interval)) {
64
+ $interval = self::DEFAULT_POLLING_INTERVAL;
65
+ }
66
+ return $interval;
67
+ }
68
+ }
app/design/adminhtml/default/default/template/bmbleb/auth.phtml CHANGED
@@ -2,4 +2,3 @@
2
  <div class="form-wrap last">
3
  <?php echo $this->getChildHtml('login_form'); ?>
4
  </div>
5
- </div>
2
  <div class="form-wrap last">
3
  <?php echo $this->getChildHtml('login_form'); ?>
4
  </div>
 
app/design/adminhtml/default/default/template/bmbleb/index.phtml CHANGED
@@ -4,9 +4,10 @@
4
  <img align=left src="<?php echo $this->getSkinUrl('bmbleb/images/plugin_dashboard_syncing.jpg'); ?>" alt="springbot logo" />&nbsp;</a>
5
  <?php
6
  try {
7
- Springbot_Boss::launchHarvest();
8
- } catch (Exception $e) {
9
- Mage::logException($e);
 
10
  }
11
  ?>
12
  </div>
4
  <img align=left src="<?php echo $this->getSkinUrl('bmbleb/images/plugin_dashboard_syncing.jpg'); ?>" alt="springbot logo" />&nbsp;</a>
5
  <?php
6
  try {
7
+ Springbot_Cli::launchHarvest();
8
+ }
9
+ catch (Exception $e) {
10
+ Springbot_Log::error($e);
11
  }
12
  ?>
13
  </div>
app/design/adminhtml/default/default/template/bmbleb/status.phtml CHANGED
@@ -7,6 +7,6 @@
7
  </div>
8
  <div class="tc-info">
9
  <p class="tc-link"><a href="http://www.springbot.com/content/terms_of_use" target="_blank" title="Terms &amp; Conditions">View our Terms &amp; Conditions</a></p>
10
- <p style="float:right;">Springbot v<?php echo Springbot_DataServices_HarvestingManager::MAGENTO_PACKAGE_VERSION ?></p>
11
  </div>
12
 
7
  </div>
8
  <div class="tc-info">
9
  <p class="tc-link"><a href="http://www.springbot.com/content/terms_of_use" target="_blank" title="Terms &amp; Conditions">View our Terms &amp; Conditions</a></p>
10
+ <p style="float:right;">Springbot v<?php echo Mage::getConfig()->getModuleConfig("Springbot_Combine")->version ?></p>
11
  </div>
12
 
app/design/frontend/base/default/layout/shadow.xml CHANGED
@@ -1,28 +1,27 @@
1
  <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * @category springbot
5
- * @package springbot_Shadow
6
- * @author springbot integration team
7
- */
8
- -->
9
  <layout>
10
- <default>
11
- <reference name="before_body_end">
12
- <block type="shadow/js_boot" name="shadow.js.boot" template="shadow/js/boot.phtml"/>
13
- </reference>
14
- </default>
15
 
16
- <shadow_frontend_index_index>
17
- <block type="core/template" name="root" output="toHtml" template="shadow/emailupdate.phtml"/>
18
- </shadow_frontend_index_index>
19
 
20
- <checkout_onepage_success>
21
- <reference name="before_body_end">
22
- <block type="core/template" template="shadow/conversion.phtml" name="shadow.conversion" />
23
- </reference>
24
- </checkout_onepage_success>
25
 
 
 
 
 
 
26
  </layout>
27
 
28
 
1
  <?xml version="1.0"?>
2
+
 
 
 
 
 
 
3
  <layout>
4
+ <default>
5
+ <reference name="before_body_end">
6
+ <block type="shadow/async" name="shadow.async" template="shadow/async.phtml"/>
7
+ </reference>
8
+ </default>
9
 
10
+ <shadow_frontend_index_index>
11
+ <block type="core/template" name="root"/>
12
+ </shadow_frontend_index_index>
13
 
14
+ <checkout_onepage_success>
15
+ <reference name="before_body_end">
16
+ <block type="core/template" template="shadow/conversion.phtml" name="shadow.conversion" />
17
+ </reference>
18
+ </checkout_onepage_success>
19
 
20
+ <catalog_product_view>
21
+ <reference name="before_body_end">
22
+ <block type="shadow/action_view" name="shadow.action.view" />
23
+ </reference>
24
+ </catalog_product_view>
25
  </layout>
26
 
27
 
app/design/frontend/base/default/template/shadow/{js/boot.phtml → async.phtml} RENAMED
File without changes
app/design/frontend/base/default/template/shadow/emailupdate.phtml DELETED
@@ -1 +0,0 @@
1
- {}
 
package.xml CHANGED
@@ -1,57 +1,58 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Springbot</name>
4
- <version>1.3.0.10</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Springbot helps merchants drive marketing actions based on insights from its &#x201C;big data&#x201D; analytics engine</summary>
10
  <description>Springbot - Better Data. Better Actions. More Revenue.&#xD;
11
- &#xD;
12
- Do you need help deciding how to spend your next marketing dollar? Springbot can help. &#xD;
13
- &#xD;
14
- Know your customers better. &#xD;
15
- Take better marketing actions. &#xD;
16
- Drive more revenue. &#xD;
17
- &#xD;
18
- Springbot helps Magento merchants drive marketing actions based on insights from its &#x201C;big data&#x201D; analytics engine. &#xD;
19
- - Analyze and augment consumer data and purchase behavior &#xD;
20
- - Integrate online marketing channels, content and marketplaces &#xD;
21
- - Prioritize future marketing actions based on the potential ROI &#xD;
22
- &#xD;
23
- Get to Know your Customers&#xD;
24
- &#xD;
25
- Springbot works magic by adding hard-to-find social and demographic data about your customers directly into Magento.&#xD;
26
- &#xD;
27
- age, gender, geo - gain an intuitive sense of your real market dynamics &#xD;
28
- social media data - facebook, twitter, linkedin... find your customers online without googling all of them! &#xD;
29
- home owner data - renting vs. owning and home value can drive purchase behavior &#xD;
30
- &#xD;
31
- plus employment data, income data and much more! &#xD;
32
- &#xD;
33
- Get Started Now with a Limited Time Free Data Offer&#xD;
34
- &#xD;
35
- It's completely free to sign up. We'll give you augmented data for up to 1000 of your customers so that you can experience the power of our awesome data service.&#xD;
36
- &#xD;
37
- Deep Magento Integration&#xD;
38
- &#xD;
39
- You have enough screens, graphs and forms to run your store. bmbleb enhances those screens... it doesn't replace them. Your extra customer data appears in your normal Magento customer screens. You can sort and search using it. And when you do want to dig deeper... Springbot has screens for you!&#xD;
40
- &#xD;
41
- Powerful Living Data Alerts&#xD;
42
- &#xD;
43
- Data isn't static. It changes constantly as we go about our lives. While you're busy watching over your store, Springbot watches over your data and alerts you to sales, marketing and relationship opportunities. Living Data Alerts tell you when your customers are ready to buy. Social media monitors tell you when customers are tweeting about topics relevant to your store.&#xD;
44
- &#xD;
45
- Living Data Alerts example: 378 pieces of data have been added to your customer database &#xD;
46
- Social Media Alerts example: Ted Smith Tweeted about your company &#xD;
47
- Proclivity to Buy Alerts example: Sally Avalon bought a house recently &#xD;
48
- &#xD;
49
- For support information, features and pricing and more details visit springbot.com</description>
50
- <notes>Defined package.xml for frontend template updates</notes>
51
- <authors><author><name>Springbot </name><user>Springbot</user><email>magento@springbot.com</email></author></authors>
52
- <date>2014-09-22</date>
53
- <time>18:43:41</time>
54
- <contents><target name="mageetc"><dir name="modules"><file name="Springbot.xml" hash="69a4e2c056502cd8539b4f66a2c8b1bc"/></dir></target><target name="magecommunity"><dir name="Springbot"><dir name="Bmbleb"><dir name="Block"><dir name="Adminhtml"><file name="Auth.php" hash="7dc661bbe9ec85f700a22b319981114d"/><dir name="Bmbleb"><dir name="Login"><file name="Form.php" hash="92cb0b61cce7726f20eec7d5ba8b08a8"/></dir><file name="Login.php" hash="7232e8225f5b21de5675c0d84cb452bd"/></dir><file name="Connected.php" hash="833cef8e351f5efa7a4d104b1c51ca7f"/><file name="Help.php" hash="b280b3292ed778140b751b6426ef56fb"/><dir name="Index"><file name="Messages.php" hash="1e247e31194447de32e54f49dafc3ccc"/><file name="Terms.php" hash="739e5a9ebe204f1f9ac433557c994ae6"/></dir><file name="Index.php" hash="eb7bbef5fa26a53748596e145c3677c4"/><dir name="Jobs"><file name="Grid.php" hash="67255d982ac3d50b38d7a2a525c2b922"/><file name="Status.php" hash="f1b197bf6fdc392bed93ff0734a54ad6"/></dir><file name="Jobs.php" hash="84801c6008802496e168e763a7e6d71f"/><file name="Login.php" hash="2e4d8baead482d404ed40f7d5f3d902c"/><file name="Logout.php" hash="b75af51891b751b9d070e1e784dd6914"/><file name="Logs.php" hash="686e958b553c1e3fcf74841eab30fffb"/><file name="Notifications.php" hash="b9e103d6c255078274c2f3047d944d0e"/><file name="Problems.php" hash="d88e7f1ce79746a306e9b0ff7d0e49bd"/><file name="Status.php" hash="9b67a20f0ee00608029d24850cefda4d"/><file name="Tabs.php" hash="6f93d5c6bd5208a99637c06118c6c630"/></dir></dir><dir name="Helper"><file name="Account.php" hash="b6b8a7623c221d00b3bd142d2ee30e4a"/><file name="Data.php" hash="dca14b137de1e2734a377ca645eeddbe"/><file name="PluginStatus.php" hash="1423679a7e9636aaec854f617da81fe8"/></dir><dir name="Model"><file name="Bmbleb.php" hash="700d11c3006f2dcd2e80cd8bbbab15f9"/><file name="Status.php" hash="9409d26c7884be6b8075ba97dbf71f78"/><file name="Sync.php" hash="a800b6064a88f37957392cd967f2b3cb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="HelpController.php" hash="087e7868dafe9dd2df89a642d405424a"/><file name="IndexController.php" hash="6b1059484b2d46453e0a429e2d4c8d71"/><file name="JobsController.php" hash="4e912a8fafd2f58235cb2299a83a128b"/><file name="LogsController.php" hash="20a0ce2f584f08480399b7a5ecbd9207"/><file name="ProblemsController.php" hash="a257b10a90bd3924d2396c1a7c272a38"/><file name="SettingsController.php" hash="f75a7a8ef28a296cbd46b04ae9dd5539"/></dir><file name="HelpController.php" hash="2df4608a957f151bf1d01dbde2113680"/><file name="IndexController.php" hash="ea5fa5e2b305f46b222cb2fc2a44f6a5"/><file name="LoginController.php" hash="fc5f7211f7d87c3b8d32bcf502dc1b3f"/><file name="LogoutController.php" hash="140c9d32f5557aa1169fd1b85cd5cc9f"/></dir><dir name="etc"><file name="config.xml" hash="45f7218274a3eed0086761942a95f27b"/></dir></dir><dir name="BoneCollector"><dir name="Model"><file name="HarvestAbstract.php" hash="cd3c3ebcd5c2f4d77d37147e3c722a47"/><dir name="HarvestAttribute"><file name="Observer.php" hash="50a54c290e468d584442c867e866c81b"/></dir><dir name="HarvestCaptureSKU"><file name="Observer.php" hash="428be8c5ac0c676ed4cf84cb3b94a35f"/></dir><dir name="HarvestCart"><file name="Observer.php" hash="63095a580cf0405685104d87cd4868ca"/></dir><dir name="HarvestCategory"><file name="Observer.php" hash="5983ae5a8a8a4d60594cfd081fa9541f"/></dir><dir name="HarvestCustomer"><file name="Observer.php" hash="b55ee79bb112671719e213abce02ecb5"/></dir><dir name="HarvestProduct"><file name="Observer.php" hash="2eb2c80e731d3142ef232bfd8a9035d4"/></dir><dir name="HarvestPurchase"><file name="Observer.php" hash="3310deefacb8d5d47f58bb7bdf3a2488"/></dir><dir name="HarvestRule"><file name="Observer.php" hash="c99b9c5a75f1a64ca050b5ef3a4eecfc"/></dir><dir name="HarvestSubscriber"><file name="Observer.php" hash="5e4ebcf718ff8ad9d12c9a2cb110c7d1"/></dir></dir><dir name="etc"><file name="config.xml" hash="2467d219cd2ad67e93f51f24d6adc68d"/></dir></dir><file name="Boss.php" hash="1bf233aaf41168f5a4c37f79e02d9635"/><dir name="Combine"><dir name="Helper"><file name="Attributes.php" hash="5fb06e7cc89bb710039a79fb16e2a998"/><file name="Cart.php" hash="07ce5f461ecded3b9b00ed5c30faa266"/><file name="Data.php" hash="a014e541ad0af82eede3dd5500c6aa4a"/><file name="Harvest.php" hash="1844c637796109da078feee668ba5c51"/><file name="Parser.php" hash="de4ae8ca9d83a371586fe1424f7edbcd"/><file name="Redirect.php" hash="3b81406f5105040d17699ad1e0d7cd5d"/><file name="Store.php" hash="8db94d157d7e497e7612844da43a6c11"/><file name="Trackable.php" hash="8bc28aa708be61d4d0d1f79b3ad51a78"/></dir><dir name="Model"><file name="Abstract.php" hash="77bc1e853f03ca6a12ddd1dda12feda2"/><file name="Api.php" hash="7dc599eb13f12ec51a99af1f5893790a"/><dir name="Cron"><file name="Count.php" hash="06824a092141baf29222607a2dcb3d9c"/><dir name="Manager"><file name="Status.php" hash="6cbb26b375c889049977a5ef41812a70"/></dir><dir name="Queue"><dir name="Batch"><file name="Row.php" hash="f703a1bf9e14ef428ade448febc9d35b"/></dir><file name="Batch.php" hash="ec4a31552a5f94a16478057637645dfb"/></dir><file name="Queue.php" hash="fa0d2bfd3fbb879442e0edd4ea7915a9"/><file name="Worker.php" hash="f83199c1491083b68eaea08467114d4f"/></dir><dir name="File"><file name="Io.php" hash="6d1f79eaf45897bf0525b0f3f3ac69d2"/><file name="Path.php" hash="24900b670c07fcdc4e54bae585f20002"/></dir><dir name="Harvest"><file name="Abstract.php" hash="0cdc8ab7db784c9d1a0d0524b68e2d0f"/><file name="AttributeSets.php" hash="2799ee325cd5bdcae597e482ef96551a"/><file name="Carts.php" hash="27e992f0f8cc4b274cd05efc7ce3a7f2"/><file name="Categories.php" hash="ab5bd7e91444fd7cb8bfeae376cd3ea7"/><file name="Coupons.php" hash="d168fba39963899e60a166d1eae2634c"/><file name="CustomerAttributeSets.php" hash="9be018cc3cbb0f495aec4f1c3a9013c8"/><file name="Customers.php" hash="f31427406c56f2dcde5a4f7d04a773c9"/><file name="Guests.php" hash="bcb1fbdfb7b5bf822934d300c423e17f"/><file name="Products.php" hash="2261f2c79b59e59977d050630d0fe92f"/><file name="Purchases.php" hash="585b1cf18e857850920abc7425830388"/><file name="Rules.php" hash="1614bc2a6b69f69acd3edc6fa09def7a"/><file name="Subscribers.php" hash="0c6f8ce380f036599141c9231562aaa9"/></dir><file name="Harvester.php" hash="0578a78bb29782d6fba8fcfb5bcc30ce"/><dir name="Mysql4"><dir name="Cron"><file name="Count.php" hash="acbbb7ec28afbbe98101f5d114cb30b3"/><dir name="Queue"><file name="Collection.php" hash="b26806c9e7cefd052bb784f5a6ce814c"/></dir><file name="Queue.php" hash="4add10644bfc94b88ef5042b23c82ae7"/></dir><dir name="Redirect"><file name="Collection.php" hash="3bbe4f8729c603f8d8131154a0a117c1"/><dir name="Order"><file name="Collection.php" hash="88c0cfcce31b0eed8c035dee4e7e86df"/></dir><file name="Order.php" hash="852bea330edac3372ec5c168111301a8"/></dir><file name="Redirect.php" hash="842e4ba35c6b049c8eaa64704588ca76"/><file name="Setup.php" hash="3fdec335980846a4c3adbc6f4e3478eb"/><dir name="Trackable"><file name="Collection.php" hash="8799c5bf630d267b551cf9dba986cbb0"/></dir><file name="Trackable.php" hash="b38749697b641874b42dceae38ab4a30"/></dir><dir name="Parser"><file name="Abstract.php" hash="bb7ed7476afbdd115876be43108aa149"/><file name="AttributeSet.php" hash="fcb90beeebb921b349b28cadf354786c"/><file name="Category.php" hash="352b6ed7328c94524f4a7c3042949295"/><file name="Coupon.php" hash="53b3d28470146b03e8be2f828dfa92f1"/><file name="Customer.php" hash="083edca18fbdf0c496e6ad22775f596e"/><file name="CustomerAttributeSet.php" hash="f926ec29d1ae837c0ae3c0a9257438d4"/><file name="Guest.php" hash="cbcbf7532c67c72d7e3b77022abc76c3"/><file name="Product.php" hash="2a0d3822877074b2258cd10f9d230cb1"/><dir name="Purchase"><file name="Item.php" hash="f997c74c97f79054ba22e342eab88928"/></dir><file name="Purchase.php" hash="4f161bc021af1851c92bb1c9c33a26ee"/><dir name="Quote"><file name="Item.php" hash="4763cfb492dc6d60575154d8624d256f"/></dir><file name="Quote.php" hash="63c0899564e14208042ac64e371ce71d"/><file name="Rule.php" hash="1069dc15f2c30ec462eb1af51aeceb85"/><file name="Subscriber.php" hash="7cce4dbb928983be6444ce5ef369ffb0"/></dir><file name="Parser.php" hash="72b273215802ee5244fd9e24c223beb8"/><dir name="Redirect"><file name="Order.php" hash="0c31dee69473751d95e5c52f5c60ea48"/></dir><file name="Redirect.php" hash="4abc597d06bd9fa223218ee19be66e0c"/><dir name="Resource"><file name="Abstract.php" hash="a50723654e084875378838b89ffb74ce"/><dir name="Cron"><dir name="Count"><file name="Collection.php" hash="c5cb4ab406c1d008c1bc22bb95b3ba28"/></dir><file name="Count.php" hash="6a356b5d92b509945c4567f479b9bfdd"/><dir name="Queue"><file name="Collection.php" hash="c182c6f6f7d29ee26ddf2900a8497cdb"/></dir><file name="Queue.php" hash="01d35c9491516f7f4ef7d9cccb7b6202"/></dir><dir name="Redirect"><file name="Collection.php" hash="0f9db83ade4c50c2f7bbe40deae1c065"/><dir name="Order"><file name="Collection.php" hash="162359ed9499b6f976f5c341fd0585c3"/></dir><file name="Order.php" hash="7ea4477380a5215dc0efe561ede359d9"/></dir><file name="Redirect.php" hash="d239af442388bb9fa80db81a7fc43711"/><file name="Setup.php" hash="46cc5ec83478021a1fe7251d73ee568e"/><dir name="Trackable"><file name="Collection.php" hash="6f060c3537b49710302e38e881885a69"/></dir><file name="Trackable.php" hash="764b0d21c492dd69b9f85ae3c647666e"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="LogFormat.php" hash="828680dafe5a7042221900cb6d9dfa17"/><file name="LogLevel.php" hash="b86c793ca04205f045efd9ea42d02a10"/><file name="Stability.php" hash="830e5bc4e8ce9657221224dbaf99cee6"/><file name="UrlType.php" hash="28f9a5bc024afe5526685d429a751ad8"/></dir></dir></dir><file name="Trackable.php" hash="710d298645c0a809a1b70b936b0e4d09"/></dir><dir name="etc"><file name="adminhtml.xml" hash="794fc8a1d67ac3e6b5d71c707a0c7cad"/><file name="config.xml" hash="a1bbfc56960608d27a758d8f2b78acd6"/><file name="system.xml" hash="12f0f05be054854c29751767a3c8ef97"/></dir><dir name="sql"><dir name="combine_setup"><file name="mysql4-install-1.0.0.70.php" hash="607957cf80927e2575e455074fea17ec"/><file name="mysql4-upgrade-1.0.0.70-1.0.0.84.php" hash="e51deaff9e65f43483ab00573605329d"/><file name="mysql4-upgrade-1.0.0.84-1.0.0.88.php" hash="89bd8a585c0d351aae6838ace48f608d"/><file name="mysql4-upgrade-1.0.0.88-1.2.0.0.php" hash="09f98d701b5030ccc27d9ca1503212c4"/><file name="mysql4-upgrade-1.2.0.0-1.2.0.1.php" hash="01a7ef2466b9f676884db4d7a7c562a9"/><file name="mysql4-upgrade-1.2.0.1-1.2.1.0.php" hash="ca68ef04700f892ae847aaf20155cb6a"/></dir></dir></dir><dir name="DataServices"><file name="HarvestingManager.php" hash="3e947c03730bfe37cbe14e4d5bffe9cf"/></dir><file name="Log.php" hash="742aa65d2a2eb1d9cb4b203b0141e2aa"/><dir name="Services"><file name="Abstract.php" hash="f779d8f0a1eaaa20364ccbf400c9e0ae"/><dir name="Cmd"><file name="Forecast.php" hash="3ac2b917db8c05ac085f213640b7be14"/><file name="Halt.php" hash="af1a47f7e9940c29b9c8380fbc69a447"/><file name="Harvest.php" hash="34eb715d51953451b4d082f0a141275c"/><file name="Healthcheck.php" hash="a51b3b7766afa1e6cca60fc3b206fb85"/><file name="Parse.php" hash="dbf89d3e1395511728063128703e3e97"/><file name="Update.php" hash="804da06229cc47eb850291847883c96d"/></dir><dir name="Harvest"><file name="AttributeSets.php" hash="c37c4c0642a06a27c6a28bee27e20b14"/><file name="Carts.php" hash="9496d5150a9b5e1282adb78d96f846fc"/><file name="Categories.php" hash="fc1b5b26d612d3232838c975c3e55646"/><file name="Coupons.php" hash="933ac544b0438b7b6e5c26f1d94b369a"/><file name="CustomerAttributeSets.php" hash="67368d6ba001310912d39df0bd9037ad"/><file name="Customers.php" hash="9ae9805bb89a7546ad7c126281ce5220"/><file name="Guests.php" hash="940bcfd10c656195953b77159a4ace10"/><file name="Products.php" hash="d249ec369bdaa38964906f9998d77d4b"/><file name="Purchases.php" hash="859c8af86ee44a896d94ac69decb851a"/><file name="Rules.php" hash="8da50acb7c2bfa0551dcc7727bb958d5"/><file name="Subscribers.php" hash="8fa28e316d7396ca79300813ea9bd7ca"/></dir><file name="Harvest.php" hash="1ed4efb9aa1f0ae30a3a4afb2cbf98f6"/><dir name="Log"><file name="Installer.php" hash="584f730627201a9e73f1d4101ad3fedd"/><file name="Purchase.php" hash="6060265974fe6b45768617f96ebba6b1"/></dir><dir name="Post"><file name="Attribute.php" hash="7e7a307180eb9b9cd7f5b9137e4bd647"/><file name="AttributeSet.php" hash="66968b3ea659253789bbf96ec828afcc"/><file name="Cart.php" hash="7465d7587762b82ffaefef6f27b40a58"/><file name="Category.php" hash="68be39b090f46f3f438ad2ed9f97f09f"/><file name="Coupon.php" hash="1c5484e6f2fd1d68e4a25a429f74376b"/><file name="Customer.php" hash="ecce6d30d3458e0786d4c6335a4c02cc"/><file name="Json.php" hash="86a5f26aa5367d8c4c66d278e4c02546"/><file name="Jsonstring.php" hash="9dfb5761d1a7835bf35040a073fa8fc4"/><file name="Product.php" hash="787e33146cc39d5f5eecd2d3a4ea842b"/><file name="Purchase.php" hash="80480bf01d11b1068d481c6ed50c2e1f"/><file name="Rule.php" hash="24c4c0bea020dbb3a4ff5420888d1f22"/><file name="Subscriber.php" hash="4d18235c4c0d11a8650b3e60c098908f"/></dir><file name="Post.php" hash="df362d5839aa050daa7b23660603b16d"/><file name="Priority.php" hash="d8fc0b57442d8e2e2ff7ba789c3d1fc9"/><file name="Registry.php" hash="c4f17c52b0814c29b7ab93e911a2de28"/><dir name="Store"><file name="Finalize.php" hash="6f61c4cd23ef3cd815b7eee545ecaa23"/><file name="Register.php" hash="523100a10a3ac39fa444801551bdbf25"/></dir><dir name="Update"><file name="Abstract.php" hash="7b9a1d36b4486e250587820731b7fb7c"/><file name="Connect.php" hash="3e4366a42e563ec3406a0fcb9a5f77bf"/><file name="Downloader.php" hash="934ef5788acb45ce94e0a32c1d705df1"/><file name="Installer.php" hash="a09ec2e9f7bbf12c117c8950e46072b0"/><file name="Package.php" hash="b025fa1c27aed03454e7d45d09705b3a"/></dir><dir name="Work"><file name="Cleanup.php" hash="d0915a0cde6d9cd4287a2f9fc4bc0056"/><file name="Manager.php" hash="d455384f9e9c14e2c4be2eb49677d372"/><file name="Report.php" hash="688df023f8e1518d15e297b030618254"/><file name="Restart.php" hash="43af836b8950852efe62996facf4ad87"/><file name="Runner.php" hash="a2929a0e03dc99ac0ad5702b623eeb56"/><file name="Stop.php" hash="5e51ecf333282ad5d8dd6d40243c5e8e"/></dir></dir><dir name="Shadow"><dir name="Block"><dir name="Js"><file name="Boot.php" hash="3dec841c75ca7d3605681080aa19798b"/></dir></dir><dir name="Helper"><file name="Listeners.php" hash="432794c308714015009014a2620fca16"/></dir><dir name="Model"><dir name="Listeners"><file name="Observer.php" hash="3326cfb14a374c039f639bd74947c4fb"/></dir><file name="Timer.php" hash="bfdaef5388bfc7faf48544c18cee6854"/></dir><dir name="controllers"><file name="IndexController.php" hash="7740556a1a409412075fd3d1ce3514c5"/></dir><dir name="etc"><file name="config.xml" hash="6f8002880ac72e062ff1a22ddcc346ee"/></dir></dir><dir name="Util"><file name="Caller.php" hash="7674f6d3f6d0fc5e238c7e31e0516c52"/><file name="Categories.php" hash="1292843306c38d9593902616e04320a6"/><dir name="Log"><file name="Rollover.php" hash="47ecb75b56743147d77b33219ac657ac"/></dir><file name="Logger.php" hash="59abca8cb07ef933ca8ef2ac824591b5"/><file name="Partition.php" hash="b9296b086003ba58ba12f8b8b0373c50"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bmbleb.xml" hash="aa390e236576f79375b407262961043e"/></dir><dir name="template"><dir name="bmbleb"><file name="auth.phtml" hash="2fc86d90ab53799e7309d3f88afff077"/><file name="dashboard_loggedout.phtml" hash="19281143b19a544d4e3072dc754ada2d"/><dir name="help"><file name="index.phtml" hash="e9d3f11c623c735c3e699e406ff9e0e7"/></dir><dir name="index"><file name="messages.phtml" hash="fcbbb47d2cc30c493ed2316a8b888f5d"/><file name="terms.phtml" hash="dfff1182d2fe7d8eee69b9b302c4cbc7"/></dir><file name="index.phtml" hash="86ad04e7c0f91dad8e2a08a3f5d70b64"/><dir name="jobs"><file name="status.phtml" hash="77f0b0ae7c3c6c42031675cfc959e270"/></dir><file name="jobs.phtml" hash="961ac83f56bf8703dbc433894da4933e"/><file name="login.phtml" hash="0a1a20dfaffe8646bb56323ab811d46a"/><file name="logout.phtml" hash="09b92790c5e124a01086d6929ed7e8de"/><dir name="logs"><file name="index.phtml" hash="17e773a761a24e292b09fe7da1bd7662"/></dir><file name="notifications.phtml" hash="45f8767a090a4f7a7e177151bbc43f4f"/><dir name="problems"><file name="index.phtml" hash="2027d07eed8848a4ed8e801d67072796"/></dir><file name="status.phtml" hash="4c6d8cd43e39184f35c715b785c8595a"/><file name="tabs.phtml" hash="778b686fb073a8aeb973db3bfb0302aa"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shadow.xml" hash="da2d548a83dc754a94d36714b28d269b"/></dir><dir name="template"><dir name="shadow"><file name="conversion.phtml" hash="3d46a8930d9658a24a77ff34d52e40eb"/><file name="emailupdate.phtml" hash="99914b932bd37a50b983c5e7c90ae93b"/><dir><dir name="js"><file name="boot.phtml" hash="af147801ed74d45bb0580b0bb69ce0fd"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="shell"><file name="springbot.php" hash="4de4684c57c242cbcb661cd6bc98844a"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="bmbleb"><file name="bmbleb.css" hash="8aea7d5d46e2a0d0ece11abca6ef5d3f"/><dir name="images"><file name="arrows_up-down-large.png" hash="72c27995e1ab1d182891dad0a4d1dae2"/><file name="bmb-ctl.png" hash="de59a694a82b8699560df5146b2e315f"/><file name="check.png" hash="126f33ed483549e79a16186b7499c190"/><file name="grn-bg.png" hash="f681a524e2b4561dbe94152a2d24d60b"/><file name="h3-bg.png" hash="b93df0b0bdba8e8f6e0a07cc31fcc180"/><file name="icon-alert.png" hash="ac2e70efdcebc3813222d0d3ee62a6d9"/><file name="icon-bmbleb.png" hash="fb5574b5e63ee33b84eee26b3d8ef8e3"/><file name="icon-insights.png" hash="725fd29fe1b705e358c9080408693d3d"/><file name="icon-status.png" hash="bd13429f23166a6d431739010ea1b2cd"/><file name="left-ico1.png" hash="7d188f5e6021569750756f58067f0a3b"/><file name="left-ico2.png" hash="d2f6379a73290a8ffa4cb3e19a809d25"/><file name="left-ico3.png" hash="73bc75f7a746e54a75f14eda7a28a6b9"/><file name="left-ico4.png" hash="1da2c26187fed26b6c61599682b2dc4b"/><file name="left-ico5.png" hash="ada61cb32805f2cb8e8dace46361613e"/><file name="left-ico6.png" hash="1e62822267f72589ffa0771352a002da"/><file name="left-ico7.png" hash="16118412d581f0c83ce45c44f62f25a1"/><file name="left-ico8.png" hash="c7de2fe523c892b432b575648cc05631"/><file name="left-ico_demographics.png" hash="3fe23a2dea68f6c65114f248a8bdaa5e"/><file name="login-icn-b.png" hash="64e72070f595e215ece79736ac77ee2f"/><file name="login-icn.png" hash="6142cc2fc8ee2d1c40bf3c8f9ac1fa85"/><file name="logo.png" hash="8fb783f7d68fca3914123f56b8c066a4"/><file name="orng-bg.png" hash="074a6912ca2a139df537e3d15b6bc9b2"/><file name="plugin_dashboard_syncing.jpg" hash="8511648541f6f1b96ff1c53dda3a439b"/><file name="register.png" hash="f73fe51cf7df27ab11089385fa50714e"/><file name="registration-bg-25.png" hash="9d2cf77619cc8fce3ae4d44b0aae30c1"/><file name="registration-bg-50.png" hash="99942fdc8c3f88b0d4b09f87c9e39045"/><file name="registration-bg.png" hash="96365b39495e56ffe491dd9930fe221d"/><file name="spinner.gif" hash="add667817f25bce331a213ab3cc9621f"/><file name="springbot-ctl.png" hash="de59a694a82b8699560df5146b2e315f"/><file name="submit-btn-bg.png" hash="d98aa287b7b73dad9f780b22cb53fbdb"/><file name="sync_icon.png" hash="cb12f2e8943c8e324e3456375f953c86"/><file name="white-check.png" hash="126f33ed483549e79a16186b7499c190"/></dir></dir></dir></dir></dir></target></contents>
 
55
  <compatible/>
56
- <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
57
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Springbot</name>
4
+ <version>1.4.0.1</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/OSL-3.0">Open Software License v3.0 (OSL-3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Springbot helps merchants drive marketing actions based on insights from its &#x201C;big data&#x201D; analytics engine</summary>
10
  <description>Springbot - Better Data. Better Actions. More Revenue.&#xD;
11
+ &#xD;
12
+ Do you need help deciding how to spend your next marketing dollar? Springbot can help. &#xD;
13
+ &#xD;
14
+ Know your customers better. &#xD;
15
+ Take better marketing actions. &#xD;
16
+ Drive more revenue. &#xD;
17
+ &#xD;
18
+ Springbot helps Magento merchants drive marketing actions based on insights from its &#x201C;big data&#x201D; analytics engine. &#xD;
19
+ - Analyze and augment consumer data and purchase behavior &#xD;
20
+ - Integrate online marketing channels, content and marketplaces &#xD;
21
+ - Prioritize future marketing actions based on the potential ROI &#xD;
22
+ &#xD;
23
+ Get to Know your Customers&#xD;
24
+ &#xD;
25
+ Springbot works magic by adding hard-to-find social and demographic data about your customers directly into Magento.&#xD;
26
+ &#xD;
27
+ age, gender, geo - gain an intuitive sense of your real market dynamics &#xD;
28
+ social media data - facebook, twitter, linkedin... find your customers online without googling all of them! &#xD;
29
+ home owner data - renting vs. owning and home value can drive purchase behavior &#xD;
30
+ &#xD;
31
+ plus employment data, income data and much more! &#xD;
32
+ &#xD;
33
+ Get Started Now with a Limited Time Free Data Offer&#xD;
34
+ &#xD;
35
+ It's completely free to sign up. We'll give you augmented data for up to 1000 of your customers so that you can experience the power of our awesome data service.&#xD;
36
+ &#xD;
37
+ Deep Magento Integration&#xD;
38
+ &#xD;
39
+ You have enough screens, graphs and forms to run your store. bmbleb enhances those screens... it doesn't replace them. Your extra customer data appears in your normal Magento customer screens. You can sort and search using it. And when you do want to dig deeper... Springbot has screens for you!&#xD;
40
+ &#xD;
41
+ Powerful Living Data Alerts&#xD;
42
+ &#xD;
43
+ Data isn't static. It changes constantly as we go about our lives. While you're busy watching over your store, Springbot watches over your data and alerts you to sales, marketing and relationship opportunities. Living Data Alerts tell you when your customers are ready to buy. Social media monitors tell you when customers are tweeting about topics relevant to your store.&#xD;
44
+ &#xD;
45
+ Living Data Alerts example: 378 pieces of data have been added to your customer database &#xD;
46
+ Social Media Alerts example: Ted Smith Tweeted about your company &#xD;
47
+ Proclivity to Buy Alerts example: Sally Avalon bought a house recently &#xD;
48
+ &#xD;
49
+ For support information, features and pricing and more details visit springbot.com </description>
50
+ <notes>Enhanced product action logging&#xD;
51
+ Prattler support</notes>
52
+ <authors><author><name>Springbot Integrations Team</name><user>Springbot</user><email>magento@springbot.com</email></author></authors>
53
+ <date>2014-12-02</date>
54
+ <time>22:14:02</time>
55
+ <contents><target name="magecommunity"><dir name="Springbot"><dir name="Shadow"><dir name="Block"><dir name="Action"><file name="View.php" hash="498947c2762fba3382bdd9b5bf3fb607"/></dir><file name="Async.php" hash="0d203fe1a722f7045029613a0e97bfc2"/></dir><dir name="Controller"><file name="Action.php" hash="5dc41d4ddf12a468fb23fc757ef49a95"/></dir><dir name="Helper"><file name="Data.php" hash="82089d4cfecee69628ae9d627ad2de0c"/><file name="Prattler.php" hash="73a32436616e23c8136a3c22ffe9713f"/></dir><dir name="Model"><dir name="Listeners"><file name="Observer.php" hash="e5b827a61c3b04fdb73e38a424d167eb"/></dir></dir><dir name="controllers"><file name="ActionController.php" hash="2532947b3368c5a4d64bf77cc7aa9316"/><file name="IndexController.php" hash="6f308dd9d8f2c62b8dc3906dff451dca"/></dir><dir name="etc"><file name="config.xml" hash="b1717e37375197b449c0736adff99d87"/></dir></dir><dir name="Services"><dir name="Cmd"><file name="Forecast.php" hash="efaeb6ca5b2667b30929b223cddfb044"/><file name="Halt.php" hash="85c85ae257e9b86d0fb10fb46060fea3"/><file name="Harvest.php" hash="83c74d0736f17475574d1ef3064443fe"/><file name="Healthcheck.php" hash="9505292b6ebcc467976af8d01ddbf2c3"/><file name="Update.php" hash="ecc55c4b1d3e7bb0a275727bcb7f904d"/></dir><dir name="Harvest"><file name="AttributeSets.php" hash="95610f6fd6323e0473589c01051781f2"/><file name="Carts.php" hash="ecaf8583962fc63e49cf069d73eb22bf"/><file name="Categories.php" hash="86bb52f1930657e195215f92018c7a1e"/><file name="Coupons.php" hash="4692e989f73e5a285c869c60fa5ac501"/><file name="CustomerAttributeSets.php" hash="7c3a0bed9f841900f692f5a17e7c6e8f"/><file name="Customers.php" hash="4e79c1ba937a3a9f67ff5b19893dfd39"/><file name="Guests.php" hash="e0f6d955ba9bc3f020cc95f3083913ad"/><file name="Products.php" hash="087d01eddc45b4a30c4aa7dba5cc5dce"/><file name="Purchases.php" hash="157d748193623edae627b64644500df9"/><file name="Rules.php" hash="355ecad7266987a391ceca9d2eb0244f"/><file name="Subscribers.php" hash="adcba840c9b1fd40caa05f317320d458"/></dir><file name="Harvest.php" hash="af3b9604c7b9d7da76cffe846dc34d70"/><dir name="Log"><file name="Installer.php" hash="342706712eb2731ea27aeec993fd2d7f"/></dir><dir name="Post"><file name="Attribute.php" hash="e0a283984de84bc16d5f89a893a8dc83"/><file name="AttributeSet.php" hash="c8f66b5a189125a63e834196402b709a"/><file name="Cart.php" hash="26d33fb887417e46d3ba3e46badc04a3"/><file name="Category.php" hash="0645d5eb9bb790f25e29666bc3a703e0"/><file name="Coupon.php" hash="6b8b49327874ce431f6100b6917ba21f"/><file name="Customer.php" hash="d2f018919afdb7d49617e6b9ac7d2760"/><file name="Guest.php" hash="3b7ee9f0e274340713d8c4302d01b361"/><file name="Json.php" hash="86a5f26aa5367d8c4c66d278e4c02546"/><file name="Jsonstring.php" hash="9dfb5761d1a7835bf35040a073fa8fc4"/><file name="Product.php" hash="5ec9cbf29df156da09d17e1b6526f53d"/><file name="Purchase.php" hash="0b924c8e5d8f7018eb335ba9fb6d63dd"/><file name="Rule.php" hash="fa038fa414a176d960ed6470c7b7b4cd"/><file name="Subscriber.php" hash="88c5dbcaae805866595217eedbbf5f34"/></dir><file name="Post.php" hash="df9bf80bee670259f3a54e3308d0dbd3"/><file name="Registry.php" hash="c4f17c52b0814c29b7ab93e911a2de28"/><dir name="Store"><file name="Finalize.php" hash="e3636b532bc8f55ba0e618a973e2faa0"/><file name="Register.php" hash="72ae8d75c11dc1c0635c799e284ecb2d"/></dir><dir name="Tasks"><file name="DeliverEventLog.php" hash="d4448212c228d74a320b541385162b10"/><file name="Forecast.php" hash="9cb195b603f843cf2eac74530aa6c84b"/><file name="GetLog.php" hash="8e663a1dbd2dd87a7bfb65b8e8bc2b4a"/><file name="KillHarvest.php" hash="55c540031b57c0a38d83b99e72865bca"/><file name="LaunchFullHarvest.php" hash="b2a9d9c75a46b8c9c4889ddf02094921"/><file name="LaunchPartialHarvest.php" hash="c1ca1f8ebec4c7ed38eb4cebfc865aaa"/><file name="PackageUpdate.php" hash="d6e74ff5b2ec7e1abb4a75551c92b36b"/><file name="PostItem.php" hash="58c51f04b3e6d297b33fdf15baf2e8f1"/><file name="ResumeHarvest.php" hash="4cd58b8cb691267b4c1366ea3da47673"/><file name="SetVar.php" hash="5b4bea2e94b4bea05bbf326ee3e74fab"/><file name="SkipStoreHarvest.php" hash="1919b0dba7e20c6ff0e3fc302cc2f172"/></dir><dir name="Update"><file name="Abstract.php" hash="7b9a1d36b4486e250587820731b7fb7c"/><file name="Connect.php" hash="3e4366a42e563ec3406a0fcb9a5f77bf"/><file name="Downloader.php" hash="934ef5788acb45ce94e0a32c1d705df1"/><file name="Installer.php" hash="a09ec2e9f7bbf12c117c8950e46072b0"/><file name="Package.php" hash="60ec01b28a2ded244bf6d4a971918bd5"/></dir><dir name="Work"><file name="Cleanup.php" hash="100fef130220e91dc255b5e0f30c37f1"/><file name="Manager.php" hash="9dbdfb717865b7724f4ffd38b3ec866e"/><file name="Report.php" hash="a6482e618e657688ab85221576d1898f"/><file name="Restart.php" hash="d55e811fbba86348890b4047fa5a579f"/><file name="Runner.php" hash="c0ced9ce83e5e51b4ba5f10bb46760af"/><file name="Stop.php" hash="db97407b43396f0adf44a2354a23a0a5"/></dir></dir><dir name="Util"><file name="Cache.php" hash="2c6eb2ee4ee723758fc92989e9220f6e"/><file name="Caller.php" hash="4fcc265eb1a58fed5c3b404ec864514b"/><file name="Categories.php" hash="1292843306c38d9593902616e04320a6"/><dir name="Log"><file name="Rollover.php" hash="6ad4bd93adb7e906c1de5a05a2871ea8"/></dir><file name="Logger.php" hash="59abca8cb07ef933ca8ef2ac824591b5"/><file name="Partition.php" hash="b9296b086003ba58ba12f8b8b0373c50"/><file name="Timer.php" hash="fe07f62aee3239ad7f9df1e652fd5a1c"/></dir><file name="Services.php" hash="4a50a43def6f03351bd9128ccda0e9cd"/><dir name="Bmbleb"><dir name="Block"><dir name="Adminhtml"><file name="Auth.php" hash="7dc661bbe9ec85f700a22b319981114d"/><dir name="Bmbleb"><dir name="Login"><file name="Form.php" hash="6d54c1272c7e0a37f3dfe7a23b97a451"/></dir><file name="Login.php" hash="7232e8225f5b21de5675c0d84cb452bd"/></dir><file name="Connected.php" hash="833cef8e351f5efa7a4d104b1c51ca7f"/><file name="Help.php" hash="b280b3292ed778140b751b6426ef56fb"/><dir name="Index"><file name="Messages.php" hash="1e247e31194447de32e54f49dafc3ccc"/><file name="Terms.php" hash="739e5a9ebe204f1f9ac433557c994ae6"/></dir><file name="Index.php" hash="eb7bbef5fa26a53748596e145c3677c4"/><dir name="Jobs"><file name="Grid.php" hash="67255d982ac3d50b38d7a2a525c2b922"/><file name="Status.php" hash="f1b197bf6fdc392bed93ff0734a54ad6"/></dir><file name="Jobs.php" hash="84801c6008802496e168e763a7e6d71f"/><file name="Login.php" hash="2e4d8baead482d404ed40f7d5f3d902c"/><file name="Logout.php" hash="b75af51891b751b9d070e1e784dd6914"/><file name="Logs.php" hash="686e958b553c1e3fcf74841eab30fffb"/><file name="Notifications.php" hash="b9e103d6c255078274c2f3047d944d0e"/><file name="Problems.php" hash="c2fd654e2c4c3a6dd9fbb083d0995e5e"/><file name="Status.php" hash="9b67a20f0ee00608029d24850cefda4d"/><file name="Tabs.php" hash="6f93d5c6bd5208a99637c06118c6c630"/></dir></dir><dir name="Helper"><file name="Account.php" hash="c41f40e6f58abd3b8486e0e92cc079d8"/><file name="Data.php" hash="dca14b137de1e2734a377ca645eeddbe"/><file name="PluginStatus.php" hash="09f2585984aee574ebfe75fd5b86a583"/></dir><dir name="Model"><file name="Bmbleb.php" hash="700d11c3006f2dcd2e80cd8bbbab15f9"/><file name="Status.php" hash="9409d26c7884be6b8075ba97dbf71f78"/><file name="Sync.php" hash="a800b6064a88f37957392cd967f2b3cb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="HelpController.php" hash="087e7868dafe9dd2df89a642d405424a"/><file name="IndexController.php" hash="61a95eed027fcb7a7179485288f1b05f"/><file name="JobsController.php" hash="4e912a8fafd2f58235cb2299a83a128b"/><file name="LogsController.php" hash="20a0ce2f584f08480399b7a5ecbd9207"/><file name="ProblemsController.php" hash="9753f4b2d3e7d4873e4bd92b5b2b6aaf"/><file name="SettingsController.php" hash="f75a7a8ef28a296cbd46b04ae9dd5539"/></dir><file name="HelpController.php" hash="2df4608a957f151bf1d01dbde2113680"/><file name="IndexController.php" hash="ea5fa5e2b305f46b222cb2fc2a44f6a5"/><file name="LoginController.php" hash="41a0c13dce233a613f89b614cffa0eb1"/><file name="LogoutController.php" hash="140c9d32f5557aa1169fd1b85cd5cc9f"/></dir><dir name="etc"><file name="config.xml" hash="45f7218274a3eed0086761942a95f27b"/></dir></dir><file name="Boss.php" hash="62fd9b5667559a6530f649988e4ced13"/><file name="Cli.php" hash="84e3d0391b70498f15ef357677f56b2b"/><file name="Log.php" hash="5ab61d7cf21805adb8f826f83b9bf7b1"/><dir name="Combine"><dir name="Helper"><file name="Attributes.php" hash="5fb06e7cc89bb710039a79fb16e2a998"/><file name="Cart.php" hash="07ce5f461ecded3b9b00ed5c30faa266"/><file name="Data.php" hash="bba3915380a71aaacacc306f10396ef1"/><file name="Harvest.php" hash="fe1a09f2c51db4ce83f46b3fef909f14"/><file name="Parser.php" hash="072584a751b067cf981f8430be076294"/><file name="Redirect.php" hash="92053fb1b356fdd6b3131be0b6a8017c"/><file name="Store.php" hash="8db94d157d7e497e7612844da43a6c11"/><file name="Trackable.php" hash="a042cb0d176730ec87353b1c5c6d21f7"/></dir><dir name="Model"><file name="Action.php" hash="6375461263bdf7fe26e71235d2449c21"/><file name="Api.php" hash="978590ad36b4d6ad6b3a14742f8bb31c"/><dir name="Cron"><file name="Count.php" hash="57552740b6ffdd9a4e879191a51043b0"/><dir name="Manager"><file name="Status.php" hash="aeb4445bc2d4b1b7e0e19c09172f0483"/></dir><dir name="Queue"><dir name="Batch"><file name="Row.php" hash="87e03af3c5d80ddf84df3843bcc8a3b7"/></dir><file name="Batch.php" hash="70b58e8a9a3e604a43c95ce6c2f21232"/></dir><file name="Queue.php" hash="44dc400302dcfd7fe11a7d1dddbd07f0"/><file name="Worker.php" hash="8b5040f1c5c5b3221542e739dc951de7"/></dir><file name="Cron.php" hash="40f2bc9634610f4ed5464de48630ce16"/><dir name="File"><file name="Io.php" hash="6d1f79eaf45897bf0525b0f3f3ac69d2"/><file name="Path.php" hash="24900b670c07fcdc4e54bae585f20002"/></dir><dir name="Harvest"><file name="AttributeSets.php" hash="f96517c3c4aa0d01083253d58214152e"/><file name="Carts.php" hash="0b303b2b7d4458a9a0cbf0653b9d660f"/><file name="Categories.php" hash="fd5f13ad449a320616569f64c82327ff"/><file name="Coupons.php" hash="14112f9063bbf20cea7ff3649f238524"/><file name="CustomerAttributeSets.php" hash="bd763562f3fcdf199c2e93876d238fa9"/><file name="Customers.php" hash="c7850418a39abf09c10fbfafcb96f8e1"/><file name="Guests.php" hash="3685b3220b724e518dc83daad015577f"/><file name="Products.php" hash="da471abcc04837391b5270464164aefd"/><file name="Purchases.php" hash="427d38d1f6579f63730aa6bdf6b7bba4"/><file name="Rules.php" hash="fd1789174225c4ed6ad1e1137fe2aee5"/><file name="Subscribers.php" hash="e499e299612a6e2ce07ee19228cf43c5"/></dir><file name="Harvest.php" hash="8104fb4584411f90706f2fd9c8d8ce9b"/><dir name="Mysql4"><dir name="Action"><file name="Collection.php" hash="830a7db2ea307d594fe945701654d883"/></dir><file name="Action.php" hash="5b18cc8842c83d981575b7b2de496f66"/><dir name="Cron"><file name="Count.php" hash="acbbb7ec28afbbe98101f5d114cb30b3"/><dir name="Queue"><file name="Collection.php" hash="b26806c9e7cefd052bb784f5a6ce814c"/></dir><file name="Queue.php" hash="4add10644bfc94b88ef5042b23c82ae7"/></dir><dir name="Redirect"><file name="Collection.php" hash="3bbe4f8729c603f8d8131154a0a117c1"/><dir name="Order"><file name="Collection.php" hash="88c0cfcce31b0eed8c035dee4e7e86df"/></dir><file name="Order.php" hash="852bea330edac3372ec5c168111301a8"/></dir><file name="Redirect.php" hash="842e4ba35c6b049c8eaa64704588ca76"/><file name="Setup.php" hash="3fdec335980846a4c3adbc6f4e3478eb"/><dir name="Trackable"><file name="Collection.php" hash="8799c5bf630d267b551cf9dba986cbb0"/></dir><file name="Trackable.php" hash="b38749697b641874b42dceae38ab4a30"/></dir><dir name="Parser"><file name="AttributeSet.php" hash="9ae4013d42da5de0e9c8492fb29cd8d6"/><file name="Category.php" hash="0c3c71ff784307b9120d7cf781005069"/><file name="Coupon.php" hash="a66b3d4c8397610863cd74e35cbd5b62"/><file name="Customer.php" hash="4e4b3cf2a33e759a70d36d9fdad6737d"/><file name="CustomerAttributeSet.php" hash="1b51f9300a9ee102872ff9d7f9bbccbc"/><file name="Guest.php" hash="002c900d3722f761e3e3ac63be84014f"/><file name="Product.php" hash="7e0fa4a55ca45fc876e588442cce72eb"/><dir name="Purchase"><file name="Item.php" hash="ca7facc8c81504ea990fdb1feeba64dd"/></dir><file name="Purchase.php" hash="6b9882d860338fc2dd17aaf73995fbc3"/><dir name="Quote"><file name="Item.php" hash="37cbc74a49a16e67e02f421978e1741f"/></dir><file name="Quote.php" hash="df651461575cb44bd08f7eb8466782eb"/><file name="Rule.php" hash="0a0f70172aeff0e5157f2f1652c3ae09"/><file name="Subscriber.php" hash="57ab5db177d4a37f30865cb127912631"/></dir><file name="Parser.php" hash="c6ae117f4671a6f9e6f9107236fdfee8"/><dir name="Redirect"><file name="Order.php" hash="5ca85ca596ef6e45468c8a12cee72614"/></dir><file name="Redirect.php" hash="05dddaa1e9c17c4c79d70d63b56ed454"/><dir name="Resource"><file name="Abstract.php" hash="5e58e98d53c3d49e454d6b0bd2f308c2"/><dir name="Action"><file name="Collection.php" hash="22e278b8cbc5d18d4faa48c4f224d145"/></dir><file name="Action.php" hash="901395757d3b278c0aa04cfd989eca42"/><dir name="Cron"><dir name="Count"><file name="Collection.php" hash="c5cb4ab406c1d008c1bc22bb95b3ba28"/></dir><file name="Count.php" hash="6a356b5d92b509945c4567f479b9bfdd"/><dir name="Queue"><file name="Collection.php" hash="2f4caa8ba890db605f97d21bd31b74c8"/></dir><file name="Queue.php" hash="5e9b36137eb9e53a4dbf40f7e8ad01b6"/></dir><dir name="Redirect"><file name="Collection.php" hash="0f9db83ade4c50c2f7bbe40deae1c065"/><dir name="Order"><file name="Collection.php" hash="162359ed9499b6f976f5c341fd0585c3"/></dir><file name="Order.php" hash="7ea4477380a5215dc0efe561ede359d9"/></dir><file name="Redirect.php" hash="d239af442388bb9fa80db81a7fc43711"/><file name="Setup.php" hash="0405c44c124f19619ccc9f429d781d44"/><dir name="Trackable"><file name="Collection.php" hash="6f060c3537b49710302e38e881885a69"/></dir><file name="Trackable.php" hash="764b0d21c492dd69b9f85ae3c647666e"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="LogFormat.php" hash="828680dafe5a7042221900cb6d9dfa17"/><file name="LogLevel.php" hash="b86c793ca04205f045efd9ea42d02a10"/><file name="Stability.php" hash="830e5bc4e8ce9657221224dbaf99cee6"/><file name="UrlType.php" hash="28f9a5bc024afe5526685d429a751ad8"/></dir></dir></dir><file name="Trackable.php" hash="0af2cd1e6e1eb948157918df2570bf10"/></dir><dir name="etc"><file name="adminhtml.xml" hash="794fc8a1d67ac3e6b5d71c707a0c7cad"/><file name="config.xml" hash="b90013f783bd3265a03f689acb4c908a"/><file name="system.xml" hash="887d99c8efe22f532aa7f8d1bc93fe17"/></dir><dir name="sql"><dir name="combine_setup"><file name="mysql4-install-1.0.0.70.php" hash="425be4a54012cd64753ee1a216255d67"/><file name="mysql4-upgrade-1.0.0.70-1.0.0.84.php" hash="e51deaff9e65f43483ab00573605329d"/><file name="mysql4-upgrade-1.0.0.84-1.0.0.88.php" hash="89bd8a585c0d351aae6838ace48f608d"/><file name="mysql4-upgrade-1.0.0.88-1.2.0.0.php" hash="4779a5072d23ebdb27177de0dfd19f5d"/><file name="mysql4-upgrade-1.2.0.0-1.2.0.1.php" hash="01a7ef2466b9f676884db4d7a7c562a9"/><file name="mysql4-upgrade-1.2.0.1-1.2.1.0.php" hash="dbba441ac757db26289f21443a948f6b"/><file name="mysql4-upgrade-1.3.9.9-1.4.0.0.php" hash="de0b3996e28572fc3dbc7c12cb12ee1a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Springbot.xml" hash="69a4e2c056502cd8539b4f66a2c8b1bc"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bmbleb.xml" hash="aa390e236576f79375b407262961043e"/></dir><dir name="template"><dir name="bmbleb"><file name="auth.phtml" hash="bf509b53c49cd69ec3ea60e3effe69c3"/><file name="dashboard_loggedout.phtml" hash="19281143b19a544d4e3072dc754ada2d"/><dir name="help"><file name="index.phtml" hash="e9d3f11c623c735c3e699e406ff9e0e7"/></dir><dir name="index"><file name="messages.phtml" hash="fcbbb47d2cc30c493ed2316a8b888f5d"/><file name="terms.phtml" hash="dfff1182d2fe7d8eee69b9b302c4cbc7"/></dir><file name="index.phtml" hash="a5132e593910b8b59a3467b555d4ed87"/><dir name="jobs"><file name="status.phtml" hash="77f0b0ae7c3c6c42031675cfc959e270"/></dir><file name="jobs.phtml" hash="961ac83f56bf8703dbc433894da4933e"/><file name="login.phtml" hash="0a1a20dfaffe8646bb56323ab811d46a"/><file name="logout.phtml" hash="09b92790c5e124a01086d6929ed7e8de"/><dir name="logs"><file name="index.phtml" hash="17e773a761a24e292b09fe7da1bd7662"/></dir><file name="notifications.phtml" hash="45f8767a090a4f7a7e177151bbc43f4f"/><dir name="problems"><file name="index.phtml" hash="2027d07eed8848a4ed8e801d67072796"/></dir><file name="status.phtml" hash="1acc630a6549b234bc1fa5923e04b8ce"/><file name="tabs.phtml" hash="778b686fb073a8aeb973db3bfb0302aa"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shadow.xml" hash="3f29bebbcf7e42c57dcac9150c6b7d68"/></dir><dir name="template"><dir name="shadow"><file name="async.phtml" hash="af147801ed74d45bb0580b0bb69ce0fd"/><file name="conversion.phtml" hash="3d46a8930d9658a24a77ff34d52e40eb"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="bmbleb"><file name="bmbleb.css" hash="8aea7d5d46e2a0d0ece11abca6ef5d3f"/><dir name="images"><file name="arrows_up-down-large.png" hash="72c27995e1ab1d182891dad0a4d1dae2"/><file name="bmb-ctl.png" hash="de59a694a82b8699560df5146b2e315f"/><file name="check.png" hash="126f33ed483549e79a16186b7499c190"/><file name="grn-bg.png" hash="f681a524e2b4561dbe94152a2d24d60b"/><file name="h3-bg.png" hash="b93df0b0bdba8e8f6e0a07cc31fcc180"/><file name="icon-alert.png" hash="ac2e70efdcebc3813222d0d3ee62a6d9"/><file name="icon-bmbleb.png" hash="fb5574b5e63ee33b84eee26b3d8ef8e3"/><file name="icon-insights.png" hash="725fd29fe1b705e358c9080408693d3d"/><file name="icon-status.png" hash="bd13429f23166a6d431739010ea1b2cd"/><file name="left-ico1.png" hash="7d188f5e6021569750756f58067f0a3b"/><file name="left-ico2.png" hash="d2f6379a73290a8ffa4cb3e19a809d25"/><file name="left-ico3.png" hash="73bc75f7a746e54a75f14eda7a28a6b9"/><file name="left-ico4.png" hash="1da2c26187fed26b6c61599682b2dc4b"/><file name="left-ico5.png" hash="ada61cb32805f2cb8e8dace46361613e"/><file name="left-ico6.png" hash="1e62822267f72589ffa0771352a002da"/><file name="left-ico7.png" hash="16118412d581f0c83ce45c44f62f25a1"/><file name="left-ico8.png" hash="c7de2fe523c892b432b575648cc05631"/><file name="left-ico_demographics.png" hash="3fe23a2dea68f6c65114f248a8bdaa5e"/><file name="login-icn-b.png" hash="64e72070f595e215ece79736ac77ee2f"/><file name="login-icn.png" hash="6142cc2fc8ee2d1c40bf3c8f9ac1fa85"/><file name="logo.png" hash="8fb783f7d68fca3914123f56b8c066a4"/><file name="orng-bg.png" hash="074a6912ca2a139df537e3d15b6bc9b2"/><file name="plugin_dashboard_syncing.jpg" hash="8511648541f6f1b96ff1c53dda3a439b"/><file name="register.png" hash="f73fe51cf7df27ab11089385fa50714e"/><file name="registration-bg-25.png" hash="9d2cf77619cc8fce3ae4d44b0aae30c1"/><file name="registration-bg-50.png" hash="99942fdc8c3f88b0d4b09f87c9e39045"/><file name="registration-bg.png" hash="96365b39495e56ffe491dd9930fe221d"/><file name="spinner.gif" hash="add667817f25bce331a213ab3cc9621f"/><file name="springbot-ctl.png" hash="de59a694a82b8699560df5146b2e315f"/><file name="submit-btn-bg.png" hash="d98aa287b7b73dad9f780b22cb53fbdb"/><file name="sync_icon.png" hash="cb12f2e8943c8e324e3456375f953c86"/><file name="white-check.png" hash="126f33ed483549e79a16186b7499c190"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="shell"><file name="springbot.php" hash="40a39e4b3400ba8724621898c3d562a2"/></dir></target></contents>
56
  <compatible/>
57
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
58
  </package>
shell/springbot.php CHANGED
@@ -5,19 +5,19 @@
5
  */
6
  class Springbot_Shell
7
  {
8
- protected $_action;
9
- protected $_type;
10
- protected $_appCode = 'admin';
11
- protected $_appType = 'store';
12
- protected $_magentoRootDir;
13
- protected $_args;
14
-
15
- protected $_registry = array(
16
  'harvest' => array(
17
  'attributeSets' => 'Springbot_Services_Harvest_AttributeSets',
18
  'carts' => 'Springbot_Services_Harvest_Carts',
19
  'categories' => 'Springbot_Services_Harvest_Categories',
20
- 'coupons' => 'Springbot_Services_Harvest_Coupons',
21
  'customerAttributeSets' => 'Springbot_Services_Harvest_CustomerAttributeSets',
22
  'customers' => 'Springbot_Services_Harvest_Customers',
23
  'guests' => 'Springbot_Services_Harvest_Guests',
@@ -33,6 +33,7 @@ class Springbot_Shell
33
  'category' => 'Springbot_Services_Post_Category',
34
  'coupon' => 'Springbot_Services_Post_Coupon',
35
  'customer' => 'Springbot_Services_Post_Customer',
 
36
  'json' => 'Springbot_Services_Post_Json',
37
  'product' => 'Springbot_Services_Post_Product',
38
  'purchase' => 'Springbot_Services_Post_Purchase',
@@ -44,7 +45,6 @@ class Springbot_Shell
44
  'halt' => 'Springbot_Services_Cmd_Halt',
45
  'harvest' => 'Springbot_Services_Cmd_Harvest',
46
  'healthcheck' => 'Springbot_Services_Cmd_Healthcheck',
47
- 'parse' => 'Springbot_Services_Cmd_Parse',
48
  'update' => 'Springbot_Services_Cmd_Update',
49
  'forecast' => 'Springbot_Services_Cmd_Forecast',
50
  ),
@@ -53,7 +53,6 @@ class Springbot_Shell
53
  'finalize' => 'Springbot_Services_Store_Finalize'
54
  ),
55
  'log' => array(
56
- 'purchase' => 'Springbot_Services_Log_Purchase',
57
  'installer' => 'Springbot_Services_Log_Installer',
58
  ),
59
  'work' => array(
@@ -64,27 +63,28 @@ class Springbot_Shell
64
  'stop' => 'Springbot_Services_Work_Stop',
65
  'report' => 'Springbot_Services_Work_Report'
66
  ),
 
 
 
67
  );
68
-
69
  public function __construct()
70
  {
71
- $this->_validate();
72
-
73
  require_once $this->getApplicationPath() . $this->getMagePath();
74
  Mage::app($this->_appCode, $this->_appType);
75
-
76
  $this->_parseArgs();
77
  }
78
 
79
  public function run()
80
  {
81
- try{
82
  Springbot_Log::debug("Running {$this->_action}:{$this->_type}");
83
  $className = $this->_registry[$this->_action][$this->_type];
 
84
  $class = new $className();
85
  $ret = $class->setData($this->_args)->run();
86
  echo $ret;
87
- } catch (Exception $e) {
 
88
  Springbot_Log::error($e);
89
  echo $e->getMessage() . PHP_EOL;
90
  exit(1);
@@ -101,7 +101,8 @@ class Springbot_Shell
101
  if(!isset($this->_magentoRootDir)) {
102
  if(file_exists($this->getMagePath())) {
103
  $this->_magentoRootDir = getcwd() . DIRECTORY_SEPARATOR;
104
- } else {
 
105
  for ($i = 0, $d = ''; !file_exists($d.$this->getMagePath()) && $i++ < 10; $d .= '../');
106
  $this->_magentoRootDir = getcwd() . DIRECTORY_SEPARATOR . $d;
107
  }
@@ -113,47 +114,35 @@ class Springbot_Shell
113
  return $this->_magentoRootDir;
114
  }
115
 
116
- protected function _parseArgs()
117
  {
118
  try {
119
  $argv = $_SERVER['argv'];
120
-
121
  $opts = getopt('s:i:h:c:o:dfrv:m:j:n:p:');
122
-
123
  list($this->_action, $this->_type) = explode(':', end($argv));
124
-
125
  $this->_args = Springbot_Services_Registry::parseOpts($opts);
126
-
127
  if(!isset($this->_action) || !isset($this->_type)) {
128
  throw new Exception;
129
  }
130
-
131
  if(!isset($this->_registry[$this->_action][$this->_type])) {
132
  $msg = 'Provided action not registered!';
133
  print $msg . PHP_EOL;
134
  Springbot_Log::debug($msg);
135
  exit(1);
136
  }
137
- } catch (Exception $e) {
 
138
  Springbot_Log::error($e);
139
  $this->_usage();
140
  exit;
141
  }
142
  }
143
 
144
- protected function _validate()
145
  {
146
- }
147
-
148
- protected function _usage()
149
- {
150
- print <<<USAGE
151
- Usage: \033[1mphp shell/springbot.php -s\033[0m \033[4mstore_id\033[0m \033[1m-i\033[0m \033[4mstart_id\033[0m:\033[4mend_id\033[0m \033[1maction:type\033[0m
152
-
153
- USAGE;
154
  }
155
  }
156
 
157
  $shell = new Springbot_Shell;
158
-
159
  $shell->run();
5
  */
6
  class Springbot_Shell
7
  {
8
+ private $_action;
9
+ private $_type;
10
+ private $_appCode = 'admin';
11
+ private $_appType = 'store';
12
+ private $_magentoRootDir;
13
+ private $_args;
14
+
15
+ private $_registry = array(
16
  'harvest' => array(
17
  'attributeSets' => 'Springbot_Services_Harvest_AttributeSets',
18
  'carts' => 'Springbot_Services_Harvest_Carts',
19
  'categories' => 'Springbot_Services_Harvest_Categories',
20
+ 'coupons' => 'Springbot_Services_Harvest_Coupons',
21
  'customerAttributeSets' => 'Springbot_Services_Harvest_CustomerAttributeSets',
22
  'customers' => 'Springbot_Services_Harvest_Customers',
23
  'guests' => 'Springbot_Services_Harvest_Guests',
33
  'category' => 'Springbot_Services_Post_Category',
34
  'coupon' => 'Springbot_Services_Post_Coupon',
35
  'customer' => 'Springbot_Services_Post_Customer',
36
+ 'guest' => 'Springbot_Services_Post_Guest',
37
  'json' => 'Springbot_Services_Post_Json',
38
  'product' => 'Springbot_Services_Post_Product',
39
  'purchase' => 'Springbot_Services_Post_Purchase',
45
  'halt' => 'Springbot_Services_Cmd_Halt',
46
  'harvest' => 'Springbot_Services_Cmd_Harvest',
47
  'healthcheck' => 'Springbot_Services_Cmd_Healthcheck',
 
48
  'update' => 'Springbot_Services_Cmd_Update',
49
  'forecast' => 'Springbot_Services_Cmd_Forecast',
50
  ),
53
  'finalize' => 'Springbot_Services_Store_Finalize'
54
  ),
55
  'log' => array(
 
56
  'installer' => 'Springbot_Services_Log_Installer',
57
  ),
58
  'work' => array(
63
  'stop' => 'Springbot_Services_Work_Stop',
64
  'report' => 'Springbot_Services_Work_Report'
65
  ),
66
+ 'tasks' => array(
67
+ 'deliverEventLog' => 'Springbot_Services_Tasks_DeliverEventLog',
68
+ ),
69
  );
 
70
  public function __construct()
71
  {
 
 
72
  require_once $this->getApplicationPath() . $this->getMagePath();
73
  Mage::app($this->_appCode, $this->_appType);
 
74
  $this->_parseArgs();
75
  }
76
 
77
  public function run()
78
  {
79
+ try {
80
  Springbot_Log::debug("Running {$this->_action}:{$this->_type}");
81
  $className = $this->_registry[$this->_action][$this->_type];
82
+ //$api = Mage::getModel('combine/api');
83
  $class = new $className();
84
  $ret = $class->setData($this->_args)->run();
85
  echo $ret;
86
+ }
87
+ catch (Exception $e) {
88
  Springbot_Log::error($e);
89
  echo $e->getMessage() . PHP_EOL;
90
  exit(1);
101
  if(!isset($this->_magentoRootDir)) {
102
  if(file_exists($this->getMagePath())) {
103
  $this->_magentoRootDir = getcwd() . DIRECTORY_SEPARATOR;
104
+ }
105
+ else {
106
  for ($i = 0, $d = ''; !file_exists($d.$this->getMagePath()) && $i++ < 10; $d .= '../');
107
  $this->_magentoRootDir = getcwd() . DIRECTORY_SEPARATOR . $d;
108
  }
114
  return $this->_magentoRootDir;
115
  }
116
 
117
+ private function _parseArgs()
118
  {
119
  try {
120
  $argv = $_SERVER['argv'];
 
121
  $opts = getopt('s:i:h:c:o:dfrv:m:j:n:p:');
 
122
  list($this->_action, $this->_type) = explode(':', end($argv));
 
123
  $this->_args = Springbot_Services_Registry::parseOpts($opts);
 
124
  if(!isset($this->_action) || !isset($this->_type)) {
125
  throw new Exception;
126
  }
 
127
  if(!isset($this->_registry[$this->_action][$this->_type])) {
128
  $msg = 'Provided action not registered!';
129
  print $msg . PHP_EOL;
130
  Springbot_Log::debug($msg);
131
  exit(1);
132
  }
133
+ }
134
+ catch (Exception $e) {
135
  Springbot_Log::error($e);
136
  $this->_usage();
137
  exit;
138
  }
139
  }
140
 
141
+ private function _usage()
142
  {
143
+ echo "Usage: \033[1mphp shell/springbot.php -s\033[0m \033[4mstore_id\033[0m \033[1m-i\033[0m \033[4mstart_id\033[0m:\033[4mend_id\033[0m \033[1maction:type\033[0m\n\n";
 
 
 
 
 
 
 
144
  }
145
  }
146
 
147
  $shell = new Springbot_Shell;
 
148
  $shell->run();