Intelivemetrics_Unityreports - Version 0.8.1

Version Notes

Added support for product attributes

Download this release

Release Info

Developer Eduard G. Dumitrescu
Extension Intelivemetrics_Unityreports
Version 0.8.1
Comparing to
See all releases


Code changes from version 0.8.0 to 0.8.1

Files changed (21) hide show
  1. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Attributes.php +24 -0
  2. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Cron.php +2 -2
  3. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Customers.php +20 -0
  4. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Invoices.php +22 -0
  5. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Orders.php +22 -0
  6. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Products.php +20 -0
  7. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/SyncPercent.php +66 -0
  8. app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/UseShipping.php +22 -0
  9. app/code/community/Intelivemetrics/Unityreports/Model/Cron/Stock.php +90 -0
  10. app/code/community/Intelivemetrics/Unityreports/Model/Cron/Sync.php +1 -7
  11. app/code/community/Intelivemetrics/Unityreports/Model/Sync/Invoice.php +2 -1
  12. app/code/community/Intelivemetrics/Unityreports/Model/Sync/Order.php +25 -11
  13. app/code/community/Intelivemetrics/Unityreports/Model/Sync/Product.php +38 -10
  14. app/code/community/Intelivemetrics/Unityreports/Model/Utils.php +43 -19
  15. app/code/community/Intelivemetrics/Unityreports/controllers/IndexController.php +0 -2
  16. app/code/community/Intelivemetrics/Unityreports/controllers/TestController.php +60 -3
  17. app/code/community/Intelivemetrics/Unityreports/etc/config.xml +13 -13
  18. app/code/community/Intelivemetrics/Unityreports/etc/system.xml +53 -1
  19. app/code/community/Intelivemetrics/Unityreports/sql/unityreports_setup/mysql4-install-0.7.2.php +1 -1
  20. app/code/community/Intelivemetrics/Unityreports/sql/unityreports_setup/mysql4-install-0.7.3.php +1 -1
  21. package.xml +5 -5
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Attributes.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Options for on/off selector
5
+ *
6
+ * @category Unityreports
7
+ * @package Intelivemetrics_Unityreports
8
+ * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
+ * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
+ */
11
+ class Intelivemetrics_Unityreports_Model_Admin_Status_Attributes extends Mage_Core_Model_Abstract {
12
+
13
+ public function toOptionArray() {
14
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
15
+ ->addFieldToFilter('is_user_defined', 1)
16
+ ->getItems();
17
+ foreach ($attributes as $attribute) {
18
+ $attrib_data[] = array('value' => $attribute->getAttributeCode(), 'label' => $attribute->getData('frontend_label'));
19
+ }
20
+
21
+ return $attrib_data;
22
+ }
23
+
24
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Cron.php CHANGED
@@ -41,9 +41,9 @@ class Intelivemetrics_Unityreports_Model_Admin_Status_Cron extends Mage_Core_Mod
41
  $status = self::getStatus();
42
  if (is_array($status)) {
43
  if ($status['status'] == 0) {
44
- return 'Inactive';
45
  } elseif ($status['status'] == 1) {
46
- return 'Active - last executed at:' . $status['executed_at'];
47
  }
48
  }
49
 
41
  $status = self::getStatus();
42
  if (is_array($status)) {
43
  if ($status['status'] == 0) {
44
+ return '<b>Inactive</b>';
45
  } elseif ($status['status'] == 1) {
46
+ return '<b>Active</b> - last executed at:' . $status['executed_at'];
47
  }
48
  }
49
 
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Customers.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Orders
5
+ *
6
+ * @author Eddie
7
+ * @date
8
+ */
9
+ class Intelivemetrics_Unityreports_Model_Admin_Status_Sync_Customers extends Intelivemetrics_Unityreports_Model_Admin_Status_SyncPercent {
10
+
11
+ protected $_base_tbl = null;
12
+ protected $_unity_tbl = null;
13
+
14
+ public function __construct() {
15
+ $this->_base_tbl = Mage::getSingleton('unityreports/utils')->getTableName('customer/entity');
16
+ $this->_unity_tbl = Mage::getSingleton('unityreports/utils')->getTableName('unityreports/customers');
17
+ parent::__construct();
18
+ }
19
+
20
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Invoices.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Checks status of the sync cron
5
+ *
6
+ * @category Unityreports
7
+ * @package Intelivemetrics_Unityreports
8
+ * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
+ * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
+ */
11
+ class Intelivemetrics_Unityreports_Model_Admin_Status_Sync_Invoices extends Intelivemetrics_Unityreports_Model_Admin_Status_SyncPercent {
12
+
13
+ protected $_base_tbl = null;
14
+ protected $_unity_tbl = null;
15
+
16
+ public function __construct() {
17
+ $this->_base_tbl = Mage::getSingleton('unityreports/utils')->getTableName('sales/invoice');
18
+ $this->_unity_tbl = Mage::getSingleton('unityreports/utils')->getTableName('unityreports/invoices');
19
+ parent::__construct();
20
+ }
21
+
22
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Orders.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Checks status of the sync cron
5
+ *
6
+ * @category Unityreports
7
+ * @package Intelivemetrics_Unityreports
8
+ * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
+ * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
+ */
11
+ class Intelivemetrics_Unityreports_Model_Admin_Status_Sync_Orders extends Intelivemetrics_Unityreports_Model_Admin_Status_SyncPercent {
12
+
13
+ protected $_base_tbl = null;
14
+ protected $_unity_tbl = null;
15
+
16
+ public function __construct() {
17
+ $this->_base_tbl = Mage::getSingleton('unityreports/utils')->getTableName('sales/order');
18
+ $this->_unity_tbl = Mage::getSingleton('unityreports/utils')->getTableName('unityreports/orders');
19
+ parent::__construct();
20
+ }
21
+
22
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/Sync/Products.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Description of Orders
5
+ *
6
+ * @author Eddie
7
+ * @date
8
+ */
9
+ class Intelivemetrics_Unityreports_Model_Admin_Status_Sync_Products extends Intelivemetrics_Unityreports_Model_Admin_Status_SyncPercent {
10
+
11
+ protected $_base_tbl = null;
12
+ protected $_unity_tbl = null;
13
+
14
+ public function __construct() {
15
+ $this->_base_tbl = Mage::getSingleton('unityreports/utils')->getTableName('catalog/product');
16
+ $this->_unity_tbl = Mage::getSingleton('unityreports/utils')->getTableName('unityreports/products');
17
+ parent::__construct();
18
+ }
19
+
20
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/SyncPercent.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base class for sync percent
5
+ *
6
+ * @category Unityreports
7
+ * @package Intelivemetrics_Unityreports
8
+ * @copyright Copyright (c) 2016 Intelive Metrics Srl
9
+ * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
+ */
11
+
12
+ class Intelivemetrics_Unityreports_Model_Admin_Status_SyncPercent extends Mage_Core_Model_Abstract {
13
+
14
+ protected $_base_tbl=null;
15
+ protected $_unity_tbl=null;
16
+
17
+ public function setBaseTbl($t){
18
+ $this->_base_tbl = $t;
19
+ return $this;
20
+ }
21
+
22
+ public function getBaseTbl(){
23
+ return $this->_base_tbl;
24
+ }
25
+
26
+ public function setUnityTbl($t){
27
+ $this->_unity_tbl = $t;
28
+ return $this;
29
+ }
30
+
31
+ public function getUnityTbl(){
32
+ return $this->_unity_tbl;
33
+ }
34
+
35
+ protected function _getItemsCount($table) {
36
+ $helper = Mage::helper('unityreports');
37
+ $db = Mage::getSingleton('unityreports/utils')->getDb();
38
+ $result = $db->query($query = "SELECT COUNT(*) as c FROM {$table}");
39
+
40
+ if (!$result) {
41
+ $helper->debug("Cannot query: {$query}");
42
+ return FALSE;
43
+ }
44
+
45
+ $row = $result->fetch(PDO::FETCH_ASSOC);
46
+ if (!$row) {
47
+ return 0;
48
+ }
49
+
50
+ return $row['c'];
51
+ }
52
+
53
+ public function toHtml() {
54
+ $total = $this->_getItemsCount($this->getBaseTbl());
55
+ $done = $this->_getItemsCount($this->getUnityTbl());
56
+ if($done>$total) $done=$total;
57
+ $perc = round($done*100/$total,2);
58
+
59
+ return "<b>{$perc}%</b> - synced {$done} items out of {$total} ";
60
+
61
+ }
62
+
63
+ public function toOptionArray() {
64
+ return array();
65
+ }
66
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Admin/Status/UseShipping.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Unityreports
6
+ * @package Intelivemetrics_Unityreports
7
+ * @copyright Copyright (c) 2014 Intelive Metrics Srl
8
+ * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
9
+ */
10
+
11
+ class Intelivemetrics_Unityreports_Model_Admin_Status_UseShipping extends Mage_Core_Model_Abstract {
12
+
13
+ public function toOptionArray()
14
+ {
15
+ return array(
16
+ array('value'=>1, 'label'=>'Use invoice data'),
17
+ array('value'=>2, 'label'=>'Use shipping data')
18
+ );
19
+
20
+ }
21
+
22
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Cron/Stock.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Syncs prod stock
5
+ *
6
+ * @category Unityreports
7
+ * @package Intelivemetrics_Unityreports
8
+ * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
+ * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
+ */
11
+ class Intelivemetrics_Unityreports_Model_Cron_Stock extends Intelivemetrics_Unityreports_Model_Cron {
12
+
13
+ /**
14
+ * Called with magento cron
15
+ * @return boolean
16
+ * @assert () == true
17
+ */
18
+ public function runSync() {
19
+ $helper = Mage::helper('unityreports');
20
+ $helper->debug('*******NEW STOCK SYNC*******');
21
+ try {
22
+ //Check app status before syncing
23
+ if (!$this->_appIsOk()) {
24
+ $helper->debug('Endpoint is not receiving');
25
+ return false;
26
+ }
27
+
28
+ //get a soap client
29
+ $client = $this->_getClient();
30
+
31
+ //get token
32
+ $responseToken = json_decode($client->getToken(
33
+ $helper->getApiKey(), $helper->getApiSecret(), $helper->getLicenseKey()
34
+ ));
35
+ if ($responseToken->code != 'OK') {
36
+ $helper->debug('Cannot get a valid Token.' . $responseToken->msg);
37
+ return false;
38
+ }
39
+
40
+ //send data
41
+ $data = $this->_getData();
42
+ $blob = Intelivemetrics_Unityreports_Model_Utils::prepareDataForSending($data);
43
+ $helper->debug('STRING length' . mb_strlen($blob));
44
+ $client->post(
45
+ $responseToken->msg, array(
46
+ 'type' => 'STOCK',
47
+ 'data' => $blob,
48
+ 'license' => $helper->getLicenseKey()
49
+ )
50
+ );
51
+ $helper->debug('Ok - sent ' . count($data['stock']) . ' stock counters');
52
+
53
+ return true;
54
+ } catch (Exception $e) {
55
+ $helper->debug($e, Zend_Log::ERR);
56
+ $helper->debug('FILE: ' . __FILE__ . 'LINE: ' . __LINE__);
57
+ return false;
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Get all stock data > 0
63
+ * @return array associativo contenente i dati
64
+ */
65
+ protected function _getData() {
66
+ $helper = Mage::helper('unityreports');
67
+ $db = Mage::getSingleton('unityreports/utils')->getDb();
68
+ $table = Mage::getSingleton('unityreports/utils')->getTableName('cataloginventory/stock_item');
69
+ $sql = "SELECT product_id as id, SUM(qty) as s FROM {$table} GROUP BY product_id HAVING s>0";
70
+
71
+ try {
72
+ $result = $db->query($sql);
73
+
74
+ if (!$result) {
75
+ $helper->debug("Cannot query: {$sql}");
76
+ return FALSE;
77
+ }
78
+
79
+ return array(
80
+ 'date' => date('Y-m-d'),
81
+ 'stock' => $result->fetchAll(PDO::FETCH_ASSOC)
82
+ );
83
+ } catch (Exception $ex) {
84
+ $helper->debug($ex, Zend_Log::ERR);
85
+ $helper->debug('FILE: ' . __FILE__ . 'LINE: ' . __LINE__);
86
+ return null;
87
+ }
88
+ }
89
+
90
+ }
app/code/community/Intelivemetrics/Unityreports/Model/Cron/Sync.php CHANGED
@@ -31,19 +31,12 @@ extends Intelivemetrics_Unityreports_Model_Cron{
31
  //sync prods & variations
32
  if (($res1 = Mage::getModel('unityreports/sync_product')->runSync()) !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
33
  $helper->debug('OK syncing products');
34
- }
35
- if (($res2 = Mage::getModel('unityreports/sync_productVariation')->runSync()) !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
36
- $helper->debug('OK syncing product variations');
37
- }
38
- if ($res1 !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC || $res2 !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
39
  return true;
40
  }
41
 
42
  //sync customers
43
  if (($res1 = Mage::getModel('unityreports/sync_customer')->runSync()) !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
44
  $helper->debug('OK syncing customers');
45
- }
46
- if ($res1 !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
47
  return true;
48
  }
49
 
@@ -76,6 +69,7 @@ extends Intelivemetrics_Unityreports_Model_Cron{
76
  if ($res2 !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
77
  return true;
78
  }
 
79
  } catch (Exception $e) {
80
  $helper->debug($e, Zend_Log::ERR);
81
  return false;
31
  //sync prods & variations
32
  if (($res1 = Mage::getModel('unityreports/sync_product')->runSync()) !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
33
  $helper->debug('OK syncing products');
 
 
 
 
 
34
  return true;
35
  }
36
 
37
  //sync customers
38
  if (($res1 = Mage::getModel('unityreports/sync_customer')->runSync()) !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
39
  $helper->debug('OK syncing customers');
 
 
40
  return true;
41
  }
42
 
69
  if ($res2 !== Intelivemetrics_Unityreports_Model_Sync::NOTHING_TO_SYNC) {
70
  return true;
71
  }
72
+
73
  } catch (Exception $e) {
74
  $helper->debug($e, Zend_Log::ERR);
75
  return false;
app/code/community/Intelivemetrics/Unityreports/Model/Sync/Invoice.php CHANGED
@@ -67,7 +67,7 @@ class Intelivemetrics_Unityreports_Model_Sync_Invoice extends Intelivemetrics_Un
67
  $ordersTableMage = Intelivemetrics_Unityreports_Model_Utils::getTableName('sales_flat_order');
68
  $now = date('Y-m-d H:i:s');
69
  try {
70
- if (self::USE_SHIPPING) {
71
  $collection = Mage::getModel('sales/order_shipment')->getCollection()
72
  ->addAttributeToSelect('*');
73
  $collection->getSelect()
@@ -83,6 +83,7 @@ class Intelivemetrics_Unityreports_Model_Sync_Invoice extends Intelivemetrics_Un
83
  ->joinLeft(array('orders' => $ordersTableMage), "orders.entity_id=main_table.order_id", array('o_increment_id' => 'increment_id'))
84
  ->where("main_table.increment_id NOT IN (SELECT increment_id FROM $invoicesTable WHERE synced=1 OR sents>={$this->getMaxSents()} OR TIMESTAMPDIFF(MINUTE,last_sent_at,'{$now}')<60)")
85
  ->where("orders.increment_id IN (SELECT increment_id FROM $ordersTable WHERE synced=1)")
 
86
  ->limit($limit)
87
  ;
88
  }
67
  $ordersTableMage = Intelivemetrics_Unityreports_Model_Utils::getTableName('sales_flat_order');
68
  $now = date('Y-m-d H:i:s');
69
  try {
70
+ if (Mage::getStoreConfig('unityreports/advanced/use_shipping')==2) {
71
  $collection = Mage::getModel('sales/order_shipment')->getCollection()
72
  ->addAttributeToSelect('*');
73
  $collection->getSelect()
83
  ->joinLeft(array('orders' => $ordersTableMage), "orders.entity_id=main_table.order_id", array('o_increment_id' => 'increment_id'))
84
  ->where("main_table.increment_id NOT IN (SELECT increment_id FROM $invoicesTable WHERE synced=1 OR sents>={$this->getMaxSents()} OR TIMESTAMPDIFF(MINUTE,last_sent_at,'{$now}')<60)")
85
  ->where("orders.increment_id IN (SELECT increment_id FROM $ordersTable WHERE synced=1)")
86
+ ->where("main_table.created_at > '2014-01-01'")//HMIZATE
87
  ->limit($limit)
88
  ;
89
  }
app/code/community/Intelivemetrics/Unityreports/Model/Sync/Order.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
 
3
-
4
  /**
5
  * Send orders data
6
  *
@@ -9,8 +8,6 @@
9
  * @copyright Copyright (c) 2014 Intelive Metrics Srl
10
  * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
11
  */
12
-
13
-
14
  class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unityreports_Model_Sync implements Intelivemetrics_Unityreports_Model_Sync_Interface {
15
 
16
  const ENTITY_TYPE = 'sales_order';
@@ -92,21 +89,22 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
92
  ->limit($limit)
93
  ;
94
  //$helper->debug($collection->getSelectSql()->__toString());
95
-
96
-
97
  // nothing to sync get out
98
  if (count($collection) == 0) {
99
  $helper->debug('No order data found to sync', Zend_Log::INFO);
100
  return null;
101
  }
102
 
 
 
 
103
  // pack order data
104
  $data = array();
105
  $order_count = 0;
106
  $category = Mage::getModel('catalog/category');
107
  foreach ($collection as $order) {
108
  $attributes = $order->getData();
109
-
110
  try {
111
  $currency = $attributes['order_currency_code'];
112
 
@@ -117,6 +115,8 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
117
  'coupon_code' => $attributes['coupon_code'],
118
  'store_id' => $attributes['store_id'],
119
  'customer_id' => $attributes['customer_id'],
 
 
120
  'customer_group' => $this->_getGroupCode($attributes['group_id']),
121
  'grand_total' => $attributes['grand_total'],
122
  'shipping_amount' => $attributes['shipping_amount'],
@@ -135,7 +135,7 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
135
  'medium' => $attributes['medium'],
136
  'content' => $attributes['content'],
137
  'campaign' => $attributes['campaign'],
138
- 'payment_method' => $order->getPayment()->getMethod()
139
  );
140
 
141
  // indirizzo di spedizione
@@ -185,7 +185,7 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
185
 
186
  //recupera path categorie, solo della prima categoria associata
187
  //TODO: what if no category info is available? put some fake cateogry like UNKNOWN
188
- if ( ($product = $item->getProduct()) || ($product=Mage::getModel('catalog/product')->load($item->getProductId())) ) {
189
  $mainCategory = $product->getCategoryCollection()->getFirstItem();
190
  $ids = array_reverse($mainCategory->getPathIds());
191
  $counter = 1;
@@ -205,7 +205,7 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
205
  $item_arr['categories'] = $_categories;
206
  }
207
 
208
- // recupera le opzioni scelte
209
  if ($item_attribs['product_type'] == 'configurable') {
210
  $productOptions = $item->getProductOptions();
211
  $superAttributeIds = array();
@@ -223,6 +223,20 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
223
  }
224
  $item_arr['options'][] = $option;
225
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
  $items_arr['item_' . $item_attribs['item_id']] = $item_arr;
228
  }
@@ -232,14 +246,14 @@ class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unit
232
  $order_count++;
233
  } catch (Exception $ex) {
234
  $helper->debug($ex->getMessage(), Zend_Log::ERR);
235
- $helper->debug('FILE: ' . __FILE__.'LINE: ' . __LINE__);
236
  }
237
  }//end order loop
238
 
239
  return $data;
240
  } catch (Exception $ex) {
241
  $helper->debug($ex->getMessage(), Zend_Log::ERR);
242
- $helper->debug('FILE: ' . __FILE__.'LINE: ' . __LINE__);
243
  return null;
244
  }
245
  }
1
  <?php
2
 
 
3
  /**
4
  * Send orders data
5
  *
8
  * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
  * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
  */
 
 
11
  class Intelivemetrics_Unityreports_Model_Sync_Order extends Intelivemetrics_Unityreports_Model_Sync implements Intelivemetrics_Unityreports_Model_Sync_Interface {
12
 
13
  const ENTITY_TYPE = 'sales_order';
89
  ->limit($limit)
90
  ;
91
  //$helper->debug($collection->getSelectSql()->__toString());
 
 
92
  // nothing to sync get out
93
  if (count($collection) == 0) {
94
  $helper->debug('No order data found to sync', Zend_Log::INFO);
95
  return null;
96
  }
97
 
98
+ //get additional produc attributes list
99
+ $attribs = Intelivemetrics_Unityreports_Model_Utils::getProductAttributesToSync();
100
+
101
  // pack order data
102
  $data = array();
103
  $order_count = 0;
104
  $category = Mage::getModel('catalog/category');
105
  foreach ($collection as $order) {
106
  $attributes = $order->getData();
107
+
108
  try {
109
  $currency = $attributes['order_currency_code'];
110
 
115
  'coupon_code' => $attributes['coupon_code'],
116
  'store_id' => $attributes['store_id'],
117
  'customer_id' => $attributes['customer_id'],
118
+ 'customer_email' => $attributes['customer_email'],
119
+ 'customer_name' => $attributes['customer_firstname'].' '.$attributes['customer_lastname'],
120
  'customer_group' => $this->_getGroupCode($attributes['group_id']),
121
  'grand_total' => $attributes['grand_total'],
122
  'shipping_amount' => $attributes['shipping_amount'],
135
  'medium' => $attributes['medium'],
136
  'content' => $attributes['content'],
137
  'campaign' => $attributes['campaign'],
138
+ 'payment_method' => (is_object($order->getPayment())?$order->getPayment()->getMethod():'unknown')
139
  );
140
 
141
  // indirizzo di spedizione
185
 
186
  //recupera path categorie, solo della prima categoria associata
187
  //TODO: what if no category info is available? put some fake cateogry like UNKNOWN
188
+ if (($product = $item->getProduct()) || ($product = Mage::getModel('catalog/product')->load($item->getProductId()))) {
189
  $mainCategory = $product->getCategoryCollection()->getFirstItem();
190
  $ids = array_reverse($mainCategory->getPathIds());
191
  $counter = 1;
205
  $item_arr['categories'] = $_categories;
206
  }
207
 
208
+ //add configurable options
209
  if ($item_attribs['product_type'] == 'configurable') {
210
  $productOptions = $item->getProductOptions();
211
  $superAttributeIds = array();
223
  }
224
  $item_arr['options'][] = $option;
225
  }
226
+
227
+ //add custom prod attributes
228
+ if (is_array($attribs) && count($attribs) > 0) {
229
+ foreach ($attribs as $_code => $_id) {
230
+ $_value = ($product->getAttributeText($_code) ? $product->getAttributeText($_code) : $product->getData($_code));
231
+ if(!$_value) continue;
232
+
233
+ $item_arr['options'][] = array(
234
+ 'attribute_id' => $_id,
235
+ 'label' => $_code,
236
+ 'value' => $_value,
237
+ );
238
+ }
239
+ }
240
 
241
  $items_arr['item_' . $item_attribs['item_id']] = $item_arr;
242
  }
246
  $order_count++;
247
  } catch (Exception $ex) {
248
  $helper->debug($ex->getMessage(), Zend_Log::ERR);
249
+ $helper->debug('FILE: ' . __FILE__ . 'LINE: ' . __LINE__);
250
  }
251
  }//end order loop
252
 
253
  return $data;
254
  } catch (Exception $ex) {
255
  $helper->debug($ex->getMessage(), Zend_Log::ERR);
256
+ $helper->debug('FILE: ' . __FILE__ . 'LINE: ' . __LINE__);
257
  return null;
258
  }
259
  }
app/code/community/Intelivemetrics/Unityreports/Model/Sync/Product.php CHANGED
@@ -74,20 +74,35 @@ class Intelivemetrics_Unityreports_Model_Sync_Product extends Intelivemetrics_Un
74
  $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
75
  Mage::app()->setCurrentStore($adminStore);
76
 
 
 
 
 
 
 
 
 
 
 
 
77
  $collection = Mage::getModel('catalog/product')->getCollection()
78
- ->addAttributeToSelect(array('name', 'sku', 'type_id', 'created_at', 'updated_at', 'visibility', 'status'))
79
- ->addAttributeToSort('updated_at', 'ASC');
80
- //add price
81
- $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $adminStore);
82
- //add stock
83
- $collection->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left');
84
- //filter already sent
 
85
  $table = Intelivemetrics_Unityreports_Model_Utils::getTableName('unityreports/products');
86
  $collection->getSelect()
87
- ->where("e.sku IS NOT NULL")
88
  ->where("e.entity_id NOT IN (SELECT product_id FROM $table WHERE synced=1 OR sents>={$this->getMaxSents()} OR TIMESTAMPDIFF(MINUTE,last_sent_at,'{$now}')<60)")
 
 
89
  ->limit($limit)
90
  ;
 
91
 
92
  // se non ci sono record, esce
93
  if (count($collection) == 0) {
@@ -126,8 +141,22 @@ class Intelivemetrics_Unityreports_Model_Sync_Product extends Intelivemetrics_Un
126
  }
127
  $data['item_' . $product->getEntityId()]['parent_id'] = $parentId;
128
  }
129
- }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
  return $data;
133
  } catch (Exception $ex) {
@@ -139,4 +168,3 @@ class Intelivemetrics_Unityreports_Model_Sync_Product extends Intelivemetrics_Un
139
 
140
  }
141
 
142
- ?>
74
  $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
75
  Mage::app()->setCurrentStore($adminStore);
76
 
77
+ //get additional produc attributes list
78
+ $attribs = Intelivemetrics_Unityreports_Model_Utils::getProductAttributesToSync();
79
+
80
+ //build attrib list to take in
81
+ $_attribs = array('name', 'sku', 'type_id', 'created_at', 'updated_at', 'visibility', 'status');
82
+ if (count($attribs)) {
83
+ foreach ($attribs as $_code => $_id) {
84
+ $_attribs[] = $_code;
85
+ }
86
+ }
87
+
88
  $collection = Mage::getModel('catalog/product')->getCollection()
89
+ ->addAttributeToSelect($_attribs)
90
+ ->addAttributeToSort('updated_at', 'ASC')
91
+ //add price
92
+ ->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $adminStore)
93
+ //add stock
94
+ ->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left')
95
+ ;
96
+
97
  $table = Intelivemetrics_Unityreports_Model_Utils::getTableName('unityreports/products');
98
  $collection->getSelect()
99
+ //filter already sent
100
  ->where("e.entity_id NOT IN (SELECT product_id FROM $table WHERE synced=1 OR sents>={$this->getMaxSents()} OR TIMESTAMPDIFF(MINUTE,last_sent_at,'{$now}')<60)")
101
+ //don't send product immediatly after creation because attrib data is usually added later
102
+ ->where("TIMESTAMPDIFF(HOUR,e.created_at,'{$now}')>24")
103
  ->limit($limit)
104
  ;
105
+ // $helper->debug($collection->getSelectSql()->__toString());
106
 
107
  // se non ci sono record, esce
108
  if (count($collection) == 0) {
141
  }
142
  $data['item_' . $product->getEntityId()]['parent_id'] = $parentId;
143
  }
 
144
 
145
+ //add custom options
146
+ if (is_array($attribs) && count($attribs) > 0) {
147
+ foreach ($attribs as $_code => $_id) {
148
+ $_value = ($product->getAttributeText($_code) ? $product->getAttributeText($_code) : $product->getData($_code));
149
+ if (!$_value)
150
+ continue;
151
+
152
+ $data['item_' . $product->getEntityId()]['options'][] = array(
153
+ 'attribute_id' => $_id,
154
+ 'label' => $_code,
155
+ 'value' => $_value,
156
+ );
157
+ }
158
+ }
159
+ }
160
 
161
  return $data;
162
  } catch (Exception $ex) {
168
 
169
  }
170
 
 
app/code/community/Intelivemetrics/Unityreports/Model/Utils.php CHANGED
@@ -8,12 +8,12 @@
8
  * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
  * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
  */
11
-
12
-
13
  class Intelivemetrics_Unityreports_Model_Utils {
14
-
15
  protected static $_db = null;
16
  protected static $_soapClient = null;
 
 
17
 
18
  public static function getTableName($table) {
19
  return Mage::getSingleton('core/resource')->getTableName($table);
@@ -50,7 +50,7 @@ class Intelivemetrics_Unityreports_Model_Utils {
50
  $db = Mage::getModel('core/resource')->getConnection('core_read');
51
  $table = self::getTableName('unityreports/settings');
52
  $key = self::sanitize($key);
53
-
54
  if (is_null($key)) {
55
  $result = $db->query("SELECT `val` FROM `{$table}`");
56
  $out = array();
@@ -79,7 +79,7 @@ class Intelivemetrics_Unityreports_Model_Utils {
79
  $table = self::getTableName('unityreports/settings');
80
  $key = self::sanitize($key);
81
  $val = self::sanitize($val);
82
-
83
  try {
84
  $db->query("REPLACE INTO `{$table}`(`key`,`val`) VALUES('{$key}','{$val}')");
85
  self::log("set $key to $val");
@@ -89,7 +89,7 @@ class Intelivemetrics_Unityreports_Model_Utils {
89
  return false;
90
  }
91
  }
92
-
93
  /**
94
  * Gets a SOAP client
95
  * @return \Zend_Soap_Client
@@ -98,43 +98,67 @@ class Intelivemetrics_Unityreports_Model_Utils {
98
  $ws_endpoint = Mage::getStoreConfig('unityreports/general/ws_endpoint');
99
 
100
  // inizializza client SOAP
101
- if(is_null(self::$_soapClient)){
102
  self::$_soapClient = new Zend_Soap_Client($ws_endpoint . "?wsdl");
103
  self::$_soapClient->setWsdlCache(1);
104
  }
105
 
106
  return self::$_soapClient;
107
  }
108
-
109
  /**
110
  * Get db write connection
111
  * @return type
112
  */
113
- public static function getDb(){
114
- if(is_null(self::$_db)){
115
  self::$_db = Mage::getModel('core/resource')->getConnection('core_write');
116
  }
117
-
118
  return self::$_db;
119
  }
120
-
121
  /**
122
  * How many items of each type to send in one sync session
123
  * @return int
124
  */
125
- public static function getMaxItemsPerSync(){
126
  $items = Intelivemetrics_Unityreports_Model_Utils::getConfig('max_items_per_sync');
127
- if(!$items || is_null($items)){
128
  $items = Intelivemetrics_Unityreports_Model_Config::MAX_ITEMS_PER_SYNC;
129
  }
130
-
131
  return $items;
132
  }
133
-
134
- public static function prepareDataForSending($data){
135
  return base64_encode(gzcompress(serialize($data)));
136
  }
137
 
138
- }
 
 
 
 
 
 
 
 
139
 
140
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  * @copyright Copyright (c) 2014 Intelive Metrics Srl
9
  * @author Eduard Gabriel Dumitrescu (balaur@gmail.com)
10
  */
 
 
11
  class Intelivemetrics_Unityreports_Model_Utils {
12
+
13
  protected static $_db = null;
14
  protected static $_soapClient = null;
15
+ protected static $_prodAttributes = null;
16
+ protected static $_customerAttributes = null;
17
 
18
  public static function getTableName($table) {
19
  return Mage::getSingleton('core/resource')->getTableName($table);
50
  $db = Mage::getModel('core/resource')->getConnection('core_read');
51
  $table = self::getTableName('unityreports/settings');
52
  $key = self::sanitize($key);
53
+
54
  if (is_null($key)) {
55
  $result = $db->query("SELECT `val` FROM `{$table}`");
56
  $out = array();
79
  $table = self::getTableName('unityreports/settings');
80
  $key = self::sanitize($key);
81
  $val = self::sanitize($val);
82
+
83
  try {
84
  $db->query("REPLACE INTO `{$table}`(`key`,`val`) VALUES('{$key}','{$val}')");
85
  self::log("set $key to $val");
89
  return false;
90
  }
91
  }
92
+
93
  /**
94
  * Gets a SOAP client
95
  * @return \Zend_Soap_Client
98
  $ws_endpoint = Mage::getStoreConfig('unityreports/general/ws_endpoint');
99
 
100
  // inizializza client SOAP
101
+ if (is_null(self::$_soapClient)) {
102
  self::$_soapClient = new Zend_Soap_Client($ws_endpoint . "?wsdl");
103
  self::$_soapClient->setWsdlCache(1);
104
  }
105
 
106
  return self::$_soapClient;
107
  }
108
+
109
  /**
110
  * Get db write connection
111
  * @return type
112
  */
113
+ public static function getDb() {
114
+ if (is_null(self::$_db)) {
115
  self::$_db = Mage::getModel('core/resource')->getConnection('core_write');
116
  }
117
+
118
  return self::$_db;
119
  }
120
+
121
  /**
122
  * How many items of each type to send in one sync session
123
  * @return int
124
  */
125
+ public static function getMaxItemsPerSync() {
126
  $items = Intelivemetrics_Unityreports_Model_Utils::getConfig('max_items_per_sync');
127
+ if (!$items || is_null($items)) {
128
  $items = Intelivemetrics_Unityreports_Model_Config::MAX_ITEMS_PER_SYNC;
129
  }
130
+
131
  return $items;
132
  }
133
+
134
+ public static function prepareDataForSending($data) {
135
  return base64_encode(gzcompress(serialize($data)));
136
  }
137
 
138
+ public static function getProductAttributesToSync() {
139
+ if (is_null(self::$_prodAttributes)) {
140
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
141
+ ->addFieldToFilter('is_user_defined', 1)
142
+ ->getItems();
143
+ foreach ($attributes as $attribute) {
144
+ self::$_prodAttributes[$attribute->getAttributeCode()] = (int) $attribute->getId();
145
+ }
146
+ }
147
 
148
+ return self::$_prodAttributes;
149
+ }
150
+
151
+ public static function getCustomerAttributesToSync() {
152
+ if (is_null(self::$_customerAttributes)) {
153
+ $attributes = Mage::getResourceModel('customer/attribute_collection')
154
+ ->addFieldToFilter('is_user_defined', 1)
155
+ ->getItems();
156
+ foreach ($attributes as $attribute) {
157
+ self::$_customerAttributes[$attribute->getAttributeCode()] = (int) $attribute->getId();
158
+ }
159
+ }
160
+
161
+ return self::$_customerAttributes;
162
+ }
163
+
164
+ }
app/code/community/Intelivemetrics/Unityreports/controllers/IndexController.php CHANGED
@@ -57,8 +57,6 @@ class Intelivemetrics_Unityreports_IndexController extends Mage_Adminhtml_Contro
57
  $success = false;
58
  }
59
 
60
- Mage::log("Complete");
61
-
62
  if ($success) {
63
  $msg = $msg . "<br/> Testing completed successfully, if you are still experiencing difficulties please contact us on <a target='_blank' href='http://www.unityreports.com/contacts'>Unityreports.com</a>.";
64
  Mage::getSingleton('adminhtml/session')->addSuccess($msg);
57
  $success = false;
58
  }
59
 
 
 
60
  if ($success) {
61
  $msg = $msg . "<br/> Testing completed successfully, if you are still experiencing difficulties please contact us on <a target='_blank' href='http://www.unityreports.com/contacts'>Unityreports.com</a>.";
62
  Mage::getSingleton('adminhtml/session')->addSuccess($msg);
app/code/community/Intelivemetrics/Unityreports/controllers/TestController.php CHANGED
@@ -255,37 +255,94 @@ td {text-align: left; font-size: 80%; padding: 4px; border-bottom: 1px solid bla
255
  protected function _sync() {
256
  Mage::getModel('unityreports/cron_sync')->runSync();
257
  }
 
258
  protected function _request() {
259
  Mage::getModel('unityreports/cron_request')->check();
260
  }
 
261
  protected function _abcarts() {
262
- Mage::getModel('unityreports/sync_abcart')->runSync();
263
  }
 
264
  protected function _customers() {
265
- Mage::getModel('unityreports/sync_customer')->runSync();
266
  }
 
267
  protected function _actions() {
268
- Mage::getModel('unityreports/sync_customerAction')->runSync();
269
  }
 
270
  protected function _invoices() {
271
  Mage::getModel('unityreports/sync_invoice')->runSync();
272
  }
 
273
  protected function _orders() {
274
  Mage::getModel('unityreports/sync_order')->runSync();
275
  }
 
276
  protected function _returns() {
277
  Mage::getModel('unityreports/sync_creditnote')->runSync();
278
  }
 
279
  protected function _products() {
280
  Mage::getModel('unityreports/sync_product')->runSync();
281
  }
 
282
  protected function _counters() {
283
  Mage::getModel('unityreports/cron_count')->runSync();
284
  }
 
285
  protected function _variations() {
286
  Mage::getModel('unityreports/sync_productVariation')->runSync();
287
  }
 
288
  protected function _fix() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  }
290
 
291
  public function indexAction() {
255
  protected function _sync() {
256
  Mage::getModel('unityreports/cron_sync')->runSync();
257
  }
258
+
259
  protected function _request() {
260
  Mage::getModel('unityreports/cron_request')->check();
261
  }
262
+
263
  protected function _abcarts() {
264
+ Mage::getModel('unityreports/sync_abcart')->runSync();
265
  }
266
+
267
  protected function _customers() {
268
+ Mage::getModel('unityreports/sync_customer')->runSync();
269
  }
270
+
271
  protected function _actions() {
272
+ Mage::getModel('unityreports/sync_customerAction')->runSync();
273
  }
274
+
275
  protected function _invoices() {
276
  Mage::getModel('unityreports/sync_invoice')->runSync();
277
  }
278
+
279
  protected function _orders() {
280
  Mage::getModel('unityreports/sync_order')->runSync();
281
  }
282
+
283
  protected function _returns() {
284
  Mage::getModel('unityreports/sync_creditnote')->runSync();
285
  }
286
+
287
  protected function _products() {
288
  Mage::getModel('unityreports/sync_product')->runSync();
289
  }
290
+
291
  protected function _counters() {
292
  Mage::getModel('unityreports/cron_count')->runSync();
293
  }
294
+
295
  protected function _variations() {
296
  Mage::getModel('unityreports/sync_productVariation')->runSync();
297
  }
298
+
299
  protected function _fix() {
300
+
301
+ }
302
+
303
+ protected function _stock() {
304
+
305
+ Mage::getModel('unityreports/cron_stock')->runSync();
306
+
307
+ // $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct(1505);
308
+ // echo "<pre>";
309
+ // echo get_class($stock);
310
+ // print_r($stock->getAvailableQtyForSale());
311
+ // echo "</pre>";
312
+
313
+
314
+ // $stockIds = Mage::getModel('cataloginventory/stock_item')
315
+ // ->getCollection()
316
+ // ->addQtyFilter('>', 0)
317
+ // ->setPageSize(10)
318
+ // //->getAllIds()
319
+ // ;
320
+ // echo get_class($stockIds);
321
+ // //echo $stockIds->getSelectSql()->__toString();
322
+ // foreach ($stockIds as $s) {
323
+ // print_r($s->getData());
324
+ // }
325
+
326
+
327
+ // $helper = Mage::helper('unityreports');
328
+ // $db = Mage::getSingleton('unityreports/utils')->getDb();
329
+ // $table = Mage::getSingleton('unityreports/utils')->getTableName('cataloginventory/stock_item');
330
+ // echo $sql = "SELECT product_id as id, SUM(qty) as s FROM {$table} GROUP BY product_id HAVING s>0";
331
+ // $result = $db->query($sql);
332
+ //
333
+ // if (!$result) {
334
+ // $helper->debug("Cannot query: {$sql}");
335
+ // return FALSE;
336
+ // }
337
+ //
338
+ // $row = $result->fetchAll(PDO::FETCH_ASSOC);
339
+ // print_r($row);
340
+ // if (!$row) {
341
+ // return 0;
342
+ // }
343
+ //
344
+ // echo $row['c'];
345
+
346
  }
347
 
348
  public function indexAction() {
app/code/community/Intelivemetrics/Unityreports/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Intelivemetrics_Unityreports>
5
- <version>0.7.7</version>
6
  </Intelivemetrics_Unityreports>
7
  </modules>
8
  <global>
@@ -137,30 +137,30 @@
137
  <model>unityreports/cron_sync::runSync</model>
138
  </run>
139
  </unityreports_sync>
140
- <unityreports_count>
141
  <schedule>
142
- <cron_expr>0 3 * * *</cron_expr>
143
  </schedule>
144
  <run>
145
- <model>unityreports/cron_count::runSync</model>
146
  </run>
147
- </unityreports_count>
148
- <unityreports_globalcounter>
149
  <schedule>
150
- <cron_expr>10 3 * * *</cron_expr>
151
  </schedule>
152
  <run>
153
- <model>unityreports/cron_globalCounters::runSync</model>
154
  </run>
155
- </unityreports_globalcounter>
156
- <unityreports_stat>
157
  <schedule>
158
- <cron_expr>*/5 * * * *</cron_expr>
159
  </schedule>
160
  <run>
161
- <model>unityreports/cron_request::check</model>
162
  </run>
163
- </unityreports_stat>
164
  </jobs>
165
  </crontab>
166
  <default>
2
  <config>
3
  <modules>
4
  <Intelivemetrics_Unityreports>
5
+ <version>0.8.1</version>
6
  </Intelivemetrics_Unityreports>
7
  </modules>
8
  <global>
137
  <model>unityreports/cron_sync::runSync</model>
138
  </run>
139
  </unityreports_sync>
140
+ <unityreports_stat>
141
  <schedule>
142
+ <cron_expr>*/5 * * * *</cron_expr>
143
  </schedule>
144
  <run>
145
+ <model>unityreports/cron_request::check</model>
146
  </run>
147
+ </unityreports_stat>
148
+ <unityreports_stock>
149
  <schedule>
150
+ <cron_expr>0 2 * * *</cron_expr>
151
  </schedule>
152
  <run>
153
+ <model>unityreports/cron_stock::runSync</model>
154
  </run>
155
+ </unityreports_stock>
156
+ <unityreports_count>
157
  <schedule>
158
+ <cron_expr>0 3 * * *</cron_expr>
159
  </schedule>
160
  <run>
161
+ <model>unityreports/cron_count::runSync</model>
162
  </run>
163
+ </unityreports_count>
164
  </jobs>
165
  </crontab>
166
  <default>
app/code/community/Intelivemetrics/Unityreports/etc/system.xml CHANGED
@@ -21,7 +21,8 @@
21
  <comment><![CDATA[The bellow credentials should have been given to you during the registration procedure. If you don't have them, <a href='https://app.unityreports.com' target='_blank'><b>log in</b></a> into your account and retrieve them from the "Profiles" section.<br>
22
  If you don't have an account yet, you must <a href='https://app.unityreports.com/account/create' target='_blank'><b>create one</b></a> before using this module.<br><BR>
23
  If you are experiencing problems with this extension please run the self diagnosing test by clicking the button below.<br>
24
- For any questions or help please visit us at <a href='http://unityreports.com/contacts' target='_blank'>Unityreports.com</a>.<br><br>]]></comment>
 
25
  <frontend_type>text</frontend_type>
26
  <sort_order>10</sort_order>
27
  <show_in_default>1</show_in_default>
@@ -90,7 +91,48 @@
90
  <show_in_default>1</show_in_default>
91
  <show_in_website>0</show_in_website>
92
  <show_in_store>0</show_in_store>
 
93
  <fields>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  <cron_sync_status translate="label">
95
  <label>Cron sync status</label>
96
  <frontend_type>label</frontend_type>
@@ -154,6 +196,16 @@
154
  <show_in_website>0</show_in_website>
155
  <show_in_store>0</show_in_store>
156
  <fields>
 
 
 
 
 
 
 
 
 
 
157
  <debug_status translate="label">
158
  <label>Debug</label>
159
  <frontend_type>select</frontend_type>
21
  <comment><![CDATA[The bellow credentials should have been given to you during the registration procedure. If you don't have them, <a href='https://app.unityreports.com' target='_blank'><b>log in</b></a> into your account and retrieve them from the "Profiles" section.<br>
22
  If you don't have an account yet, you must <a href='https://app.unityreports.com/account/create' target='_blank'><b>create one</b></a> before using this module.<br><BR>
23
  If you are experiencing problems with this extension please run the self diagnosing test by clicking the button below.<br>
24
+ For any questions or help please visit us at <a href='http://unityreports.com/contacts' target='_blank'>Unityreports.com</a>.<br><br>
25
+ <span style='color:red;'><b>IMPORTANT NOTICE:</b> Remember to save the configuration <b>BEFORE</b> hitting the <b>TEST</b> button.</span><br><br>]]></comment>
26
  <frontend_type>text</frontend_type>
27
  <sort_order>10</sort_order>
28
  <show_in_default>1</show_in_default>
91
  <show_in_default>1</show_in_default>
92
  <show_in_website>0</show_in_website>
93
  <show_in_store>0</show_in_store>
94
+ <comment><![CDATA[<span style='color:red;'><b>IMPORTANT NOTICE:</b> Historical data sync process always happens from the oldest items to the newest</span><br><br>]]></comment>
95
  <fields>
96
+ <prod_sync_status translate="label">
97
+ <label>Product sync status</label>
98
+ <frontend_type>label</frontend_type>
99
+ <frontend_model>unityreports/adminhtml_label_renderer</frontend_model>
100
+ <source_model>unityreports/admin_status_sync_products</source_model>
101
+ <sort_order>1</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>0</show_in_website>
104
+ <show_in_store>0</show_in_store>
105
+ </prod_sync_status>
106
+ <cust_sync_status translate="label">
107
+ <label>Customer sync status</label>
108
+ <frontend_type>label</frontend_type>
109
+ <frontend_model>unityreports/adminhtml_label_renderer</frontend_model>
110
+ <source_model>unityreports/admin_status_sync_customers</source_model>
111
+ <sort_order>2</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>0</show_in_website>
114
+ <show_in_store>0</show_in_store>
115
+ </cust_sync_status>
116
+ <ord_sync_status translate="label">
117
+ <label>Order sync status</label>
118
+ <frontend_type>label</frontend_type>
119
+ <frontend_model>unityreports/adminhtml_label_renderer</frontend_model>
120
+ <source_model>unityreports/admin_status_sync_orders </source_model>
121
+ <sort_order>5</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>0</show_in_website>
124
+ <show_in_store>0</show_in_store>
125
+ </ord_sync_status>
126
+ <inv_sync_status translate="label">
127
+ <label>Invoice sync status</label>
128
+ <frontend_type>label</frontend_type>
129
+ <frontend_model>unityreports/adminhtml_label_renderer</frontend_model>
130
+ <source_model>unityreports/admin_status_sync_invoices</source_model>
131
+ <sort_order>6</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>0</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ </inv_sync_status>
136
  <cron_sync_status translate="label">
137
  <label>Cron sync status</label>
138
  <frontend_type>label</frontend_type>
196
  <show_in_website>0</show_in_website>
197
  <show_in_store>0</show_in_store>
198
  <fields>
199
+ <use_shipping translate="label">
200
+ <label>Complete orders</label>
201
+ <frontend_type>select</frontend_type>
202
+ <source_model>unityreports/admin_status_useShipping</source_model>
203
+ <sort_order>20</sort_order>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>0</show_in_website>
206
+ <show_in_store>0</show_in_store>
207
+ <comment>Contact UnityReports.com before changing this setting</comment>
208
+ </use_shipping>
209
  <debug_status translate="label">
210
  <label>Debug</label>
211
  <frontend_type>select</frontend_type>
app/code/community/Intelivemetrics/Unityreports/sql/unityreports_setup/mysql4-install-0.7.2.php CHANGED
@@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS `{$this->getTable('unityreports/settings')}` (
140
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
141
 
142
  INSERT INTO `{$this->getTable('unityreports/settings')}` (`key`, `val`) VALUES
143
- ('max_items_per_sync', '10');
144
 
145
  COMMIT;
146
  ");
140
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
141
 
142
  INSERT INTO `{$this->getTable('unityreports/settings')}` (`key`, `val`) VALUES
143
+ ('max_items_per_sync', '100');
144
 
145
  COMMIT;
146
  ");
app/code/community/Intelivemetrics/Unityreports/sql/unityreports_setup/mysql4-install-0.7.3.php CHANGED
@@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS `{$this->getTable('unityreports/settings')}` (
140
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
141
 
142
  INSERT INTO `{$this->getTable('unityreports/settings')}` (`key`, `val`) VALUES
143
- ('max_items_per_sync', '10');
144
 
145
  COMMIT;
146
  ");
140
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
141
 
142
  INSERT INTO `{$this->getTable('unityreports/settings')}` (`key`, `val`) VALUES
143
+ ('max_items_per_sync', '100');
144
 
145
  COMMIT;
146
  ");
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Intelivemetrics_Unityreports</name>
4
- <version>0.8.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://choosealicense.com/licenses/apache-2.0/">APACHE</license>
7
  <channel>community</channel>
@@ -10,11 +10,11 @@
10
  <description>Unityreports brings powerful e-commerce analytics by combining Magento, Google Analytics and Google Adwords data.&#xD;
11
  http://www.unityreports.com&#xD;
12
  </description>
13
- <notes>Added customer id on abandoned carts</notes>
14
  <authors><author><name>Eduard G. Dumitrescu</name><user>bregoiu</user><email>eddie.dumitrescu@gmail.com</email></author></authors>
15
- <date>2015-11-16</date>
16
- <time>12:20:29</time>
17
- <contents><target name="magecommunity"><dir name="Intelivemetrics"><dir name="Unityreports"><dir name="Block"><dir name="Adminhtml"><dir name="Button"><file name="Test.php" hash="f23e261d8cf7ef8314f121978b3b03d3"/></dir><dir name="Label"><file name="Renderer.php" hash="89a6ec5dddca5fcf86fbe85b83d87650"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="28ec3fc4be05e608c27da2722b75d2d1"/></dir><dir name="Model"><dir name="Admin"><dir name="Status"><file name="Active.php" hash="28d46ddb38425dcdddf34a694fcbcd84"/><dir name="Cron"><file name="Count.php" hash="8f8de0b781e5889c63b508dcba24532b"/><file name="GlobalCounters.php" hash="7b89f230d9a4fbd65bbf1dd87fd2d196"/><file name="Mage.php" hash="922159223ba73f6ecb4cb019595009f4"/><file name="Stat.php" hash="64e4b605214a0a966adada181d413d79"/><file name="Sync.php" hash="ab2313a6949823565001b9787a1a255a"/></dir><file name="Cron.php" hash="2f5e7a78dcdf1f593d239851316787cf"/></dir></dir><file name="Config.php" hash="590dd9e3939f58560d9b004763d48c05"/><dir name="Cron"><file name="Count.php" hash="e9fb746dabb7a9e2c8433f43fa723df8"/><file name="GlobalCounters.php" hash="c55ce27f8ea8c9a22b22053ae3715bff"/><file name="Request.php" hash="d0d5c8e1b3ba294ef4a628148f4eff3f"/><file name="Sync.php" hash="b929a2328350c060bc1566bbe5140aca"/></dir><file name="Cron.php" hash="51f800a9c3c0ab0acdcda3aa9ba51104"/><file name="Customer.php" hash="c99b23d2ec6ffd8acdcc11cf7ed6421e"/><file name="Observer.php" hash="6d29e3b6e3b740f8fcdbaf8f78feabba"/><dir name="Request"><file name="Base.php" hash="2c3fea1af836bedb205786d67465b97d"/><file name="Diagnose.php" hash="5e8525e5392c705660e800faf9b3e057"/><file name="Dq.php" hash="813628e7a57c45f37f83024cce909bdb"/><file name="GetCounters.php" hash="58350a26c70f552349a1eac4a29bb729"/><file name="HandShake.php" hash="904a425860be3685d747503367cc2b11"/><file name="Interface.php" hash="680707fa0a26ecd7237d116bc0b0a3da"/><file name="ResetAbcarts.php" hash="facdc1c2486398a2a62db126c8518174"/><file name="ResetAll.php" hash="b2533da935c5c66f741490f7f082c8df"/><file name="ResetCreditmemos.php" hash="a199f6f07c67e219d85990a3a08454cc"/><file name="ResetCustomers.php" hash="570aff03d862608cea5e09ded7e7fd9b"/><file name="ResetInvoices.php" hash="7c62cfe07c089b6ca64e32c9f4667297"/><file name="ResetOrders.php" hash="b73a88a0b1bd908c9e9e1d386f23087f"/><file name="ResetProductCounters.php" hash="e84ea87e8c2dcf28189e870c84118317"/><file name="ResetProducts.php" hash="9cfbc9b3f2a1388ef61f0af516ea8e02"/><file name="SetSpeed.php" hash="48496a1971c80fdaa689e0d65d0acd16"/><file name="StartSync.php" hash="30d94be6608c4bce5cebb114ad241fdb"/><file name="StopSync.php" hash="61fb6758c1600eed20c40e4ec28fcef1"/><file name="SyncResult.php" hash="c2f9893e2a083f9c792bc43a212196e4"/></dir><dir name="Resource"><dir name="Config"><file name="Collection.php" hash="dc7cc10daf7e597be061d7bf841d0f66"/></dir><file name="Config.php" hash="e3f733d66219ffc946a1b3cd5eca980d"/><file name="Setup.php" hash="2f7cb85c64bd6103faf9208c7d5f451f"/></dir><dir name="Sync"><file name="Abcart.php" hash="8c941a318ee81c497656c245cce10779"/><file name="Creditnote.php" hash="6485779bff48de00a9ba0960c906cf9f"/><file name="Customer.php" hash="b49c41bf3a310a1b874f0498b4863af7"/><file name="CustomerAction.php" hash="160ace0a2e9fa8e28ce522f0d03db25d"/><file name="Interface.php" hash="d74a42d2d34c34ce8ec3379bb220127f"/><file name="Invoice.php" hash="bc7adc628e4bff44e7314438b40a0cd3"/><file name="Order.php" hash="8895d8ca48a1c252fcab651b366ee3d9"/><file name="Product.php" hash="ac1a6cd15f3fc1858e11170accf5145c"/><file name="ProductVariation.php" hash="c3042550b9849335c1af13cc26d61504"/></dir><file name="Sync.php" hash="8aa9f12fbe6fde9304046ff332ecfda9"/><file name="Utils.php" hash="911a0d029646f3c6ed69c812b472afe4"/><file name="Utmz.php" hash="b3b1d805e042142f8d713e253836b1b1"/></dir><dir name="controllers"><file name="IndexController.php" hash="a8424f7e6841bc8f0c59867a41c8c2f1"/><file name="PublicController.php" hash="49b73f02a1ed29bba55490f82af75608"/><file name="TestController.php" hash="f9394956fe1befcc5ce2c4830eae0149"/></dir><dir name="etc"><file name="adminhtml.xml" hash="aab2ef0e4aedb050d8b60937a085537c"/><file name="config.xml" hash="fe50df73d2f0d0316f958795f9ef9d11"/><file name="system.xml" hash="dd6cee8070b16c894b64f1b7d84a4571"/></dir><dir name="sql"><dir name="unityreports_setup"><file name="mysql4-install-0.7.2.php" hash="54f2cbb15d70806b1756c6196d9b3ec1"/><file name="mysql4-install-0.7.3.php" hash="54f2cbb15d70806b1756c6196d9b3ec1"/><file name="mysql4-upgrade-0.6.2-0.7.2.php" hash="7c1abd7bed806f811ffedf9cdb2c0cc0"/><file name="mysql4-upgrade-0.7.2-0.7.3.php" hash="fcbc4f1c8b216548ee212855142857f8"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelivemetrics_Unityreports.xml" hash="ccb9d92196bbc626b5552746ac3ad08b"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="unityreports.xml" hash="1378f49dd55356156426785b3d1e3eab"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="intelivemetrics"><dir name="unityreports"><file name="utmz-alternative.js" hash="20f145b83473ec9c13b738b3f15ee969"/></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Intelivemetrics_Unityreports</name>
4
+ <version>0.8.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://choosealicense.com/licenses/apache-2.0/">APACHE</license>
7
  <channel>community</channel>
10
  <description>Unityreports brings powerful e-commerce analytics by combining Magento, Google Analytics and Google Adwords data.&#xD;
11
  http://www.unityreports.com&#xD;
12
  </description>
13
+ <notes>Added support for product attributes</notes>
14
  <authors><author><name>Eduard G. Dumitrescu</name><user>bregoiu</user><email>eddie.dumitrescu@gmail.com</email></author></authors>
15
+ <date>2016-02-04</date>
16
+ <time>07:09:38</time>
17
+ <contents><target name="magecommunity"><dir name="Intelivemetrics"><dir name="Unityreports"><dir name="Block"><dir name="Adminhtml"><dir name="Button"><file name="Test.php" hash="f23e261d8cf7ef8314f121978b3b03d3"/></dir><dir name="Label"><file name="Renderer.php" hash="89a6ec5dddca5fcf86fbe85b83d87650"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="28ec3fc4be05e608c27da2722b75d2d1"/></dir><dir name="Model"><dir name="Admin"><dir name="Status"><file name="Active.php" hash="28d46ddb38425dcdddf34a694fcbcd84"/><file name="Attributes.php" hash="88821a4f01364ff8223409c33a0b6167"/><dir name="Cron"><file name="Count.php" hash="8f8de0b781e5889c63b508dcba24532b"/><file name="GlobalCounters.php" hash="7b89f230d9a4fbd65bbf1dd87fd2d196"/><file name="Mage.php" hash="922159223ba73f6ecb4cb019595009f4"/><file name="Stat.php" hash="64e4b605214a0a966adada181d413d79"/><file name="Sync.php" hash="ab2313a6949823565001b9787a1a255a"/></dir><file name="Cron.php" hash="438fdf0f97428fed2cf30fe91f96f882"/><dir name="Sync"><file name="Customers.php" hash="1446fca53ddd58161169127191c400d6"/><file name="Invoices.php" hash="744b4b376c0e9bbfef8dcaef4e3e9118"/><file name="Orders.php" hash="37374a9ef8d14ecaf4c14aea024db042"/><file name="Products.php" hash="e8372e002264bfcbb8fc8d07e911c13e"/></dir><file name="SyncPercent.php" hash="a8184ca9718a8e72a14c69067dc867bf"/><file name="UseShipping.php" hash="4fa20aab09e013955dc989595ebf0aab"/></dir></dir><file name="Config.php" hash="590dd9e3939f58560d9b004763d48c05"/><dir name="Cron"><file name="Count.php" hash="e9fb746dabb7a9e2c8433f43fa723df8"/><file name="GlobalCounters.php" hash="c55ce27f8ea8c9a22b22053ae3715bff"/><file name="Request.php" hash="d0d5c8e1b3ba294ef4a628148f4eff3f"/><file name="Stock.php" hash="b2e4edf9c16b25b57d224ff41255d249"/><file name="Sync.php" hash="7ee01469a97d64392e0d45df462af342"/></dir><file name="Cron.php" hash="51f800a9c3c0ab0acdcda3aa9ba51104"/><file name="Customer.php" hash="c99b23d2ec6ffd8acdcc11cf7ed6421e"/><file name="Observer.php" hash="6d29e3b6e3b740f8fcdbaf8f78feabba"/><dir name="Request"><file name="Base.php" hash="2c3fea1af836bedb205786d67465b97d"/><file name="Diagnose.php" hash="5e8525e5392c705660e800faf9b3e057"/><file name="Dq.php" hash="813628e7a57c45f37f83024cce909bdb"/><file name="GetCounters.php" hash="58350a26c70f552349a1eac4a29bb729"/><file name="HandShake.php" hash="904a425860be3685d747503367cc2b11"/><file name="Interface.php" hash="680707fa0a26ecd7237d116bc0b0a3da"/><file name="ResetAbcarts.php" hash="facdc1c2486398a2a62db126c8518174"/><file name="ResetAll.php" hash="b2533da935c5c66f741490f7f082c8df"/><file name="ResetCreditmemos.php" hash="a199f6f07c67e219d85990a3a08454cc"/><file name="ResetCustomers.php" hash="570aff03d862608cea5e09ded7e7fd9b"/><file name="ResetInvoices.php" hash="7c62cfe07c089b6ca64e32c9f4667297"/><file name="ResetOrders.php" hash="b73a88a0b1bd908c9e9e1d386f23087f"/><file name="ResetProductCounters.php" hash="e84ea87e8c2dcf28189e870c84118317"/><file name="ResetProducts.php" hash="9cfbc9b3f2a1388ef61f0af516ea8e02"/><file name="SetSpeed.php" hash="48496a1971c80fdaa689e0d65d0acd16"/><file name="StartSync.php" hash="30d94be6608c4bce5cebb114ad241fdb"/><file name="StopSync.php" hash="61fb6758c1600eed20c40e4ec28fcef1"/><file name="SyncResult.php" hash="c2f9893e2a083f9c792bc43a212196e4"/></dir><dir name="Resource"><dir name="Config"><file name="Collection.php" hash="dc7cc10daf7e597be061d7bf841d0f66"/></dir><file name="Config.php" hash="e3f733d66219ffc946a1b3cd5eca980d"/><file name="Setup.php" hash="2f7cb85c64bd6103faf9208c7d5f451f"/></dir><dir name="Sync"><file name="Abcart.php" hash="8c941a318ee81c497656c245cce10779"/><file name="Creditnote.php" hash="6485779bff48de00a9ba0960c906cf9f"/><file name="Customer.php" hash="b49c41bf3a310a1b874f0498b4863af7"/><file name="CustomerAction.php" hash="160ace0a2e9fa8e28ce522f0d03db25d"/><file name="Interface.php" hash="d74a42d2d34c34ce8ec3379bb220127f"/><file name="Invoice.php" hash="d5869cc321f5f5c5b6ad9f103aab7bc2"/><file name="Order.php" hash="5cf743f522fe085b55fbc9f22124d3d5"/><file name="Product.php" hash="991c961a389a1046c7262abae5bba575"/><file name="ProductVariation.php" hash="c3042550b9849335c1af13cc26d61504"/></dir><file name="Sync.php" hash="8aa9f12fbe6fde9304046ff332ecfda9"/><file name="Utils.php" hash="a77825d378f0692900f396288c727358"/><file name="Utmz.php" hash="b3b1d805e042142f8d713e253836b1b1"/></dir><dir name="controllers"><file name="IndexController.php" hash="3e82f22fc3c16aa11a8a3b925a8ef2fb"/><file name="PublicController.php" hash="49b73f02a1ed29bba55490f82af75608"/><file name="TestController.php" hash="1aa552084dd6f585c2bb49b9ea13eeb5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="aab2ef0e4aedb050d8b60937a085537c"/><file name="config.xml" hash="7fecb0ebd5b365c81c49237f8d4b1237"/><file name="system.xml" hash="ea549855e9eeef1ca9ae51e7449a78e9"/></dir><dir name="sql"><dir name="unityreports_setup"><file name="mysql4-install-0.7.2.php" hash="15298718b85d6aa3bec4e1220f804d8f"/><file name="mysql4-install-0.7.3.php" hash="15298718b85d6aa3bec4e1220f804d8f"/><file name="mysql4-upgrade-0.6.2-0.7.2.php" hash="7c1abd7bed806f811ffedf9cdb2c0cc0"/><file name="mysql4-upgrade-0.7.2-0.7.3.php" hash="fcbc4f1c8b216548ee212855142857f8"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelivemetrics_Unityreports.xml" hash="ccb9d92196bbc626b5552746ac3ad08b"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="unityreports.xml" hash="1378f49dd55356156426785b3d1e3eab"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="intelivemetrics"><dir name="unityreports"><file name="utmz-alternative.js" hash="20f145b83473ec9c13b738b3f15ee969"/></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php></required></dependencies>
20
  </package>