Version Notes
Dev
Download this release
Release Info
| Developer | Maarten van Schalkwijk |
| Extension | Hellodialog_Tracker |
| Version | 2.0.4 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.3 to 2.0.4
app/code/community/Hellodialog/Tracker/Model/Cron.php
CHANGED
|
@@ -4,8 +4,11 @@
|
|
| 4 |
// 2.400 per day (job every 15 minutes), this ensures we stay within Google's gecode limits (2500/24hrs)
|
| 5 |
private static $orders_per_job = 25;
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
public static function orders_per_job() {
|
| 8 |
-
return self::$orders_per_job;
|
| 9 |
}
|
| 10 |
|
| 11 |
public static function current_page() {
|
|
@@ -27,7 +30,6 @@
|
|
| 27 |
}
|
| 28 |
|
| 29 |
// configuration
|
| 30 |
-
$orders_per_job = self::orders_per_job();
|
| 31 |
$current_page = self::current_page();
|
| 32 |
$hd_observer = new HelloDialog_Tracker_Model_Observer();
|
| 33 |
$total = $orders = Mage::getModel('sales/order')->getCollection()
|
|
@@ -59,7 +61,9 @@
|
|
| 59 |
|
| 60 |
foreach ($orders as $order) {
|
| 61 |
self::log("- processing order ".$order->getIncrementId()." (".$order->getCustomerName().")");
|
|
|
|
| 62 |
$hd_observer->sync_order($order);
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
// update current page in config
|
| 4 |
// 2.400 per day (job every 15 minutes), this ensures we stay within Google's gecode limits (2500/24hrs)
|
| 5 |
private static $orders_per_job = 25;
|
| 6 |
|
| 7 |
+
// 9600 per day (job every 15 minutes) if we're not using Google's geocode
|
| 8 |
+
private static $orders_per_job_sans_geocoding = 100;
|
| 9 |
+
|
| 10 |
public static function orders_per_job() {
|
| 11 |
+
return Mage::getStoreConfig('hellodialog/general/geocode') ? self::$orders_per_job : self::$orders_per_job_sans_geocoding;
|
| 12 |
}
|
| 13 |
|
| 14 |
public static function current_page() {
|
| 30 |
}
|
| 31 |
|
| 32 |
// configuration
|
|
|
|
| 33 |
$current_page = self::current_page();
|
| 34 |
$hd_observer = new HelloDialog_Tracker_Model_Observer();
|
| 35 |
$total = $orders = Mage::getModel('sales/order')->getCollection()
|
| 61 |
|
| 62 |
foreach ($orders as $order) {
|
| 63 |
self::log("- processing order ".$order->getIncrementId()." (".$order->getCustomerName().")");
|
| 64 |
+
$start = microtime(true);
|
| 65 |
$hd_observer->sync_order($order);
|
| 66 |
+
self::log("- order #{$order->getIncrementId()} processed in " . round(((microtime(true) - $start) * 1000), 2).'ms');
|
| 67 |
}
|
| 68 |
|
| 69 |
// update current page in config
|
app/code/community/Hellodialog/Tracker/Model/Observer.php
CHANGED
|
@@ -227,17 +227,19 @@
|
|
| 227 |
Mage::log("Asserting existance of contact with email: ".$this->_value('email'), null, 'hellodialog.log');
|
| 228 |
$contact = $this->_createHellodialogContact();
|
| 229 |
$api = new HDApi('contacts');
|
| 230 |
-
$result
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
$result = $api->data($contact)->put($result->result->data->id_of_duplicate);
|
| 235 |
Mage::log("... UPDATED (Contact already existed, updated information)", null, 'hellodialog.log');
|
| 236 |
} else {
|
|
|
|
| 237 |
Mage::log("... OK (Contact created)", null, 'hellodialog.log');
|
| 238 |
}
|
| 239 |
|
| 240 |
-
|
| 241 |
// eCommerce plugin
|
| 242 |
// ---------------------------------
|
| 243 |
// Only synch the actual order when
|
|
@@ -282,7 +284,7 @@
|
|
| 282 |
if ($ordersResult->result->code == '200') {
|
| 283 |
Mage::log("... OK (Orders created)", null, 'hellodialog.log');
|
| 284 |
} else {
|
| 285 |
-
Mage::log("... FAILED (".$ordersResult->result->data->errors[0]->message.")", null, 'hellodialog.log');
|
| 286 |
}
|
| 287 |
} else {
|
| 288 |
Mage::log("... FAILED (unexpected response)", null, 'hellodialog.log');
|
| 227 |
Mage::log("Asserting existance of contact with email: ".$this->_value('email'), null, 'hellodialog.log');
|
| 228 |
$contact = $this->_createHellodialogContact();
|
| 229 |
$api = new HDApi('contacts');
|
| 230 |
+
$result = json_decode(
|
| 231 |
+
json_encode((new HDApi('contacts'))->condition('email', $contact['email'])->get()),
|
| 232 |
+
true
|
| 233 |
+
);
|
| 234 |
|
| 235 |
+
if ($existingContact = array_shift($result)) {
|
| 236 |
+
$api->data($contact)->put($existingContact['id']);
|
|
|
|
| 237 |
Mage::log("... UPDATED (Contact already existed, updated information)", null, 'hellodialog.log');
|
| 238 |
} else {
|
| 239 |
+
$api->data($contact)->post();
|
| 240 |
Mage::log("... OK (Contact created)", null, 'hellodialog.log');
|
| 241 |
}
|
| 242 |
|
|
|
|
| 243 |
// eCommerce plugin
|
| 244 |
// ---------------------------------
|
| 245 |
// Only synch the actual order when
|
| 284 |
if ($ordersResult->result->code == '200') {
|
| 285 |
Mage::log("... OK (Orders created)", null, 'hellodialog.log');
|
| 286 |
} else {
|
| 287 |
+
Mage::log("... FAILED (".$ordersResult->result->data->errors[0]->message.") -- Errors: " . json_encode($ordersResult->data->errors), null, 'hellodialog.log');
|
| 288 |
}
|
| 289 |
} else {
|
| 290 |
Mage::log("... FAILED (unexpected response)", null, 'hellodialog.log');
|
app/code/community/Hellodialog/Tracker/etc/config.xml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
|
| 4 |
<modules>
|
| 5 |
<Hellodialog_Tracker>
|
| 6 |
-
<version>2.0.
|
| 7 |
</Hellodialog_Tracker>
|
| 8 |
</modules>
|
| 9 |
|
| 3 |
|
| 4 |
<modules>
|
| 5 |
<Hellodialog_Tracker>
|
| 6 |
+
<version>2.0.4</version>
|
| 7 |
</Hellodialog_Tracker>
|
| 8 |
</modules>
|
| 9 |
|
app/code/community/Hellodialog/Tracker/etc/system.xml
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
<show_in_store>1</show_in_store>
|
| 18 |
<groups>
|
| 19 |
<general>
|
| 20 |
-
<label>Hellodialog Magento plugin v2.0.
|
| 21 |
<frontend_type>text</frontend_type>
|
| 22 |
<sort_order>1</sort_order>
|
| 23 |
<show_in_default>1</show_in_default>
|
|
@@ -28,7 +28,7 @@
|
|
| 28 |
<