Metrilo_Analytics - Version 1.2.3

Version Notes

Change import process to be synchronized.
Code cleanup.

Download this release

Release Info

Developer Murry Ivanoff
Extension Metrilo_Analytics
Version 1.2.3
Comparing to
See all releases


Code changes from version 1.2.2 to 1.2.3

app/code/community/Metrilo/Analytics/Block/Head.php CHANGED
@@ -18,7 +18,6 @@ class Metrilo_Analytics_Block_Head extends Mage_Core_Block_Template
18
  */
19
  public function getEvents()
20
  {
21
- $helper = Mage::helper('metrilo_analytics');
22
  $events = (array)Mage::getSingleton('core/session')->getData(self::DATA_TAG);
23
  // clear events from session ater get events once
24
  Mage::getSingleton('core/session')->setData(self::DATA_TAG,'');
@@ -38,7 +37,10 @@ class Metrilo_Analytics_Block_Head extends Mage_Core_Block_Template
38
  $request = Mage::app()->getRequest();
39
  $storeId = $helper->getStoreId($request);
40
 
41
- if($helper->isEnabled($storeId))
42
  return $html;
 
 
 
43
  }
44
  }
18
  */
19
  public function getEvents()
20
  {
 
21
  $events = (array)Mage::getSingleton('core/session')->getData(self::DATA_TAG);
22
  // clear events from session ater get events once
23
  Mage::getSingleton('core/session')->setData(self::DATA_TAG,'');
37
  $request = Mage::app()->getRequest();
38
  $storeId = $helper->getStoreId($request);
39
 
40
+ if($helper->isEnabled($storeId)) {
41
  return $html;
42
+ }
43
+
44
+ return "";
45
  }
46
  }
app/code/community/Metrilo/Analytics/Helper/Asynchttpclient.php CHANGED
@@ -12,45 +12,29 @@ class Metrilo_Analytics_Helper_Asynchttpclient extends Mage_Core_Helper_Abstract
12
  * @param String $url
13
  * @return void
14
  */
15
- public function get($url)
16
  {
17
  $parsedUrl = parse_url($url);
18
  $raw = $this->_buildRawGet($parsedUrl['host'], $parsedUrl['path']);
19
 
20
- $fp = fsockopen(
21
- $parsedUrl['host'],
22
- isset($parsedUrl['port']) ? $parsedUrl['port'] : 80,
23
- $errno, $errstr, 30);
24
-
25
- if ($fp) {
26
- fwrite($fp, $raw);
27
- fclose($fp);
28
- }
29
  }
30
 
31
  /**
32
- * Create HTTP POSTasync request to URL
33
- *
34
- * @param String $url
35
- * @param Array $bodyArray
36
- * @return void
37
  */
38
- public function post($url, $bodyArray = false)
39
  {
40
  $parsedUrl = parse_url($url);
41
  $encodedBody = $bodyArray ? json_encode($bodyArray) : '';
42
 
43
  $raw = $this->_buildRawPost($parsedUrl['host'], $parsedUrl['path'], $encodedBody);
44
 
45
- $fp = fsockopen(
46
- $parsedUrl['host'],
47
- isset($parsedUrl['port']) ? $parsedUrl['port'] : 80,
48
- $errno, $errstr, 30);
49
-
50
- if ($fp) {
51
- fwrite($fp, $raw);
52
- fclose($fp);
53
- }
54
  }
55
 
56
  private function _buildRawGet($host, $path)
@@ -77,4 +61,27 @@ class Metrilo_Analytics_Helper_Asynchttpclient extends Mage_Core_Helper_Abstract
77
 
78
  return $out;
79
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
12
  * @param String $url
13
  * @return void
14
  */
15
+ public function get($url, $async = true)
16
  {
17
  $parsedUrl = parse_url($url);
18
  $raw = $this->_buildRawGet($parsedUrl['host'], $parsedUrl['path']);
19
 
20
+ $this->_executeRequest($parsedUrl, $raw, $async);
 
 
 
 
 
 
 
 
21
  }
22
 
23
  /**
24
+ * Create HTTP POSTasync request to URL
25
+ * @param string $url
26
+ * @param $bodyArray
27
+ * @param bool $async
28
+ * @return void
29
  */
30
+ public function post($url, $bodyArray = false, $async = true)
31
  {
32
  $parsedUrl = parse_url($url);
33
  $encodedBody = $bodyArray ? json_encode($bodyArray) : '';
34
 
35
  $raw = $this->_buildRawPost($parsedUrl['host'], $parsedUrl['path'], $encodedBody);
36
 
37
+ $this->_executeRequest($parsedUrl, $raw, $async);
 
 
 
 
 
 
 
 
38
  }
39
 
40
  private function _buildRawGet($host, $path)
61
 
62
  return $out;
63
  }
64
+
65
+ private function _executeRequest($parsedUrl, $raw, $async = true)
66
+ {
67
+ $fp = fsockopen($parsedUrl['host'],
68
+ isset($parsedUrl['port']) ? $parsedUrl['port'] : 80,
69
+ $errno, $errstr, 30);
70
+
71
+ if ($fp) {
72
+ fwrite($fp, $raw);
73
+
74
+ if (!$async) {
75
+ $this->_waitForResponse($fp);
76
+ }
77
+
78
+ fclose($fp);
79
+ }
80
+ }
81
+
82
+ private function _waitForResponse($fp) {
83
+ while (!feof($fp)) {
84
+ fgets($fp, 1024);
85
+ }
86
+ }
87
  }
app/code/community/Metrilo/Analytics/Helper/Data.php CHANGED
@@ -187,8 +187,9 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
187
  'hs' => $basedCall
188
  );
189
 
 
190
  $asyncHttpHelper = Mage::helper('metrilo_analytics/asynchttpclient');
191
- $asyncHttpHelper->post('http://p.metrilo.com/bt', $requestBody);
192
  }
193
 
194
  /**
187
  'hs' => $basedCall
188
  );
189
 
190
+ /** @var Metrilo_Analytics_Helper_Asynchttpclient $asyncHttpHelper */
191
  $asyncHttpHelper = Mage::helper('metrilo_analytics/asynchttpclient');
192
+ $asyncHttpHelper->post('http://p.metrilo.com/bt', $requestBody, false);
193
  }
194
 
195
  /**
app/code/community/Metrilo/Analytics/controllers/Adminhtml/AjaxController.php CHANGED
@@ -22,8 +22,8 @@ class Metrilo_Analytics_Adminhtml_AjaxController extends Mage_Adminhtml_Controll
22
  $chunkId = (int)$this->getRequest()->getParam('chunk_id');
23
  // Get orders from the Database
24
  $orders = $import->getOrders($storeId, $chunkId);
25
- // Send orders via API helper method
26
- $helper->callBatchApi($storeId, $orders);
27
  $result['success'] = true;
28
  } catch (Exception $e) {
29
  Mage::logException($e);
22
  $chunkId = (int)$this->getRequest()->getParam('chunk_id');
23
  // Get orders from the Database
24
  $orders = $import->getOrders($storeId, $chunkId);
25
+ // Send orders via API helper method (last parameter shows synchronity)
26
+ $helper->callBatchApi($storeId, $orders, false);
27
  $result['success'] = true;
28
  } catch (Exception $e) {
29
  Mage::logException($e);
app/code/community/Metrilo/Analytics/etc/config.xml CHANGED
@@ -8,7 +8,7 @@
8
  <config>
9
  <modules>
10
  <Metrilo_Analytics>
11
- <version>1.2.2</version>
12
  </Metrilo_Analytics>
13
  </modules>
14
  <frontend>
8
  <config>
9
  <modules>
10
  <Metrilo_Analytics>
11
+ <version>1.2.3</version>
12
  </Metrilo_Analytics>
13
  </modules>
14
  <frontend>
package.xml CHANGED
@@ -1,28 +1,29 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Metrilo_Analytics</name>
4
- <version>1.2.2</version>
5
  <stability>stable</stability>
6
  <license>Apache Software License (ASL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Metrilo is simple, yet extremely powerful Customer Insights, CRM and Email Marketing product that turns your Magento data into insights to grow your business. Metrilo helps you know everything about your customers from their first touch with your Magento store to their latest purchase.</summary>
10
- <description>&gt;Metrilo is simple, yet extremely powerful Customer Insights, CRM and Email Marketing product that turns your Magento data into insights to grow your business. Metrilo helps you know everything about your customers from their first touch with your Magento store to their latest purchase.&amp;#xD;&#xD;
11
- &amp;#xD;&#xD;
12
- * Have all your customer data in one place.&amp;#xD;&#xD;
13
- * Identify cohorts of customers, cart abandoners or high-value spenders. Metrilo gets all your customer data in one place and makes it easy for you to get to know your biggest asset - your customers.&amp;#xD;&#xD;
14
- * More repeat purchases, just a few clicks away. Send targeted email messages in 3 easy steps.&amp;#xD;&#xD;
15
- * Metrilo tracks all important eCommerce metrics for you. Automatically.&amp;#xD;&#xD;
16
- * Optimize your acquisition channels&amp;#xD;&#xD;
17
- * Track product performance&amp;#xD;&#xD;
18
- * Powerful intelligence for your sales team&amp;#xD;&#xD;
19
- * With Metrilo, you have an amazing real-time overview of who's doing what on your eCommerce store.&amp;#xD;&#xD;
20
  * Metrilo automatically collects and analyzes your eCommerce data to use for your email campaigns.</description>
21
- <notes>Update maximum supported Magento version</notes>
22
- <authors><author><name>Murry Ivanoff</name><user>Metrilo</user><email>murry@metrilo.com</email></author><author><name>Zhivko Draganov</name><user>zhivko</user><email>zhivko@metrilo.com</email></author><author><name>Miroslav Petrov</name><user>miro</user><email>miro91tn@gmail.com</email></author></authors>
23
- <date>2017-03-02</date>
24
- <time>14:24:59</time>
25
- <contents><target name="magecommunity"><dir name="Metrilo"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="d080857c4ae4de4d9bb8bccae029a238"/></dir></dir></dir></dir><file name="Head.php" hash="8a638942f22453f34d4191aff820ffd5"/></dir><dir name="Helper"><file name="Asynchttpclient.php" hash="99d530582ba6407b604f377ad21eddc3"/><file name="Data.php" hash="fe390eb72f0d49b3cb12ab9a25c024ad"/></dir><dir name="Model"><file name="Import.php" hash="a85251d30dba509ccf3e8b742fdf4385"/><file name="Observer.php" hash="35b53b63d89a51bc8a58a2def76100aa"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxController.php" hash="0a7205a952ffab171828eac9945eb539"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2fdab5ef85143c8c30f4c3bb15628f83"/><file name="config.xml" hash="52c4330d1a3c1954396fefaef7072dca"/><file name="system.xml" hash="f9d4a7a38b56e4f167299cdb52a35230"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="metrilo_analytics.xml" hash="0e6911e2e883992f2182969286d929b1"/></dir><dir name="template"><dir name="metrilo"><dir name="system"><dir name="config"><file name="button.phtml" hash="ae861308ebc1460950edcac10bf8024f"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="metrilo_analytics.xml" hash="c7dcf4057bc31d906865e82159ac5eca"/></dir><dir name="template"><dir name="metrilo"><file name="head.phtml" hash="8bc0f1562031c7061110477cba3d662f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Metrilo_Analytics.xml" hash="3a4dbecc4e093537f11dd4c8fa2756e7"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="metrilo"><file name="favicon-metrilo.png" hash="743558f1e49a730be9d515197a36567b"/><file name="loader.gif" hash="e05e6bb35d035cac4f3e0c8af213e9ab"/><file name="logo.png" hash="e9e54afd81384e12f77aca4eaebf5be8"/><file name="styles.css" hash="da0c07513d917e4ad08ff50814b536e1"/></dir></dir></dir></dir></target></contents>
 
26
  <compatible/>
27
  <dependencies><required><php><min>5.2.1</min><max>5.6.30</max></php></required></dependencies>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Metrilo_Analytics</name>
4
+ <version>1.2.3</version>
5
  <stability>stable</stability>
6
  <license>Apache Software License (ASL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Metrilo is simple, yet extremely powerful Customer Insights, CRM and Email Marketing product that turns your Magento data into insights to grow your business. Metrilo helps you know everything about your customers from their first touch with your Magento store to their latest purchase.</summary>
10
+ <description>&amp;gt;Metrilo is simple, yet extremely powerful Customer Insights, CRM and Email Marketing product that turns your Magento data into insights to grow your business. Metrilo helps you know everything about your customers from their first touch with your Magento store to their latest purchase.&amp;amp;#xD;&amp;#xD;&#xD;
11
+ &amp;amp;#xD;&amp;#xD;&#xD;
12
+ * Have all your customer data in one place.&amp;amp;#xD;&amp;#xD;&#xD;
13
+ * Identify cohorts of customers, cart abandoners or high-value spenders. Metrilo gets all your customer data in one place and makes it easy for you to get to know your biggest asset - your customers.&amp;amp;#xD;&amp;#xD;&#xD;
14
+ * More repeat purchases, just a few clicks away. Send targeted email messages in 3 easy steps.&amp;amp;#xD;&amp;#xD;&#xD;
15
+ * Metrilo tracks all important eCommerce metrics for you. Automatically.&amp;amp;#xD;&amp;#xD;&#xD;
16
+ * Optimize your acquisition channels&amp;amp;#xD;&amp;#xD;&#xD;
17
+ * Track product performance&amp;amp;#xD;&amp;#xD;&#xD;
18
+ * Powerful intelligence for your sales team&amp;amp;#xD;&amp;#xD;&#xD;
19
+ * With Metrilo, you have an amazing real-time overview of who's doing what on your eCommerce store.&amp;amp;#xD;&amp;#xD;&#xD;
20
  * Metrilo automatically collects and analyzes your eCommerce data to use for your email campaigns.</description>
21
+ <notes>Change import process to be synchronized.&#xD;
22
+ Code cleanup.</notes>
23
+ <authors><author><name>Murry Ivanoff</name><user>Metrilo</user><email>murry@metrilo.com</email></author><author><name>Zhivko Draganov</name><user>zhivko</user><email>zhivko@metrilo.com</email></author><author><name>Miroslav Petrov</name><user>miro</user><email>miro91tn@gmail.com</email></author><author><name>Marush Denchev</name><user>marush</user><email>avreon@gmail.com</email></author></authors>
24
+ <date>2017-05-25</date>
25
+ <time>09:41:38</time>
26
+ <contents><target name="magecommunity"><dir name="Metrilo"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="d080857c4ae4de4d9bb8bccae029a238"/></dir></dir></dir></dir><file name="Head.php" hash="e310a5a89fce3f08920790ad11e79af0"/></dir><dir name="Helper"><file name="Asynchttpclient.php" hash="91af14d00df28453aadcd88ebedc948a"/><file name="Data.php" hash="9f38e8acd85a0dc5a95448ffe05490d5"/></dir><dir name="Model"><file name="Import.php" hash="a85251d30dba509ccf3e8b742fdf4385"/><file name="Observer.php" hash="35b53b63d89a51bc8a58a2def76100aa"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxController.php" hash="7f695800ee5f3be90f65c2be692f5655"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2fdab5ef85143c8c30f4c3bb15628f83"/><file name="config.xml" hash="2eaa2312944ce725515d36bd5f0a530f"/><file name="system.xml" hash="f9d4a7a38b56e4f167299cdb52a35230"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="metrilo"><file name="favicon-metrilo.png" hash="743558f1e49a730be9d515197a36567b"/><file name="loader.gif" hash="e05e6bb35d035cac4f3e0c8af213e9ab"/><file name="logo.png" hash="e9e54afd81384e12f77aca4eaebf5be8"/><file name="styles.css" hash="da0c07513d917e4ad08ff50814b536e1"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="metrilo"><dir name="system"><dir name="config"><file name="button.phtml" hash="ae861308ebc1460950edcac10bf8024f"/></dir></dir></dir></dir><dir name="layout"><file name="metrilo_analytics.xml" hash="0e6911e2e883992f2182969286d929b1"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="metrilo"><file name="head.phtml" hash="8bc0f1562031c7061110477cba3d662f"/></dir></dir><dir name="layout"><file name="metrilo_analytics.xml" hash="c7dcf4057bc31d906865e82159ac5eca"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Metrilo_Analytics.xml" hash="3a4dbecc4e093537f11dd4c8fa2756e7"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>5.2.1</min><max>5.6.30</max></php></required></dependencies>
29
  </package>