VantageAnalytics_Analytics - Version 0.9.0

Version Notes

First release

Download this release

Release Info

Developer Brandon Kane
Extension VantageAnalytics_Analytics
Version 0.9.0
Comparing to
See all releases


Version 0.9.0

Files changed (86) hide show
  1. app/code/community/VantageAnalytics/Analytics/Block/Adminhtml/Analyticsbackend.php +9 -0
  2. app/code/community/VantageAnalytics/Analytics/Block/Adminhtml/Reset.php +17 -0
  3. app/code/community/VantageAnalytics/Analytics/Helper/Account.php +65 -0
  4. app/code/community/VantageAnalytics/Analytics/Helper/Data.php +6 -0
  5. app/code/community/VantageAnalytics/Analytics/Helper/DateFormatter.php +40 -0
  6. app/code/community/VantageAnalytics/Analytics/Helper/Extension/Lister.php +38 -0
  7. app/code/community/VantageAnalytics/Analytics/Helper/Extension/Pool.php +44 -0
  8. app/code/community/VantageAnalytics/Analytics/Helper/Log.php +39 -0
  9. app/code/community/VantageAnalytics/Analytics/Helper/Queue.php +74 -0
  10. app/code/community/VantageAnalytics/Analytics/Helper/Statuses.php +102 -0
  11. app/code/community/VantageAnalytics/Analytics/Helper/Tracking.php +43 -0
  12. app/code/community/VantageAnalytics/Analytics/Model/AddressRetriever.php +25 -0
  13. app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/BadRequest.php +6 -0
  14. app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/CurlError.php +6 -0
  15. app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/MaxRetries.php +6 -0
  16. app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/ServerError.php +6 -0
  17. app/code/community/VantageAnalytics/Analytics/Model/Api/Request.php +109 -0
  18. app/code/community/VantageAnalytics/Analytics/Model/Api/RequestQueue.php +14 -0
  19. app/code/community/VantageAnalytics/Analytics/Model/Api/Secret.php +46 -0
  20. app/code/community/VantageAnalytics/Analytics/Model/Api/Signature.php +25 -0
  21. app/code/community/VantageAnalytics/Analytics/Model/Api/Username.php +13 -0
  22. app/code/community/VantageAnalytics/Analytics/Model/Api/Webhook.php +52 -0
  23. app/code/community/VantageAnalytics/Analytics/Model/Cron.php +79 -0
  24. app/code/community/VantageAnalytics/Analytics/Model/Debug.php +103 -0
  25. app/code/community/VantageAnalytics/Analytics/Model/Export/Base.php +55 -0
  26. app/code/community/VantageAnalytics/Analytics/Model/Export/Customer.php +17 -0
  27. app/code/community/VantageAnalytics/Analytics/Model/Export/Order.php +21 -0
  28. app/code/community/VantageAnalytics/Analytics/Model/Export/Product.php +17 -0
  29. app/code/community/VantageAnalytics/Analytics/Model/Export/Runner.php +68 -0
  30. app/code/community/VantageAnalytics/Analytics/Model/Export/Store.php +20 -0
  31. app/code/community/VantageAnalytics/Analytics/Model/Heartbeat.php +16 -0
  32. app/code/community/VantageAnalytics/Analytics/Model/Observer/Base.php +47 -0
  33. app/code/community/VantageAnalytics/Analytics/Model/Observer/CatalogProduct.php +23 -0
  34. app/code/community/VantageAnalytics/Analytics/Model/Observer/Customer.php +29 -0
  35. app/code/community/VantageAnalytics/Analytics/Model/Observer/SalesOrder.php +43 -0
  36. app/code/community/VantageAnalytics/Analytics/Model/Observer/SalesQuote.php +30 -0
  37. app/code/community/VantageAnalytics/Analytics/Model/Observer/Tracking.php +24 -0
  38. app/code/community/VantageAnalytics/Analytics/Model/ParentProduct.php +70 -0
  39. app/code/community/VantageAnalytics/Analytics/Model/ProductCategories.php +37 -0
  40. app/code/community/VantageAnalytics/Analytics/Model/ProductImages.php +44 -0
  41. app/code/community/VantageAnalytics/Analytics/Model/ProductOptions.php +50 -0
  42. app/code/community/VantageAnalytics/Analytics/Model/Queue/Adapter/Db.php +19 -0
  43. app/code/community/VantageAnalytics/Analytics/Model/Resource/Mysql4/Setup.php +9 -0
  44. app/code/community/VantageAnalytics/Analytics/Model/SubscriberInformation.php +42 -0
  45. app/code/community/VantageAnalytics/Analytics/Model/Transformer/Address.php +122 -0
  46. app/code/community/VantageAnalytics/Analytics/Model/Transformer/Base.php +44 -0
  47. app/code/community/VantageAnalytics/Analytics/Model/Transformer/BaseSales.php +159 -0
  48. app/code/community/VantageAnalytics/Analytics/Model/Transformer/BaseSalesItem.php +67 -0
  49. app/code/community/VantageAnalytics/Analytics/Model/Transformer/Customer.php +101 -0
  50. app/code/community/VantageAnalytics/Analytics/Model/Transformer/Product.php +127 -0
  51. app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesOrder.php +106 -0
  52. app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesOrderLineItem.php +67 -0
  53. app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesQuote.php +85 -0
  54. app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesQuoteLineItem.php +27 -0
  55. app/code/community/VantageAnalytics/Analytics/Model/Transformer/Store.php +150 -0
  56. app/code/community/VantageAnalytics/Analytics/Test/Model/Api/Signature.php +28 -0
  57. app/code/community/VantageAnalytics/Analytics/Test/Model/Base.php +12 -0
  58. app/code/community/VantageAnalytics/Analytics/Test/Model/Config.php +14 -0
  59. app/code/community/VantageAnalytics/Analytics/Test/Model/Customer.php +40 -0
  60. app/code/community/VantageAnalytics/Analytics/Test/Model/Customer/fixtures/simpleCustomer.yaml +34 -0
  61. app/code/community/VantageAnalytics/Analytics/Test/Model/DateFormatterTest.php +28 -0
  62. app/code/community/VantageAnalytics/Analytics/Test/Model/LineItem.php +31 -0
  63. app/code/community/VantageAnalytics/Analytics/Test/Model/LineItem/fixtures/simpleOrder.yaml +87 -0
  64. app/code/community/VantageAnalytics/Analytics/Test/Model/Order.php +72 -0
  65. app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/orderStatus.yaml +61 -0
  66. app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/orderStatusCanceled.yaml +5 -0
  67. app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/orderStatusComplete.yaml +44 -0
  68. app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/paymentStatusUnpaid.yaml +22 -0
  69. app/code/community/VantageAnalytics/Analytics/Test/Model/Order/providers/orderStatus.yaml +15 -0
  70. app/code/community/VantageAnalytics/Analytics/Test/Model/Product.php +54 -0
  71. app/code/community/VantageAnalytics/Analytics/Test/Model/Product/fixtures/parentProduct.yaml +62 -0
  72. app/code/community/VantageAnalytics/Analytics/Test/Model/Product/fixtures/simpleProduct.yaml +45 -0
  73. app/code/community/VantageAnalytics/Analytics/Test/Model/Webhook.php +17 -0
  74. app/code/community/VantageAnalytics/Analytics/controllers/Adminhtml/AnalyticsbackendController.php +127 -0
  75. app/code/community/VantageAnalytics/Analytics/controllers/Adminhtml/ResetController.php +30 -0
  76. app/code/community/VantageAnalytics/Analytics/etc/adminhtml.xml +27 -0
  77. app/code/community/VantageAnalytics/Analytics/etc/config.xml +219 -0
  78. app/code/community/VantageAnalytics/Analytics/etc/system.xml +84 -0
  79. app/code/community/VantageAnalytics/Analytics/sql/vantageanalytics_analytics_setup/install-0.1.0.php +40 -0
  80. app/code/community/VantageAnalytics/Analytics/sql/vantageanalytics_analytics_setup/mysql4-upgrade-0.1.0-0.2.0.php +7 -0
  81. app/design/adminhtml/default/default/layout/analytics.xml +19 -0
  82. app/design/adminhtml/default/default/template/analytics/analyticsbackend.phtml +37 -0
  83. app/etc/modules/VantageAnalytics_Analytics.xml +9 -0
  84. package.xml +19 -0
  85. skin/adminhtml/base/default/images/vantage-for-magento.png +0 -0
  86. skin/adminhtml/default/default/css/register.css +41 -0
app/code/community/VantageAnalytics/Analytics/Block/Adminhtml/Analyticsbackend.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Block_Adminhtml_Analyticsbackend extends Mage_Adminhtml_Block_Template {
4
+
5
+ public function isAccountVerified()
6
+ {
7
+ return Mage::helper('analytics/account')->isVerified();
8
+ }
9
+ }
app/code/community/VantageAnalytics/Analytics/Block/Adminhtml/Reset.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Block_Adminhtml_Reset extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $resetUrl = $this->getUrl('analytics/adminhtml_reset/reset');
8
+ $this->setElement($element);
9
+ return $this->getLayout()
10
+ ->createBlock('adminhtml/widget_button')
11
+ ->setType('button')
12
+ ->setClass('scalable')
13
+ ->setLabel('Reset')
14
+ ->setOnClick("setLocation('{$resetUrl}')")
15
+ ->toHtml();
16
+ }
17
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Account.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Helper_Account extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function username()
6
+ {
7
+ return Mage::getStoreConfig('vantageanalytics/accountoptions/accountid', Mage::app()->getStore());
8
+ }
9
+
10
+ public function setUsername($username)
11
+ {
12
+ Mage::getConfig()->saveConfig('vantageanalytics/accountoptions/accountid', $username);
13
+ Mage::getConfig()->reinit();
14
+ }
15
+
16
+ public function secret()
17
+ {
18
+ return Mage::getStoreConfig('vantageanalytics/accountoptions/accountpwd', Mage::app()->getStore());
19
+ }
20
+
21
+ public function setSecret($secret)
22
+ {
23
+ Mage::getConfig()->saveConfig('vantageanalytics/accountoptions/accountpwd', $secret);
24
+ Mage::getConfig()->reinit();
25
+ }
26
+
27
+ public function vantageUrl()
28
+ {
29
+ return Mage::getStoreConfig('vantageanalytics/accountoptions/vantageurl', Mage::app()->getStore());
30
+ }
31
+
32
+ public function registerAccountUrl()
33
+ {
34
+ return dirname($this->vantageUrl()) . '/register/';
35
+ }
36
+
37
+ public function setVantageUrl($url)
38
+ {
39
+ Mage::getConfig()->saveConfig('vantageanalytics/accountoptions/vantageurl', $url);
40
+ Mage::getConfig()->reinit();
41
+ }
42
+
43
+ public function isVerified()
44
+ {
45
+ return Mage::getStoreConfig('vantageanalytics/accountoptions/verified', Mage::app()->getStore());
46
+ }
47
+
48
+ public function setIsVerified($isVerified)
49
+ {
50
+ Mage::getConfig()->saveConfig('vantageanalytics/accountoptions/verified', $isVerified);
51
+ Mage::getConfig()->reinit();
52
+ }
53
+
54
+ public function isExportDone()
55
+ {
56
+ return Mage::getStoreConfig('vantageanalytics/export/done', Mage::app()->getStore());
57
+ }
58
+
59
+ public function setExportDone($done)
60
+ {
61
+ Mage::getConfig()->saveConfig('vantageanalytics/export/done', $done);
62
+ Mage::getConfig()->reinit();
63
+ }
64
+
65
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/VantageAnalytics/Analytics/Helper/DateFormatter.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Helper_DateFormatter
3
+ {
4
+ public static function factory($dateString)
5
+ {
6
+ return new self($dateString);
7
+ }
8
+
9
+ public function __construct($dateString)
10
+ {
11
+ $this->dateString = $dateString;
12
+ }
13
+
14
+ public function defaultTimezone()
15
+ {
16
+ return new DateTimeZone("UTC");
17
+ }
18
+
19
+ public function dateFormat()
20
+ {
21
+ return "c";
22
+ }
23
+
24
+ public function toDate()
25
+ {
26
+ $datetime = new DateTime($this->dateString);
27
+
28
+ return $datetime->format($this->dateFormat());
29
+ }
30
+
31
+ public function toUtcDate()
32
+ {
33
+ $datetime = new DateTime($this->dateString);
34
+
35
+ $datetime->setTimeZone($this->defaultTimezone());
36
+
37
+ return $datetime->format($this->dateFormat());
38
+ }
39
+
40
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Extension/Lister.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Helper_Extension_Lister
3
+ {
4
+ public static function factory()
5
+ {
6
+ return new self();
7
+ }
8
+
9
+ public function __construct()
10
+ {
11
+ $this->config = Mage::getConfig();
12
+ }
13
+
14
+ public function extensions()
15
+ {
16
+ return array_map("basename", $this->filePaths());
17
+ }
18
+
19
+ public function pools()
20
+ {
21
+ return array('core','community','local');
22
+ }
23
+
24
+ private function filePaths()
25
+ {
26
+ $extensions = array();
27
+
28
+ foreach($this->pools() as $pool)
29
+ {
30
+ $extensions[] =
31
+ VantageAnalytics_Analytics_Helper_Extension_Pool::factory($pool)
32
+ ->files();
33
+ }
34
+
35
+ return call_user_func_array('array_merge', $extensions);
36
+ }
37
+
38
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Extension/Pool.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Helper_Extension_Pool
3
+ {
4
+ public static function factory($poolName)
5
+ {
6
+ return new self($poolName);
7
+ }
8
+
9
+ public function __construct($poolName)
10
+ {
11
+ $this->poolName = $poolName;
12
+ $this->config = Mage::getConfig();
13
+ }
14
+
15
+ public function files()
16
+ {
17
+ $final = array();
18
+
19
+ foreach($this->_files() as $file)
20
+ {
21
+ if(is_dir($file))
22
+ {
23
+ $final[] = $file;
24
+ }
25
+ }
26
+ return $final;
27
+ }
28
+
29
+ private function _files()
30
+ {
31
+ return glob($this->_poolPath($this->poolName) . DS . '*');
32
+ }
33
+
34
+ private function _basePath()
35
+ {
36
+ return $this->config->getOptions()->getCodeDir();
37
+ }
38
+
39
+ private function _poolPath($pool)
40
+ {
41
+ return $this->_basePath() . DS . $pool;
42
+ }
43
+ }
44
+
app/code/community/VantageAnalytics/Analytics/Helper/Log.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Helper_Log extends Mage_Core_Helper_Abstract
4
+ {
5
+ const LOGFILE = 'vantage-analytics.log';
6
+ const MARKER = '[VantageAnalytics] ';
7
+
8
+ protected function format($message, $findCaller=false)
9
+ {
10
+ if ($findCaller) {
11
+ $callerInfo = debug_backtrace();
12
+ $callerLine = $callerInfo[1]['line'];
13
+ $callerFile = $callerInfo[1]['file'];
14
+ return self::MARKER . " ({$callerFile}:{$callerLine}) {$message}";
15
+ }
16
+ return self::MARKER . " {$message}";
17
+ }
18
+
19
+ public function logInfo($msg)
20
+ {
21
+ Mage::log($this->format($msg), Zend_Log::INFO, self::LOGFILE);
22
+ }
23
+
24
+ public function logWarn($msg)
25
+ {
26
+ Mage::log($this->format($msg), Zend_Log::WARN, self::LOGFILE);
27
+ }
28
+
29
+ public function logError($msg)
30
+ {
31
+ Mage::log($this->format($msg, true), Zend_Log::ERR, self::LOGFILE, true);
32
+ }
33
+
34
+ public function logException($e)
35
+ {
36
+ Mage::log($this->format("\n" . $e->__toString(), true), Zend_Log::ERR, self::LOGFILE, true);
37
+ Mage::logException($e); // These always make it to a file named exception.log
38
+ }
39
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Queue.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Helper_Queue extends Mage_Core_Helper_Abstract
4
+ {
5
+ protected $queueName = "vantage";
6
+ protected $registry = array();
7
+ protected $maxBatchSize = 1000;
8
+
9
+ protected function getQueue()
10
+ {
11
+ if (!isset($this->registry[$this->queueName]))
12
+ {
13
+ $config = Mage::getConfig()->getResourceConnectionConfig("default_setup");
14
+ $queueOptions = array(
15
+ Zend_Queue::NAME => $this->queueName,
16
+ 'messageTableName' => 'vantage_message',
17
+ 'queueTableName' => 'vantage_queue',
18
+ 'driverOptions' => array(
19
+ 'host' => $config->host,
20
+ 'port' => $config->port,
21
+ 'username' => $config->username,
22
+ 'password' => $config->password,
23
+ 'dbname' => $config->dbname,
24
+ 'type' => 'pdo_mysql',
25
+ Zend_Queue::TIMEOUT => 1,
26
+ Zend_Queue::VISIBILITY_TIMEOUT => 1
27
+ )
28
+ );
29
+ $zendDb = new VantageAnalytics_Analytics_Model_Queue_Adapter_Db($queueOptions);
30
+ $this->registry[$this->queueName] = new Zend_Queue($zendDb, $queueOptions);
31
+ }
32
+ return $this->registry[$this->queueName];
33
+ }
34
+
35
+ protected function buildJob($msg)
36
+ {
37
+ $jobclass = $msg['class'];
38
+ $classname = "VantageAnalytics_Analytics_Model_{$jobclass}";
39
+ return new $classname;
40
+ }
41
+
42
+ protected function runJob($message)
43
+ {
44
+ $msg = json_decode($message->body, true);
45
+ $job = $this->buildJob($msg);
46
+ $method = $msg['method'];
47
+ return call_user_func_array(array($job, $method), $msg['args']);
48
+ }
49
+
50
+ public function processQueue()
51
+ {
52
+ try
53
+ {
54
+ $queue = $this->getQueue();
55
+ foreach ($queue->receive($this->maxBatchSize) as $message) {
56
+ $this->runJob($message);
57
+ $queue->deleteMessage($message);
58
+ }
59
+ }
60
+ catch (Exception $e)
61
+ {
62
+ Mage::helper('analytics/log')->logException($e);
63
+ return false;
64
+ }
65
+ return true;
66
+ }
67
+
68
+ public function enqueue($task)
69
+ {
70
+ $msg = json_encode($task);
71
+ $this->getQueue()->send($msg);
72
+ return true;
73
+ }
74
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Statuses.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Helper_Statuses
4
+ {
5
+ /*
6
+ * see: https://github.com/OpenMage/magento-mirror/blob/magento-1.7/app/code/core/Mage/Sales/Model/Order/Item.php#L194
7
+ * see: https://github.com/OpenMage/magento-mirror/blob/magento-1.7/app/code/core/Mage/Sales/Model/Order.php#L334
8
+ * see: http://www.magentocommerce.com/wiki/2_-_magento_concepts_and_architecture/order_management
9
+ */
10
+
11
+ public static function factory($salesEntity)
12
+ {
13
+ return new self($salesEntity);
14
+ }
15
+
16
+ public function __construct($salesEntity)
17
+ {
18
+ $this->salesEntity = $salesEntity;
19
+ }
20
+
21
+ public function paymentStatus()
22
+ {
23
+ $state = $this->_getOrderState();
24
+
25
+ if($state == Mage_Sales_Model_Order::STATUS_FRAUD) {
26
+ return 'paid';
27
+ }
28
+
29
+ $due = $this->salesEntity->getTotalDue();
30
+
31
+ if ($due == 0) {
32
+ return 'paid';
33
+ }
34
+
35
+ return 'unpaid';
36
+ }
37
+
38
+ public function fulfillmentStatus()
39
+ {
40
+ $statuses = array();
41
+
42
+ foreach ($this->salesEntity->getAllVisibleItems() as $item) {
43
+ $statuses[] = $item->getStatusId();
44
+ }
45
+
46
+ if ($this->_allItemsShipped($statuses)) {
47
+ return 'fulfilled';
48
+ }
49
+
50
+ if ($this->_partiallyFulfilled($statuses)) {
51
+ return 'partial-fulfilled';
52
+ }
53
+
54
+ return 'unfulfilled';
55
+ }
56
+
57
+ private function _allItemsShipped($statuses)
58
+ {
59
+ $unique_statuses = array_unique($statuses);
60
+
61
+ return (count($unique_statuses) == 1 && ($unique_statuses[0] == Mage_Sales_Model_Order_Item::STATUS_SHIPPED));
62
+ }
63
+
64
+ private function _partiallyFulfilled($statuses)
65
+ {
66
+ $unique_statuses = array_unique($statuses);
67
+
68
+ /* If one line item is fully fulfilled, while others are not
69
+ * then the order is also only partially fulfilled
70
+ */
71
+ return in_array(Mage_Sales_Model_Order_Item::STATUS_PARTIAL, $unique_statuses) ||
72
+ (in_array(Mage_Sales_Model_Order_Item::STATUS_SHIPPED, $unique_statuses) && (count($unique_statuses) > 1));
73
+ }
74
+
75
+ public function orderStatus()
76
+ {
77
+ $state = $this->_getOrderState();
78
+ switch ($state)
79
+ {
80
+ case Mage_Sales_Model_Order::STATE_CLOSED:
81
+ case Mage_Sales_Model_Order::STATE_COMPLETE:
82
+ return 'closed';
83
+ case Mage_Sales_Model_Order::STATE_CANCELED:
84
+ case Mage_Sales_Model_Order::STATUS_FRAUD:
85
+ return 'canceled';
86
+ case Mage_Sales_Model_Order::STATE_NEW:
87
+ case Mage_Sales_Model_Order::STATE_HOLDED:
88
+ case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
89
+ case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
90
+ case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
91
+ case Mage_Sales_Model_Order::STATE_PROCESSING:
92
+ return 'placed';
93
+ default:
94
+ return 'open';
95
+ }
96
+ }
97
+
98
+ private function _getOrderState()
99
+ {
100
+ return $this->salesEntity->getState();
101
+ }
102
+ }
app/code/community/VantageAnalytics/Analytics/Helper/Tracking.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Helper_Tracking extends Mage_Core_Helper_Abstract
4
+ {
5
+ const COOKIE_NAME = '__vantage';
6
+
7
+ public function gatherTrackingData($request)
8
+ {
9
+ $tracking = array(
10
+ 'landing_site' => $request->getRequestUri(),
11
+ 'referral_site' => $request->getServer('HTTP_REFERER')
12
+ );
13
+ return $tracking;
14
+ }
15
+
16
+ public function setInitialCookie($request)
17
+ {
18
+ if ($this->hasTrackingCookie()) {
19
+ return;
20
+ }
21
+ $tracking = $this->gatherTrackingData($request);
22
+ $cookie = json_encode($tracking);
23
+ $sixtyDays = 86400 * 60;
24
+ Mage::getModel('core/cookie')->set(self::COOKIE_NAME, $cookie, $sixtyDays);
25
+ }
26
+
27
+ public function hasTrackingCookie()
28
+ {
29
+ $currentCookie = $this->getTrackingFromCookie();
30
+ return (count($currentCookie) > 0);
31
+ }
32
+
33
+ public function getTrackingFromCookie()
34
+ {
35
+ $cookie = Mage::getModel('core/cookie')->get(self::COOKIE_NAME);
36
+ $tracking = json_decode($cookie, true);
37
+ if (!is_null($tracking)) {
38
+ return $tracking;
39
+ }
40
+ return array();
41
+ }
42
+
43
+ }
app/code/community/VantageAnalytics/Analytics/Model/AddressRetriever.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_AddressRetriever
4
+ {
5
+ public function __construct($customer)
6
+ {
7
+ $this->customer = $customer;
8
+ }
9
+
10
+ public static function factory($customer)
11
+ {
12
+ return new self($customer);
13
+ }
14
+
15
+ protected function addressId()
16
+ {
17
+ return $this->customer->getDefaultBilling();
18
+ }
19
+
20
+ public function address()
21
+ {
22
+ return Mage::getModel('customer/address')->load($this->addressId());
23
+ }
24
+
25
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/BadRequest.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Exceptions_BadRequest extends Exception
4
+ {
5
+
6
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/CurlError.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Exceptions_CurlError extends Exception
4
+ {
5
+
6
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/MaxRetries.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Exceptions_MaxRetries extends Exception
4
+ {
5
+
6
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Exceptions/ServerError.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Exceptions_ServerError extends Exception
4
+ {
5
+
6
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Request.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Request
4
+ {
5
+ public function __construct($vantageUrl=null, $username=null, $secret=null)
6
+ {
7
+ $this->vantageUrl = $vantageUrl ? $vantageUrl : Mage::helper("analytics/account")->vantageUrl();
8
+ $this->apiUsername = $username ? $username : Mage::helper("analytics/account")->username();
9
+ $this->apiSecret = $secret ? $secret : Mage::helper("analytics/account")->secret();
10
+ }
11
+
12
+ protected function makeSignatureHeader($body)
13
+ {
14
+ $signer = new VantageAnalytics_Analytics_Model_Api_Signature($body, $this->apiSecret);
15
+ return $signer->signatureHeader();
16
+ }
17
+
18
+
19
+ protected function setupCurl($method, $entityData)
20
+ {
21
+ $uri = "{$this->vantageUrl}/";
22
+ $channel = curl_init("$uri");
23
+ if (!$channel) {
24
+ $errorDesc = curl_error($channel);
25
+ throw new VantageAnalytics_Analytics_Model_Api_Exceptions_CurlError(
26
+ $errorDesc
27
+ );
28
+ }
29
+ curl_setopt($channel, CURLOPT_SSL_VERIFYHOST, 2);
30
+ curl_setopt($channel, CURLOPT_CUSTOMREQUEST, $method);
31
+ curl_setopt($channel, CURLOPT_RETURNTRANSFER, true);
32
+
33
+ $entityData['username'] = $this->apiUsername;
34
+ $body = json_encode($entityData);
35
+ curl_setopt($channel, CURLOPT_POSTFIELDS, $body);
36
+ $headers = array(
37
+ 'Content-type: application/json',
38
+ 'Content-length: ' . strlen($body),
39
+ $this->makeSignatureHeader($body)
40
+ );
41
+ curl_setopt($channel, CURLOPT_HTTPHEADER, $headers);
42
+
43
+ return $channel;
44
+ }
45
+
46
+ protected function raiseOnError($channel)
47
+ {
48
+ $status = curl_getinfo($channel, CURLINFO_HTTP_CODE);
49
+
50
+ if ($status >= 400 && $status < 500) {
51
+ throw new VantageAnalytics_Analytics_Model_Api_Exceptions_BadRequest;
52
+ }
53
+ if ($status >= 500) {
54
+ throw new VantageAnalytics_Analytics_Model_Api_Exceptions_ServerError;
55
+ }
56
+
57
+ if (curl_errno($channel)) {
58
+ $errorDesc = curl_error($channel);
59
+ curl_close($channel);
60
+ throw new VantageAnalytics_Analytics_Model_Api_Exceptions_CurlError(
61
+ $errorDesc
62
+ );
63
+ }
64
+ }
65
+
66
+ protected function wait($attempt)
67
+ {
68
+ if ($attempt == 10) {
69
+ Mage::helper('analytics/log')->logError("Tried $attempt times, giving up");
70
+ throw new VantageAnalytics_Analytics_Model_Api_Exceptions_MaxRetries("Maximum retries exceeded");
71
+ }
72
+ $waitTimes = array(30, 60, 5*60, 10*60, 30*60, 60*60,
73
+ 2*60*60, 5*60*60, 12*60*60, 24*60*60);
74
+ $seconds = $waitTimes[$attempt];
75
+ Mage::helper('analytics/log')->logWarn("Waiting for {$seconds} seconds.");
76
+ sleep($seconds);
77
+ }
78
+
79
+ protected function execCurl($method, $entityData)
80
+ {
81
+ $attempts = 0;
82
+ $success = false;
83
+ while ($attempts < 10 && !$success) {
84
+ try {
85
+ $channel = $this->setupCurl($method, $entityData);
86
+ $response = curl_exec($channel);
87
+ $this->raiseOnError($channel);
88
+ curl_close($channel);
89
+ $success = true;
90
+ } catch (VantageAnalytics_Analytics_Model_Api_Exceptions_ServerError $e) {
91
+ $this->wait($attempts);
92
+ } catch (VantageAnalytics_Analytics_Model_Api_Exceptions_CurlError $e) {
93
+ $this->wait($attempts);
94
+ } catch (VantageAnalytics_Analytics_Model_Api_Exceptions_BadRequest $e) {
95
+ $this->wait($attempts);
96
+ }
97
+ $attempts += 1;
98
+ }
99
+ return $response;
100
+ }
101
+
102
+ public function send($method, $entity)
103
+ {
104
+ $postData = VantageAnalytics_Analytics_Model_Api_Webhook::factory(
105
+ $entity, $method
106
+ )->getPostData();
107
+ $this->execCurl("POST", $postData);
108
+ }
109
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/RequestQueue.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_RequestQueue
4
+ {
5
+ public function enqueue($method, $resource)
6
+ {
7
+ $queue = Mage::helper('analytics/queue');
8
+ $queue->enqueue(array(
9
+ 'class' => 'Api_Request',
10
+ 'method' => 'send',
11
+ 'args' => array($method, $resource)
12
+ ));
13
+ }
14
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Secret.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Secret extends Mage_Core_Model_Config_Data
4
+ {
5
+ public function save()
6
+ {
7
+ $secret = $this->getValue();
8
+ if (strlen($secret) == 0) {
9
+ Mage::throwException("The VantageAnalytics Secret is required.");
10
+ }
11
+ if (strlen($secret) < 32) {
12
+ Mage::throwException(
13
+ "Double check the VantageAnalytics Secret, it " .
14
+ " should be 32 characters long."
15
+ );
16
+ }
17
+
18
+ $username = Mage::helper('analytics/account')->username();
19
+ $post = Mage::app()->getRequest()->getPost();
20
+ $username = $post['groups']['accountoptions']['fields']
21
+ ['accountid']['value'];
22
+
23
+ $vantageUrl = Mage::helper('analytics/account')->vantageUrl();
24
+
25
+ $api = new VantageAnalytics_Analytics_Model_Api_Request(
26
+ $vantageUrl, $username, $secret
27
+ );
28
+ $verifiyEntity = array('entity_type' => 'verification');
29
+
30
+ try {
31
+ $api->send('create', $verifiyEntity);
32
+ Mage::helper('analytics/account')->setIsVerified(1);
33
+ Mage::getSingleton('core/session')->addSuccess("Your VantageAnalytics "
34
+ . "username and secret were verified."
35
+ );
36
+ } catch (VantageAnalytics_Analytics_Model_Api_Exception_BadRequest $e) {
37
+ Mage::helper('analytics/account')->setIsVerified(0);
38
+ Mage::throwException(
39
+ "Verfication with VantageAnalytics.com failed! " .
40
+ "Re-enter the VantageAnalytics username and secret. "
41
+ );
42
+ }
43
+
44
+ return parent::save();
45
+ }
46
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Signature.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Signature
4
+ {
5
+ const HEADER = 'X-Vantage-Hmac-SHA256';
6
+
7
+ public function __construct($message, $secret)
8
+ {
9
+ $this->message = $message;
10
+ $this->secret = $secret;
11
+ }
12
+
13
+ public function sign()
14
+ {
15
+ return hash_hmac('sha256', $this->message, $this->secret);
16
+ }
17
+
18
+ public function signatureHeader()
19
+ {
20
+ $header = self::HEADER;
21
+ $signature = $this->sign();
22
+ return "{$header}: {$signature}";
23
+ }
24
+ }
25
+
app/code/community/VantageAnalytics/Analytics/Model/Api/Username.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Username extends Mage_Core_Model_Config_Data
4
+ {
5
+ public function save()
6
+ {
7
+ $username = $this->getValue();
8
+ if (strlen($username) == 0) {
9
+ Mage::throwException("Your VantageAnalytics username is required");
10
+ }
11
+ return parent::save();
12
+ }
13
+ }
app/code/community/VantageAnalytics/Analytics/Model/Api/Webhook.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Api_Webhook
4
+ {
5
+ public function __construct($resource, $method)
6
+ {
7
+ $this->resource = $resource;
8
+ $this->method = $method;
9
+ }
10
+
11
+ public static function factory($resource, $method)
12
+ {
13
+ return new self($resource, $method);
14
+ }
15
+
16
+ public function getPostData()
17
+ {
18
+ return array_merge($this->preamble(), $this->body());
19
+ }
20
+
21
+ public function preamble()
22
+ {
23
+ return array(
24
+ "webhook" => array(
25
+ "created" => $this->createdAt(),
26
+ "type" => $this->type()
27
+ ),
28
+ );
29
+ }
30
+
31
+ public function body()
32
+ {
33
+ return array("body" => $this->resource);
34
+ }
35
+
36
+ private function type()
37
+ {
38
+ return $this->_name() . "." . $this->method;
39
+ }
40
+
41
+ private function createdAt()
42
+ {
43
+ $date = gmdate('Y-m-d H:i:s');
44
+
45
+ return VantageAnalytics_Analytics_Helper_DateFormatter::factory($date)->toDate();
46
+ }
47
+
48
+ private function _name()
49
+ {
50
+ return array_key_exists('entity_type', $this->resource) ? $this->resource['entity_type'] : "object";
51
+ }
52
+ }
app/code/community/VantageAnalytics/Analytics/Model/Cron.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Cron
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->lockfile = null;
8
+ }
9
+
10
+ protected function log($msg)
11
+ {
12
+ Mage::helper('analytics/log')->logInfo('Cron ' . $msg);
13
+ }
14
+
15
+ protected function jitter()
16
+ {
17
+ $seconds = rand(0, 5*60);
18
+ $this->log("Sleeping for {$seconds} seconds");
19
+ sleep($seconds);
20
+ }
21
+
22
+ protected function getCronLockfile()
23
+ {
24
+ if (is_null($this->lockfile)) {
25
+ $this->log('lock file opened');
26
+ $this->lockfile = fopen(Mage::getBaseDir('var').DS.'locks'.DS.'vantage_cron_lock', 'w');
27
+ }
28
+ return $this->lockfile;
29
+ }
30
+
31
+ public function acquireCronLock()
32
+ {
33
+ $this->log('attempting to acquire the lock');
34
+ $file = $this->getCronLockfile();
35
+ return flock($file, LOCK_EX | LOCK_NB);
36
+ }
37
+
38
+ public function releaseCronLock()
39
+ {
40
+ // Not strictly necessary because the process will close the handle on exit anyway
41
+ $this->log('lock file closed');
42
+ fclose($this->lockfile);
43
+ }
44
+
45
+ public function runHistoricalExport()
46
+ {
47
+ $export = Mage::getModel('analytics/Export_Runner');
48
+ $export->run();
49
+ }
50
+
51
+ protected function accountIsVerified()
52
+ {
53
+ return Mage::helper('analytics/account')->isVerified();
54
+ }
55
+
56
+ public function run()
57
+ {
58
+ $this->jitter();
59
+
60
+ if (!$this->acquireCronLock()) {
61
+ $this->log('lock not acquired - cron is already running');
62
+ return;
63
+ }
64
+
65
+ $this->runHistoricalExport();
66
+
67
+ if (!$this->accountIsVerified()) {
68
+ $this->log('account verification required or failed. Not running.');
69
+ return;
70
+ }
71
+
72
+ $this->log('processing the queue');
73
+ $queue = Mage::helper('analytics/queue');
74
+ $queue->processQueue();
75
+
76
+ $this->log('the queue is empty');
77
+ $this->releaseCronLock();
78
+ }
79
+ }
app/code/community/VantageAnalytics/Analytics/Model/Debug.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Debug
4
+ {
5
+
6
+ public static function factory()
7
+ {
8
+ return new self();
9
+ }
10
+
11
+ // Makes it simpler to accept the
12
+ // debug information in the inbound-api
13
+ public function storeIds()
14
+ {
15
+ return array_values(Mage::app()->getWebsite()->getStoreIds());
16
+ }
17
+
18
+ public function entityType()
19
+ {
20
+ return 'heartbeat';
21
+ }
22
+
23
+ public function php()
24
+ {
25
+ return phpversion();
26
+ }
27
+
28
+ public function magentoVersion()
29
+ {
30
+ $version = Mage::getVersion();
31
+ $edition = Mage::getEdition();
32
+
33
+ return $version . "/" . $edition;
34
+ }
35
+
36
+ public function machine()
37
+ {
38
+ return php_uname();
39
+ }
40
+
41
+ public function installDate()
42
+ {
43
+ $config = Mage::app()->getConfig();
44
+
45
+ return VantageAnalytics_Analytics_Helper_DateFormatter::factory(
46
+ $config->getNode('global/install/date')
47
+ )->toDate();
48
+ }
49
+
50
+ public function stores()
51
+ {
52
+ $stores = array();
53
+
54
+ foreach (Mage::app()->getStores() as $store) {
55
+ $stores[$store->getId()] = $store->getCode();
56
+ }
57
+
58
+ return $stores;
59
+ }
60
+
61
+ public function websites()
62
+ {
63
+ $websites = array();
64
+
65
+ $sites = Mage::app()->getWebsites(true);
66
+
67
+ foreach($sites as $website) {
68
+ $websites[$website->getId()] = $website->getCode();
69
+ }
70
+
71
+
72
+ return $websites;
73
+ }
74
+
75
+ public function extensions()
76
+ {
77
+ return VantageAnalytics_Analytics_Helper_Extension_Lister::factory()->extensions();
78
+ }
79
+
80
+ public function verified()
81
+ {
82
+ return Mage::helper('analytics/account')->isVerified();
83
+ }
84
+
85
+ public function toVantage()
86
+ {
87
+ $methods = array_diff(
88
+ get_class_methods($this),
89
+ array('toVantage', '__construct', 'factory')
90
+ );
91
+
92
+ $data = array();
93
+
94
+ foreach ($methods as $method) {
95
+ $attr = strtolower(preg_replace(
96
+ '/(?<=\\w)(?=[A-Z])/',"_$1", $method));
97
+ $data[$attr] = call_user_func(array($this, $method));
98
+ }
99
+
100
+ return $data;
101
+ }
102
+
103
+ }
app/code/community/VantageAnalytics/Analytics/Model/Export/Base.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class VantageAnalytics_Analytics_Model_Export_Base
4
+ {
5
+ const PAGE_SIZE = 500;
6
+
7
+ abstract protected function createCollection($website);
8
+
9
+ public function __construct($pageSize = null, $api=null, $transformer='')
10
+ {
11
+ $this->transformer = $transformer;
12
+ $this->pageSize = !is_null($pageSize) ? $pageSize : self::PAGE_SIZE;
13
+ $this->api = (!is_null($api) ? $api :
14
+ new VantageAnalytics_Analytics_Model_Api_RequestQueue());
15
+ }
16
+
17
+ protected function makeTransformer($entity)
18
+ {
19
+ return Mage::getModel("analytics/Transformer_{$this->transformer}", $entity);
20
+ }
21
+
22
+ protected function enqueue($data)
23
+ {
24
+ $this->api->enqueue('create', $data);
25
+ }
26
+
27
+ protected function exportEntity($entity)
28
+ {
29
+ $transformer = $this->makeTransformer($entity);
30
+ $data = $transformer->toVantage();
31
+ $this->enqueue($data);
32
+ }
33
+
34
+ protected function exportWebsite($website)
35
+ {
36
+ $collection = $this->createCollection($website);
37
+ $totalPages = $collection->getLastPageNumber();
38
+ $currentPage = 1;
39
+ while ($currentPage <= $totalPages) {
40
+ foreach ($collection as $entity) {
41
+ $this->exportEntity($entity);
42
+ }
43
+ $currentPage++;
44
+ $collection->clear();
45
+ }
46
+ }
47
+
48
+ public function run()
49
+ {
50
+ $websites = Mage::app()->getWebsites();
51
+ foreach ($websites as $website) {
52
+ $this->exportWebsite($website);
53
+ }
54
+ }
55
+ }
app/code/community/VantageAnalytics/Analytics/Model/Export/Customer.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Export_Customer extends VantageAnalytics_Analytics_Model_Export_Base
4
+ {
5
+ public function __construct($pageSize=null, $api=null)
6
+ {
7
+ parent::__construct($pageSize, $api, 'Customer');
8
+ }
9
+
10
+ protected function createCollection($website)
11
+ {
12
+ return Mage::getModel('customer/customer')->getCollection()
13
+ ->addAttributeToSelect('*')
14
+ ->addFieldToFilter('website_id', $website->getId())
15
+ ->setPageSize(self::PAGE_SIZE);
16
+ }
17
+ }
app/code/community/VantageAnalytics/Analytics/Model/Export/Order.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Export_Order extends VantageAnalytics_Analytics_Model_Export_Base
4
+ {
5
+ public function __construct($pageSize=null, $api=null)
6
+ {
7
+ parent::__construct($pageSize, $api, 'SalesOrder');
8
+ }
9
+
10
+ protected function createCollection($website)
11
+ {
12
+ $filter = array();
13
+ foreach ($website->getStoreIds() as $storeId) {
14
+ $filter[] = array('eq', $storeId);
15
+ }
16
+ return Mage::getModel('sales/order')->getCollection()
17
+ ->addAttributeToSelect('*')
18
+ ->addFieldToFilter('store_id', $filter)
19
+ ->setPageSize($this->pageSize);
20
+ }
21
+ }
app/code/community/VantageAnalytics/Analytics/Model/Export/Product.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Export_Product extends VantageAnalytics_Analytics_Model_Export_Base
4
+ {
5
+ public function __construct($pageSize=null, $api=null)
6
+ {
7
+ parent::__construct($pageSize, $api, 'Product');
8
+ }
9
+
10
+ protected function createCollection($website)
11
+ {
12
+ return Mage::getModel('catalog/product')->getCollection()
13
+ ->addWebsiteFilter($website->getId())
14
+ ->addAttributeToSelect('*');
15
+ }
16
+ }
17
+
app/code/community/VantageAnalytics/Analytics/Model/Export/Runner.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Export_Runner
4
+ {
5
+
6
+
7
+ protected function enqueue($method, $resource)
8
+ {
9
+ $api = new VantageAnalytics_Analytics_Model_Api_RequestQueue();
10
+ $api->enqueue($method, $resource);
11
+ }
12
+
13
+ public function run()
14
+ {
15
+ if ($this->isExportDone()) {
16
+ return;
17
+ }
18
+
19
+ $this->notifyExportStart();
20
+ $this->setExportDone(); // Hope for the best
21
+
22
+ $entities = array('Store', 'Customer', 'Product', 'Order');
23
+ Mage::helper('analytics/log')->logInfo("Start exporting all entities");
24
+ foreach ($entities as $entity) {
25
+ $exporter = Mage::getModel('analytics/Export_' . $entity);
26
+ $exporter->run();
27
+ }
28
+
29
+ $this->notifyExportComplete();
30
+ Mage::helper('analytics/log')->logInfo("Done exporting all entities");
31
+ }
32
+
33
+ public function isExportDone()
34
+ {
35
+ return Mage::helper('analytics/account')->isExportDone();
36
+ }
37
+
38
+ public function setExportDone($done=1)
39
+ {
40
+ return Mage::helper('analytics/account')->setExportDone($done);
41
+ }
42
+
43
+ protected function websiteIds()
44
+ {
45
+ $websites = Mage::app()->getWebsites();
46
+ $websiteIds = array();
47
+ foreach ($websites as $website) {
48
+ $websiteIds[] = $website->getId();
49
+ }
50
+ return $websiteIds;
51
+ }
52
+
53
+ public function notifyExportStart()
54
+ {
55
+ foreach ($this->websiteIds() as $websiteId) {
56
+ $exportStarting = array('entity_type' => 'export', 'store_ids' => array($websiteId));
57
+ $this->enqueue('start', $exportStarting);
58
+ }
59
+ }
60
+
61
+ public function notifyExportComplete()
62
+ {
63
+ foreach ($this->websiteIds() as $websiteId) {
64
+ $exportComplete = array('entity_type' => 'export', 'store_ids' => array($websiteId));
65
+ $this->enqueue('complete', $exportComplete);
66
+ }
67
+ }
68
+ }
app/code/community/VantageAnalytics/Analytics/Model/Export/Store.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Export_Store extends VantageAnalytics_Analytics_Model_Export_Base
4
+ {
5
+ public function __construct($pageSize=null, $api=null)
6
+ {
7
+ parent::__construct($pageSize, $api, 'Store');
8
+ }
9
+
10
+ protected function createCollection($website)
11
+ {
12
+ // stub out abstract function from base class
13
+ }
14
+
15
+ public function exportWebsite($website)
16
+ {
17
+ $this->exportEntity($website);
18
+ }
19
+ }
20
+
app/code/community/VantageAnalytics/Analytics/Model/Heartbeat.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Heartbeat
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->api = new VantageAnalytics_Analytics_Model_Api_Request();
8
+ }
9
+
10
+ public function send()
11
+ {
12
+ $data = VantageAnalytics_Analytics_Model_Debug::factory()->toVantage();
13
+
14
+ $this->api->send('create', $data);
15
+ }
16
+ }
app/code/community/VantageAnalytics/Analytics/Model/Observer/Base.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class VantageAnalytics_Analytics_Model_Observer_Base
3
+ {
4
+ public function __construct($transformer='')
5
+ {
6
+ $this->api = new VantageAnalytics_Analytics_Model_Api_RequestQueue();
7
+ $this->transformer = $transformer;
8
+ }
9
+
10
+ // abstract protected function
11
+ abstract protected function getEntity($event);
12
+
13
+ protected function collectData($entity)
14
+ {
15
+ $transform = Mage::getModel("analytics/Transformer_{$this->transformer}", $entity);
16
+ return $transform->toVantage();
17
+ }
18
+
19
+ public function isAdmin()
20
+ {
21
+ return (Mage::app()->getStore()->isAdmin() ||
22
+ Mage::getDesign()->getArea() == 'adminhtml');
23
+ }
24
+
25
+ public function performSave($observer)
26
+ {
27
+ try {
28
+ $entity = $this->getEntity($observer->getEvent());
29
+ $data = $this->collectData($entity);
30
+ $this->api->enqueue('create', $data);
31
+ } catch (Exception $e) {
32
+ Mage::helper('analytics/log')->logException($e);
33
+ }
34
+ }
35
+
36
+ public function performDelete($observer)
37
+ {
38
+ try {
39
+ $entity = $this->getEntity($observer->getEvent());
40
+ $data = $this->collectData($entity);
41
+ $this->api->enqueue('delete', $data);
42
+ } catch (Exception $e) {
43
+ Mage::helper('analytics/log')->logException($e);
44
+ }
45
+ }
46
+
47
+ }
app/code/community/VantageAnalytics/Analytics/Model/Observer/CatalogProduct.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_Observer_CatalogProduct extends VantageAnalytics_Analytics_Model_Observer_Base
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct("Product");
7
+ }
8
+
9
+ protected function getEntity($event)
10
+ {
11
+ return $event->getProduct();
12
+ }
13
+
14
+ public function catalogProductSaveAfter($observer)
15
+ {
16
+ $this->performSave($observer);
17
+ }
18
+
19
+ public function catalogProductDeleteAfter($observer)
20
+ {
21
+ $this->performDelete($observer);
22
+ }
23
+ }
app/code/community/VantageAnalytics/Analytics/Model/Observer/Customer.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_Observer_Customer extends VantageAnalytics_Analytics_Model_Observer_Base
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct('Customer');
7
+ }
8
+
9
+ protected function getEntity($event)
10
+ {
11
+ return $event->getCustomer();
12
+ }
13
+
14
+ public function customerRegisterSuccess($observer)
15
+ {
16
+ $this->performSave($observer);
17
+ }
18
+
19
+ public function customerSaveAfter($observer)
20
+ {
21
+ $this->performSave($observer);
22
+ }
23
+
24
+ public function customerDeleteAfter($observer)
25
+ {
26
+ $this->performDelete($observer);
27
+ }
28
+ }
29
+
app/code/community/VantageAnalytics/Analytics/Model/Observer/SalesOrder.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_Observer_SalesOrder extends VantageAnalytics_Analytics_Model_Observer_Base
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct('SalesOrder');
7
+ }
8
+
9
+ protected function getEntity($event)
10
+ {
11
+ return $event->getOrder();
12
+ }
13
+
14
+ protected function collectData($entity)
15
+ {
16
+ $data = parent::collectData($entity);
17
+
18
+ // Collect cookies from real shoppers and not site admins.
19
+ if (!$this->isAdmin()) {
20
+ $tracking = Mage::helper('analytics/tracking')->getTrackingFromCookie();
21
+ if ($tracking) {
22
+ $data = array_merge($data, $tracking);
23
+ }
24
+ }
25
+
26
+ return $data;
27
+ }
28
+
29
+ public function salesOrderSaveAfter($observer)
30
+ {
31
+ $this->performSave($observer);
32
+ }
33
+
34
+ public function salesOrderPlaceAfter($observer)
35
+ {
36
+ $this->performSave($observer);
37
+ }
38
+
39
+ public function salesOrderDeleteAfter($observer)
40
+ {
41
+ $this->performDelete($observer);
42
+ }
43
+ }
app/code/community/VantageAnalytics/Analytics/Model/Observer/SalesQuote.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_Observer_SalesQuote extends VantageAnalytics_Analytics_Model_Observer_Base
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct('SalesQuote');
7
+ }
8
+
9
+ protected function getEntity($event)
10
+ {
11
+ return $event->getQuote();
12
+ }
13
+
14
+ protected function collectData($entity)
15
+ {
16
+ $data = parent::collectData($entity);
17
+ if (!$this->isAdmin()) { // Get cookies from real shoppers, not site admins
18
+ $tracking = Mage::helper('analytics/tracking')->getTrackingFromCookie();
19
+ if ($tracking) {
20
+ $data = array_merge($data, $tracking);
21
+ }
22
+ }
23
+ return $data;
24
+ }
25
+
26
+ public function salesQuoteSaveAfter($observer)
27
+ {
28
+ $this->performSave($observer);
29
+ }
30
+ }
app/code/community/VantageAnalytics/Analytics/Model/Observer/Tracking.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Observer_Tracking
4
+ {
5
+ protected function isAdmin()
6
+ {
7
+ return (Mage::app()->getStore()->isAdmin() ||
8
+ Mage::getDesign()->getArea() == 'adminhtml');
9
+ }
10
+
11
+ public function controllerFrontInitBefore($observer)
12
+ {
13
+ try {
14
+ if ($this->isAdmin()) {
15
+ return;
16
+ }
17
+ $frontController = $observer->getEvent()->getFront();
18
+ $request = $frontController->getRequest();
19
+ Mage::helper('analytics/tracking')->setInitialCookie($request);
20
+ } catch (Exception $e) {
21
+ Mage::helper('analytics/log')->logException($e);
22
+ }
23
+ }
24
+ }
app/code/community/VantageAnalytics/Analytics/Model/ParentProduct.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_ParentProduct
3
+ {
4
+ public static function factory($product)
5
+ {
6
+ return new self($product);
7
+ }
8
+
9
+ public function __construct($product)
10
+ {
11
+ $this->product = $product;
12
+ }
13
+
14
+ public function id()
15
+ {
16
+ // Configurable products do not have parent products
17
+ // hence, there's no ParentProduct->id()
18
+ if ($this->_configurableProduct($this->product)) {
19
+ return NULL;
20
+ }
21
+
22
+ $parentProduct = $this->parent();
23
+
24
+ return $parentProduct ? $parentProduct->getId() : NULL;
25
+ }
26
+
27
+ public function parent()
28
+ {
29
+ // A parent is the configurable product related to a simple product
30
+ // A simple product can have multiple parents
31
+ // Parents can be "grouped products" or "configurable products"
32
+ // Only one of those parents can be a "configurable product"
33
+ // An example of a grouped product "Buy a phone and a car charger"
34
+ $parents = $this->_parents();
35
+
36
+ foreach($parents as $parent)
37
+ {
38
+ if ($this->_configurableProduct($parent))
39
+ {
40
+ return $parent;
41
+ }
42
+ }
43
+
44
+ return NULL;
45
+ }
46
+
47
+ private function _parents()
48
+ {
49
+ $parents = array();
50
+
51
+ $parentIds = $this->_parentIds();
52
+
53
+ foreach($parentIds as $parentId) {
54
+ $parents[] = Mage::getModel('catalog/product')->load($parentId);
55
+ }
56
+
57
+ return $parents;
58
+ }
59
+
60
+ private function _parentIds()
61
+ {
62
+ return Mage::getModel('catalog/product_type_configurable')
63
+ ->getParentIdsByChild($this->product->getId());
64
+ }
65
+
66
+ private function _configurableProduct($product)
67
+ {
68
+ return ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
69
+ }
70
+ }
app/code/community/VantageAnalytics/Analytics/Model/ProductCategories.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_ProductCategories
3
+ {
4
+ public static function factory($product)
5
+ {
6
+ return new self($product);
7
+ }
8
+
9
+ public function __construct($product)
10
+ {
11
+ $this->product = $product;
12
+ }
13
+
14
+ public function categories()
15
+ {
16
+ $categories = array();
17
+
18
+ foreach ($this->_categoryIds() as $catId) {
19
+ $categories[$catId] = $this->_getCategoryName($catId);
20
+ }
21
+
22
+ return $categories;
23
+ }
24
+
25
+ private function _categoryIds()
26
+ {
27
+ return $this->product->getCategoryIds();
28
+ }
29
+
30
+ private function _getCategoryName($categoryId)
31
+ {
32
+ $category = Mage::getModel('catalog/category')->load($categoryId);
33
+
34
+ return $category->getName();
35
+ }
36
+
37
+ }
app/code/community/VantageAnalytics/Analytics/Model/ProductImages.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_ProductImages
3
+ {
4
+ public static function factory($product)
5
+ {
6
+ return new self($product);
7
+ }
8
+
9
+ public function __construct($product)
10
+ {
11
+ $this->product = $product;
12
+ $this->config = $product->getMediaConfig();
13
+ }
14
+
15
+ public function urls()
16
+ {
17
+ return array(
18
+ "base" => $this->_imageUrl($this->_baseImage()),
19
+ "small" => $this->_imageUrl($this->_smallImage()),
20
+ "thumbnail" => $this->_imageUrl($this->_thumbnail())
21
+ );
22
+ }
23
+
24
+ private function _imageUrl($image)
25
+ {
26
+ return $image ? $this->config->getMediaUrl($image) : NULL;
27
+ }
28
+
29
+ private function _baseImage()
30
+ {
31
+ return $this->product->getImage();
32
+ }
33
+
34
+ private function _smallImage()
35
+ {
36
+ return $this->product->getSmallImage();
37
+ }
38
+
39
+ private function _thumbnail()
40
+ {
41
+ return $this->product->getThumbnail();
42
+ }
43
+
44
+ }
app/code/community/VantageAnalytics/Analytics/Model/ProductOptions.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_ProductOptions
3
+ {
4
+ public static function factory($lineItem)
5
+ {
6
+ return new self($lineItem);
7
+ }
8
+
9
+ public function __construct($lineItem)
10
+ {
11
+ $this->lineItem = $lineItem;
12
+ $this->product = $this->lineItem->getProduct();
13
+ }
14
+
15
+ public function _configurableProduct()
16
+ {
17
+ $type = $this->product->getTypeID();
18
+ return ($type == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
19
+ }
20
+
21
+ public function options()
22
+ {
23
+ // Only configurable products have options
24
+ // If we dont have product options, send NULL
25
+ // PHP converts empty dictionaries to arrays
26
+ // and with forceObject set, it breaks other things
27
+ if (!$this->_configurableProduct()) {
28
+ return NULL;
29
+ }
30
+
31
+ $attributes = $this->_attributes();
32
+ $options = array();
33
+ foreach ($attributes as $option) {
34
+ $options += $this->_buildSelection($option);
35
+ }
36
+
37
+ return empty($options) ? NULL : $options;
38
+ }
39
+
40
+ private function _attributes() {
41
+ $attributes = $this->lineItem->getProductOptions();
42
+ return $attributes['attributes_info'];
43
+ }
44
+
45
+ private function _buildSelection($option) {
46
+ $values = array_map("strtolower", array_values($option));
47
+ return array($values[0] => $values[1]);
48
+ }
49
+
50
+ }
app/code/community/VantageAnalytics/Analytics/Model/Queue/Adapter/Db.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Queue_Adapter_Db extends Zend_Queue_Adapter_Db
4
+ {
5
+ public function __construct($options, Zend_Queue $queue = null)
6
+ {
7
+ parent::__construct($options, $queue);
8
+ if (isset($options['queueTableName'])) {
9
+ $this->_queueTable->setOptions(
10
+ array(Zend_Db_Table_Abstract::NAME => $options['queueTableName'])
11
+ );
12
+ }
13
+ if (isset($options['messageTableName'])) {
14
+ $this->_messageTable->setOptions(
15
+ array(Zend_Db_Table_Abstract::NAME => $options['messageTableName'])
16
+ );
17
+ }
18
+ }
19
+ }
app/code/community/VantageAnalytics/Analytics/Model/Resource/Mysql4/Setup.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
4
+ {
5
+ public function resetConfig()
6
+ {
7
+ Mage::helper('analytics/account')->setIsVerified(0);
8
+ }
9
+ }
app/code/community/VantageAnalytics/Analytics/Model/SubscriberInformation.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_SubscriberInformation
3
+ {
4
+ public static function factory($email)
5
+ {
6
+ return new self($email);
7
+ }
8
+
9
+ public function __construct($email)
10
+ {
11
+ $this->email = $email;
12
+ }
13
+
14
+ private function _subscribedStatus()
15
+ {
16
+ // http://docs.magentocommerce.com/Mage_Newsletter/Mage_Newsletter_Model_Subscriber.html
17
+ // STATUS_NOT_ACTIVE = 2
18
+ // STATUS_SUBSCRIBED = 1
19
+ // STATUS_UNCONFIRMED = 4
20
+ // STATUS_UNSUBSCRIBED = 3
21
+
22
+ return 1;
23
+ }
24
+
25
+ public function subscriber()
26
+ {
27
+ return Mage::getModel('newsletter/subscriber')
28
+ ->loadByEmail($this->email);
29
+ }
30
+
31
+ public function status()
32
+ {
33
+ return $this->subscriber()->getStatus();
34
+
35
+ }
36
+
37
+ public function acceptsMarketing()
38
+ {
39
+ return $this->status() == $this->_subscribedStatus();
40
+ }
41
+
42
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/Address.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_Address
4
+ {
5
+ public function __construct($magentoAddress, $addressType='')
6
+ {
7
+ $this->address = $magentoAddress;
8
+ $this->addressType = $addressType;
9
+ }
10
+
11
+ public static function factory($magentoAddress, $addressType='')
12
+ {
13
+ return new self($magentoAddress, $addressType);
14
+ }
15
+
16
+ public function externalIdentifier()
17
+ {
18
+ return $this->address->getId();
19
+ }
20
+
21
+ public function addressLine1()
22
+ {
23
+ return $this->address ? $this->address->getStreet1() : '';
24
+ }
25
+
26
+ public function addressLine2()
27
+ {
28
+ return $this->address ? $this->address->getStreet2() : '';
29
+ }
30
+
31
+ public function city()
32
+ {
33
+ return $this->address ? $this->address->getCity() : '';
34
+ }
35
+
36
+ public function province()
37
+ {
38
+ // Note to self, get region returns the name
39
+ // when called on a customer/address model.
40
+ return $this->address ? $this->address->getRegion() : '';
41
+ }
42
+
43
+ public function provinceCode()
44
+ {
45
+ return $this->address ? $this->address->getRegionCode() : '';
46
+ }
47
+
48
+ protected function countryModel()
49
+ {
50
+ if($this->address) {
51
+ return $this->address->getCountryModel();
52
+ }
53
+
54
+ return '';
55
+ }
56
+
57
+ public function country()
58
+ {
59
+ if($this->address) {
60
+ return $this->countryModel()->getName();
61
+ }
62
+
63
+ return '';
64
+
65
+ }
66
+
67
+ public function countryCode()
68
+ {
69
+ if($this->address) {
70
+ return $this->countryModel()->getCountryId();
71
+ }
72
+
73
+ return '';
74
+ }
75
+
76
+ public function telephone()
77
+ {
78
+ return $this->address ? $this->address->getTelephone() :'';
79
+ }
80
+
81
+ public function postalCode()
82
+ {
83
+ return $this->address ? $this->address->getPostcode() : '';
84
+ }
85
+
86
+ public function company()
87
+ {
88
+ return $this->address ? $this->address->getCompany() : '';
89
+ }
90
+
91
+ public function type()
92
+ {
93
+ return $this->addressType;
94
+ }
95
+
96
+ public function entityType()
97
+ {
98
+ return "address";
99
+ }
100
+
101
+ public function toVantage()
102
+ {
103
+ $prefix = '';
104
+ if ($this->type()) {
105
+ $prefix = $this->type() . "_";
106
+ }
107
+
108
+ $data = array(
109
+ "{$prefix}address_line_1" => $this->addressLine1(),
110
+ "{$prefix}address_line_2" => $this->addressLine2(),
111
+ "{$prefix}city" => $this->city(),
112
+ "{$prefix}province" => $this->province(),
113
+ "{$prefix}country" => $this->country(),
114
+ "{$prefix}postal_code" => $this->postalCode(),
115
+ "{$prefix}province_code" => $this->provinceCode(),
116
+ "{$prefix}country_code" => $this->countryCode(),
117
+ "{$prefix}company" => $this->company(),
118
+ );
119
+
120
+ return $data;
121
+ }
122
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/Base.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class VantageAnalytics_Analytics_Model_Transformer_Base
4
+ {
5
+ /* Magento returns the "created_at" in the store's
6
+ * timezone thus, it needs to be converted to UTC.
7
+ * 'updated_at' is already in UTC, and does not
8
+ * require conversion. Neither are formatted correctly.
9
+ */
10
+ public function __construct($magentoEntity)
11
+ {
12
+ $this->entity = $magentoEntity;
13
+ $this->data = $this->entity->getData();
14
+ }
15
+
16
+ public function sourceCreatedAt()
17
+ {
18
+ $name = 'created_at';
19
+
20
+ if (isset($this->data[$name])) {
21
+ return VantageAnalytics_Analytics_Helper_DateFormatter::factory(
22
+ $this->data[$name]
23
+ )->toUtcDate();
24
+ }
25
+
26
+ return NULL;
27
+ }
28
+
29
+ public function sourceUpdatedAt()
30
+ {
31
+ $name = 'updated_at';
32
+
33
+ if (isset($this->data[$name])) {
34
+ return VantageAnalytics_Analytics_Helper_DateFormatter::factory(
35
+ $this->data[$name]
36
+ )->toDate();
37
+ }
38
+
39
+ return NULL;
40
+ }
41
+
42
+ public abstract function entityType();
43
+ public abstract function toVantage();
44
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/BaseSales.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class VantageAnalytics_Analytics_Model_Transformer_BaseSales extends VantageAnalytics_Analytics_Model_Transformer_Base
4
+ {
5
+ public function __construct($magentoSalesEntity)
6
+ {
7
+ parent::__construct($magentoSalesEntity);
8
+
9
+ $this->billingAddress = VantageAnalytics_Analytics_Model_Transformer_Address::factory(
10
+ $this->entity->getBillingAddress(), 'billing');
11
+
12
+ $this->shippingAddress = VantageAnalytics_Analytics_Model_Transformer_Address::factory(
13
+ $this->entity->getShippingAddress(), 'shipping');
14
+ }
15
+
16
+ protected abstract function orderStatus();
17
+ protected abstract function paymentStatus();
18
+ protected abstract function fulfillmentStatus();
19
+ protected abstract function currencyCode();
20
+ protected abstract function processingMethod();
21
+ protected abstract function cardType();
22
+ protected abstract function totalQuantity();
23
+ protected abstract function refund();
24
+
25
+
26
+ protected abstract function lineItems();
27
+ protected abstract function buildLine($item);
28
+
29
+ // lines returns line items for internal use
30
+ protected function _lines()
31
+ {
32
+ return $this->entity->getAllVisibleItems();
33
+ }
34
+
35
+ protected function storeIds()
36
+ {
37
+ return array($this->entity->getStore()->getWebsiteId());
38
+ }
39
+
40
+ protected function externalIdentifier()
41
+ {
42
+ return $this->entity->getEntityId();
43
+ }
44
+
45
+ protected function sourceName()
46
+ {
47
+ return 'web';
48
+ }
49
+
50
+ protected function customerExternalId()
51
+ {
52
+ $customerId = $this->entity->getCustomerId();
53
+ return strlen($customerId) > 0 ? $customerId : null;
54
+ }
55
+
56
+ protected function customerFirstName()
57
+ {
58
+ return $this->entity->getCustomerFirstname();
59
+ }
60
+
61
+ protected function customerLastName()
62
+ {
63
+ return $this->entity->getCustomerLastname();
64
+ }
65
+
66
+ protected function customerCompany()
67
+ {
68
+ // Confirmed the customer doesn't have company
69
+ // you can customize magento to make company
70
+ // a required field, but it's not part of the
71
+ // default install
72
+ return $this->billingAddress->company();
73
+ }
74
+
75
+ protected function customerEmail()
76
+ {
77
+ return $this->entity->getCustomerEmail();
78
+ }
79
+
80
+ protected function landingSite()
81
+ {
82
+ // XXX to implement
83
+ }
84
+
85
+ protected function referringSite()
86
+ {
87
+ // XXX to implement
88
+ }
89
+
90
+ protected function subtotal()
91
+ {
92
+ return $this->entity->getSubtotal();
93
+ }
94
+
95
+ protected function tax()
96
+ {
97
+ return $this->entity->getTaxAmount();
98
+ }
99
+
100
+ protected function discount()
101
+ {
102
+ return $this->entity->getDiscountAmount();
103
+ }
104
+
105
+ protected function shippingCost()
106
+ {
107
+ return $this->entity->getShippingAmount();
108
+ }
109
+
110
+ protected function total()
111
+ {
112
+ return $this->entity->getGrandTotal();
113
+ }
114
+
115
+ protected function externalParentIdentifier()
116
+ {
117
+ return NULL;
118
+ }
119
+
120
+ public function toVantage()
121
+ {
122
+ $quoteData = array(
123
+ "external_identifier" => $this->externalIdentifier(),
124
+ "store_ids" => $this->storeIds(),
125
+ "source_created_at" => $this->sourceCreatedAt(),
126
+ "source_updated_at" => $this->sourceUpdatedAt(),
127
+ "source_name" => $this->sourceName(),
128
+ "customer_external_id" => $this->customerExternalId(),
129
+ "customer_first_name" => $this->customerFirstName(),
130
+ "customer_last_name" => $this->customerLastName(),
131
+ "customer_company" => $this->customerCompany(),
132
+ "customer_email" => $this->customerEmail(),
133
+ "order_status" => $this->orderStatus(),
134
+ "payment_status" => $this->paymentStatus(),
135
+ "fulfillment_status" => $this->fulfillmentStatus(),
136
+ "landing_site" => $this->landingSite(),
137
+ "referring_site" => $this->referringSite(),
138
+ "currency_code" => $this->currencyCode(),
139
+ "processing_method" => $this->processingMethod(),
140
+ "card_type" => $this->cardType(),
141
+ "total_quantity" => $this->totalQuantity(),
142
+ "subtotal" => $this->subtotal(),
143
+ "tax" => $this->tax(),
144
+ "discount" => $this->discount(),
145
+ "shipping_cost" => $this->shippingCost(),
146
+ "total" => $this->total(),
147
+ "refund" => $this->refund(),
148
+ "entity_type" => $this->entityType(),
149
+ "external_parent_identifier" => $this->externalParentIdentifier(),
150
+ "line_items" => $this->lineItems()
151
+ );
152
+
153
+ $shippingAddressData = $this->shippingAddress->toVantage();
154
+ $billingAddressData = $this->billingAddress->toVantage();
155
+ $data = array_merge($quoteData, $shippingAddressData, $billingAddressData);
156
+
157
+ return $data;
158
+ }
159
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/BaseSalesItem.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class VantageAnalytics_Analytics_Model_Transformer_BaseSalesItem extends VantageAnalytics_Analytics_Model_Transformer_Base
4
+ {
5
+ public abstract function externalParentIdentifier();
6
+ public abstract function quantity();
7
+ public abstract function price();
8
+
9
+ public function externalIdentifier()
10
+ {
11
+ return $this->entity->getItemId();
12
+ }
13
+
14
+ public function storeIds()
15
+ {
16
+ return array($this->entity->getStore()->getWebsiteId());
17
+ }
18
+
19
+ public function externalProductId()
20
+ {
21
+ return $this->entity->getProductId();
22
+ }
23
+
24
+ protected function _magentoProduct()
25
+ {
26
+ return $this->entity->getProduct();
27
+ }
28
+
29
+ public function productName()
30
+ {
31
+ return $this->_magentoProduct()->getName();
32
+ }
33
+
34
+ public function sku()
35
+ {
36
+ return $this->_magentoProduct()->getSku();
37
+ }
38
+
39
+ public function entityType()
40
+ {
41
+ return "lineItem";
42
+ }
43
+
44
+ public function productOptions()
45
+ {
46
+ return VantageAnalytics_Analytics_Model_ProductOptions::factory($this->entity)
47
+ ->options();
48
+ }
49
+
50
+ public function toVantage()
51
+ {
52
+ $lineData = array(
53
+ "external_identifier" => $this->externalIdentifier(),
54
+ "store_ids" => $this->storeIds(),
55
+ "source_created_at" => $this->sourceCreatedAt(),
56
+ "source_updated_at" => $this->sourceUpdatedAt(),
57
+ "external_product_id" => $this->externalProductId(),
58
+ "product_name" => $this->productName(),
59
+ "sku" => $this->sku(),
60
+ "price" => $this->price(),
61
+ "quantity" => $this->quantity(),
62
+ "product_options" => $this->productOptions()
63
+ );
64
+
65
+ return $lineData;
66
+ }
67
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/Customer.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_Customer extends VantageAnalytics_Analytics_Model_Transformer_Base
4
+ {
5
+
6
+ public static function factory($magentoCustomer)
7
+ {
8
+ return new self($magentoCustomer);
9
+ }
10
+
11
+ public function storeIds()
12
+ {
13
+ return array($this->entity->getStore()->getWebsiteId());
14
+ }
15
+
16
+ public function externalIdentifier()
17
+ {
18
+ return $this->entity->getId();
19
+ }
20
+
21
+ public function email()
22
+ {
23
+ return $this->entity->getEmail();
24
+ }
25
+
26
+ public function firstName()
27
+ {
28
+ return $this->entity->getFirstname();
29
+ }
30
+
31
+ public function lastName()
32
+ {
33
+ return $this->entity->getLastname();
34
+ }
35
+
36
+ public function emailVerified()
37
+ {
38
+ return $this->entity->getConfirmation() == NULL;
39
+ }
40
+
41
+ public function acceptsMarketing()
42
+ {
43
+ $subscriber = VantageAnalytics_Analytics_Model_SubscriberInformation::factory($this->email());
44
+ return $subscriber->acceptsMarketing();
45
+ }
46
+
47
+ public function company()
48
+ {
49
+ return $this->entity->getCompany();
50
+ }
51
+
52
+ public function phoneNumber()
53
+ {
54
+ $address = $this->entity->getDefaultAddress();
55
+ }
56
+
57
+ public function entityType()
58
+ {
59
+ return "customer";
60
+ }
61
+
62
+ public function toVantage()
63
+ {
64
+
65
+ $address =
66
+ VantageAnalytics_Analytics_Model_AddressRetriever::factory($this->entity)
67
+ ->address();
68
+
69
+ $vantageAddress =
70
+ VantageAnalytics_Analytics_Model_Transformer_Address::factory($address);
71
+
72
+ $c = array();
73
+
74
+ $c['entity_type'] = $this->entityType();
75
+ $c['external_identifier'] = $this->externalIdentifier();
76
+ $c['store_ids'] = $this->storeIds();
77
+ $c['source_created_at'] = $this->sourceCreatedAt();
78
+ $c['source_updated_at'] = $this->sourceUpdatedAt();
79
+ $c['first_name'] = $this->firstName();
80
+ $c['last_name'] = $this->lastName();
81
+ $c['email'] = $this->email();
82
+ $c['email_verified'] = $this->emailVerified();
83
+ $c['accepts_marketing'] = $this->acceptsMarketing();
84
+ $c['company'] = $this->company();
85
+ $c["phone"] = $vantageAddress->telephone();
86
+ $c["external_address_id"] = $vantageAddress->externalIdentifier();
87
+ $c["address_line_1"] = $vantageAddress->addressLine1();
88
+ $c["address_line_2"] = $vantageAddress->addressLine2();
89
+ $c["city"] = $vantageAddress->city();
90
+ $c["province"] = $vantageAddress->province();
91
+ $c["country"] = $vantageAddress->country();
92
+ $c["postal_code"] = $vantageAddress->postalCode();
93
+ $c["province_code"] = $vantageAddress->provinceCode();
94
+ $c["country_code"] = $vantageAddress->countryCode();
95
+ $c["type"] = $vantageAddress->type();
96
+
97
+ $c["addresses"] = null;
98
+
99
+ return $c;
100
+ }
101
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/Product.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class VantageAnalytics_Analytics_Model_Transformer_Product extends VantageAnalytics_Analytics_Model_Transformer_Base
3
+ {
4
+ public static function factory($magentoProduct)
5
+ {
6
+ return new VantageAnalytics_Analytics_Model_Transformer_Product($magentoProduct);
7
+ }
8
+
9
+ public function entityType()
10
+ {
11
+ return "product";
12
+ }
13
+
14
+ public function storeIds()
15
+ {
16
+ return $this->entity->getWebsiteIds();
17
+ }
18
+
19
+ public function externalIdentifier()
20
+ {
21
+ return $this->entity->getId();
22
+ }
23
+
24
+ public function externalParentIdentifier()
25
+ {
26
+ return VantageAnalytics_Analytics_Model_ParentProduct::factory($this->entity)
27
+ ->id();
28
+ }
29
+
30
+ public function name()
31
+ {
32
+ return $this->entity->getName();
33
+ }
34
+
35
+ public function type()
36
+ {
37
+ return $this->entity->getTypeId();
38
+ }
39
+
40
+ public function sku()
41
+ {
42
+ return $this->entity->getSku();
43
+ }
44
+
45
+ public function taxable()
46
+ {
47
+ return $this->entity->getTaxClassId() == 2;
48
+ }
49
+
50
+ public function availability()
51
+ {
52
+ return $this->entity->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
53
+ }
54
+
55
+ public function price()
56
+ {
57
+ // XXX: Final price vs. price
58
+ return $this->entity->getPrice();
59
+ }
60
+
61
+ public function weight()
62
+ {
63
+ return $this->entity->getWeight();
64
+ }
65
+
66
+ public function shippingRequired()
67
+ {
68
+ return $this->type() != Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL;
69
+ }
70
+
71
+ public function quantity()
72
+ {
73
+ return Mage::getModel('cataloginventory/stock_item')
74
+ ->loadByProduct($this->externalIdentifier())
75
+ ->getQty();
76
+ }
77
+
78
+ public function productUrl()
79
+ {
80
+ // Reload the product in the context of the store
81
+ // to get the correct url for the product
82
+ $product = Mage::helper('catalog/product')->getProduct(
83
+ $this->externalIdentifier(),
84
+ Mage::app()->getStore()->getId()
85
+ );
86
+
87
+ return empty($product) ? NULL: $product->getProductUrl();
88
+ }
89
+
90
+ public function imageUrls()
91
+ {
92
+ $images = VantageAnalytics_Analytics_Model_ProductImages::factory($this->entity);
93
+ return $images->urls();
94
+ }
95
+
96
+ public function categories()
97
+ {
98
+ return VantageAnalytics_Analytics_Model_ProductCategories::factory($this->entity)
99
+ ->categories();
100
+ }
101
+
102
+ public function toVantage()
103
+ {
104
+ $product = Array();
105
+
106
+ $product['store_ids'] = $this->storeIds();
107
+ $product['external_identifier'] = $this->externalIdentifier();
108
+ $product['external_parent_identifier'] = $this->externalParentIdentifier();
109
+ $product['source_created_at'] = $this->sourceCreatedAt();
110
+ $product['source_updated_at'] = $this->sourceUpdatedAt();
111
+ $product['name'] = $this->name();
112
+ $product['type'] = $this->type();
113
+ $product['sku'] = $this->sku();
114
+ $product['taxable'] = $this->taxable();
115
+ $product['availability'] = $this->availability();
116
+ $product['price'] = $this->price();
117
+ $product['weight'] = $this->weight();
118
+ $product['requires_shipping'] = $this->shippingRequired();
119
+ $product['quantity'] = $this->quantity();
120
+ $product['entity_type'] = $this->entityType();
121
+ $product['images'] = $this->imageUrls();
122
+ $product['categories'] = $this->categories();
123
+ $product['url'] = $this->productUrl();
124
+
125
+ return $product;
126
+ }
127
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesOrder.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_SalesOrder extends VantageAnalytics_Analytics_Model_Transformer_BaseSales
4
+ {
5
+ public static function factory($magentoSalesEntity)
6
+ {
7
+ return new self($magentoSalesEntity);
8
+ }
9
+
10
+ public function __construct($magentoSalesEntity)
11
+ {
12
+ parent::__construct($magentoSalesEntity);
13
+
14
+ $this->statuses = VantageAnalytics_Analytics_Helper_Statuses::factory($magentoSalesEntity);
15
+ }
16
+
17
+ public function entityType()
18
+ {
19
+ return "order";
20
+ }
21
+
22
+ protected function orderStatus()
23
+ {
24
+ return $this->statuses->orderStatus();
25
+ }
26
+
27
+ protected function paymentStatus()
28
+ {
29
+ return $this->statuses->paymentStatus();
30
+ }
31
+
32
+ protected function fulfillmentStatus()
33
+ {
34
+ return $this->statuses->fulfillmentStatus();
35
+ }
36
+
37
+ protected function landingSite()
38
+ {
39
+ // XXX - this requires that we sniff out tracking cookies
40
+ }
41
+
42
+ protected function referringSite()
43
+ {
44
+ // XXX - this requires that we sniff out tracking cookies
45
+ }
46
+
47
+ protected function currencyCode()
48
+ {
49
+ return $this->entity->getOrderCurrency()->getCode();
50
+ }
51
+
52
+ protected function processingMethod()
53
+ {
54
+ $payment = $this->entity->getPayment();
55
+ if ($payment)
56
+ {
57
+ return $payment->getCode();
58
+ }
59
+ }
60
+
61
+ protected function cardType()
62
+ {
63
+ $payment = $this->entity->getPayment();
64
+
65
+ return $payment ? $payment->getCcTypeName() : NULL;
66
+ }
67
+
68
+ protected function refund()
69
+ {
70
+ return $this->entity->getData('total_refunded');
71
+ }
72
+
73
+ public function externalParentIdentifier()
74
+ {
75
+ return $this->entity->getQuoteId();
76
+ }
77
+
78
+ protected function totalQuantity()
79
+ {
80
+ // Total item is only avaialable on order
81
+ $total = 0;
82
+
83
+ foreach($this->_lines() as $item) {
84
+ $total += $item->getQtyOrdered();
85
+ }
86
+
87
+ return $total;
88
+ }
89
+
90
+ protected function lineItems()
91
+ {
92
+ $lines = array();
93
+
94
+ foreach ($this->_lines() as $item) {
95
+ $lines[] = $this->buildLine($item);
96
+ }
97
+
98
+ return $lines;
99
+ }
100
+
101
+ protected function buildLine($item)
102
+ {
103
+ return VantageAnalytics_Analytics_Model_Transformer_SalesOrderLineItem::factory($item)
104
+ ->toVantage();
105
+ }
106
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesOrderLineItem.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_SalesOrderLineItem extends VantageAnalytics_Analytics_Model_Transformer_BaseSalesItem
4
+ {
5
+ public static function factory($magentoSalesOrderLineItem)
6
+ {
7
+ return new self($magentoSalesOrderLineItem);
8
+ }
9
+
10
+ public function storeIds()
11
+ {
12
+ $storeId = $this->entity->getStoreId();
13
+ return array(
14
+ Mage::getModel('core/store')->load($storeId)->getWebsiteId()
15
+ );
16
+ }
17
+
18
+ public function externalIdentifier()
19
+ {
20
+ return $this->entity->getItemId();
21
+ }
22
+
23
+ public function externalOrderIdentifier()
24
+ {
25
+ return $this->entity->getOrderId();
26
+ }
27
+
28
+ public function externalProductId()
29
+ {
30
+ return $this->entity->getProductId();
31
+ }
32
+
33
+ private function magentoProduct()
34
+ {
35
+ $id = $this->externalProductId();
36
+
37
+ return Mage::getModel('catalog/product')->load($id);
38
+ }
39
+
40
+ public function productName()
41
+ {
42
+ return $this->magentoProduct()->getName();
43
+ }
44
+
45
+ public function sku()
46
+ {
47
+ return $this->magentoProduct()->getSku();
48
+ }
49
+
50
+ public function externalParentIdentifier()
51
+ {
52
+ return $this->entity->getOrderId();
53
+ }
54
+
55
+ public function quantity()
56
+ {
57
+ // Get total item quantity *ordered*
58
+ return $this->entity->getQtyOrdered();
59
+ }
60
+
61
+ public function price()
62
+ {
63
+ // price here is the item price, w/o discounts applied.
64
+ return $this->entity->getOriginalPrice();
65
+ }
66
+
67
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesQuote.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_SalesQuote extends VantageAnalytics_Analytics_Model_Transformer_BaseSales
4
+ {
5
+ public static function factory($magentoSalesEntity)
6
+ {
7
+ return new self($magentoSalesEntity);
8
+ }
9
+
10
+ public function entityType()
11
+ {
12
+ return "quote";
13
+ }
14
+
15
+ private function _store()
16
+ {
17
+ $store = $this->entity->getStore();
18
+ return VantageAnalytics_Analytics_Model_Transformer_Store::factory($store->getWebsite());
19
+ }
20
+
21
+ public function orderStatus()
22
+ {
23
+ return "open";
24
+ }
25
+
26
+ public function paymentStatus()
27
+ {
28
+ return "unpaid";
29
+ }
30
+
31
+ public function fulfillmentStatus()
32
+ {
33
+ return "unfulfilled";
34
+ }
35
+
36
+ public function processingMethod()
37
+ {
38
+ return NULL;
39
+ }
40
+
41
+ public function cardType()
42
+ {
43
+ return NULL;
44
+ }
45
+
46
+ public function refund()
47
+ {
48
+ return 0.0000;
49
+ }
50
+
51
+ // Currency logic
52
+ // global - currency which is set for default in backend
53
+ // base - currency which is set for current website. all attributes that
54
+ // have 'base_' prefix saved in this currency
55
+ // store - all the time it was currency of website and all attributes
56
+ // quote/order - currency which was selected by customer or configured by
57
+ // admin for current store. currency in which customer sees
58
+ // price thought all checkout.
59
+ public function currencyCode()
60
+ {
61
+ return $this->_store()->currencyCode();
62
+ }
63
+
64
+ public function totalQuantity()
65
+ {
66
+ return $this->entity->getItemsQty();
67
+ }
68
+
69
+ protected function lineItems()
70
+ {
71
+ $lines = array();
72
+
73
+ foreach ($this->_lines() as $item) {
74
+ $lines[] = $this->buildLine($item);
75
+ }
76
+
77
+ return $lines;
78
+ }
79
+
80
+ protected function buildLine($item)
81
+ {
82
+ return VantageAnalytics_Analytics_Model_Transformer_SalesQuoteLineItem::factory($item)
83
+ ->toVantage();
84
+ }
85
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/SalesQuoteLineItem.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_SalesQuoteLineItem extends VantageAnalytics_Analytics_Model_Transformer_BaseSalesItem
4
+ {
5
+ public static function factory($magentoSalesQuoteLineItem)
6
+ {
7
+ return new self($magentoSalesQuoteLineItem);
8
+ }
9
+
10
+ public function externalParentIdentifier()
11
+ {
12
+ return $this->entity->getQuoteId();
13
+ }
14
+
15
+ public function quantity()
16
+ {
17
+ // Get total item quantity (include parent item relation)
18
+ // I have very little idea of what this means (now)
19
+ return $this->entity->getTotalQty();
20
+ }
21
+
22
+ public function price()
23
+ {
24
+ // price here is the item price, w/o discounts applied.
25
+ return $this->_magentoProduct()->getPrice();
26
+ }
27
+ }
app/code/community/VantageAnalytics/Analytics/Model/Transformer/Store.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Model_Transformer_Store extends VantageAnalytics_Analytics_Model_Transformer_Base
4
+ {
5
+
6
+ public function __construct($magentoWebsite)
7
+ {
8
+ $this->website = $magentoWebsite;
9
+ $this->entity = $magentoWebsite->getDefaultStore();
10
+ }
11
+
12
+ public static function factory($magentoWebsite)
13
+ {
14
+ return new self($magentoWebsite);
15
+ }
16
+
17
+ public function sourceCreatedAt()
18
+ {
19
+ $config = Mage::app()->getConfig();
20
+
21
+ return VantageAnalytics_Analytics_Helper_DateFormatter::factory(
22
+ $config->getNode('global/install/date')
23
+ )->toDate();
24
+
25
+ }
26
+
27
+ public function sourceUpdatedAt()
28
+ {
29
+ return date("c");
30
+ }
31
+
32
+ public function storeId()
33
+ {
34
+ return $this->website->getId();
35
+ }
36
+
37
+ public function storeIds()
38
+ {
39
+ return array($this->storeId());
40
+ }
41
+
42
+ public function externalIdentifier()
43
+ {
44
+ return $this->entity->getId();
45
+ }
46
+
47
+ public function domain()
48
+ {
49
+ return $this->entity->getBaseUrl();
50
+ }
51
+
52
+ public function name()
53
+ {
54
+ return $this->website->getName();
55
+ }
56
+
57
+ public function countryCode()
58
+ {
59
+ // general settings apply to stores/websites in installation
60
+ return Mage::getStoreConfig('general/country/default', $this->entity->getId());
61
+ }
62
+
63
+ public function country()
64
+ {
65
+ $code = $this->countryCode();
66
+
67
+ return Mage::getModel('directory/country')
68
+ ->loadByCode($code)
69
+ ->getName();
70
+ }
71
+
72
+ public function currencyCode()
73
+ {
74
+ return $this->entity->getCurrentCurrencyCode();
75
+ }
76
+
77
+ public function readOnly()
78
+ {
79
+ // Would map to "password enabled"
80
+ return $this->entity->isReadOnly();
81
+ }
82
+
83
+ public function localeCode()
84
+ {
85
+ $locale = Mage::app()->getLocale();
86
+
87
+ return $locale->getLocaleCode();
88
+ }
89
+
90
+ public function language()
91
+ {
92
+ $locale = Mage::app()->getLocale();
93
+
94
+ return $locale->getLocaleCode();
95
+ }
96
+
97
+ public function timezone()
98
+ {
99
+ $locale = Mage::app()->getLocale();
100
+
101
+ return $locale->getTimezone();
102
+ }
103
+
104
+ public function addressLine()
105
+ {
106
+ // Magento uses a free form address field for the store
107
+ return Mage::getStoreConfig('general/store_information/address', $this->storeId());
108
+ }
109
+
110
+ public function shopOwnerPhone()
111
+ {
112
+ return Mage::getStoreConfig('general/store_information/phone', $this->storeId());
113
+ }
114
+
115
+ public function shopOwnerEmail()
116
+ {
117
+ // Best guess is that this is the store's email address
118
+ return Mage::getStoreConfig('trans_email/ident_general/email', $this->storeId());
119
+ }
120
+
121
+ public function supportEmail()
122
+ {
123
+ return Mage::getStoreConfig('trans_email/ident_support/email', $this->storeId());
124
+ }
125
+
126
+ public function shopOwnerName()
127
+ {
128
+ return Mage::getStoreConfig('trans_email/ident_general/name', $this->storeId());
129
+ }
130
+
131
+ public function entityType()
132
+ {
133
+ return "store";
134
+ }
135
+
136
+ public function toVantage()
137
+ {
138
+ $methods = array_diff(
139
+ get_class_methods($this),
140
+ array('toVantage', '__construct', 'factory')
141
+ );
142
+ $data = array();
143
+ foreach ($methods as $method) {
144
+ $attr = strtolower(preg_replace(
145
+ '/(?<=\\w)(?=[A-Z])/',"_$1", $method));
146
+ $data[$attr] = call_user_func(array($this, $method));
147
+ }
148
+ return $data;
149
+ }
150
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Api/Signature.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_Api_Signature extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ /**
6
+ * @test
7
+ */
8
+ public function sign()
9
+ {
10
+ $signer = new VantageAnalytics_Analytics_Model_Api_Signature('', '');
11
+ $this->assertEquals(
12
+ "b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad",
13
+ $signer->sign()
14
+ );
15
+ }
16
+
17
+ /**
18
+ * @test
19
+ */
20
+ public function signatureHeader()
21
+ {
22
+ $signer = new VantageAnalytics_Analytics_Model_Api_Signature('', '');
23
+ $this->assertEquals(
24
+ "X-Vantage-Hmac-SHA256: b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad",
25
+ $signer->signatureHeader()
26
+ );
27
+ }
28
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Base.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class VantageAnalytics_Analytics_Test_Model_Base extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ public function setUp()
6
+ {
7
+ $tracking = $this->getMockBuilder('VantageAnalytics_Analytics_Model_Helper_Tracking')
8
+ ->disableOriginalConstructor()->setMethods(array('setInitialCookie'))->getMock();
9
+ $tracking->expects($this->any())->method('setInitialCookie');
10
+ $this->replaceByMock('helper', 'analytics/tracking', $tracking);
11
+ }
12
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Config.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_Config extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ /**
6
+ * @test
7
+ */
8
+ public function configIsFoundAndHasExpectedStructure()
9
+ {
10
+ $config = Mage::getStoreConfig('vantageanalytics/accountoptions', Mage::app()->getStore());
11
+ $this->assertTrue(array_key_exists('vantageurl', $config));
12
+ }
13
+
14
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Customer.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_Customer extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ /**
6
+ * @test
7
+ * @loadFixture
8
+ * @doNotIndexAll
9
+ */
10
+ public function simpleCustomer()
11
+ {
12
+ $customer = Mage::getModel('customer/customer')->load(1);
13
+
14
+ $transformer =
15
+ VantageAnalytics_Analytics_Model_Transformer_Customer::factory($customer);
16
+
17
+ $this->assertEquals("example@example.com", $transformer->email());
18
+ $this->assertEquals("john", $transformer->firstName());
19
+ $this->assertEquals("smith", $transformer->lastName());
20
+ $this->assertEquals('2012-08-17T18:00:41+00:00', $transformer->sourceCreatedAt());
21
+ }
22
+
23
+ /**
24
+ * @test
25
+ * @loadFixture simpleCustomer
26
+ * @doNotIndexAll
27
+ */
28
+ public function vantageCustomerTest()
29
+ {
30
+ $customer = Mage::getModel('customer/customer')->load(1);
31
+
32
+ $transformer =
33
+ VantageAnalytics_Analytics_Model_Transformer_Customer::factory($customer);
34
+
35
+ $data = $transformer->toVantage();
36
+
37
+ $this->assertEquals(NULL, $data['external_address_id']);
38
+ $this->assertEquals('customer', $data['entity_type']);
39
+ }
40
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Customer/fixtures/simpleCustomer.yaml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ scope:
2
+ website:
3
+ - website_id: 2
4
+ code: usa_website
5
+ name: USA Website
6
+ default_group_id: 2
7
+ group:
8
+ - group_id: 2
9
+ website_id: 2
10
+ name: USA Store Group
11
+ default_store_id: 2
12
+ root_category_id: 2 # Default Category
13
+ store:
14
+ - store_id: 2
15
+ website_id: 2
16
+ group_id: 2
17
+ code: usa
18
+ name: USA Store
19
+ is_active: 1
20
+ config:
21
+ default/catalog/price/scope: 1 # Set price scope to websit
22
+ eav:
23
+ customer:
24
+ - entity_id: 1
25
+ entity_type_id: 1
26
+ attribute_set_id: 0
27
+ website_id: 1
28
+ email: example@example.com
29
+ group_id: 1
30
+ store_id: 1
31
+ is_active: 1
32
+ firstname: john
33
+ lastname: smith
34
+ created_at: 2012-08-17 18:00:41
app/code/community/VantageAnalytics/Analytics/Test/Model/DateFormatterTest.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_DateFormatterTest extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ /**
6
+ * @test
7
+ */
8
+ public function test_utc_date_convrsion()
9
+ {
10
+ $created_at = '2015-01-05T15:31:04-05:00';
11
+
12
+ $utcDate = VantageAnalytics_Analytics_Helper_DateFormatter::factory($created_at)->toUtcDate();
13
+
14
+ $this->assertEquals("2015-01-05T20:31:04+00:00", $utcDate);
15
+ }
16
+
17
+ /**
18
+ * @test
19
+ */
20
+ public function test_utc_dat_formatting()
21
+ {
22
+ $updated_at = '2015-01-05 20:31:04';
23
+
24
+ $utcDate = VantageAnalytics_Analytics_Helper_DateFormatter::factory($updated_at)->toUtcDate();
25
+
26
+ $this->assertEquals("2015-01-05T20:31:04+00:00", $utcDate);
27
+ }
28
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/LineItem.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_LineItem extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ public function setUp()
6
+ {
7
+ $tracking = $this->getMockBuilder('VantageAnalytics_Analytics_Model_Helper_Tracking')
8
+ ->disableOriginalConstructor()->setMethods(array('setInitialCookie'))->getMock();
9
+ $tracking->expects($this->any())->method('setInitialCookie');
10
+ $this->replaceByMock('helper', 'analytics/tracking', $tracking);
11
+ }
12
+
13
+ /**
14
+ * @test
15
+ * @loadFixture
16
+ * @doNotIndexAll
17
+ */
18
+ public function simpleOrder()
19
+ {
20
+ $order = Mage::getModel('sales/order')->load(1);
21
+ $items = $order->getAllItems();
22
+
23
+ $transformer =
24
+ VantageAnalytics_Analytics_Model_Transformer_SalesOrderLineItem::factory($items[0]);
25
+
26
+ $this->assertEquals("book", $transformer->sku());
27
+ $this->assertEquals("1", $transformer->externalParentIdentifier());
28
+ $this->assertEquals("13.00", $transformer->price());
29
+ $this->assertEquals("lineItem", $transformer->entityType());
30
+ }
31
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/LineItem/fixtures/simpleOrder.yaml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ scope:
2
+ website: # Initialize websites
3
+ - website_id: 2
4
+ code: usa_website
5
+ name: USA Website
6
+ default_group_id: 2
7
+ group: # Initializes store groups
8
+ - group_id: 2
9
+ website_id: 2
10
+ name: USA Store Group
11
+ default_store_id: 2
12
+ root_category_id: 2 # Default Category
13
+ store: # Initializes store views
14
+ - store_id: 2
15
+ website_id: 2
16
+ group_id: 2
17
+ code: usa
18
+ name: USA Store
19
+ is_active: 1
20
+ config:
21
+ default/catalog/price/scope: 1 # Set price scope to websit
22
+ eav:
23
+ catalog_product:
24
+ - entity_id: 1
25
+ attribute_set_id: 1
26
+ type_id: simple
27
+ sku: book
28
+ name: Ender's Gamè
29
+ short_description: Book
30
+ description: Book
31
+ url_key: book
32
+ stock:
33
+ qty: 100.00
34
+ is_in_stock: 1
35
+ website_ids:
36
+ - usa_website
37
+ price: 13.00
38
+ tax_class_id: 2 # Taxable Goods
39
+ status: 1 # Enabled
40
+ visibility: 4 # Visible in Catalog & Search
41
+ /websites: # Set different prices per website
42
+ usa_website:
43
+ special_price: 9.99
44
+ tables:
45
+ sales/order:
46
+ - entity_id: 1
47
+ is_active: 1
48
+ created_at: 2012-08-17 18:00:41
49
+ updated_at: 2012-08-17 18:00:41
50
+ converted_at: null
51
+ is_virtual: 0
52
+ is_multi_shipping: 0
53
+ items_count: 1
54
+ items_qty: 2.0000
55
+ sales/order_item:
56
+ - item_id: 1
57
+ order_id: 1
58
+ product_id: 1
59
+ parent_item_id: null
60
+ is_virtual: 0
61
+ sku: 14156575-XS-9394
62
+ name: LEGGING
63
+ description: null
64
+ applied_rule_ids: 0
65
+ additional_data: null
66
+ free_shipping: 0
67
+ is_qty_decimal: 0
68
+ no_discount: 0
69
+ weight: 0.4000
70
+ qty: 2
71
+ price: 13.0000
72
+ base_price: 13.0000
73
+ custom_price: 10.0000
74
+ discount_percent: 0.0000
75
+ discount_amount: 0.0000
76
+ base_discount_amount: 0.0000
77
+ tax_percent: 0.0000
78
+ tax_amount: 0.0000
79
+ base_tax_amount: 0.0000
80
+ row_total: 20.0000
81
+ base_row_total: 20.0000
82
+ row_total_with_discount: 0.0000
83
+ row_weight: 0.0000
84
+ product_type: configurable
85
+ base_tax_before_discount: null
86
+ tax_before_discount: null
87
+ original_custom_price: 10.0000
app/code/community/VantageAnalytics/Analytics/Test/Model/Order.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_Order extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ protected function getTransformedOrder($state=null, $orderid=1)
6
+ {
7
+ $order = Mage::getModel('sales/order')->load(1);
8
+ if ($state) {
9
+ $order->setState($state);
10
+ }
11
+ $transform = VantageAnalytics_Analytics_Model_Transformer_SalesOrder::factory($order);
12
+ return $transform->toVantage();
13
+ }
14
+
15
+ /**
16
+ * @test
17
+ * @loadFixture
18
+ * @dataProvider dataProvider
19
+ * @doNotIndexAll
20
+ */
21
+ public function orderStatus($state, $status)
22
+ {
23
+ $dict = $this->getTransformedOrder($state);
24
+
25
+ $this->assertEquals($status, $dict['order_status']);
26
+ }
27
+
28
+ /**
29
+ * @test
30
+ * @loadFixture
31
+ * @doNotIndexAll
32
+ */
33
+ public function orderStatusComplete()
34
+ {
35
+ $dict = $this->getTransformedOrder();
36
+ $this->assertEquals('closed', $dict['order_status']);
37
+ }
38
+
39
+ /**
40
+ * @test
41
+ * @loadFixture
42
+ * @doNotIndexAll
43
+ */
44
+ public function orderStatusCanceled()
45
+ {
46
+ $dict = $this->getTransformedOrder();
47
+ $this->assertEquals('canceled', $dict['order_status']);
48
+ }
49
+
50
+ /**
51
+ * @test
52
+ * @loadFixture
53
+ * @doNotIndexAll
54
+ */
55
+ public function paymentStatusUnpaid()
56
+ {
57
+ $dict = $this->getTransformedOrder();
58
+ $this->assertEquals('unpaid', $dict['payment_status']);
59
+ }
60
+
61
+ /**
62
+ * @test
63
+ * @loadFixture orderStatus
64
+ * @doNotIndexAll
65
+ */
66
+ public function entityType()
67
+ {
68
+ $dict = $this->getTransformedOrder();
69
+ $this->assertEquals("order" , $dict['entity_type']);
70
+ }
71
+
72
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/orderStatus.yaml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 1
4
+ state: ''
5
+ - entity_id: 2
6
+ state: pending
7
+ sales/quote:
8
+ - entity_id: 1
9
+ firstname: David
10
+ lastname: Geiger
11
+ street: 123 Sesame St
12
+ city: New York
13
+ postcode: 90210
14
+ telephone: 911
15
+ country_id: US
16
+ region_id: NY
17
+ scope:
18
+ website: # Initialize websites
19
+ - website_id: 2
20
+ code: usa_website
21
+ name: USA Website
22
+ default_group_id: 2
23
+ group: # Initializes store groups
24
+ - group_id: 2
25
+ website_id: 2
26
+ name: USA Store Group
27
+ default_store_id: 2
28
+ root_category_id: 2 # Default Category
29
+ store: # Initializes store views
30
+ - store_id: 2
31
+ website_id: 2
32
+ group_id: 2
33
+ code: usa
34
+ name: USA Store
35
+ is_active: 1
36
+ config:
37
+ default/catalog/price/scope: 1 # Set price scope to website
38
+ eav:
39
+ catalog_product:
40
+ - entity_id: 1
41
+ attribute_set_id: 1
42
+ type_id: simple
43
+ sku: book
44
+ name: Book
45
+ short_description: Book
46
+ description: Book
47
+ url_key: book
48
+ stock:
49
+ qty: 100.00
50
+ is_in_stock: 1
51
+ website_ids:
52
+ - usa_website
53
+ #category_ids:
54
+ # - 2 # Default Category
55
+ price: 12.99
56
+ tax_class_id: 2 # Taxable Goods
57
+ status: 1 # Enabled
58
+ visibility: 4 # Visible in Catalog & Search
59
+ /websites: # Set different prices per website
60
+ usa_website:
61
+ special_price: 9.99
app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/orderStatusCanceled.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 1
4
+ state: canceled
5
+ status: canceled
app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/orderStatusComplete.yaml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 1
4
+ state: complete
5
+ sales/invoice:
6
+ - entity_id: 1
7
+ store_id: 1
8
+ order_id: 1
9
+ base_grand_total: 92.8600
10
+ shipping_tax_amount: 0.0000
11
+ tax_amount: 6.1900
12
+ base_tax_amount: 6.1900
13
+ store_to_order_rate: 1.0000
14
+ base_shipping_tax_amount: 0.0000
15
+ base_discount_amount: 0.0000
16
+ base_to_order_rate: 1.0000
17
+ grand_total: 92.8600
18
+ shipping_amount: 11.6700
19
+ subtotal_incl_tax: 81.1900
20
+ base_subtotal_incl_tax: 81.1900
21
+ store_to_base_rate: 1.0000
22
+ base_shipping_amount: 11.6700
23
+ total_qty: 2.0000
24
+ base_to_global_rate: 1.0000
25
+ subtotal: 75.0000
26
+ base_subtotal: 75.0000
27
+ discount_amount: 0.0000
28
+ billing_address_id: 472
29
+ shipping_address_id: 473
30
+ can_void_flag: 0
31
+ state: 2
32
+ store_currency_code: USD
33
+ transaction_id: NULL
34
+ order_currency_code: USD
35
+ base_currency_code: USD
36
+ global_currency_code: USD
37
+ increment_id: 103000003
38
+ created_at: 2014-10-28 19:31:28
39
+ updated_at: 2014-10-28 19:31:28
40
+ hidden_tax_amount: 0.0000
41
+ base_hidden_tax_amount: 0.0000
42
+ shipping_hidden_tax_amount: 0.0000
43
+ shipping_incl_tax: 11.6700
44
+ base_shipping_incl_tax: 11.6700
app/code/community/VantageAnalytics/Analytics/Test/Model/Order/fixtures/paymentStatusUnpaid.yaml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tables:
2
+ sales/order:
3
+ - entity_id: 1
4
+ state: processing
5
+ base_grand_total: 92.8600
6
+ shipping_tax_amount: 0.0000
7
+ tax_amount: 6.1900
8
+ base_tax_amount: 6.1900
9
+ store_to_order_rate: 1.0000
10
+ base_shipping_tax_amount: 0.0000
11
+ base_discount_amount: 0.0000
12
+ base_to_order_rate: 1.0000
13
+ grand_total: 92.8600
14
+ shipping_amount: 11.6700
15
+ subtotal_incl_tax: 81.1900
16
+ base_subtotal_incl_tax: 81.1900
17
+ store_to_base_rate: 1.0000
18
+ base_shipping_amount: 11.6700
19
+ total_qty: 2.0000
20
+ base_to_global_rate: 1.0000
21
+ subtotal: 75.0000
22
+ base_subtotal: 75.0000
app/code/community/VantageAnalytics/Analytics/Test/Model/Order/providers/orderStatus.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -
2
+ - ''
3
+ - open
4
+ -
5
+ - new
6
+ - placed
7
+ -
8
+ - holded
9
+ - placed
10
+ -
11
+ - pending_payment
12
+ - placed
13
+ -
14
+ - payment_review
15
+ - placed
app/code/community/VantageAnalytics/Analytics/Test/Model/Product.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_Product extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ /**
6
+ * @test
7
+ * @loadFixture
8
+ * @doNotIndexAll
9
+ */
10
+ public function simpleProduct()
11
+ {
12
+ $price = 70.50;
13
+ $product = Mage::getModel('catalog/product')->load(1);
14
+ $product->setPrice($price);
15
+
16
+ $transformer =
17
+ VantageAnalytics_Analytics_Model_Transformer_Product::factory($product);
18
+
19
+ $this->assertEquals("book", $transformer->sku());
20
+ $this->assertEquals('2012-08-17T18:00:41+00:00', $transformer->sourceCreatedAt());
21
+ $this->assertEquals($price, $transformer->price());
22
+ }
23
+
24
+ /**
25
+ * @test
26
+ * @loadFixture simpleProduct
27
+ * @doNotIndexAll
28
+ */
29
+ public function toVantageTest()
30
+ {
31
+ $product = Mage::getModel('catalog/product')->load(1);
32
+
33
+ $transformer =
34
+ VantageAnalytics_Analytics_Model_Transformer_Product::factory($product);
35
+
36
+ $data = $transformer->toVantage();
37
+ $this->assertEquals('product', $data['entity_type']);
38
+ }
39
+
40
+ /**
41
+ * @test
42
+ * @loadFixture
43
+ * @doNotIndexAll
44
+ */
45
+ public function parentProduct()
46
+ {
47
+ $product = Mage::getModel('catalog/product')->load(410955);
48
+
49
+ $parentId = VantageAnalytics_Analytics_Model_ParentProduct::factory($product)->id();
50
+
51
+ $this->assertEquals(336835, $parentId);
52
+ }
53
+
54
+ }
app/code/community/VantageAnalytics/Analytics/Test/Model/Product/fixtures/parentProduct.yaml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ scope:
2
+ website: # Initialize websites
3
+ - website_id: 2
4
+ code: usa_website
5
+ name: USA Website
6
+ default_group_id: 2
7
+ group: # Initializes store groups
8
+ - group_id: 2
9
+ website_id: 2
10
+ name: USA Store Group
11
+ default_store_id: 2
12
+ root_category_id: 2 # Default Category
13
+ store: # Initializes store views
14
+ - store_id: 2
15
+ website_id: 2
16
+ group_id: 2
17
+ code: usa
18
+ name: USA Store
19
+ is_active: 1
20
+ config:
21
+ default/catalog/price/scope: 1 # Set price scope to websit
22
+ eav:
23
+ catalog_product:
24
+ - entity_id: 410955
25
+ attribute_set_id: 4
26
+ type_id: simple
27
+ sku: "Test Simple Child"
28
+ name: "Test Simple Child"
29
+ short_description: "Test Simple Child"
30
+ description: "Test Simple Child"
31
+ url_key: test-child
32
+ website_ids:
33
+ - usa_website
34
+ category_ids:
35
+ - 2 # Default Category
36
+ price: 30.00
37
+ special_price: 30.00
38
+ tax_class_id: 2 # Taxable Goods
39
+ status: 1 # Enabled
40
+ visibility: 4 # Visible in Catalog & Search
41
+ color: 4 # Configurable Super Attribute
42
+ - entity_id: '336835'
43
+ attribute_set_id: 4
44
+ type_id: configurable
45
+ sku: "test-configurable"
46
+ name: "Test Configurable"
47
+ short_description: "Test Configurable"
48
+ description: "Test Configurable"
49
+ url_key: test-configurable
50
+ super_attributes:
51
+ - color
52
+ configurable_children:
53
+ - 410955
54
+ website_ids:
55
+ - usa_website
56
+ category_ids:
57
+ - 2 # Default Category
58
+ price: 30.00
59
+ special_price: 30.00
60
+ tax_class_id: 2 # Taxable Goods
61
+ status: 1 # Enabled
62
+ visibility: 4 # Visible in Catalog & Search
app/code/community/VantageAnalytics/Analytics/Test/Model/Product/fixtures/simpleProduct.yaml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ scope:
2
+ website: # Initialize websites
3
+ - website_id: 2
4
+ code: usa_website
5
+ name: USA Website
6
+ default_group_id: 2
7
+ group: # Initializes store groups
8
+ - group_id: 2
9
+ website_id: 2
10
+ name: USA Store Group
11
+ default_store_id: 2
12
+ root_category_id: 2 # Default Category
13
+ store: # Initializes store views
14
+ - store_id: 2
15
+ website_id: 2
16
+ group_id: 2
17
+ code: usa
18
+ name: USA Store
19
+ is_active: 1
20
+ config:
21
+ default/catalog/price/scope: 1 # Set price scope to websit
22
+ eav:
23
+ catalog_product:
24
+ - entity_id: 1
25
+ attribute_set_id: 1
26
+ type_id: simple
27
+ sku: book
28
+ name: Ender's Gamè
29
+ short_description: Book
30
+ description: Book
31
+ url_key: book
32
+ stock:
33
+ qty: 100.00
34
+ is_in_stock: 1
35
+ website_ids:
36
+ - usa_website
37
+ price: 13.00
38
+ tax_class_id: 2 # Taxable Goods
39
+ status: 1 # Enabled
40
+ visibility: 4 # Visible in Catalog & Search
41
+ created_at: 2012-08-17 18:00:41
42
+ updated_at: 2012-08-17 18:00:41
43
+ /websites: # Set different prices per website
44
+ usa_website:
45
+ price: 9.99
app/code/community/VantageAnalytics/Analytics/Test/Model/Webhook.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Test_Model_Webhook extends VantageAnalytics_Analytics_Test_Model_Base
4
+ {
5
+ /**
6
+ * @test
7
+ * @doNotIndexAll
8
+ */
9
+ public function webhookType()
10
+ {
11
+ $webhook =
12
+ VantageAnalytics_Analytics_Model_Api_Webhook::factory(array(), "update")->preamble();
13
+
14
+ $this->assertEquals("object.update", $webhook['webhook']['type']);
15
+ }
16
+
17
+ }
app/code/community/VantageAnalytics/Analytics/controllers/Adminhtml/AnalyticsbackendController.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Adminhtml_AnalyticsbackendController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('analytics/adminhtml_analyticsbackend')
9
+ ->_title($this->__("Vantage Analytics"));
10
+
11
+ $this->renderLayout();
12
+ }
13
+
14
+ protected function collectStoreInfo()
15
+ {
16
+ $stores = array();
17
+
18
+ foreach (Mage::app()->getWebsites() as $store) {
19
+ $stores[] = array(
20
+ 'store_id' => $store->getId(),
21
+ 'domain' => $store->getDefaultStore()->getBaseUrl(),
22
+ 'name' => $store->getName()
23
+ );
24
+ }
25
+
26
+ return $stores;
27
+ }
28
+
29
+ protected function registerAccount($params)
30
+ {
31
+ $registerUrl = Mage::helper("analytics/account")->registerAccountUrl();
32
+ $channel = curl_init($registerUrl);
33
+
34
+ curl_setopt($channel, CURLOPT_SSL_VERIFYHOST, 2);
35
+ curl_setopt($channel, CURLOPT_CUSTOMREQUEST, 'POST');
36
+ curl_setopt($channel, CURLOPT_RETURNTRANSFER, true);
37
+
38
+ $account = array(
39
+ 'username' => $params['username'],
40
+ 'password' => $params['password'],
41
+ 'password_confirmation' => $params['password_confirmation'],
42
+ 'stores' => $this->collectStoreInfo()
43
+ );
44
+
45
+ $body = json_encode($account);
46
+ curl_setopt($channel, CURLOPT_POSTFIELDS, $body);
47
+ $headers = array(
48
+ 'Content-type: application/json',
49
+ 'Content-length: ' . strlen($body)
50
+ );
51
+
52
+
53
+ curl_setopt($channel, CURLOPT_HTTPHEADER, $headers);
54
+ $result = curl_exec($channel);
55
+
56
+ $status = curl_getinfo($channel, CURLINFO_HTTP_CODE);
57
+ if ($status >= 500) {
58
+ Mage::throwException("An error occurred. Please try again later.");
59
+ }
60
+
61
+ if (curl_errno($channel)) {
62
+ $errorDesc = curl_error($channel);
63
+ curl_close($channel);
64
+ Mage::throwException("An error occurred. Please try again later.");
65
+ }
66
+
67
+ curl_close($channel);
68
+ $response = json_decode($result, true);
69
+
70
+ return $response;
71
+ }
72
+
73
+ protected function saveAccountLogin($response)
74
+ {
75
+ if (empty($response['username']) || empty($response['secret'])) {
76
+ return;
77
+ }
78
+
79
+ Mage::helper('analytics/account')->setUsername($response['username']);
80
+ Mage::helper('analytics/account')->setSecret($response['secret']);
81
+ Mage::helper('analytics/account')->setIsVerified(1);
82
+ }
83
+
84
+ protected function handleValidation($response)
85
+ {
86
+ $fieldNames = array('username' => 'Email: ',
87
+ 'password' => 'Password: ',
88
+ 'password_confirmation' => 'Confirm Password: ',
89
+ 'non_field_errors' => ''
90
+ );
91
+ if (empty($response['errors'])) {
92
+ Mage::getSingleton('adminhtml/session')
93
+ ->init('core', 'adminhtml')
94
+ ->addSuccess('Your Vantage Analytics account was created!');
95
+ } else {
96
+ foreach ($response['errors'] as $field => $errors) {
97
+ foreach ($errors as $error) {
98
+ $fieldName = array_key_exists($field, $fieldNames) ?
99
+ $fieldNames[$field] : $field;
100
+ Mage::getSingleton('adminhtml/session')
101
+ ->init('core', 'adminhtml')
102
+ ->addError($fieldName . $error);
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ public function registerAction()
109
+ {
110
+ try {
111
+ $params = $this->getRequest()->getParams();
112
+ $response = $this->registerAccount($params);
113
+ $this->handleValidation($response);
114
+ $this->saveAccountLogin($response);
115
+ } catch (Mage_Core_Exception $e) {
116
+ Mage::getSingleton('adminhtml/session')
117
+ ->init('core', 'adminhtml')
118
+ ->addError($e->getMessage());
119
+ }
120
+
121
+ $this->loadLayout()
122
+ ->_setActiveMenu('analytics/adminhtml_analyticsbackend')
123
+ ->_title($this->__("Vantage Analytics"));
124
+
125
+ $this->renderLayout();
126
+ }
127
+ }
app/code/community/VantageAnalytics/Analytics/controllers/Adminhtml/ResetController.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class VantageAnalytics_Analytics_Adminhtml_ResetController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ private function resetConfig()
6
+ {
7
+ Mage::helper('analytics/log')->logInfo("Resetting config...");
8
+ Mage::helper('analytics/account')->setIsVerified(0);
9
+ Mage::helper('analytics/account')->setExportDone(0);
10
+ Mage::app()->reinitStores();
11
+ }
12
+
13
+ private function emptyQueue()
14
+ {
15
+ Mage::helper('analytics/log')->logInfo("Emptying message queue...");
16
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
17
+ $db->query("TRUNCATE `vantage_message`;");
18
+ }
19
+
20
+ public function resetAction()
21
+ {
22
+ $this->emptyQueue();
23
+ $this->resetConfig();
24
+ Mage::getSingleton('adminhtml/session')
25
+ ->init('core', 'adminhtml')
26
+ ->addSuccess('Your Vantage settings were reset. Please re-enter your username and secret.');
27
+
28
+ $this->_redirectUrl(($this->_getRefererUrl()));
29
+ }
30
+ }
app/code/community/VantageAnalytics/Analytics/etc/adminhtml.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <info translate="title" module="analytics">
12
+ <title>Information Section</title>
13
+ <sort_order>0</sort_order>
14
+ </info>
15
+ <vantageanalytics translate="title" module="analytics">
16
+ <title>Configuration Section</title>
17
+ <sort_order>1</sort_order>
18
+ </vantageanalytics>
19
+ </children>
20
+ </config>
21
+ </children>
22
+ </system>
23
+ </children>
24
+ </admin>
25
+ </resources>
26
+ </acl>
27
+ </config>
app/code/community/VantageAnalytics/Analytics/etc/config.xml ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <VantageAnalytics_Analytics>
5
+ <version>0.9.0</version>
6
+ </VantageAnalytics_Analytics>
7
+ </modules>
8
+ <phpunit>
9
+ <suite>
10
+ <modules>
11
+ <VantageAnalytics_Analytics />
12
+ </modules>
13
+ </suite>
14
+ </phpunit>
15
+
16
+ <global>
17
+ <resources>
18
+ <vantageanalytics_analytics_setup>
19
+ <setup>
20
+ <module>VantageAnalytics_Analytics</module>
21
+ <class>VantageAnalytics_Analytics_Model_Resource_Mysql4_Setup</class>
22
+ </setup>
23
+ <connection>
24
+ <use>core_setup</use>
25
+ </connection>
26
+ </vantageanalytics_analytics_setup>
27
+ </resources>
28
+
29
+ <helpers>
30
+ <analytics>
31
+ <class>VantageAnalytics_Analytics_Helper</class>
32
+ </analytics>
33
+ </helpers>
34
+ <models>
35
+ <analytics>
36
+ <class>VantageAnalytics_Analytics_Model</class>
37
+ </analytics>
38
+ </models>
39
+ <blocks>
40
+ <analytics>
41
+ <class>VantageAnalytics_Analytics_Block</class>
42
+ </analytics>
43
+ </blocks>
44
+
45
+ <events>
46
+
47
+
48
+ <sales_order_save_after>
49
+ <observers>
50
+ <vantageanalytics_analytics_sales_order_save_after>
51
+ <type>singleton</type>
52
+ <class>VantageAnalytics_Analytics_Model_Observer_SalesOrder</class>
53
+ <method>salesOrderSaveAfter</method>
54
+ </vantageanalytics_analytics_sales_order_save_after>
55
+ </observers>
56
+ </sales_order_save_after>
57
+
58
+ <sales_order_delete_after>
59
+ <observers>
60
+ <vantageanalytics_analytics_sales_order_delete_after>
61
+ <type>singleton</type>
62
+ <class>VantageAnalytics_Analytics_Model_Observer_SalesOrder</class>
63
+ <method>salesOrderDeleteAfter</method>
64
+ </vantageanalytics_analytics_sales_order_delete_after>
65
+ </observers>
66
+ </sales_order_delete_after>
67
+
68
+ <sales_quote_save_after>
69
+ <observers>
70
+ <vantageanalytics_analytics_sales_quote_save_after>
71
+ <type>singleton</type>
72
+ <class>VantageAnalytics_Analytics_Model_Observer_SalesQuote</class>
73
+ <method>salesQuoteSaveAfter</method>
74
+ </vantageanalytics_analytics_sales_quote_save_after>
75
+ </observers>
76
+ </sales_quote_save_after>
77
+
78
+ <catalog_product_save_after>
79
+ <observers>
80
+ <vantageanalytics_analytics_catalog_product_save_after>
81
+ <type>singleton</type>
82
+ <class>VantageAnalytics_Analytics_Model_Observer_CatalogProduct</class>
83
+ <method>catalogProductSaveAfter</method>
84
+ </vantageanalytics_analytics_catalog_product_save_after>
85
+ </observers>
86
+ </catalog_product_save_after>
87
+
88
+ <catalog_product_delete_after>
89
+ <observers>
90
+ <vantageanalytics_analytics_catalog_product_delete_after>
91
+ <type>singleton</type>
92
+ <class>VantageAnalytics_Analytics_Model_Observer_CatalogProduct</class>
93
+ <method>catalogProductDeleteAfter</method>
94
+ </vantageanalytics_analytics_catalog_product_delete_after>
95
+ </observers>
96
+ </catalog_product_delete_after>
97
+
98
+ <customer_save_after>
99
+ <observers>
100
+ <vantageanalytics_analytics_customer_save_after>
101
+ <class>VantageAnalytics_Analytics_Model_Observer_Customer</class>
102
+ <method>customerSaveAfter</method>
103
+ </vantageanalytics_analytics_customer_save_after>
104
+ </observers>
105
+ </customer_save_after>
106
+
107
+ <customer_delete_after>
108
+ <observers>
109
+ <vantageanalytics_analytics_customer_delete_after>
110
+ <type>singleton</type>
111
+ <class>VantageAnalytics_Analytics_Model_Observer_Customer</class>
112
+ <method>customerDeleteAfter</method>
113
+ </vantageanalytics_analytics_customer_delete_after>
114
+ </observers>
115
+ </customer_delete_after>
116
+
117
+ <controller_front_init_before>
118
+ <observers>
119
+ <vantageanalytics_analytics_tracking>
120
+ <class>VantageAnalytics_Analytics_Model_Observer_Tracking</class>
121
+ <method>controllerFrontInitBefore</method>
122
+ <type>singleton</type>
123
+ </vantageanalytics_analytics_tracking>
124
+ </observers>
125
+ </controller_front_init_before>
126
+ </events>
127
+ </global>
128
+
129
+ <frontend>
130
+ <events>
131
+ <sales_order_place_after>
132
+ <observers>
133
+ <vantageanalytics_analytics_sales_order_place_after>
134
+ <class>VantageAnalytics_Analytics_Model_Observer_SalesOrder</class>
135
+ <method>salesOrderPlaceAfter</method>
136
+ </vantageanalytics_analytics_sales_order_place_after>
137
+ </observers>
138
+ </sales_order_place_after>
139
+ </events>
140
+ </frontend>
141
+
142
+ <admin>
143
+ <routers>
144
+ <analytics>_
145
+ <use>admin</use>
146
+ <args>
147
+ <module>VantageAnalytics_Analytics</module>
148
+ <frontName>analytics</frontName>
149
+ </args>
150
+ </analytics>
151
+ </routers>
152
+ </admin>
153
+
154
+ <adminhtml>
155
+ <menu>
156
+ <analytics module="analytics">
157
+ <title>Vantage</title>
158
+ <sort_order>100</sort_order>
159
+ <action>analytics/adminhtml_analyticsbackend</action>
160
+ </analytics>
161
+ </menu>
162
+ <acl>
163
+ <resources>
164
+ <all>
165
+ <title>Vantage Analytics</title>
166
+ </all>
167
+ <admin>
168
+ <children>
169
+ <analytics translate="title" module="analytics">
170
+ <title>Vantage Analytics Index</title>
171
+ <sort_order>1000</sort_order>
172
+ </analytics>
173
+ </children>
174
+ </admin>
175
+ </resources>
176
+ </acl>
177
+
178
+ <layout>
179
+ <updates>
180
+ <analytics>
181
+ <file>analytics.xml</file>
182
+ </analytics>
183
+ </updates>
184
+ </layout>
185
+ </adminhtml>
186
+
187
+ <crontab>
188
+ <jobs>
189
+ <analytics>
190
+ <schedule>
191
+ <cron_expr>*/5 * * * *</cron_expr>
192
+ </schedule>
193
+ <run>
194
+ <model>analytics/cron::run</model>
195
+ </run>
196
+ </analytics>
197
+ <analytics_heartbeat>
198
+ <schedule>
199
+ <cron_expr>5 * * * *</cron_expr>
200
+ </schedule>
201
+ <run>
202
+ <model>analytics/heartbeat::send</model>
203
+ </run>
204
+ </analytics_heartbeat>
205
+ </jobs>
206
+ </crontab>
207
+
208
+ <default>
209
+ <vantageanalytics>
210
+ <accountoptions>
211
+ <vantageurl>https://satellite.vantageanalytics.com/magento/webhook</vantageurl>
212
+ </accountoptions>
213
+ <export>
214
+ <done>0</done>
215
+ </export>
216
+ </vantageanalytics>
217
+ </default>
218
+
219
+ </config>
app/code/community/VantageAnalytics/Analytics/etc/system.xml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <vantageanalyticstab translate="label" module="analytics">
5
+ <label>Vantage</label>
6
+ <sort_order>99999</sort_order>
7
+ </vantageanalyticstab>
8
+ </tabs>
9
+ <sections>
10
+ <vantageanalytics translate="label" module="analytics">
11
+ <label>Configuration</label>
12
+ <tab>vantageanalyticstab</tab>
13
+ <sort_order>1</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <accountoptions translate="label">
19
+ <label>Account Options</label>
20
+ <sort_order>0</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <expanded>1</expanded>
25
+ <fields>
26
+ <accountid translate="label">
27
+ <label>Vantage Username</label>
28
+ <frontend_type>text</frontend_type>
29
+ <backend_model>VantageAnalytics_Analytics_Model_Api_Username</backend_model>
30
+ <sort_order>0</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <comment>The email address you used to sign up to Vantage.</comment>
35
+ </accountid>
36
+ <accountpwd translate="label">
37
+ <label>Vantage Secret</label>
38
+ <frontend_type>password</frontend_type>
39
+ <backend_model>VantageAnalytics_Analytics_Model_Api_Secret</backend_model>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <comment><![CDATA[
45
+ The API Secret in your Vantage account settings.
46
+ ]]></comment>
47
+ </accountpwd>
48
+ </fields>
49
+ </accountoptions>
50
+ <export translate="label">
51
+ <label>Advanced</label>
52
+ <sort_order>1</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ <fields>
57
+ <done translate="label">
58
+ <label>Export Completed?</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>1</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ <comment>
66
+ Set to "No" to force a full historical data export.
67
+ </comment>
68
+ </done>
69
+ <reset translate="label">
70
+ <label>Reset Settings</label>
71
+ <frontend_type>button</frontend_type>
72
+ <frontend_model>VantageAnalytics_Analytics_Block_Adminhtml_Reset</frontend_model>
73
+ <sort_order>20</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <comment>Reset your account. Use with caution.</comment>
78
+ </reset>
79
+ </fields>
80
+ </export>
81
+ </groups>
82
+ </vantageanalytics>
83
+ </sections>
84
+ </config>
app/code/community/VantageAnalytics/Analytics/sql/vantageanalytics_analytics_setup/install-0.1.0.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+ $installer->run("
7
+ DROP TABLE IF EXISTS `vantage_message`;
8
+ CREATE TABLE `vantage_message` (
9
+ `message_id` bigint(20) unsigned NOT NULL auto_increment,
10
+ `queue_id` int(10) unsigned NOT NULL,
11
+ `handle` char(32) default NULL,
12
+ `body` mediumtext NOT NULL,
13
+ `md5` char(32) NOT NULL,
14
+ `timeout` decimal(14,4) unsigned default NULL,
15
+ `created` int(10) unsigned NOT NULL,
16
+ PRIMARY KEY (`message_id`),
17
+ UNIQUE KEY `message_handle` (`handle`),
18
+ KEY `message_queueid` (`queue_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+ ");
21
+
22
+ $installer->run("
23
+ DROP TABLE IF EXISTS `vantage_queue`;
24
+ CREATE TABLE `vantage_queue` (
25
+ `queue_id` int(10) unsigned NOT NULL auto_increment,
26
+ `queue_name` varchar(100) NOT NULL,
27
+ `timeout` smallint(5) unsigned NOT NULL default '30',
28
+ PRIMARY KEY (`queue_id`)
29
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30
+ ");
31
+
32
+ $installer->run("
33
+ ALTER TABLE `vantage_message`
34
+ ADD CONSTRAINT fk_vantage_queue_id
35
+ FOREIGN KEY (`queue_id`) REFERENCES `vantage_queue` (`queue_id`)
36
+ ON DELETE CASCADE
37
+ ON UPDATE CASCADE;
38
+ ");
39
+
40
+ $installer->endSetup();
app/code/community/VantageAnalytics/Analytics/sql/vantageanalytics_analytics_setup/mysql4-upgrade-0.1.0-0.2.0.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+ $installer->resetConfig();
7
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/analytics.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.2.0">
3
+ <analytics_adminhtml_analyticsbackend_index>
4
+ <reference name="head">
5
+ <action method="addCss"><name>css/register.css</name></action>
6
+ </reference>
7
+ <reference name="content">
8
+ <block type="analytics/adminhtml_analyticsbackend" name="analyticsbackend" template="analytics/analyticsbackend.phtml"/>
9
+ </reference>
10
+ </analytics_adminhtml_analyticsbackend_index>
11
+ <analytics_adminhtml_analyticsbackend_register>
12
+ <reference name="head">
13
+ <action method="addCss"><name>css/register.css</name></action>
14
+ </reference>
15
+ <reference name="content">
16
+ <block type="analytics/adminhtml_analyticsbackend" name="analyticsbackend" template="analytics/analyticsbackend.phtml"/>
17
+ </reference>
18
+ </analytics_adminhtml_analyticsbackend_register>
19
+ </layout>
app/design/adminhtml/default/default/template/analytics/analyticsbackend.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isAccountVerified()): ?>
2
+ <div class="va-register">
3
+ <img class="va-register-logo" src="<?php echo $this->getSkinUrl('images/vantage-for-magento.png'); ?>">
4
+ <p class="va-register-text">
5
+ <a href="https://app.vantageanalytics.com/" target="_blank">Log in</a> to access your Vantage account.
6
+ </p>
7
+ </div>
8
+ <?php else: ?>
9
+ <form action="<?php echo $this->getUrl('analytics/adminhtml_analyticsbackend/register') ?>" id="registerform" name="registerform" method="post" enctype="multipart/form-data">
10
+ <div class="va-register">
11
+ <img class="va-register-logo" src="<?php echo $this->getSkinUrl('images/vantage-for-magento.png'); ?>">
12
+ <p class="va-register-text">
13
+ You’re almost done! Just create an account.
14
+ </p>
15
+ <div class="fieldset">
16
+ <ul class="form-list">
17
+ <li class="fields">
18
+ <div class="field">
19
+ <label for="username" class="required"><?php echo Mage::helper('analytics')->__('Your email') ?></label>
20
+ <input name="username" id="username" title="<?php echo Mage::helper('analytics')->__('Your email') ?>" value="" class="input-text required-entry" type="text" />
21
+ </div>
22
+ <div class="field">
23
+ <label for="password" class="required"><?php echo Mage::helper('analytics')->__('Password') ?></label>
24
+ <input name="password" id="password" title="<?php echo Mage::helper('analytics')->__('Password') ?>" value="" class="input-text required-entry" type="password" />
25
+ </div>
26
+ <div class="field">
27
+ <label for="password_confirmation" class="required"><?php echo Mage::helper('analytics')->__('Confirm Password') ?></label>
28
+ <input name="password_confirmation" id="password_confirmation" title="<?php echo Mage::helper('analytics')->__('Confirm Password') ?>" value="" class="input-text required-entry" type="password" />
29
+ </div>
30
+ <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
31
+ <button class="button btn-search" type="submit" title="<?php echo Mage::helper('analytics')->__('Get Vantage Now') ?>" >Get Vantage Now</button>
32
+ </li>
33
+ </ul>
34
+ </div>
35
+ </div>
36
+ </form>
37
+ <?php endif; ?>
app/etc/modules/VantageAnalytics_Analytics.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <VantageAnalytics_Analytics>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </VantageAnalytics_Analytics>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>VantageAnalytics_Analytics</name>
4
+ <version>0.9.0</version>
5
+ <stability>beta</stability>
6
+ <license uri="http://vantageanalytics.com/legal/terms-of-use/">Commercial - Vantage</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Vantage is a must-have tool for Magento store managers who want to grow their business without getting totally wrapped up in numbers and analysis. </summary>
10
+ <description>Vantage is a must-have tool for Magento store managers who want to grow their business without getting totally wrapped up in numbers and analysis.&#xD;
11
+ We help you see the trends of what is happening in your store and then suggest actions you can take that will make a big difference to your success. Then we help you drive execution of the best strategies, quickly and easily.</description>
12
+ <notes>First release</notes>
13
+ <authors><author><name>Vantage Analytics</name><user>brandon</user><email>founders@vantageanalytics.com</email></author></authors>
14
+ <date>2015-01-15</date>
15
+ <time>14:45:55</time>
16
+ <contents><target name="magecommunity"><dir name="VantageAnalytics"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><file name="Analyticsbackend.php" hash="e305f2e7b0bfad28d84da570b27e7ab7"/><file name="Reset.php" hash="6863822bc8654d1df59e9e6bbe0e067b"/></dir></dir><dir name="Helper"><file name="Account.php" hash="d27fdc873b1d504753e846820b6c079e"/><file name="Data.php" hash="e2368bb846dc4e8090a31c2cd9b4dd64"/><file name="DateFormatter.php" hash="6e98a6efb5263f01a9d463faa1043d6e"/><dir name="Extension"><file name="Lister.php" hash="bcd42cde1226011937276f35b84043b0"/><file name="Pool.php" hash="198c0585d60c9c3cd0d161de43eed4cc"/></dir><file name="Log.php" hash="393f22705307f3253332b2845f291426"/><file name="Queue.php" hash="2d9b23e9b7d6f9847a444c2837ca1f2e"/><file name="Statuses.php" hash="9527eb737121cd34530c813aea52e962"/><file name="Tracking.php" hash="6776a0af3ed0b1fefc91a34d5924f3a1"/></dir><dir name="Model"><file name="AddressRetriever.php" hash="6d6761b08aa8d50f5473ee79b5211254"/><dir name="Api"><dir name="Exceptions"><file name="BadRequest.php" hash="90e31638b100c1f160b04a06a96c75f7"/><file name="CurlError.php" hash="cf82c3b693522cf86c02f9d1f1e83217"/><file name="MaxRetries.php" hash="2f2be83f975277cca1a5c0442d1e0cb3"/><file name="ServerError.php" hash="d68761c5e4e5e9666a4aa992db74a611"/></dir><file name="Request.php" hash="c0caaffbb1b9bfbb1322dde5c15e2c77"/><file name="RequestQueue.php" hash="147d2b63d329baa0afbca75d963dfb6c"/><file name="Secret.php" hash="7056e3d3ae2d54dda82191d9e51832f2"/><file name="Signature.php" hash="9769075f75e55e60442f6e7afe0964d6"/><file name="Username.php" hash="8e8b3b0ae689b615aa19db8608741db9"/><file name="Webhook.php" hash="e75bc24138854f57e3467d98303487a1"/></dir><file name="Cron.php" hash="677b36129ace58629710aeedb9701a05"/><file name="Debug.php" hash="c24900a7e9ecbfeb8c0d9509f3f8e44d"/><dir name="Export"><file name="Base.php" hash="94c85e0918141f25f05ba3f525919608"/><file name="Customer.php" hash="8b06c4fb062e0a7ef0dceea299a632f8"/><file name="Order.php" hash="b019beb39d722ddb66055100a52d8e80"/><file name="Product.php" hash="26a5c6ca05b0eebce9bfc42c089f0b49"/><file name="Runner.php" hash="2c2dbb0da3ea9955a866d76c782ead7f"/><file name="Store.php" hash="d48abe7899dde0026c27a04317984d7e"/></dir><file name="Heartbeat.php" hash="1a61d8c006c2dd394ff0711a50e1e525"/><dir name="Observer"><file name="Base.php" hash="f338ff2150b88b81243fb2592b1dcff4"/><file name="CatalogProduct.php" hash="c6e553ed6feb5173f0405e771a1203d3"/><file name="Customer.php" hash="0686ca80283a14d98358b8e7179c1269"/><file name="SalesOrder.php" hash="d8c271e7a528cac7c00f50d400830a52"/><file name="SalesQuote.php" hash="a9ea93aa1b0f9a96f6ce0a3fbc92341d"/><file name="Tracking.php" hash="0bdf7f4a2253c03362dbffdf82ee5643"/></dir><file name="ParentProduct.php" hash="e15d56807edb680a7c880f88d3cc654c"/><file name="ProductCategories.php" hash="b53d842897083c2ae4b4c4970c3d4c16"/><file name="ProductImages.php" hash="608c0444218733661dc94c214887cadd"/><file name="ProductOptions.php" hash="42fedb046f2ec7deb730239f8b9427d6"/><dir name="Queue"><dir name="Adapter"><file name="Db.php" hash="a1733dc68647c1f812afaf98ce3a26d9"/></dir></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="a115284cf544ad06b799c552b1f8c5c1"/></dir></dir><file name="SubscriberInformation.php" hash="67816c4724238f275a73058553010e83"/><dir name="Transformer"><file name="Address.php" hash="f9f0f27abf5597d89763b55ea9946cd3"/><file name="Base.php" hash="8f766b0d85187de732db44b26a210773"/><file name="BaseSales.php" hash="7e248d70f07b24e50a92999696833101"/><file name="BaseSalesItem.php" hash="aa281fe585defda3844baffeb6dfa9f9"/><file name="Customer.php" hash="481e0972f572340c96a59da8f582dba9"/><file name="Product.php" hash="37d2546adf4af53598c7876f23fae86b"/><file name="SalesOrder.php" hash="9fb3aa63042873fa0f2f6dedc108e4f1"/><file name="SalesOrderLineItem.php" hash="b9ffe0e6278a700a851ee2256e24965b"/><file name="SalesQuote.php" hash="c1712d7eb2b440b4d9c77d9dab96717d"/><file name="SalesQuoteLineItem.php" hash="27687eba35dab7fdadad438aeb63bf03"/><file name="Store.php" hash="cde2395de468981b3b964184dd214afb"/></dir></dir><dir name="Test"><dir name="Model"><dir name="Api"><file name="Signature.php" hash="5db3d5f9456c7948ecb636c9fe2d4850"/></dir><file name="Base.php" hash="fa7cb987301c0d1f092146447bac1d35"/><file name="Config.php" hash="84a1043ecfe94e1ff52de06b1c63254e"/><dir name="Customer"><dir name="fixtures"><file name="simpleCustomer.yaml" hash="e6b22424ddc0940226344bcccf13c745"/></dir></dir><file name="Customer.php" hash="722d0096e8211b4b57485b24efced031"/><file name="DateFormatterTest.php" hash="b7f0ff0cddfb0cce1b73c6a8de8d74dc"/><dir name="LineItem"><dir name="fixtures"><file name="simpleOrder.yaml" hash="8d6ff7b4cf8c434631305b51fca7884c"/></dir></dir><file name="LineItem.php" hash="e35411c7d970af0b5913807830ffe45e"/><dir name="Order"><dir name="fixtures"><file name="orderStatus.yaml" hash="a2786f2eda68ce0035f9edc8beaf9fee"/><file name="orderStatusCanceled.yaml" hash="800fcb6ee04f912e3e3f27efdbdafde3"/><file name="orderStatusComplete.yaml" hash="1c912c447d255f0afd096e6f32eace1c"/><file name="paymentStatusUnpaid.yaml" hash="c0d0a55eec973ad3ee3730ebc143a3b7"/></dir><dir name="providers"><file name="orderStatus.yaml" hash="e88ed6c1b39272f3f4767810a427613c"/></dir></dir><file name="Order.php" hash="24cefdde2b5bf68452f5c6301c1d5efc"/><dir name="Product"><dir name="fixtures"><file name="parentProduct.yaml" hash="931604baf487baa33cf78dc26548431c"/><file name="simpleProduct.yaml" hash="56b88f052816173a79780f43779df4ff"/></dir></dir><file name="Product.php" hash="9f22904ec0015355f6fbf2f287d5574d"/><file name="Webhook.php" hash="d34e01e88599529cf79b8cc27efad550"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AnalyticsbackendController.php" hash="930611f09144ef049e1d301623cdd4a7"/><file name="ResetController.php" hash="eb640d29682265f0b33aff6fa2559a6d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="cdfb6a37810355796f416784ce7f5584"/><file name="config.xml" hash="de9854d952810c6868a1ac61d93d2eca"/><file name="system.xml" hash="96810a47632dbee35df743615ced3c41"/></dir><dir name="sql"><dir name="vantageanalytics_analytics_setup"><file name="install-0.1.0.php" hash="0e7150e283f1ece9251af3e3d2ce76aa"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="e61c872d2e3527d8fa9e8daf21d8fc2e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="VantageAnalytics_Analytics.xml" hash="69ca3371e05fff3d8b1e89849e3fab32"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="analytics.xml" hash="54f3ead5c5c96cc323684335cccbb140"/></dir><dir name="template"><dir name="analytics"><file name="analyticsbackend.phtml" hash="09e58ba423c3ad883483a7cf30ac0656"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="register.css" hash="704cc1e177a9353715d065cb0b8841d4"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="images"><file name="vantage-for-magento.png" hash="36604b9b28ca5d8a7ff0ead39323eae9"/></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>
skin/adminhtml/base/default/images/vantage-for-magento.png ADDED
Binary file
skin/adminhtml/default/default/css/register.css ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .va-register {
2
+ width: 600px;
3
+ margin: 0 auto;
4
+ }
5
+
6
+ .va-register-logo {
7
+ display: block;
8
+ margin: 0 auto;
9
+ border-bottom: 1px solid #eee;
10
+ }
11
+
12
+ .va-register-text {
13
+ text-align: center;
14
+ font-size: 18px;
15
+ color: #666;
16
+ }
17
+
18
+ .va-register-logo,
19
+ .va-register-text {
20
+ margin-bottom: 30px;
21
+ }
22
+
23
+ .va-register .field {
24
+ margin-bottom: 15px;
25
+ }
26
+
27
+ .va-register label {
28
+ float: left;
29
+ display: block;
30
+ width: 180px;
31
+ margin-right: 30px;
32
+ text-align: right;
33
+ }
34
+
35
+ .va-register input {
36
+ width: 280px;
37
+ }
38
+
39
+ .va-register button {
40
+ margin-left: 210px;
41
+ }