Converdo_Analytics - Version 2.1.5.0

Version Notes

More reliable way to track orders and product metadata.

Download this release

Release Info

Developer Roeland van Oostenbrugge
Extension Converdo_Analytics
Version 2.1.5.0
Comparing to
See all releases


Code changes from version 2.1.0.0 to 2.1.5.0

Files changed (106) hide show
  1. app/code/community/Converdo/Analytics/Block/Tracker.php +0 -45
  2. app/code/community/Converdo/Analytics/Helper/Data.php +0 -105
  3. app/code/community/Converdo/Analytics/Model/Logger.php +0 -92
  4. app/code/community/Converdo/Analytics/Model/Observer.php +0 -73
  5. app/code/community/Converdo/Analytics/controllers/PingController.php +0 -46
  6. app/code/community/Converdo/Common/API/ConverdoAPI.php +18 -0
  7. {lib/Converdo/Analytics → app/code/community/Converdo/Common}/API/ConverdoClient.php +35 -14
  8. app/code/community/Converdo/Common/API/Factories/OrderFactory.php +48 -0
  9. app/code/community/Converdo/Common/API/Models/Contracts/OrderInterface.php +151 -0
  10. {lib/Converdo/Analytics → app/code/community/Converdo/Common}/API/Models/Order.php +71 -92
  11. app/code/community/Converdo/Common/API/Requests.php +50 -0
  12. {lib/Converdo/Analytics → app/code/community/Converdo/Common}/API/Sections/ConverdoOrderAPI.php +25 -7
  13. app/code/community/Converdo/Common/Config/Configuration.php +164 -0
  14. app/code/community/Converdo/Common/Config/Contracts/PlatformConfigurationContract.php +150 -0
  15. app/code/community/Converdo/Common/Container/Container.php +80 -0
  16. app/code/community/Converdo/Common/Controllers/PingController.php +93 -0
  17. app/code/community/Converdo/Common/Cookie/Factories/CookieFactory.php +24 -0
  18. lib/Converdo/Analytics/Cookie/Manager.php → app/code/community/Converdo/Common/Cookie/Managers/CookieManager.php +18 -17
  19. app/code/community/Converdo/Common/Cookie/Models/Contracts/CookieInterface.php +103 -0
  20. lib/Converdo/Analytics/Cookie/Model.php → app/code/community/Converdo/Common/Cookie/Models/Cookie.php +20 -43
  21. app/code/community/Converdo/Common/Input/Input.php +25 -0
  22. app/code/community/Converdo/Common/Input/InputManager.php +29 -0
  23. app/code/community/Converdo/Common/Log/LogReader.php +64 -0
  24. app/code/community/Converdo/Common/Log/Logger.php +177 -0
  25. app/code/community/Converdo/Common/Log/LoggerAwareInterface.php +17 -0
  26. app/code/community/Converdo/Common/Log/LoggerInterface.php +114 -0
  27. app/code/community/Converdo/Common/Page/Factories/PageFactory.php +21 -0
  28. app/code/community/Converdo/Common/Page/Models/Contracts/PageInterface.php +36 -0
  29. app/code/community/Converdo/Common/Page/Models/Page.php +54 -0
  30. app/code/community/Converdo/Common/Page/Support/Contracts/RouteResolverInterface.php +15 -0
  31. app/code/community/Converdo/Common/Page/Support/PageTypes.php +78 -0
  32. app/code/community/Converdo/Common/Query/Managers/QueryManager.php +111 -0
  33. app/code/community/Converdo/Common/Query/Managers/QueryMetadata.php +30 -0
  34. app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceCartInterface.php +36 -0
  35. app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceCategoryInterface.php +21 -0
  36. app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceItemInterface.php +215 -0
  37. app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceSearchInterface.php +51 -0
  38. app/code/community/Converdo/Common/Query/Models/EcommerceCart.php +54 -0
  39. app/code/community/Converdo/Common/Query/Models/EcommerceCategory.php +31 -0
  40. app/code/community/Converdo/Common/Query/Models/EcommerceItem.php +323 -0
  41. app/code/community/Converdo/Common/Query/Models/EcommerceSearch.php +77 -0
  42. app/code/community/Converdo/Common/Query/Queries/AbstractQuery.php +41 -0
  43. app/code/community/Converdo/Common/Query/Queries/AddEcommerceItem.php +45 -0
  44. app/code/community/Converdo/Common/Query/Queries/CategoryView.php +43 -0
  45. app/code/community/Converdo/Common/Query/Queries/Contracts/QueryInterface.php +34 -0
  46. app/code/community/Converdo/Common/Query/Queries/CustomVariable.php +35 -0
  47. app/code/community/Converdo/Common/Query/Queries/EcommerceView.php +59 -0
  48. app/code/community/Converdo/Common/Query/Queries/EnableHeartBeatTimer.php +27 -0
  49. app/code/community/Converdo/Common/Query/Queries/EnableLinkTracking.php +27 -0
  50. app/code/community/Converdo/Common/Query/Queries/SiteId.php +35 -0
  51. app/code/community/Converdo/Common/Query/Queries/TrackEcommerceCart.php +43 -0
  52. app/code/community/Converdo/Common/Query/Queries/TrackPageView.php +46 -0
  53. app/code/community/Converdo/Common/Query/Queries/TrackSiteSearch.php +48 -0
  54. app/code/community/Converdo/Common/Query/Queries/TrackerUrl.php +35 -0
  55. app/code/community/Converdo/Common/Response/JsonResponse.php +30 -0
  56. app/code/community/Converdo/Common/Response/Response.php +34 -0
  57. {lib/Converdo/Analytics/Support → app/code/community/Converdo/Common/Security}/Crypt.php +10 -8
  58. app/code/community/Converdo/Common/Support/Arrayable.php +37 -0
  59. app/code/community/Converdo/Common/Support/HasParameters.php +66 -0
  60. app/code/community/Converdo/Common/Support/UsesInput.php +18 -0
  61. app/code/community/Converdo/Common/autoload.php +71 -0
  62. app/code/community/Converdo/Common/bootstrap.php +17 -0
  63. app/code/community/Converdo/Common/config.php +9 -0
  64. app/code/community/Converdo/Common/dependencies.php +12 -0
  65. app/code/community/Converdo/Common/functions.php +44 -0
  66. app/code/community/Converdo/Magento/Block/Tracker.php +74 -0
  67. app/code/community/Converdo/Magento/Config/Configuration.php +191 -0
  68. app/code/community/Converdo/Magento/Container/Bindings.php +24 -0
  69. app/code/community/Converdo/Magento/Factories/EcommerceCartFactory.php +21 -0
  70. app/code/community/Converdo/Magento/Factories/EcommerceCategoryFactory.php +20 -0
  71. app/code/community/Converdo/Magento/Factories/EcommerceItemFactory.php +76 -0
  72. app/code/community/Converdo/Magento/Factories/EcommerceSearchFactory.php +25 -0
  73. app/code/community/Converdo/Magento/Helper/Data.php +6 -0
  74. app/code/community/Converdo/Magento/Model/Observer.php +48 -0
  75. app/code/community/Converdo/Magento/Page/RouteResolver.php +71 -0
  76. app/code/community/Converdo/Magento/Support/PriceHelper.php +28 -0
  77. app/code/community/Converdo/Magento/controllers/PingController.php +18 -0
  78. app/code/community/Converdo/{Analytics → Magento}/etc/adminhtml.xml +0 -0
  79. app/code/community/Converdo/{Analytics → Magento}/etc/config.xml +16 -16
  80. app/code/community/Converdo/{Analytics → Magento}/etc/system.xml +0 -0
  81. app/design/frontend/base/default/template/analytics/analytics.phtml +6 -3
  82. app/etc/modules/Converdo_Analytics.xml +2 -2
  83. lib/Converdo/Analytics/API/ConverdoAPI.php +0 -9
  84. lib/Converdo/Analytics/API/Factories/Order.php +0 -82
  85. lib/Converdo/Analytics/Models/CategoryView.php +0 -56
  86. lib/Converdo/Analytics/Models/Configuration.php +0 -170
  87. lib/Converdo/Analytics/Models/EcommerceCartUpdate.php +0 -46
  88. lib/Converdo/Analytics/Models/EcommerceOrder.php +0 -158
  89. lib/Converdo/Analytics/Models/EcommerceProduct.php +0 -159
  90. lib/Converdo/Analytics/Models/EcommerceView.php +0 -401
  91. lib/Converdo/Analytics/Models/PageView.php +0 -18
  92. lib/Converdo/Analytics/Models/SearchView.php +0 -103
  93. lib/Converdo/Analytics/Support/AbstractTracker.php +0 -31
  94. lib/Converdo/Analytics/Support/Arrayable.php +0 -14
  95. lib/Converdo/Analytics/Support/Cookie.php +0 -22
  96. lib/Converdo/Analytics/Support/HoldsAttributes.php +0 -14
  97. lib/Converdo/Analytics/Tracker.php +0 -200
  98. lib/Converdo/Analytics/Trackers/Cart.php +0 -67
  99. lib/Converdo/Analytics/Trackers/CategoryView.php +0 -38
  100. lib/Converdo/Analytics/Trackers/Configuration.php +0 -38
  101. lib/Converdo/Analytics/Trackers/EcommerceView.php +0 -59
  102. lib/Converdo/Analytics/Trackers/Options.php +0 -43
  103. lib/Converdo/Analytics/Trackers/Order.php +0 -78
  104. lib/Converdo/Analytics/Trackers/PageView.php +0 -152
  105. lib/Converdo/Analytics/Trackers/SearchView.php +0 -49
  106. package.xml +4 -4
app/code/community/Converdo/Analytics/Block/Tracker.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Block_Tracker extends Mage_Core_Block_Template
4
- {
5
- /**
6
- * @var array
7
- */
8
- protected $orderedIds = [];
9
-
10
- /**
11
- * Render Converdo tracking scripts
12
- *
13
- * @return string
14
- */
15
- protected function trackers()
16
- {
17
- if (! Mage::helper('analytics')->isEnabled()) {
18
- return null;
19
- }
20
-
21
- $trackers = [
22
- new Converdo_Analytics_Trackers_Configuration(),
23
- new Converdo_Analytics_Trackers_PageView(),
24
- new Converdo_Analytics_Trackers_SearchView(),
25
- new Converdo_Analytics_Trackers_EcommerceView(),
26
- new Converdo_Analytics_Trackers_CategoryView(),
27
- new Converdo_Analytics_Trackers_Cart(),
28
- new Converdo_Analytics_Trackers_Order(),
29
- new Converdo_Analytics_Trackers_Options(),
30
- ];
31
-
32
- foreach ($trackers as $tracker) {
33
- if (! $tracker->responsible()) {
34
- continue;
35
- }
36
-
37
- $tracker->track();
38
-
39
- Converdo_Analytics_Tracker::attributes($tracker->attributes());
40
- Converdo_Analytics_Tracker::query($tracker->toArray());
41
- }
42
-
43
- echo implode("\r\n\t\t\t\t", Converdo_Analytics_Tracker::query());
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Converdo/Analytics/Helper/Data.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
4
- {
5
- /**
6
- * Get whether Converdo Analytics is enabled for this shop.
7
- *
8
- * @param null $store
9
- * @return bool
10
- */
11
- public static function isEnabled($store = null)
12
- {
13
- return (bool) self::hasSiteId($store)
14
- && Mage::getStoreConfigFlag('converdo/analytics/active', $store)
15
- && Mage::getStoreConfigFlag('converdo/analytics/token', $store);
16
- }
17
-
18
- /**
19
- * Get the Site Id.
20
- *
21
- * @param null $store
22
- * @return string
23
- */
24
- public static function getSiteId($store = null)
25
- {
26
- return Mage::getStoreConfig('converdo/analytics/site', $store);
27
- }
28
-
29
- /**
30
- * Get whether the Site Id is set.
31
- *
32
- * @param null $store
33
- * @return bool
34
- */
35
- public static function hasSiteId($store = null)
36
- {
37
- return (bool) self::getSiteId($store);
38
- }
39
-
40
- public static function getSiteUrl()
41
- {
42
- return 'https://tracker.converdo.com/';
43
- }
44
-
45
- public static function getPhpTracker($full = false)
46
- {
47
- if ($full) {
48
- return self::getSiteUrl() . 'tracker.php';
49
- }
50
-
51
- return 'tracker.php';
52
- }
53
-
54
- public static function getJsTracker($full = false)
55
- {
56
- if ($full) {
57
- return self::getSiteUrl() . 'tracker.js';
58
- }
59
-
60
- return 'tracker.js';
61
- }
62
-
63
- /**
64
- * Gets whether the current page is a 'search' page.
65
- *
66
- * @return bool
67
- */
68
- public function isSearchPage()
69
- {
70
- return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'result';
71
- }
72
-
73
- /**
74
- * Gets whether the current page is a 'order success' page.
75
- *
76
- * @return bool
77
- */
78
- public function isSuccessPage()
79
- {
80
- return isset(Converdo_Analytics_Tracker::attributes()['pt2'])
81
- && Converdo_Analytics_Tracker::attributes()['pt2'] === 'success_index';
82
- }
83
-
84
- /**
85
- * Gets whether the current page is a 'category' page.
86
- *
87
- * @return bool
88
- */
89
- public function isCategoryPage()
90
- {
91
- return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'category'
92
- && Mage::registry('current_category');
93
- }
94
-
95
- /**
96
- * Gets whether the current page is a 'product' page.
97
- *
98
- * @return bool
99
- */
100
- public function isProductPage()
101
- {
102
- return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'product'
103
- && Mage::registry('current_product');
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Converdo/Analytics/Model/Logger.php DELETED
@@ -1,92 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Model_Logger
4
- {
5
- /**
6
- * Writes a info-level entry to the log file.
7
- *
8
- * @param $input
9
- * @return void
10
- */
11
- public static function info($input)
12
- {
13
- self::message($input, Zend_Log::INFO);
14
- }
15
-
16
- /**
17
- * Writes a debug-level entry to the log file.
18
- *
19
- * @param $input
20
- * @return void
21
- */
22
- public static function debug($input)
23
- {
24
- self::message($input, Zend_Log::DEBUG);
25
- }
26
-
27
- /**
28
- * Writes a alert-level entry to the log file.
29
- *
30
- * @param $input
31
- * @return void
32
- */
33
- public static function alert($input)
34
- {
35
- self::message($input, Zend_Log::ALERT);
36
- }
37
-
38
- /**
39
- * Writes a critical-level entry to the log file.
40
- *
41
- * @param $input
42
- * @return void
43
- */
44
- public static function critical($input)
45
- {
46
- self::message($input, Zend_Log::CRIT);
47
- }
48
-
49
- /**
50
- * Writes a emergency-level entry to the log file.
51
- *
52
- * @param $input
53
- * @return void
54
- */
55
- public static function emergency($input)
56
- {
57
- self::message($input, Zend_Log::EMERG);
58
- }
59
-
60
- /**
61
- * Writes a notice-level entry to the log file.
62
- *
63
- * @param $input
64
- * @return void
65
- */
66
- public static function notice($input)
67
- {
68
- self::message($input, Zend_Log::NOTICE);
69
- }
70
-
71
- /**
72
- * Writes a warning-level entry to the log file.
73
- *
74
- * @param $input
75
- * @return void
76
- */
77
- public static function warning($input)
78
- {
79
- self::message($input, Zend_Log::WARN);
80
- }
81
-
82
- /**
83
- * Writes the message to the log file.
84
- *
85
- * @param string $input
86
- * @param string $level
87
- */
88
- protected static function message($input, $level)
89
- {
90
- Mage::log($input, $level, 'ConverdoAnalytics.log');
91
- }
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Converdo/Analytics/Model/Observer.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Model_Observer
4
- {
5
- /**
6
- * Listens to placed orders. Sends the order to the Converdo Analytics API.
7
- *
8
- * @param Varien_Event_Observer $observer
9
- * @throws Exception
10
- */
11
- public function onOrderPlacedEvent(Varien_Event_Observer $observer)
12
- {
13
- try {
14
- $order = $this->getOrder($observer);
15
-
16
- if (! $this->enabled() || ! $order) {
17
- return;
18
- }
19
-
20
- (new Converdo_Analytics_API_ConverdoAPI())->order()->create(
21
- (new Converdo_Analytics_API_Factories_Order())->make($order)
22
- );
23
-
24
- Converdo_Analytics_Cookie_Manager::logEcommerce();
25
- } catch (Exception $e) {
26
- Converdo_Analytics_Model_Logger::info($e->getMessage());
27
- }
28
- }
29
-
30
- /**
31
- * Listens to changed orders. Sends the new order status to the Converdo Analytics API.
32
- *
33
- * @param Varien_Event_Observer $observer
34
- * @throws Exception
35
- */
36
- public function onOrderStatusChangedEvent(Varien_Event_Observer $observer)
37
- {
38
- try {
39
- $order = $this->getOrder($observer);
40
-
41
- if (! $this->enabled() || ! $order) {
42
- return;
43
- }
44
-
45
- (new Converdo_Analytics_API_ConverdoAPI())->order()->modifyStatus(
46
- (new Converdo_Analytics_API_Factories_Order())->make($order)
47
- );
48
- } catch (Exception $e) {
49
- Converdo_Analytics_Model_Logger::info($e->getMessage());
50
- }
51
- }
52
-
53
- /**
54
- * Checks whether the Converdo Analytics plugin is enabled.
55
- *
56
- * @return bool
57
- */
58
- protected function enabled()
59
- {
60
- return Mage::helper('analytics')->isEnabled();
61
- }
62
-
63
- /**
64
- * Retrieves the Magento order from the event.
65
- *
66
- * @param Varien_Event_Observer $observer
67
- * @return Mage_Sales_Model_Order
68
- */
69
- protected function getOrder(Varien_Event_Observer $observer)
70
- {
71
- return $observer->getEvent()->getOrder();
72
- }
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Converdo/Analytics/controllers/PingController.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_PingController extends Mage_Core_Controller_Front_Action
4
- {
5
- protected $output = [];
6
-
7
- public function pingerAction()
8
- {
9
- $this->output['plugin']['version'] = reset(Mage::getConfig()->getNode()->modules->Converdo_Analytics->version);
10
-
11
- if (! ($key = $this->getRequest()->getParam('key')) || $key !== Mage::getStoreConfig('converdo/analytics/site')) {
12
- return $this->response();
13
- }
14
-
15
- $api = file_get_contents('https://www.converdo.com/api/ping/' . Mage::getStoreConfig('converdo/analytics/site'));
16
- $api = json_decode($api);
17
-
18
- if (! $api || $api->error) {
19
- return $this->response();
20
- }
21
-
22
- $validSite = Mage::getStoreConfig('converdo/analytics/site') === $api->tokens->site;
23
- $validUser = Mage::getStoreConfig('converdo/analytics/token') === $api->tokens->user;
24
- $validEncryption = Mage::getStoreConfig('converdo/analytics/encryption') === $api->tokens->encryption;
25
-
26
- $this->output['validation']['enabled'] = (bool) Mage::getStoreConfigFlag('converdo/analytics/active');
27
- $this->output['validation']['valid'] = $validSite && $validUser && $validEncryption;
28
-
29
- $this->output['validation']['tokens']['site'] = $validSite;
30
- $this->output['validation']['tokens']['user'] = $validUser;
31
- $this->output['validation']['tokens']['encryption'] = $validEncryption;
32
-
33
- $this->output['info']['site'] = $api->site;
34
- $this->output['info']['url'] = $api->url;
35
- $this->output['info']['hash'] = $api->hash;
36
-
37
- return $this->response();
38
- }
39
-
40
- protected function response()
41
- {
42
- header('Content-Type: application/json;charset=utf-8');
43
-
44
- echo json_encode($this->output, true);
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Converdo/Common/API/ConverdoAPI.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\API;
4
+
5
+ use Converdo\Common\API\Sections\ConverdoOrderAPI;
6
+
7
+ class ConverdoAPI
8
+ {
9
+ /**
10
+ * Returns a new ConverdoOrderAPI instance.
11
+ *
12
+ * @return ConverdoOrderAPI
13
+ */
14
+ public static function order()
15
+ {
16
+ return new ConverdoOrderAPI();
17
+ }
18
+ }
{lib/Converdo/Analytics → app/code/community/Converdo/Common}/API/ConverdoClient.php RENAMED
@@ -1,6 +1,11 @@
1
  <?php
2
 
3
- class Converdo_Analytics_API_ConverdoClient
 
 
 
 
 
4
  {
5
  /**
6
  * @var string
@@ -60,7 +65,7 @@ class Converdo_Analytics_API_ConverdoClient
60
  */
61
  public function defaultParameters()
62
  {
63
- $cookie = Converdo_Analytics_Cookie_Manager::find();
64
 
65
  return [
66
  'visitor' => $cookie->getVisitor(),
@@ -100,19 +105,30 @@ class Converdo_Analytics_API_ConverdoClient
100
  return (int) $this->limit;
101
  }
102
 
 
 
 
 
 
103
  protected function buildUrl()
104
  {
105
- $siteId = Mage::getStoreConfig('converdo/analytics/site');
106
- $userId = Mage::getStoreConfig('converdo/analytics/token');
107
-
108
- return Mage::helper('analytics')->getSiteUrl() .
109
- "index.php?module=API" .
110
- "&method={$this->module}" .
111
- "&idSite={$siteId}" .
112
- "&token_auth={$userId}" .
113
- "&format=json";
 
114
  }
115
 
 
 
 
 
 
116
  public function post()
117
  {
118
  try {
@@ -121,11 +137,16 @@ class Converdo_Analytics_API_ConverdoClient
121
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
122
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
123
  curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getParameters());
124
- curl_exec($ch);
 
 
 
 
 
125
 
126
  curl_close($ch);
127
- } catch (\Exception $e) {
128
- // Whoops...
129
  }
130
 
131
  return true;
1
  <?php
2
 
3
+ namespace Converdo\Common\API;
4
+
5
+ use Converdo\Common\Cookie\Managers\CookieManager;
6
+ use Exception;
7
+
8
+ class ConverdoClient
9
  {
10
  /**
11
  * @var string
65
  */
66
  public function defaultParameters()
67
  {
68
+ $cookie = CookieManager::find();
69
 
70
  return [
71
  'visitor' => $cookie->getVisitor(),
105
  return (int) $this->limit;
106
  }
107
 
108
+ /**
109
+ * Builds the URL for the request.
110
+ *
111
+ * @return string
112
+ */
113
  protected function buildUrl()
114
  {
115
+ return cvd_config()->url(
116
+ "index.php?" .
117
+ http_build_query([
118
+ 'module' => 'API',
119
+ 'method' => $this->module,
120
+ 'idSite' => cvd_config()->platform()->website(),
121
+ 'token_auth' => cvd_config()->platform()->user(),
122
+ 'format' => 'json',
123
+ ])
124
+ );
125
  }
126
 
127
+ /**
128
+ * Posts the data to the API.
129
+ *
130
+ * @return bool
131
+ */
132
  public function post()
133
  {
134
  try {
137
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
138
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
139
  curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getParameters());
140
+
141
+ $response = curl_exec($ch);
142
+
143
+ if ($response === FALSE) {
144
+ throw new Exception(curl_error($ch));
145
+ }
146
 
147
  curl_close($ch);
148
+ } catch (Exception $e) {
149
+ cvd_logger()->error("Could not connect to API with message: {$e->getMessage()}");
150
  }
151
 
152
  return true;
app/code/community/Converdo/Common/API/Factories/OrderFactory.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Page\Factories;
4
+
5
+ use Converdo\Common\API\Models\Contracts\OrderInterface;
6
+ use Converdo\Common\API\Models\Order;
7
+ use Mage_Sales_Model_Order;
8
+
9
+ class OrderFactory
10
+ {
11
+ /**
12
+ * @param Mage_Sales_Model_Order $order
13
+ * @return OrderInterface
14
+ */
15
+ public static function build(Mage_Sales_Model_Order $order)
16
+ {
17
+ return (new Order())
18
+ ->setOrderId($order->getRealOrderId())
19
+ ->setCustomer(self::customer($order))
20
+ ->setProducts(cvd_config()->platform()->getActiveCartProducts())
21
+ ->setSubtotal($order->getSubtotal())
22
+ ->setTax($order->getBaseTaxAmount())
23
+ ->setShipping($order->getBaseShippingAmount())
24
+ ->setDiscount($order->getBaseDiscountAmount())
25
+ ->setCoupon($order->getCouponCode())
26
+ ->setStatus($order->getStatus());
27
+ }
28
+
29
+ /**
30
+ * Returns all associated customer data.
31
+ *
32
+ * @param Mage_Sales_Model_Order $order
33
+ * @return array
34
+ */
35
+ protected static function customer(Mage_Sales_Model_Order $order)
36
+ {
37
+ return [
38
+ 'prefix' => $order->getBillingAddress()->getPrefix(),
39
+ 'name' => $order->getBillingAddress()->getName(),
40
+ 'address' => implode(', ', $order->getBillingAddress()->getStreet()),
41
+ 'postal_code' => $order->getBillingAddress()->getPostcode(),
42
+ 'city' => $order->getBillingAddress()->getCity(),
43
+ 'country' => $order->getBillingAddress()->getCountryModel()->getName(),
44
+ 'email' => $order->getBillingAddress()->getEmail() ?: $order->getCustomerEmail(),
45
+ 'telephone' => $order->getBillingAddress()->getTelephone(),
46
+ ];
47
+ }
48
+ }
app/code/community/Converdo/Common/API/Models/Contracts/OrderInterface.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\API\Models\Contracts;
4
+
5
+ use Converdo\Common\Query\Models\EcommerceItem;
6
+
7
+ interface OrderInterface
8
+ {
9
+ /**
10
+ * Sets the order id.
11
+ *
12
+ * @param mixed $orderId
13
+ * @return $this
14
+ */
15
+ public function setOrderId($orderId);
16
+
17
+ /**
18
+ * Gets the order id.
19
+ *
20
+ * @return mixed
21
+ */
22
+ public function getOrderId();
23
+
24
+ /**
25
+ * Sets the subtotal.
26
+ *
27
+ * @param float $subtotal
28
+ * @return $this
29
+ */
30
+ public function setSubtotal($subtotal);
31
+
32
+ /**
33
+ * Gets the subtotal.
34
+ *
35
+ * @return float
36
+ */
37
+ public function getSubtotal();
38
+
39
+ /**
40
+ * Sets the tax fees.
41
+ *
42
+ * @param float $tax
43
+ * @return $this
44
+ */
45
+ public function setTax($tax);
46
+
47
+ /**
48
+ * Gets the tax fees.
49
+ *
50
+ * @return float
51
+ */
52
+ public function getTax();
53
+
54
+ /**
55
+ * Sets the shipping fees.
56
+ *
57
+ * @param float $shipping
58
+ * @return $this
59
+ */
60
+ public function setShipping($shipping);
61
+
62
+ /**
63
+ * Gets the shipping fees.
64
+ *
65
+ * @return float
66
+ */
67
+ public function getShipping();
68
+
69
+ /**
70
+ * Sets the discount.
71
+ *
72
+ * @param float $discount
73
+ * @return $this
74
+ */
75
+ public function setDiscount($discount);
76
+
77
+ /**
78
+ * Gets the discount.
79
+ *
80
+ * @return float
81
+ */
82
+ public function getDiscount();
83
+
84
+ /**
85
+ * Sets the customer data.
86
+ *
87
+ * @param array $customer
88
+ * @return $this
89
+ */
90
+ public function setCustomer(array $customer);
91
+
92
+ /**
93
+ * Gets the customer data.
94
+ *
95
+ * @param mixed|null $key
96
+ * @return array
97
+ */
98
+ public function getCustomer($key = null);
99
+
100
+ /**
101
+ * Sets the products.
102
+ *
103
+ * @param array $products
104
+ * @return $this
105
+ */
106
+ public function setProducts($products);
107
+
108
+ /**
109
+ * Gets the products.
110
+ *
111
+ * @return EcommerceItem[]
112
+ */
113
+ public function getProducts();
114
+
115
+ /**
116
+ * Sets the order status.
117
+ *
118
+ * @param string $status
119
+ * @return $this
120
+ */
121
+ public function setStatus($status);
122
+
123
+ /**
124
+ * Gets the order status.
125
+ *
126
+ * @return string
127
+ */
128
+ public function getStatus();
129
+
130
+ /**
131
+ * Sets the used coupon.
132
+ *
133
+ * @param string $coupon
134
+ * @return string|null
135
+ */
136
+ public function setCoupon($coupon);
137
+
138
+ /**
139
+ * Gets the used coupon.
140
+ *
141
+ * @return string|null
142
+ */
143
+ public function getCoupon();
144
+
145
+ /**
146
+ * Gets the SKUs of all products in the cart.
147
+ *
148
+ * @return array
149
+ */
150
+ public function getProductSKUs();
151
+ }
{lib/Converdo/Analytics → app/code/community/Converdo/Common}/API/Models/Order.php RENAMED
@@ -1,17 +1,16 @@
1
  <?php
2
 
3
- class Converdo_Analytics_API_Models_Order
 
 
 
 
4
  {
5
  /**
6
  * @var mixed
7
  */
8
  protected $orderId;
9
 
10
- /**
11
- * @var string
12
- */
13
- protected $orderIdUrl;
14
-
15
  /**
16
  * @var float
17
  */
@@ -27,6 +26,11 @@ class Converdo_Analytics_API_Models_Order
27
  */
28
  protected $shipping;
29
 
 
 
 
 
 
30
  /**
31
  * @var array
32
  */
@@ -43,50 +47,22 @@ class Converdo_Analytics_API_Models_Order
43
  protected $status;
44
 
45
  /**
46
- * Sets the order id.
47
- *
48
- * @param mixed $orderId
49
- * @return $this
50
  */
51
- public function setOrderId($orderId)
52
- {
53
- $this->orderId = $orderId;
54
-
55
- $this->setOrderIdUrl($orderId);
56
-
57
- return $this;
58
- }
59
 
60
  /**
61
- * Sets the order id url.
62
- *
63
- * @param mixed $orderId
64
- * @return $this
65
  */
66
- public function setOrderIdUrl($orderId)
67
  {
68
- $this->orderIdUrl = Mage::getUrl('adminhtml/sales_order/view', [
69
- 'order_id' => $orderId,
70
- '_type' => Mage_Core_Model_Store::URL_TYPE_WEB,
71
- ]);
72
 
73
  return $this;
74
  }
75
 
76
  /**
77
- * Gets the order id url.
78
- *
79
- * @return string
80
- */
81
- public function getOrderIdUrl()
82
- {
83
- return $this->orderIdUrl;
84
- }
85
-
86
- /**
87
- * Gets the order id.
88
- *
89
- * @return mixed
90
  */
91
  public function getOrderId()
92
  {
@@ -94,10 +70,7 @@ class Converdo_Analytics_API_Models_Order
94
  }
95
 
96
  /**
97
- * Sets the subtotal.
98
- *
99
- * @param float $subtotal
100
- * @return $this
101
  */
102
  public function setSubtotal($subtotal)
103
  {
@@ -107,32 +80,25 @@ class Converdo_Analytics_API_Models_Order
107
  }
108
 
109
  /**
110
- * Gets the subtotal.
111
- *
112
- * @return float
113
  */
114
  public function getSubtotal()
115
  {
116
- return (float) $this->subtotal;
117
  }
118
 
119
  /**
120
- * Sets the tax fees.
121
- *
122
- * @param float $tax
123
- * @return $this
124
  */
125
  public function setTax($tax)
126
  {
127
- $this->tax = $tax;
128
 
129
  return $this;
130
  }
131
 
132
  /**
133
- * Gets the tax fees.
134
- *
135
- * @return float
136
  */
137
  public function getTax()
138
  {
@@ -140,33 +106,43 @@ class Converdo_Analytics_API_Models_Order
140
  }
141
 
142
  /**
143
- * Sets the shipping fees.
144
- *
145
- * @param float $shipping
146
- * @return $this
147
  */
148
  public function setShipping($shipping)
149
  {
150
- $this->shipping = $shipping;
151
 
152
  return $this;
153
  }
154
 
155
  /**
156
- * Gets the shipping fees.
157
- *
158
- * @return float
159
  */
160
  public function getShipping()
161
  {
162
- return (float) $this->shipping;
163
  }
164
 
165
  /**
166
- * Sets the customer data.
167
- *
168
- * @param array $customer
169
- * @return $this
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  */
171
  public function setCustomer(array $customer)
172
  {
@@ -176,10 +152,7 @@ class Converdo_Analytics_API_Models_Order
176
  }
177
 
178
  /**
179
- * Gets the customer data.
180
- *
181
- * @param mixed|null $key
182
- * @return array
183
  */
184
  public function getCustomer($key = null)
185
  {
@@ -191,10 +164,7 @@ class Converdo_Analytics_API_Models_Order
191
  }
192
 
193
  /**
194
- * Sets the products.
195
- *
196
- * @param array $products
197
- * @return $this
198
  */
199
  public function setProducts($products)
200
  {
@@ -204,9 +174,7 @@ class Converdo_Analytics_API_Models_Order
204
  }
205
 
206
  /**
207
- * Gets the products.
208
- *
209
- * @return array
210
  */
211
  public function getProducts()
212
  {
@@ -214,10 +182,7 @@ class Converdo_Analytics_API_Models_Order
214
  }
215
 
216
  /**
217
- * Sets the order status.
218
- *
219
- * @param string $status
220
- * @return $this
221
  */
222
  public function setStatus($status)
223
  {
@@ -227,9 +192,7 @@ class Converdo_Analytics_API_Models_Order
227
  }
228
 
229
  /**
230
- * Gets the order status.
231
- *
232
- * @return string
233
  */
234
  public function getStatus()
235
  {
@@ -237,16 +200,32 @@ class Converdo_Analytics_API_Models_Order
237
  }
238
 
239
  /**
240
- * Gets the SKUs of all products in the cart.
241
- *
242
- * @return array
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  */
244
- public function getProductSkus()
245
  {
246
  $skus = [];
247
 
248
  foreach ($this->getProducts() as $product) {
249
- $skus[] = $product['sku'];
250
  }
251
 
252
  return $skus;
1
  <?php
2
 
3
+ namespace Converdo\Common\API\Models;
4
+
5
+ use Converdo\Common\API\Models\Contracts\OrderInterface;
6
+
7
+ class Order implements OrderInterface
8
  {
9
  /**
10
  * @var mixed
11
  */
12
  protected $orderId;
13
 
 
 
 
 
 
14
  /**
15
  * @var float
16
  */
26
  */
27
  protected $shipping;
28
 
29
+ /**
30
+ * @var float
31
+ */
32
+ protected $discount;
33
+
34
  /**
35
  * @var array
36
  */
47
  protected $status;
48
 
49
  /**
50
+ * @var string
 
 
 
51
  */
52
+ protected $coupon;
 
 
 
 
 
 
 
53
 
54
  /**
55
+ * @inheritDoc
 
 
 
56
  */
57
+ public function setOrderId($orderId)
58
  {
59
+ $this->orderId = $orderId;
 
 
 
60
 
61
  return $this;
62
  }
63
 
64
  /**
65
+ * @inheritDoc
 
 
 
 
 
 
 
 
 
 
 
 
66
  */
67
  public function getOrderId()
68
  {
70
  }
71
 
72
  /**
73
+ * @inheritDoc
 
 
 
74
  */
75
  public function setSubtotal($subtotal)
76
  {
80
  }
81
 
82
  /**
83
+ * @inheritDoc
 
 
84
  */
85
  public function getSubtotal()
86
  {
87
+ return $this->subtotal;
88
  }
89
 
90
  /**
91
+ * @inheritDoc
 
 
 
92
  */
93
  public function setTax($tax)
94
  {
95
+ $this->tax = (float) $tax;
96
 
97
  return $this;
98
  }
99
 
100
  /**
101
+ * @inheritDoc
 
 
102
  */
103
  public function getTax()
104
  {
106
  }
107
 
108
  /**
109
+ * @inheritDoc
 
 
 
110
  */
111
  public function setShipping($shipping)
112
  {
113
+ $this->shipping = (float) $shipping;
114
 
115
  return $this;
116
  }
117
 
118
  /**
119
+ * @inheritDoc
 
 
120
  */
121
  public function getShipping()
122
  {
123
+ return $this->shipping;
124
  }
125
 
126
  /**
127
+ * @inheritDoc
128
+ */
129
+ public function setDiscount($discount)
130
+ {
131
+ $this->discount = (float) $discount;
132
+
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * @inheritDoc
138
+ */
139
+ public function getDiscount()
140
+ {
141
+ return $this->discount;
142
+ }
143
+
144
+ /**
145
+ * @inheritDoc
146
  */
147
  public function setCustomer(array $customer)
148
  {
152
  }
153
 
154
  /**
155
+ * @inheritDoc
 
 
 
156
  */
157
  public function getCustomer($key = null)
158
  {
164
  }
165
 
166
  /**
167
+ * @inheritDoc
 
 
 
168
  */
169
  public function setProducts($products)
170
  {
174
  }
175
 
176
  /**
177
+ * @inheritDoc
 
 
178
  */
179
  public function getProducts()
180
  {
182
  }
183
 
184
  /**
185
+ * @inheritDoc
 
 
 
186
  */
187
  public function setStatus($status)
188
  {
192
  }
193
 
194
  /**
195
+ * @inheritDoc
 
 
196
  */
197
  public function getStatus()
198
  {
200
  }
201
 
202
  /**
203
+ * @inheritDoc
204
+ */
205
+ public function setCoupon($coupon)
206
+ {
207
+ $this->coupon = $coupon;
208
+
209
+ return $this;
210
+ }
211
+
212
+ /**
213
+ * @inheritDoc
214
+ */
215
+ public function getCoupon()
216
+ {
217
+ return $this->coupon;
218
+ }
219
+
220
+ /**
221
+ * @inheritDoc
222
  */
223
+ public function getProductSKUs()
224
  {
225
  $skus = [];
226
 
227
  foreach ($this->getProducts() as $product) {
228
+ $skus[] = $product->getSKU();
229
  }
230
 
231
  return $skus;
app/code/community/Converdo/Common/API/Requests.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\API;
4
+
5
+ use Converdo\Common\API\Models\Contracts\OrderInterface;
6
+ use Converdo\Common\Cookie\Managers\CookieManager;
7
+ use Exception;
8
+
9
+ class Requests
10
+ {
11
+ /**
12
+ * Sends the order to Converdo Analytics.
13
+ *
14
+ * @param OrderInterface $order
15
+ * @return bool
16
+ */
17
+ public static function orderCreate(OrderInterface $order)
18
+ {
19
+ try {
20
+ (new ConverdoAPI())->order()->create($order);
21
+
22
+ CookieManager::logEcommerce();
23
+
24
+ cvd_logger()->info("New order [{$order->getOrderId()}] was placed.");
25
+ } catch (Exception $e) {
26
+ cvd_logger()->error($e->getMessage());
27
+ }
28
+
29
+ return true;
30
+ }
31
+
32
+ /**
33
+ * Sends an updated status to Converdo Analytics.
34
+ *
35
+ * @param OrderInterface $order
36
+ * @return bool
37
+ */
38
+ public static function orderStatusUpdate(OrderInterface $order)
39
+ {
40
+ try {
41
+ (new ConverdoAPI())->order()->modifyStatus($order);
42
+
43
+ cvd_logger()->info("Order [{$order->getOrderId()}] status changed to [{$order->getStatus()}]");
44
+ } catch (Exception $e) {
45
+ cvd_logger()->error($e->getMessage());
46
+ }
47
+
48
+ return true;
49
+ }
50
+ }
{lib/Converdo/Analytics → app/code/community/Converdo/Common}/API/Sections/ConverdoOrderAPI.php RENAMED
@@ -1,17 +1,30 @@
1
  <?php
2
 
3
- class Converdo_Analytics_API_Sections_ConverdoOrderAPI
 
 
 
 
 
4
  {
5
- public function create(Converdo_Analytics_API_Models_Order $order)
 
 
 
 
 
 
6
  {
7
- return (new Converdo_Analytics_API_ConverdoClient())
8
  ->setModule('ConverdoEcommerce.completeOrderCVD')
9
  ->setParameters([
10
  'orderId' => $order->getOrderId(),
11
- 'orderIdUrl' => $order->getOrderIdUrl(),
12
  'subtotal' => $order->getSubtotal(),
13
  'tax' => $order->getTax(),
14
  'shipping' => $order->getShipping(),
 
 
 
15
  'customer_prefix' => $order->getCustomer('prefix'),
16
  'customer_name' => $order->getCustomer('name'),
17
  'customer_address' => $order->getCustomer('address'),
@@ -20,14 +33,19 @@ class Converdo_Analytics_API_Sections_ConverdoOrderAPI
20
  'customer_country' => $order->getCustomer('country'),
21
  'customer_email' => $order->getCustomer('email'),
22
  'customer_telephone' => $order->getCustomer('telephone'),
23
- 'products' => base64_encode(json_encode($order->getProductSkus())),
24
  ])
25
  ->post();
26
  }
27
 
28
- public function modifyStatus(Converdo_Analytics_API_Models_Order $order)
 
 
 
 
 
 
29
  {
30
- return (new Converdo_Analytics_API_ConverdoClient())
31
  ->setModule('ConverdoEcommerce.changeOrderStatusCVD')
32
  ->setParameters([
33
  'orderId' => $order->getOrderId(),
1
  <?php
2
 
3
+ namespace Converdo\Common\API\Sections;
4
+
5
+ use Converdo\Common\API\ConverdoClient;
6
+ use Converdo\Common\API\Models\Contracts\OrderInterface;
7
+
8
+ class ConverdoOrderAPI
9
  {
10
+ /**
11
+ * Sends a new order to Converdo Analytics.
12
+ *
13
+ * @param OrderInterface $order
14
+ * @return bool
15
+ */
16
+ public function create(OrderInterface $order)
17
  {
18
+ return (new ConverdoClient())
19
  ->setModule('ConverdoEcommerce.completeOrderCVD')
20
  ->setParameters([
21
  'orderId' => $order->getOrderId(),
 
22
  'subtotal' => $order->getSubtotal(),
23
  'tax' => $order->getTax(),
24
  'shipping' => $order->getShipping(),
25
+ 'discount' => $order->getDiscount(),
26
+ 'coupon' => $order->getCoupon(),
27
+ 'products' => base64_encode(json_encode($order->getProductSKUs())),
28
  'customer_prefix' => $order->getCustomer('prefix'),
29
  'customer_name' => $order->getCustomer('name'),
30
  'customer_address' => $order->getCustomer('address'),
33
  'customer_country' => $order->getCustomer('country'),
34
  'customer_email' => $order->getCustomer('email'),
35
  'customer_telephone' => $order->getCustomer('telephone'),
 
36
  ])
37
  ->post();
38
  }
39
 
40
+ /**
41
+ * Sends the modified order status of an existing order to Converdo Analytics.
42
+ *
43
+ * @param OrderInterface $order
44
+ * @return bool
45
+ */
46
+ public function modifyStatus(OrderInterface $order)
47
  {
48
+ return (new ConverdoClient())
49
  ->setModule('ConverdoEcommerce.changeOrderStatusCVD')
50
  ->setParameters([
51
  'orderId' => $order->getOrderId(),
app/code/community/Converdo/Common/Config/Configuration.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Config;
4
+
5
+ use Converdo\Common\Config\Contracts\PlatformConfigurationContract;
6
+ use Converdo\Common\Page\Support\Contracts\RouteResolverInterface;
7
+ use Converdo\Common\Security\Crypt;
8
+
9
+ class Configuration
10
+ {
11
+ /**
12
+ * The Converdo Analytics plugin version.
13
+ *
14
+ * @var string
15
+ */
16
+ const VERSION = '1.2.0.0';
17
+
18
+ /**
19
+ * The Converdo Analytics URL.
20
+ *
21
+ * @var string
22
+ */
23
+ const TRACKER_URL = '//tracker.converdo.com/';
24
+
25
+ /**
26
+ * The development debug options.
27
+ *
28
+ * @var array
29
+ */
30
+ protected $environment = [];
31
+
32
+ /**
33
+ * The absolute path to root of the platform.
34
+ *
35
+ * @var string
36
+ */
37
+ protected $basePath;
38
+
39
+ /**
40
+ * The absolute path to the plugin.
41
+ *
42
+ * @var string
43
+ */
44
+ protected $path;
45
+
46
+ /**
47
+ * The PlatformConfiguration.
48
+ *
49
+ * @var PlatformConfigurationContract
50
+ */
51
+ protected $platform;
52
+
53
+ /**
54
+ * Configuration constructor.
55
+ */
56
+ public function __construct()
57
+ {
58
+ if (defined('MAGENTO_ROOT')) {
59
+ $this->platform = cvd_app(\Converdo\Magento\Config\Configuration::class);
60
+ $this->basePath = MAGENTO_ROOT;
61
+ $this->path = realpath($this->basePath . '/app/code/community/Converdo');
62
+ }
63
+
64
+ if (defined('WC_ABSPATH')) {
65
+ // TODO: WooCommerce
66
+ }
67
+
68
+
69
+ $this->resolveBindings();
70
+
71
+ $this->resolveEnvironment();
72
+ }
73
+
74
+ /**
75
+ * Returns the version number of the plugin.
76
+ *
77
+ * @return string
78
+ */
79
+ public function version()
80
+ {
81
+ return self::VERSION;
82
+ }
83
+
84
+ /**
85
+ * Returns the tracker url.
86
+ *
87
+ * @param null|string $path
88
+ * @return string
89
+ */
90
+ public function url($path = null)
91
+ {
92
+ $url = $this->environment['tracker_url'];
93
+
94
+ if ($path) {
95
+ $url = $url . $path;
96
+ }
97
+
98
+ return $url;
99
+ }
100
+
101
+ /**
102
+ * Returns the environment of the plugin.
103
+ *
104
+ * @param null|string $check
105
+ * @return bool|string
106
+ */
107
+ public function environment($check = null)
108
+ {
109
+ if ($check) {
110
+ return $this->environment['name'] === $check;
111
+ }
112
+
113
+ return $this->environment;
114
+ }
115
+
116
+ /**
117
+ * Returns the platform-specific configuration.
118
+ *
119
+ * @return PlatformConfigurationContract|null
120
+ */
121
+ public function platform()
122
+ {
123
+ return $this->platform;
124
+ }
125
+
126
+ protected function resolveBindings()
127
+ {
128
+ cvd_app()->bindArray($this->platform()->bindings());
129
+ }
130
+
131
+ /**
132
+ * Resolves the environment of the plugin.
133
+ *
134
+ * @return array
135
+ */
136
+ protected function resolveEnvironment()
137
+ {
138
+ if (file_exists($this->basePath . '/converdoanalytics-environment.php')) {
139
+ $this->environment = include($this->basePath . '/converdoanalytics-environment.php');
140
+ } else {
141
+ $this->environment = include($this->path . '/Common/config.php');
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Returns the Crypt instance.
147
+ *
148
+ * @return Crypt
149
+ */
150
+ public function crypt()
151
+ {
152
+ return cvd_app(Crypt::class);
153
+ }
154
+
155
+ /**
156
+ * Returns the route resolver.
157
+ *
158
+ * @return RouteResolverInterface
159
+ */
160
+ public function route()
161
+ {
162
+ return cvd_app()->resolve(RouteResolverInterface::class);
163
+ }
164
+ }
app/code/community/Converdo/Common/Config/Contracts/PlatformConfigurationContract.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Config\Contracts;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceCartInterface;
6
+ use Converdo\Common\Query\Models\Contracts\EcommerceItemInterface;
7
+ use Converdo\Common\Query\Models\Contracts\EcommerceCategoryInterface;
8
+ use Converdo\Common\Query\Models\Contracts\EcommerceSearchInterface;
9
+
10
+ interface PlatformConfigurationContract
11
+ {
12
+ /**
13
+ * Returns whether the plugin is enabled.
14
+ *
15
+ * @param mixed $store
16
+ * @return bool
17
+ */
18
+ public function enabled($store = null);
19
+
20
+ /**
21
+ * Returns whether the plugin is disabled.
22
+ *
23
+ * @param mixed $store
24
+ * @return bool
25
+ */
26
+ public function disabled($store = null);
27
+
28
+ /**
29
+ * Forces the plugin to disabled mode.
30
+ *
31
+ * @return bool
32
+ */
33
+ public function terminate();
34
+
35
+ /**
36
+ * Returns the version, or checks if the version matches.
37
+ *
38
+ * @param string|null $check
39
+ * @return string
40
+ */
41
+ public function version($check = null);
42
+
43
+ /**
44
+ * Returns the website token.
45
+ *
46
+ * @param mixed $store
47
+ * @return string
48
+ */
49
+ public function website($store = null);
50
+
51
+ /**
52
+ * Returns the user token.
53
+ *
54
+ * @param mixed $store
55
+ * @return string
56
+ */
57
+ public function user($store = null);
58
+
59
+ /**
60
+ * Returns the encryption token.
61
+ *
62
+ * @param mixed $store
63
+ * @return string
64
+ */
65
+ public function encryption($store = null);
66
+
67
+ /**
68
+ * Returns whether the current visitor has a cart.
69
+ *
70
+ * @return bool
71
+ */
72
+ public function hasActiveCart();
73
+
74
+ /**
75
+ * Returns the cart of the current visitor.
76
+ *
77
+ * @return EcommerceCartInterface
78
+ */
79
+ public function getActiveCart();
80
+
81
+ /**
82
+ * Returns the cart products of the current visitor.
83
+ *
84
+ * @return EcommerceItemInterface[]
85
+ */
86
+ public function getActiveCartProducts();
87
+
88
+ /**
89
+ * Returns the product seen by the current visitor.
90
+ *
91
+ * @return EcommerceItemInterface
92
+ */
93
+ public function getViewedProduct();
94
+
95
+ /**
96
+ * Returns the product seen by the current visitor.
97
+ *
98
+ * @return EcommerceCategoryInterface
99
+ */
100
+ public function getViewedCategory();
101
+
102
+ /**
103
+ * Returns the EcommerceSearchInterface associated with the current search query.
104
+ *
105
+ * @return EcommerceSearchInterface
106
+ */
107
+ public function getSearch();
108
+
109
+ /**
110
+ * Returns the name of the current controller method.
111
+ *
112
+ * @return string
113
+ */
114
+ public function getActionName();
115
+
116
+ /**
117
+ * Returns the name of the current route.
118
+ *
119
+ * @return string
120
+ */
121
+ public function getRouteName();
122
+
123
+ /**
124
+ * Returns whether the current page is a search page.
125
+ *
126
+ * @return bool
127
+ */
128
+ public function isSearchPage();
129
+
130
+ /**
131
+ * Returns whether the current page is a category page.
132
+ *
133
+ * @return bool
134
+ */
135
+ public function isCategoryPage();
136
+
137
+ /**
138
+ * Returns whether the current page is a product page.
139
+ *
140
+ * @return bool
141
+ */
142
+ public function isProductPage();
143
+
144
+ /**
145
+ * Returns all defined interface bindings.
146
+ *
147
+ * @return array
148
+ */
149
+ public function bindings();
150
+ }
app/code/community/Converdo/Common/Container/Container.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Container;
4
+
5
+ class Container
6
+ {
7
+ /**
8
+ * @var array
9
+ */
10
+ protected static $instances = [];
11
+
12
+ /**
13
+ * @var array
14
+ */
15
+ protected static $bindings = [];
16
+
17
+ /**
18
+ * Returns the Container instance.
19
+ *
20
+ * @return static
21
+ */
22
+ public static function instance()
23
+ {
24
+ return new static;
25
+ }
26
+
27
+ /**
28
+ * Loads a class or returns an existing.
29
+ *
30
+ * @param string $string
31
+ * @return mixed
32
+ */
33
+ public static function make($string)
34
+ {
35
+ if (! isset(self::$instances[$string])) {
36
+ self::$instances[$string] = new $string;
37
+ }
38
+
39
+ return self::$instances[$string];
40
+ }
41
+
42
+ /**
43
+ * Binds an interface to a concrete implementations.
44
+ *
45
+ * @param mixed $interface
46
+ * @param mixed $concrete
47
+ */
48
+ public static function bind($interface, $concrete)
49
+ {
50
+ self::$bindings[$interface] = cvd_app($concrete);
51
+ }
52
+
53
+ /**
54
+ * Returns the concrete implementation for the interface.
55
+ *
56
+ * @param mixed $interface
57
+ * @return mixed
58
+ * @throws \Exception
59
+ */
60
+ public static function resolve($interface)
61
+ {
62
+ if (! isset(self::$bindings[$interface])) {
63
+ throw new \Exception("No concrete implementation found for {$interface}.");
64
+ }
65
+
66
+ return self::$bindings[$interface];
67
+ }
68
+
69
+ /**
70
+ * Binds all interfaces to concrete implementations.
71
+ *
72
+ * @param array $bindings
73
+ */
74
+ public static function bindArray(array $bindings)
75
+ {
76
+ foreach ($bindings as $interface => $concrete) {
77
+ self::bind($interface, $concrete);
78
+ }
79
+ }
80
+ }
app/code/community/Converdo/Common/Controllers/PingController.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Controllers;
4
+
5
+ use Converdo\Common\Response\JsonResponse;
6
+ use Converdo\Common\Support\UsesInput;
7
+
8
+ class PingController extends JsonResponse
9
+ {
10
+ use UsesInput;
11
+
12
+ /**
13
+ * Returns information about the plugin and website.
14
+ *
15
+ * @return string
16
+ */
17
+ public function ping()
18
+ {
19
+ $output['plugin'] = $this->version();
20
+
21
+ $user = cvd_config()->platform()->user();
22
+
23
+ if ($this->input()->has('key') && $this->input()->get('key') === $user) {
24
+ $output['validation'] = $this->validation();
25
+
26
+ if ($this->input()->has('log')) {
27
+ $output['log'] = $this->log();
28
+ }
29
+ }
30
+
31
+ return $this->json($output);
32
+ }
33
+
34
+ /**
35
+ * Returns the plugin version section.
36
+ *
37
+ * @return array
38
+ */
39
+ protected function version()
40
+ {
41
+ return [
42
+ 'version' => cvd_config()->platform()->version(),
43
+ ];
44
+ }
45
+
46
+ /**
47
+ * Returns the last lines of the log file.
48
+ *
49
+ * @return array
50
+ */
51
+ protected function log()
52
+ {
53
+ $log = cvd_logger()->tail($this->input()->get('log'));
54
+
55
+ return [
56
+ array_filter($log),
57
+ ];
58
+ }
59
+
60
+ /**
61
+ * Returns the validation section.
62
+ *
63
+ * @return array|null
64
+ */
65
+ protected function validation()
66
+ {
67
+ $website = cvd_config()->platform()->website();
68
+ $user = cvd_config()->platform()->user();
69
+
70
+ $api = file_get_contents("http://converdo2.dev/api/ping/{$website}");
71
+ $api = json_decode($api);
72
+
73
+ if (! $api || $api->error) {
74
+ return null;
75
+ }
76
+
77
+ $tokens = json_decode(cvd_config()->crypt()->decrypt($api->tokens), true);
78
+
79
+ $validSite = $tokens['site'] === $website;
80
+ $validUser = $tokens['user'] === $user;
81
+ $validEncryption = $tokens['encryption'] === cvd_config()->platform()->encryption();
82
+
83
+ return [
84
+ 'enabled' => cvd_config()->platform()->enabled(),
85
+ 'valid' => $validSite && $validUser && $validEncryption,
86
+ 'tokens' => [
87
+ 'site' => $validSite,
88
+ 'user' => $validUser,
89
+ 'encryption' => $validEncryption,
90
+ ]
91
+ ];
92
+ }
93
+ }
app/code/community/Converdo/Common/Cookie/Factories/CookieFactory.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Cookie\Factories;
4
+
5
+ use Converdo\Common\Cookie\Models\Contracts\CookieInterface;
6
+ use Converdo\Common\Cookie\Models\Cookie;
7
+
8
+ class CookieFactory
9
+ {
10
+ /**
11
+ * @param array $values
12
+ * @return CookieInterface
13
+ */
14
+ public static function build(array $values)
15
+ {
16
+ return (new Cookie())
17
+ ->setVisitor($values[0])
18
+ ->setUuid($values[1])
19
+ ->setCreatedAt($values[2])
20
+ ->setVisitCount($values[3])
21
+ ->setUpdatedAt($values[4])
22
+ ->setLastVisitedAt($values[5]);
23
+ }
24
+ }
lib/Converdo/Analytics/Cookie/Manager.php → app/code/community/Converdo/Common/Cookie/Managers/CookieManager.php RENAMED
@@ -1,6 +1,11 @@
1
  <?php
2
 
3
- class Converdo_Analytics_Cookie_Manager
 
 
 
 
 
4
  {
5
  /**
6
  * @var string|null
@@ -8,12 +13,14 @@ class Converdo_Analytics_Cookie_Manager
8
  protected static $name = null;
9
 
10
  /**
11
- * @var Converdo_Analytics_Cookie_Model|null
12
  */
13
  protected static $cookie = null;
14
 
15
  /**
16
- * @return Converdo_Analytics_Cookie_Model|null;
 
 
17
  */
18
  public static function find()
19
  {
@@ -22,14 +29,14 @@ class Converdo_Analytics_Cookie_Manager
22
  }
23
 
24
  foreach ($_COOKIE as $key => $cookie) {
25
- if (strpos($key, '_pk_id_' . Mage::getStoreConfig('converdo/analytics/site')) === false) {
26
  continue;
27
  }
28
 
29
  $values = explode('.', $cookie);
30
 
31
  self::$name = str_replace('.pk.id', '_pk_id', str_replace('_', '.', $key));
32
- self::$cookie = self::factory($values);
33
 
34
  return self::$cookie;
35
  }
@@ -37,7 +44,9 @@ class Converdo_Analytics_Cookie_Manager
37
  return null;
38
  }
39
 
40
-
 
 
41
  public static function logEcommerce()
42
  {
43
  self::$cookie->setLastVisitedAt(time());
@@ -46,17 +55,9 @@ class Converdo_Analytics_Cookie_Manager
46
  self::update();
47
  }
48
 
49
- protected static function factory(array $values)
50
- {
51
- return (new Converdo_Analytics_Cookie_Model())
52
- ->setVisitor($values[0])
53
- ->setUuid($values[1])
54
- ->setCreatedAt($values[2])
55
- ->setVisitCount($values[3])
56
- ->setUpdatedAt($values[4])
57
- ->setLastVisitedAt($values[5]);
58
- }
59
-
60
  protected static function update()
61
  {
62
  setcookie(self::$name, self::$cookie, time() + (86400 * 30), "/");
1
  <?php
2
 
3
+ namespace Converdo\Common\Cookie\Managers;
4
+
5
+ use Converdo\Common\Cookie\Factories\CookieFactory;
6
+ use Converdo\Common\Cookie\Models\Contracts\CookieInterface;
7
+
8
+ class CookieManager
9
  {
10
  /**
11
  * @var string|null
13
  protected static $name = null;
14
 
15
  /**
16
+ * @var CookieInterface|null
17
  */
18
  protected static $cookie = null;
19
 
20
  /**
21
+ * Finds the Converdo Analytics cookie.
22
+ *
23
+ * @return CookieInterface|null;
24
  */
25
  public static function find()
26
  {
29
  }
30
 
31
  foreach ($_COOKIE as $key => $cookie) {
32
+ if (strpos($key, '_pk_id_' . cvd_config()->platform()->website()) === false) {
33
  continue;
34
  }
35
 
36
  $values = explode('.', $cookie);
37
 
38
  self::$name = str_replace('.pk.id', '_pk_id', str_replace('_', '.', $key));
39
+ self::$cookie = CookieFactory::build($values);
40
 
41
  return self::$cookie;
42
  }
44
  return null;
45
  }
46
 
47
+ /**
48
+ * Updates the cookie after a completed cart.
49
+ */
50
  public static function logEcommerce()
51
  {
52
  self::$cookie->setLastVisitedAt(time());
55
  self::update();
56
  }
57
 
58
+ /**
59
+ * Updates the cookie with new values.
60
+ */
 
 
 
 
 
 
 
 
61
  protected static function update()
62
  {
63
  setcookie(self::$name, self::$cookie, time() + (86400 * 30), "/");
app/code/community/Converdo/Common/Cookie/Models/Contracts/CookieInterface.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Cookie\Models\Contracts;
4
+
5
+ interface CookieInterface
6
+ {
7
+ /**
8
+ * Sets the visitor ID.
9
+ *
10
+ * @param string $visitor
11
+ * @return $this
12
+ */
13
+ public function setVisitor($visitor);
14
+
15
+ /**
16
+ * Gets the visitor ID.
17
+ *
18
+ * @return string
19
+ */
20
+ public function getVisitor();
21
+
22
+ /**
23
+ * Sets the uuid.
24
+ *
25
+ * @param int $uuid
26
+ * @return $this
27
+ */
28
+ public function setUuid($uuid);
29
+
30
+ /**
31
+ * Gets the uuid.
32
+ *
33
+ * @return int
34
+ */
35
+ public function getUuid();
36
+
37
+ /**
38
+ * Sets the visit count.
39
+ *
40
+ * @param int $visitCount
41
+ * @return $this
42
+ */
43
+ public function setVisitCount($visitCount);
44
+
45
+ /**
46
+ * Gets the visit count.
47
+ *
48
+ * @return int
49
+ */
50
+ public function getVisitCount();
51
+
52
+ /**
53
+ * Sets the last visit timestamp.
54
+ *
55
+ * @param int $lastVisitedAt
56
+ * @return $this
57
+ */
58
+ public function setLastVisitedAt($lastVisitedAt);
59
+
60
+ /**
61
+ * Gets the last visit timestamp.
62
+ *
63
+ * @return int
64
+ */
65
+ public function getLastVisitedAt();
66
+
67
+ /**
68
+ * Sets the created at timestamp.
69
+ *
70
+ * @param int $createdAt
71
+ * @return $this
72
+ */
73
+ public function setCreatedAt($createdAt);
74
+
75
+ /**
76
+ * Gets the created at timestamp.
77
+ *
78
+ * @return int
79
+ */
80
+ public function getCreatedAt();
81
+
82
+ /**
83
+ * Sets the updated at timestamp.
84
+ *
85
+ * @param int $updatedAt
86
+ * @return $this
87
+ */
88
+ public function setUpdatedAt($updatedAt);
89
+
90
+ /**
91
+ * Gets the updated at timestamp.
92
+ *
93
+ * @return int
94
+ */
95
+ public function getUpdatedAt();
96
+
97
+ /**
98
+ * Outputs the cookie as a string.
99
+ *
100
+ * @return string
101
+ */
102
+ public function __toString();
103
+ }
lib/Converdo/Analytics/Cookie/Model.php → app/code/community/Converdo/Common/Cookie/Models/Cookie.php RENAMED
@@ -1,6 +1,10 @@
1
  <?php
2
 
3
- class Converdo_Analytics_Cookie_Model
 
 
 
 
4
  {
5
  /**
6
  * @var string
@@ -33,10 +37,7 @@ class Converdo_Analytics_Cookie_Model
33
  protected $updatedAt;
34
 
35
  /**
36
- * Sets the visitor ID.
37
- *
38
- * @param string $visitor
39
- * @return $this
40
  */
41
  public function setVisitor($visitor)
42
  {
@@ -46,9 +47,7 @@ class Converdo_Analytics_Cookie_Model
46
  }
47
 
48
  /**
49
- * Gets the visitor ID.
50
- *
51
- * @return string
52
  */
53
  public function getVisitor()
54
  {
@@ -56,10 +55,7 @@ class Converdo_Analytics_Cookie_Model
56
  }
57
 
58
  /**
59
- * Sets the uuid.
60
- *
61
- * @param int $uuid
62
- * @return $this
63
  */
64
  public function setUuid($uuid)
65
  {
@@ -69,9 +65,7 @@ class Converdo_Analytics_Cookie_Model
69
  }
70
 
71
  /**
72
- * Gets the uuid.
73
- *
74
- * @return int
75
  */
76
  public function getUuid()
77
  {
@@ -79,10 +73,7 @@ class Converdo_Analytics_Cookie_Model
79
  }
80
 
81
  /**
82
- * Sets the visit count.
83
- *
84
- * @param int $visitCount
85
- * @return $this
86
  */
87
  public function setVisitCount($visitCount)
88
  {
@@ -92,9 +83,7 @@ class Converdo_Analytics_Cookie_Model
92
  }
93
 
94
  /**
95
- * Gets the visit count.
96
- *
97
- * @return int
98
  */
99
  public function getVisitCount()
100
  {
@@ -102,10 +91,7 @@ class Converdo_Analytics_Cookie_Model
102
  }
103
 
104
  /**
105
- * Sets the last visit timestamp.
106
- *
107
- * @param int $lastVisitedAt
108
- * @return $this
109
  */
110
  public function setLastVisitedAt($lastVisitedAt)
111
  {
@@ -115,9 +101,7 @@ class Converdo_Analytics_Cookie_Model
115
  }
116
 
117
  /**
118
- * Gets the last visit timestamp.
119
- *
120
- * @return int
121
  */
122
  public function getLastVisitedAt()
123
  {
@@ -125,10 +109,7 @@ class Converdo_Analytics_Cookie_Model
125
  }
126
 
127
  /**
128
- * Sets the created at timestamp.
129
- *
130
- * @param int $createdAt
131
- * @return $this
132
  */
133
  public function setCreatedAt($createdAt)
134
  {
@@ -138,9 +119,7 @@ class Converdo_Analytics_Cookie_Model
138
  }
139
 
140
  /**
141
- * Gets the created at timestamp.
142
- *
143
- * @return int
144
  */
145
  public function getCreatedAt()
146
  {
@@ -148,10 +127,7 @@ class Converdo_Analytics_Cookie_Model
148
  }
149
 
150
  /**
151
- * Sets the updated at timestamp.
152
- *
153
- * @param int $updatedAt
154
- * @return $this
155
  */
156
  public function setUpdatedAt($updatedAt)
157
  {
@@ -161,15 +137,16 @@ class Converdo_Analytics_Cookie_Model
161
  }
162
 
163
  /**
164
- * Gets the updated at timestamp.
165
- *
166
- * @return int
167
  */
168
  public function getUpdatedAt()
169
  {
170
  return (int) $this->updatedAt;
171
  }
172
 
 
 
 
173
  public function __toString()
174
  {
175
  return implode('.', [
1
  <?php
2
 
3
+ namespace Converdo\Common\Cookie\Models;
4
+
5
+ use Converdo\Common\Cookie\Models\Contracts\CookieInterface;
6
+
7
+ class Cookie implements CookieInterface
8
  {
9
  /**
10
  * @var string
37
  protected $updatedAt;
38
 
39
  /**
40
+ * @inheritDoc
 
 
 
41
  */
42
  public function setVisitor($visitor)
43
  {
47
  }
48
 
49
  /**
50
+ * @inheritDoc
 
 
51
  */
52
  public function getVisitor()
53
  {
55
  }
56
 
57
  /**
58
+ * @inheritDoc
 
 
 
59
  */
60
  public function setUuid($uuid)
61
  {
65
  }
66
 
67
  /**
68
+ * @inheritDoc
 
 
69
  */
70
  public function getUuid()
71
  {
73
  }
74
 
75
  /**
76
+ * @inheritDoc
 
 
 
77
  */
78
  public function setVisitCount($visitCount)
79
  {
83
  }
84
 
85
  /**
86
+ * @inheritDoc
 
 
87
  */
88
  public function getVisitCount()
89
  {
91
  }
92
 
93
  /**
94
+ * @inheritDoc
 
 
 
95
  */
96
  public function setLastVisitedAt($lastVisitedAt)
97
  {
101
  }
102
 
103
  /**
104
+ * @inheritDoc
 
 
105
  */
106
  public function getLastVisitedAt()
107
  {
109
  }
110
 
111
  /**
112
+ * @inheritDoc
 
 
 
113
  */
114
  public function setCreatedAt($createdAt)
115
  {
119
  }
120
 
121
  /**
122
+ * @inheritDoc
 
 
123
  */
124
  public function getCreatedAt()
125
  {
127
  }
128
 
129
  /**
130
+ * @inheritDoc
 
 
 
131
  */
132
  public function setUpdatedAt($updatedAt)
133
  {
137
  }
138
 
139
  /**
140
+ * @inheritDoc
 
 
141
  */
142
  public function getUpdatedAt()
143
  {
144
  return (int) $this->updatedAt;
145
  }
146
 
147
+ /**
148
+ * @inheritDoc
149
+ */
150
  public function __toString()
151
  {
152
  return implode('.', [
app/code/community/Converdo/Common/Input/Input.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Input;
4
+
5
+ use Converdo\Common\Support\HasParameters;
6
+
7
+ class Input
8
+ {
9
+ use HasParameters;
10
+
11
+ /**
12
+ * Reads all given values.
13
+ *
14
+ * @param array $values
15
+ * @return $this
16
+ */
17
+ public function read(array $values)
18
+ {
19
+ foreach ($values as $key => $value) {
20
+ $this->set($key, $value);
21
+ }
22
+
23
+ return $this;
24
+ }
25
+ }
app/code/community/Converdo/Common/Input/InputManager.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Input;
4
+
5
+ class InputManager
6
+ {
7
+ /**
8
+ * @var Input
9
+ */
10
+ protected static $input;
11
+
12
+ /**
13
+ * Reads the Request parameters.
14
+ */
15
+ public static function read()
16
+ {
17
+ self::$input = (new Input())->read($_REQUEST);
18
+ }
19
+
20
+ /**
21
+ * Returns the Input.
22
+ *
23
+ * @return Input
24
+ */
25
+ public static function get()
26
+ {
27
+ return self::$input;
28
+ }
29
+ }
app/code/community/Converdo/Common/Log/LogReader.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Log;
4
+
5
+ class LogReader
6
+ {
7
+ /**
8
+ * Slightly modified version of http://www.geekality.net/2011/05/28/php-tail-tackling-large-files/
9
+ * @author Torleif Berger, Lorenzo Stanco
10
+ * @link http://stackoverflow.com/a/15025877/995958
11
+ * @license http://creativecommons.org/licenses/by/3.0/
12
+ *
13
+ * @param string $filepath
14
+ * @param int $lines
15
+ * @param bool $adaptive
16
+ * @return string
17
+ */
18
+ public static function tailCustom($filepath, $lines = 1, $adaptive = true) {
19
+ // Open file
20
+ $f = @fopen($filepath, "rb");
21
+ if ($f === false) return false;
22
+
23
+ // Sets buffer size, according to the number of lines to retrieve.
24
+ // This gives a performance boost when reading a few lines from the file.
25
+ if (!$adaptive) $buffer = 4096;
26
+ else $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096));
27
+
28
+ // Jump to last character
29
+ fseek($f, -1, SEEK_END);
30
+
31
+ // Read it and adjust line number if necessary
32
+ // (Otherwise the result would be wrong if file doesn't end with a blank line)
33
+ if (fread($f, 1) != "\n") $lines -= 1;
34
+
35
+ // Start reading
36
+ $output = '';
37
+ $chunk = '';
38
+
39
+ // While we would like more
40
+ while (ftell($f) > 0 && $lines >= 0) {
41
+ // Figure out how far back we should jump
42
+ $seek = min(ftell($f), $buffer);
43
+ // Do the jump (backwards, relative to where we are)
44
+ fseek($f, -$seek, SEEK_CUR);
45
+ // Read a chunk and prepend it to our output
46
+ $output = ($chunk = fread($f, $seek)) . $output;
47
+ // Jump back to where we started reading
48
+ fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
49
+ // Decrease our line counter
50
+ $lines -= substr_count($chunk, "\n");
51
+ }
52
+
53
+ // While we have too many lines
54
+ // (Because of buffer size we might have read too many)
55
+ while ($lines++ < 0) {
56
+ // Find first newline and remove all text before that
57
+ $output = substr($output, strpos($output, "\n") + 1);
58
+ }
59
+
60
+ // Close file and return
61
+ fclose($f);
62
+ return trim($output);
63
+ }
64
+ }
app/code/community/Converdo/Common/Log/Logger.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Log;
4
+
5
+ use Mage;
6
+ use Zend_Log;
7
+
8
+ class Logger implements LoggerInterface
9
+ {
10
+ /**
11
+ * System is unusable.
12
+ *
13
+ * @param string $message
14
+ * @param array $context
15
+ * @return void
16
+ */
17
+ public function emergency($message, array $context = [])
18
+ {
19
+ Mage::log($this->interpolate($message, $context), Zend_Log::EMERG, $this->output());
20
+ }
21
+
22
+ /**
23
+ * Action must be taken immediately.
24
+ *
25
+ * Example: Entire website down, database unavailable, etc. This should
26
+ * trigger the SMS alerts and wake you up.
27
+ *
28
+ * @param string $message
29
+ * @param array $context
30
+ * @return void
31
+ */
32
+ public function alert($message, array $context = [])
33
+ {
34
+ Mage::log($this->interpolate($message, $context), Zend_Log::ALERT, $this->output());
35
+ }
36
+
37
+ /**
38
+ * Critical conditions.
39
+ *
40
+ * Example: Application component unavailable, unexpected exception.
41
+ *
42
+ * @param string $message
43
+ * @param array $context
44
+ * @return void
45
+ */
46
+ public function critical($message, array $context = [])
47
+ {
48
+ Mage::log($this->interpolate($message, $context), Zend_Log::CRIT, $this->output());
49
+ }
50
+
51
+ /**
52
+ * Runtime errors that do not require immediate action but should typically
53
+ * be logged and monitored.
54
+ *
55
+ * @param string $message
56
+ * @param array $context
57
+ * @return void
58
+ */
59
+ public function error($message, array $context = [])
60
+ {
61
+ Mage::log($this->interpolate($message, $context), Zend_Log::ERR, $this->output());
62
+ }
63
+
64
+ /**
65
+ * Exceptional occurrences that are not errors.
66
+ *
67
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
68
+ * that are not necessarily wrong.
69
+ *
70
+ * @param string $message
71
+ * @param array $context
72
+ * @return void
73
+ */
74
+ public function warning($message, array $context = [])
75
+ {
76
+ Mage::log($this->interpolate($message, $context), Zend_Log::WARN, $this->output());
77
+ }
78
+
79
+ /**
80
+ * Normal but significant events.
81
+ *
82
+ * @param string $message
83
+ * @param array $context
84
+ * @return void
85
+ */
86
+ public function notice($message, array $context = [])
87
+ {
88
+ Mage::log($this->interpolate($message, $context), Zend_Log::NOTICE, $this->output());
89
+ }
90
+
91
+ /**
92
+ * Interesting events.
93
+ *
94
+ * Example: User logs in, SQL logs.
95
+ *
96
+ * @param string $message
97
+ * @param array $context
98
+ * @return void
99
+ */
100
+ public function info($message, array $context = [])
101
+ {
102
+ Mage::log($this->interpolate($message, $context), Zend_Log::INFO, $this->output());
103
+ }
104
+
105
+ /**
106
+ * Detailed debug information.
107
+ *
108
+ * @param string $message
109
+ * @param array $context
110
+ * @return void
111
+ */
112
+ public function debug($message, array $context = [])
113
+ {
114
+ Mage::log($this->interpolate($message, $context), Zend_Log::DEBUG, $this->output());
115
+ }
116
+
117
+ /**
118
+ * Logs with an arbitrary level.
119
+ *
120
+ * @param mixed $level
121
+ * @param string $message
122
+ * @param array $context
123
+ * @return void
124
+ */
125
+ public function log($level, $message, array $context = [])
126
+ {
127
+ $this->info($message, $context);
128
+ }
129
+
130
+ /**
131
+ * Interpolates context values into the message placeholders.
132
+ *
133
+ * @param string $message
134
+ * @param array $context
135
+ * @return string
136
+ */
137
+ protected function interpolate($message, array $context = array())
138
+ {
139
+ // build a replacement array with braces around the context keys
140
+ $replace = [];
141
+
142
+ foreach ($context as $key => $val) {
143
+ // check that the value can be casted to string
144
+ if (! is_array($val) && (! is_object($val) || method_exists($val, '__toString'))) {
145
+ $replace['{' . $key . '}'] = $val;
146
+ }
147
+ }
148
+
149
+ // interpolate replacement values into the message and return
150
+ return strtr($message, $replace);
151
+ }
152
+
153
+ /**
154
+ * Returns the file name of the log file.
155
+ *
156
+ * @return string
157
+ */
158
+ protected function output()
159
+ {
160
+ return cvd_config()->environment()['log_file'];
161
+ }
162
+
163
+ public function tail($limit)
164
+ {
165
+ if ((int) $limit == 0) {
166
+ return null;
167
+ }
168
+
169
+ $file = realpath(Mage::getBaseDir('var') . '/log/' . $this->output());
170
+
171
+ if (! file_exists($file)) {
172
+ return [];
173
+ }
174
+
175
+ return array_reverse(explode(PHP_EOL, LogReader::tailCustom($file, $limit)));
176
+ }
177
+ }
app/code/community/Converdo/Common/Log/LoggerAwareInterface.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Log;
4
+
5
+ /**
6
+ * Describes a logger-aware instance
7
+ */
8
+ interface LoggerAwareInterface
9
+ {
10
+ /**
11
+ * Sets a logger instance on the object
12
+ *
13
+ * @param LoggerInterface $logger
14
+ * @return null
15
+ */
16
+ public function setLogger(LoggerInterface $logger);
17
+ }
app/code/community/Converdo/Common/Log/LoggerInterface.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Log;
4
+
5
+ /**
6
+ * Describes a logger instance
7
+ *
8
+ * The message MUST be a string or object implementing __toString().
9
+ *
10
+ * The message MAY contain placeholders in the form: {foo} where foo
11
+ * will be replaced by the context data in key "foo".
12
+ *
13
+ * The context array can contain arbitrary data, the only assumption that
14
+ * can be made by implementors is that if an Exception instance is given
15
+ * to produce a stack trace, it MUST be in a key named "exception".
16
+ *
17
+ * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
18
+ * for the full interface specification.
19
+ */
20
+ interface LoggerInterface
21
+ {
22
+ /**
23
+ * System is unusable.
24
+ *
25
+ * @param string $message
26
+ * @param array $context
27
+ * @return void
28
+ */
29
+ public function emergency($message, array $context = array());
30
+
31
+ /**
32
+ * Action must be taken immediately.
33
+ *
34
+ * Example: Entire website down, database unavailable, etc. This should
35
+ * trigger the SMS alerts and wake you up.
36
+ *
37
+ * @param string $message
38
+ * @param array $context
39
+ * @return void
40
+ */
41
+ public function alert($message, array $context = array());
42
+
43
+ /**
44
+ * Critical conditions.
45
+ *
46
+ * Example: Application component unavailable, unexpected exception.
47
+ *
48
+ * @param string $message
49
+ * @param array $context
50
+ * @return void
51
+ */
52
+ public function critical($message, array $context = array());
53
+
54
+ /**
55
+ * Runtime errors that do not require immediate action but should typically
56
+ * be logged and monitored.
57
+ *
58
+ * @param string $message
59
+ * @param array $context
60
+ * @return void
61
+ */
62
+ public function error($message, array $context = array());
63
+
64
+ /**
65
+ * Exceptional occurrences that are not errors.
66
+ *
67
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
68
+ * that are not necessarily wrong.
69
+ *
70
+ * @param string $message
71
+ * @param array $context
72
+ * @return void
73
+ */
74
+ public function warning($message, array $context = array());
75
+
76
+ /**
77
+ * Normal but significant events.
78
+ *
79
+ * @param string $message
80
+ * @param array $context
81
+ * @return void
82
+ */
83
+ public function notice($message, array $context = array());
84
+
85
+ /**
86
+ * Interesting events.
87
+ *
88
+ * Example: User logs in, SQL logs.
89
+ *
90
+ * @param string $message
91
+ * @param array $context
92
+ * @return void
93
+ */
94
+ public function info($message, array $context = array());
95
+
96
+ /**
97
+ * Detailed debug information.
98
+ *
99
+ * @param string $message
100
+ * @param array $context
101
+ * @return void
102
+ */
103
+ public function debug($message, array $context = array());
104
+
105
+ /**
106
+ * Logs with an arbitrary level.
107
+ *
108
+ * @param mixed $level
109
+ * @param string $message
110
+ * @param array $context
111
+ * @return void
112
+ */
113
+ public function log($level, $message, array $context = array());
114
+ }
app/code/community/Converdo/Common/Page/Factories/PageFactory.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Page\Factories;
4
+
5
+ use Converdo\Common\Page\Models\Contracts\PageInterface;
6
+ use Converdo\Common\Page\Models\Page;
7
+
8
+ class PageFactory
9
+ {
10
+ /**
11
+ * @param string $type
12
+ * @param string $subtype
13
+ * @return PageInterface
14
+ */
15
+ public static function build($type, $subtype)
16
+ {
17
+ return (new Page())
18
+ ->setType($type)
19
+ ->setSubtype($subtype);
20
+ }
21
+ }
app/code/community/Converdo/Common/Page/Models/Contracts/PageInterface.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Page\Models\Contracts;
4
+
5
+ interface PageInterface
6
+ {
7
+ /**
8
+ * Sets the subtype.
9
+ *
10
+ * @param string $subtype
11
+ * @return $this
12
+ */
13
+ public function setSubtype($subtype);
14
+
15
+ /**
16
+ * Gets the subtype.
17
+ *
18
+ * @return string
19
+ */
20
+ public function getSubtype();
21
+
22
+ /**
23
+ * Sets the type.
24
+ *
25
+ * @param string $type
26
+ * @return $this
27
+ */
28
+ public function setType($type);
29
+
30
+ /**
31
+ * Gets the type.
32
+ *
33
+ * @return string
34
+ */
35
+ public function getType();
36
+ }
app/code/community/Converdo/Common/Page/Models/Page.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Page\Models;
4
+
5
+ use Converdo\Common\Page\Models\Contracts\PageInterface;
6
+
7
+ class Page implements PageInterface
8
+ {
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $type;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $subtype;
18
+
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ public function setSubtype($subtype)
23
+ {
24
+ $this->subtype = $subtype;
25
+
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ public function getSubtype()
33
+ {
34
+ return $this->subtype;
35
+ }
36
+
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ public function setType($type)
41
+ {
42
+ $this->type = $type;
43
+
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ public function getType()
51
+ {
52
+ return $this->type;
53
+ }
54
+ }
app/code/community/Converdo/Common/Page/Support/Contracts/RouteResolverInterface.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Page\Support\Contracts;
4
+
5
+ use Converdo\Common\Page\Models\Contracts\PageInterface;
6
+
7
+ interface RouteResolverInterface
8
+ {
9
+ /**
10
+ * Resolves the current route.
11
+ *
12
+ * @return PageInterface
13
+ */
14
+ public function current();
15
+ }
app/code/community/Converdo/Common/Page/Support/PageTypes.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Page\Support;
4
+
5
+ use Converdo\Common\Page\Factories\PageFactory;
6
+
7
+ class PageTypes
8
+ {
9
+ const PAGE_ACCOUNT = 'account';
10
+ const PAGE_CART = 'cart';
11
+ const PAGE_CATEGORY = 'category';
12
+ const PAGE_CHECKOUT = 'checkout';
13
+ const PAGE_ADMIN = 'cms';
14
+ const PAGE_CONTACT = 'contact';
15
+ const PAGE_HOMEPAGE = 'homepage';
16
+ const PAGE_PRODUCT = 'product';
17
+ const PAGE_SEARCH = 'search';
18
+ const PAGE_SUCCESS = 'success';
19
+
20
+ const ACCOUNT_LOGIN = 'account_login';
21
+ const ACCOUNT_CREATE = 'account_create';
22
+ const ACCOUNT_INDEX = 'customer_account_index';
23
+ const ACCOUNT_PASSWORD_FORGOT = 'account_forgot_password';
24
+ const ACCOUNT_EDIT_INFO = 'account_edit_info';
25
+ const ACCOUNT_EDIT_ADDRESS = 'account_edit_address';
26
+ const ACCOUNT_ORDERS = 'account_orders';
27
+ const ACCOUNT_BILLING_AGREEMENT = 'account_billing_agreement';
28
+ const ACCOUNT_RECURRING = 'account_recurring';
29
+ const ACCOUNT_REVIEWS = 'account_reviews';
30
+ const ACCOUNT_WISHLIST = 'account_wishlist';
31
+ const ACCOUNT_APPS = 'account_apps';
32
+ const ACCOUNT_NEWSLETTER_MANAGE = 'newsletter_manage_index';
33
+ const ACCOUNT_NEWSLETTER = 'account_newsletters';
34
+ const ACCOUNT_DOWNLOADS = 'account_downloads';
35
+ const ACCOUNT_LOGOUT = 'account_logout';
36
+
37
+ const CART_VIEW = 'cart_index';
38
+
39
+ const CATEGORY_VIEW = 'category_view';
40
+
41
+ const CHECKOUT_VIEW = 'checkout_onepage_index';
42
+
43
+ const ADMIN_VIEW = 'cms_page_view';
44
+
45
+ const CONTACT_VIEW = 'contact_index';
46
+
47
+ const HOMEPAGE_VIEW = 'homepage_index';
48
+
49
+ const PRODUCT_VIEW = 'product_view';
50
+
51
+ /**
52
+ * Maps the Platform routes to normalized names.
53
+ *
54
+ * @var array
55
+ */
56
+ protected $map = [];
57
+
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ public function current()
62
+ {
63
+ foreach ($this->map as $key => $type) {
64
+ foreach ($type as $subkey => $page) {
65
+ if ($subkey !== cvd_config()->platform()->getActionName()) {
66
+ continue;
67
+ }
68
+
69
+ return PageFactory::build($key, $page);
70
+ }
71
+ }
72
+
73
+ return PageFactory::build(
74
+ cvd_config()->platform()->getRouteName(),
75
+ cvd_config()->platform()->getActionName()
76
+ );
77
+ }
78
+ }
app/code/community/Converdo/Common/Query/Managers/QueryManager.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Managers;
4
+
5
+ use Converdo\Common\Query\Queries\Contracts\QueryInterface;
6
+
7
+ class QueryManager
8
+ {
9
+ /**
10
+ * Holds all QueryInterface instances.
11
+ *
12
+ * @var QueryInterface[]
13
+ */
14
+ protected static $queries = [];
15
+
16
+ /**
17
+ * Holds all processed QueryInterface instances.
18
+ *
19
+ * @var QueryInterface[]
20
+ */
21
+ protected static $pushed = [];
22
+
23
+ /**
24
+ * Holds all parsed query strings.
25
+ *
26
+ * @var string[]
27
+ */
28
+ protected static $parsed = [];
29
+
30
+ /**
31
+ * Registers a Query. Registered Queries are processed by the plugin.
32
+ *
33
+ * @param QueryInterface $query
34
+ */
35
+ public static function register(QueryInterface $query)
36
+ {
37
+ self::$queries[get_class($query)] = $query;
38
+ }
39
+
40
+ /**
41
+ * Pushes a processed Query to the Manager.
42
+ *
43
+ * @param int $position
44
+ * @param QueryInterface $query
45
+ */
46
+ public static function push($position, QueryInterface $query)
47
+ {
48
+ self::$pushed[$position] = $query;
49
+ }
50
+
51
+ /**
52
+ * Stores a parsed query string to the Manager.
53
+ *
54
+ * @param int $position
55
+ * @param string $query
56
+ */
57
+ public static function store($position, $query)
58
+ {
59
+ self::$parsed[$position] = $query;
60
+
61
+ ksort(self::$parsed);
62
+ }
63
+
64
+ /**
65
+ * Returns all registered queries.
66
+ *
67
+ * @return QueryInterface[]
68
+ */
69
+ public static function registered()
70
+ {
71
+ return self::$queries;
72
+ }
73
+
74
+ /**
75
+ * @return QueryMetadata
76
+ */
77
+ public static function metadata()
78
+ {
79
+ return cvd_app(QueryMetadata::class);
80
+ }
81
+
82
+ /**
83
+ * Returns all pushed queries.
84
+ *
85
+ * @return QueryInterface[]
86
+ */
87
+ public static function pushed()
88
+ {
89
+ return self::$pushed;
90
+ }
91
+
92
+ /**
93
+ * Returns all parsed queries.
94
+ *
95
+ * @return QueryInterface[]
96
+ */
97
+ public static function parsed()
98
+ {
99
+ return self::$parsed;
100
+ }
101
+
102
+ /**
103
+ * Renders all query strings.
104
+ *
105
+ * @return string
106
+ */
107
+ public static function render()
108
+ {
109
+ return implode("\r\n\t\t", self::$parsed);
110
+ }
111
+ }
app/code/community/Converdo/Common/Query/Managers/QueryMetadata.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Managers;
4
+
5
+ use Converdo\Common\Support\HasParameters;
6
+
7
+ class QueryMetadata
8
+ {
9
+ use HasParameters;
10
+
11
+ /**
12
+ * Returns all Query metadata as JSON string.
13
+ *
14
+ * @return string
15
+ */
16
+ public function toJson()
17
+ {
18
+ return json_encode($this->all());
19
+ }
20
+
21
+ /**
22
+ * Returns all Query metadata as encrypted JSON string.
23
+ *
24
+ * @return string
25
+ */
26
+ public function toEncryptedJsonString()
27
+ {
28
+ return cvd_config()->crypt()->encrypt($this->toJson());
29
+ }
30
+ }
app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceCartInterface.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models\Contracts;
4
+
5
+ interface EcommerceCartInterface
6
+ {
7
+ /**
8
+ * Sets the cart total value.
9
+ *
10
+ * @param float $total
11
+ * @return $this
12
+ */
13
+ public function setTotal($total);
14
+
15
+ /**
16
+ * Gets the cart total value.
17
+ *
18
+ * @return float
19
+ */
20
+ public function getTotal();
21
+
22
+ /**
23
+ * Sets the cart subtotal value.
24
+ *
25
+ * @param float $subtotal
26
+ * @return $this
27
+ */
28
+ public function setSubtotal($subtotal);
29
+
30
+ /**
31
+ * Gets the cart subtotal value.
32
+ *
33
+ * @return float
34
+ */
35
+ public function getSubtotal();
36
+ }
app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceCategoryInterface.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models\Contracts;
4
+
5
+ interface EcommerceCategoryInterface
6
+ {
7
+ /**
8
+ * Sets the category.
9
+ *
10
+ * @param string $category
11
+ * @return $this
12
+ */
13
+ public function setCategory($category);
14
+
15
+ /**
16
+ * Gets the category.
17
+ *
18
+ * @return string
19
+ */
20
+ public function getCategory();
21
+ }
app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceItemInterface.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models\Contracts;
4
+
5
+ interface EcommerceItemInterface
6
+ {
7
+ /**
8
+ * Sets the product id.
9
+ *
10
+ * @param int $id
11
+ * @return $this
12
+ */
13
+ public function setId($id);
14
+
15
+ /**
16
+ * Gets the product id.
17
+ *
18
+ * @return int
19
+ */
20
+ public function getId();
21
+
22
+ /**
23
+ * Sets the product SKU.
24
+ *
25
+ * @param string $sku
26
+ * @return $this
27
+ */
28
+ public function setSKU($sku);
29
+
30
+ /**
31
+ * Gets the product SKU.
32
+ *
33
+ * @return string
34
+ */
35
+ public function getSKU();
36
+
37
+ /**
38
+ * Sets the product name.
39
+ *
40
+ * @param string $name
41
+ * @return $this
42
+ */
43
+ public function setName($name);
44
+
45
+ /**
46
+ * Gets the product name.
47
+ *
48
+ * @return string
49
+ */
50
+ public function getName();
51
+
52
+ /**
53
+ * Sets the product categories.
54
+ *
55
+ * @param array $categories
56
+ * @return $this
57
+ */
58
+ public function setCategories(array $categories);
59
+
60
+ /**
61
+ * Gets the product categories.
62
+ *
63
+ * @return array
64
+ */
65
+ public function getCategories();
66
+
67
+ /**
68
+ * Gets the product categories as json string.
69
+ *
70
+ * @return array
71
+ */
72
+ public function getCategoriesAsJson();
73
+
74
+ /**
75
+ * Gets the product categories as comma-separated string.
76
+ *
77
+ * @return array
78
+ */
79
+ public function getCategoriesAsString();
80
+
81
+ /**
82
+ * Sets the children.
83
+ *
84
+ * @param array $children
85
+ * @return $this
86
+ */
87
+ public function setChildrenIds($children);
88
+
89
+ /**
90
+ * Gets the children.
91
+ *
92
+ * @return array
93
+ */
94
+ public function getChildrenIds();
95
+
96
+ /**
97
+ * Sets the product price.
98
+ *
99
+ * @param mixed $price
100
+ * @return $this
101
+ */
102
+ public function setPrice($price);
103
+
104
+ /**
105
+ * Gets the product price.
106
+ *
107
+ * @return float
108
+ */
109
+ public function getPrice();
110
+
111
+ /**
112
+ * Sets the product quantity.
113
+ *
114
+ * @param int $quantity
115
+ * @return $this
116
+ */
117
+ public function setQuantity($quantity);
118
+
119
+ /**
120
+ * Gets the product quantity.
121
+ *
122
+ * @return int
123
+ */
124
+ public function getQuantity();
125
+
126
+ /**
127
+ * Sets the product image.
128
+ *
129
+ * @param string $imageUrl
130
+ * @return $this
131
+ */
132
+ public function setImageUrl($imageUrl);
133
+
134
+ /**
135
+ * Gets the product image.
136
+ *
137
+ * @return string
138
+ */
139
+ public function getImageUrl();
140
+
141
+ /**
142
+ * Sets the product type.
143
+ *
144
+ * @param string $type
145
+ * @return $this
146
+ */
147
+ public function setType($type);
148
+
149
+ /**
150
+ * Gets the product type.
151
+ *
152
+ * @return string
153
+ */
154
+ public function getType();
155
+
156
+ /**
157
+ * Sets whether the product is in stock.
158
+ *
159
+ * @param bool $stock
160
+ * @return $this
161
+ */
162
+ public function setIsInStock($stock);
163
+
164
+ /**
165
+ * Gets whether the product is in stock.
166
+ *
167
+ * @return bool
168
+ */
169
+ public function getIsInStock();
170
+
171
+ /**
172
+ * Sets the product stock quantity.
173
+ *
174
+ * @param int $quantity
175
+ * @return $this
176
+ */
177
+ public function setStockQuantity($quantity);
178
+
179
+ /**
180
+ * Gets the product stock quantity.
181
+ *
182
+ * @return int
183
+ */
184
+ public function getStockQuantity();
185
+
186
+ /**
187
+ * Sets the product manufacturer.
188
+ *
189
+ * @param string $manufacturer
190
+ * @return $this
191
+ */
192
+ public function setManufacturer($manufacturer);
193
+
194
+ /**
195
+ * Gets the product manufacturer.
196
+ *
197
+ * @return string
198
+ */
199
+ public function getManufacturer();
200
+
201
+ /**
202
+ * Sets the product cost.
203
+ *
204
+ * @param float $cost
205
+ * @return $this
206
+ */
207
+ public function setCost($cost);
208
+
209
+ /**
210
+ * Gets the product cost.
211
+ *
212
+ * @return float
213
+ */
214
+ public function getCost();
215
+ }
app/code/community/Converdo/Common/Query/Models/Contracts/EcommerceSearchInterface.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models\Contracts;
4
+
5
+ interface EcommerceSearchInterface
6
+ {
7
+ /**
8
+ * Sets the search keyword.
9
+ *
10
+ * @param string $keyword
11
+ * @return $this
12
+ */
13
+ public function setKeyword($keyword);
14
+
15
+ /**
16
+ * Gets the search keyword.
17
+ *
18
+ * @return string
19
+ */
20
+ public function getKeyword();
21
+
22
+ /**
23
+ * Sets the search category.
24
+ *
25
+ * @param string $category
26
+ * @return $this
27
+ */
28
+ public function setCategory($category);
29
+
30
+ /**
31
+ * Gets the search category.
32
+ *
33
+ * @return string
34
+ */
35
+ public function getCategory();
36
+
37
+ /**
38
+ * Sets the search result count.
39
+ *
40
+ * @param int $count
41
+ * @return $this
42
+ */
43
+ public function setResultCount($count);
44
+
45
+ /**
46
+ * Gets the search result count.
47
+ *
48
+ * @return int
49
+ */
50
+ public function getResultCount();
51
+ }
app/code/community/Converdo/Common/Query/Models/EcommerceCart.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceCartInterface;
6
+
7
+ class EcommerceCart implements EcommerceCartInterface
8
+ {
9
+ /**
10
+ * @var float
11
+ */
12
+ protected $total;
13
+
14
+ /**
15
+ * @var float
16
+ */
17
+ protected $subtotal;
18
+
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ public function setTotal($total)
23
+ {
24
+ $this->total = (float) $total;
25
+
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ public function getTotal()
33
+ {
34
+ return $this->total;
35
+ }
36
+
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ public function setSubtotal($subtotal)
41
+ {
42
+ $this->subtotal = (float) $subtotal;
43
+
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ public function getSubtotal()
51
+ {
52
+ return $this->subtotal;
53
+ }
54
+ }
app/code/community/Converdo/Common/Query/Models/EcommerceCategory.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceCategoryInterface;
6
+
7
+ class EcommerceCategory implements EcommerceCategoryInterface
8
+ {
9
+ /**
10
+ * @var float
11
+ */
12
+ protected $category;
13
+
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ public function setCategory($category)
18
+ {
19
+ $this->category = $category;
20
+
21
+ return $this;
22
+ }
23
+
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ public function getCategory()
28
+ {
29
+ return $this->category;
30
+ }
31
+ }
app/code/community/Converdo/Common/Query/Models/EcommerceItem.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceItemInterface;
6
+
7
+ class EcommerceItem implements EcommerceItemInterface
8
+ {
9
+ /**
10
+ * @var int
11
+ */
12
+ protected $id;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $sku;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $name;
23
+
24
+ /**
25
+ * @var array
26
+ */
27
+ protected $categories = [];
28
+
29
+ /**
30
+ * @var array
31
+ */
32
+ protected $children = [];
33
+
34
+ /**
35
+ * @var float
36
+ */
37
+ protected $price;
38
+
39
+ /**
40
+ * @var int
41
+ */
42
+ protected $quantity;
43
+
44
+ /**
45
+ * @var string
46
+ */
47
+ protected $imageUrl;
48
+
49
+ /**
50
+ * @var string
51
+ */
52
+ protected $type;
53
+
54
+ /**
55
+ * @var bool
56
+ */
57
+ protected $isInStock;
58
+
59
+ /**
60
+ * @var float
61
+ */
62
+ protected $stockQuantity;
63
+
64
+ /**
65
+ * @var string
66
+ */
67
+ protected $manufacturer;
68
+
69
+ /**
70
+ * @var float
71
+ */
72
+ protected $cost;
73
+
74
+ /**
75
+ * @inheritDoc
76
+ */
77
+ public function setId($id)
78
+ {
79
+ $this->id = (int) $id;
80
+
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * @inheritDoc
86
+ */
87
+ public function getId()
88
+ {
89
+ return $this->id;
90
+ }
91
+
92
+ /**
93
+ * @inheritDoc
94
+ */
95
+ public function setSKU($sku)
96
+ {
97
+ $this->sku = (string) $sku;
98
+
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * @inheritDoc
104
+ */
105
+ public function getSKU()
106
+ {
107
+ return $this->sku;
108
+ }
109
+
110
+ /**
111
+ * @inheritDoc
112
+ */
113
+ public function setName($name)
114
+ {
115
+ $this->name = (string) $name;
116
+
117
+ return $this;
118
+ }
119
+
120
+ /**
121
+ * @inheritDoc
122
+ */
123
+ public function getName()
124
+ {
125
+ return $this->name;
126
+ }
127
+
128
+ /**
129
+ * @inheritDoc
130
+ */
131
+ public function setCategories(array $categories)
132
+ {
133
+ $this->categories = (array) $categories;
134
+
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * @inheritDoc
140
+ */
141
+ public function getCategories()
142
+ {
143
+ return $this->categories;
144
+ }
145
+
146
+ /**
147
+ * @inheritDoc
148
+ */
149
+ public function getCategoriesAsJson()
150
+ {
151
+ return json_encode($this->categories);
152
+ }
153
+
154
+ /**
155
+ * @inheritDoc
156
+ */
157
+ public function getCategoriesAsString()
158
+ {
159
+ return implode(', ', $this->categories);
160
+ }
161
+
162
+ /**
163
+ * @inheritDoc
164
+ */
165
+ public function setChildrenIds($children)
166
+ {
167
+ $this->children = $children;
168
+
169
+ return $this;
170
+ }
171
+
172
+ /**
173
+ * @inheritDoc
174
+ */
175
+ public function getChildrenIds()
176
+ {
177
+ return $this->children;
178
+ }
179
+
180
+ /**
181
+ * @inheritDoc
182
+ */
183
+ public function setPrice($price)
184
+ {
185
+ $this->price = (float) $price;
186
+
187
+ return $this;
188
+ }
189
+
190
+ /**
191
+ * @inheritDoc
192
+ */
193
+ public function getPrice()
194
+ {
195
+ return $this->price;
196
+ }
197
+
198
+ /**
199
+ * @inheritDoc
200
+ */
201
+ public function setQuantity($quantity)
202
+ {
203
+ $this->quantity = (int) $quantity;
204
+
205
+ return $this;
206
+ }
207
+
208
+ /**
209
+ * @inheritDoc
210
+ */
211
+ public function getQuantity()
212
+ {
213
+ return $this->quantity;
214
+ }
215
+
216
+ /**
217
+ * @inheritDoc
218
+ */
219
+ public function setImageUrl($imageUrl)
220
+ {
221
+ $this->imageUrl = $imageUrl;
222
+
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * @inheritDoc
228
+ */
229
+ public function getImageUrl()
230
+ {
231
+ return $this->imageUrl;
232
+ }
233
+
234
+ /**
235
+ * @inheritDoc
236
+ */
237
+ public function setType($type)
238
+ {
239
+ $this->type = $type;
240
+
241
+ return $this;
242
+ }
243
+
244
+ /**
245
+ * @inheritDoc
246
+ */
247
+ public function getType()
248
+ {
249
+ return $this->type;
250
+ }
251
+
252
+ /**
253
+ * @inheritDoc
254
+ */
255
+ public function setIsInStock($stock)
256
+ {
257
+ $this->isInStock = (bool) $stock;
258
+
259
+ return $this;
260
+ }
261
+
262
+ /**
263
+ * @inheritDoc
264
+ */
265
+ public function getIsInStock()
266
+ {
267
+ return $this->isInStock;
268
+ }
269
+
270
+ /**
271
+ * @inheritDoc
272
+ */
273
+ public function setStockQuantity($quantity)
274
+ {
275
+ $this->stockQuantity = (float) $quantity;
276
+
277
+ return $this;
278
+ }
279
+
280
+ /**
281
+ * @inheritDoc
282
+ */
283
+ public function getStockQuantity()
284
+ {
285
+ return $this->stockQuantity;
286
+ }
287
+
288
+ /**
289
+ * @inheritDoc
290
+ */
291
+ public function setManufacturer($manufacturer)
292
+ {
293
+ $this->manufacturer = $manufacturer;
294
+
295
+ return $this;
296
+ }
297
+
298
+ /**
299
+ * @inheritDoc
300
+ */
301
+ public function getManufacturer()
302
+ {
303
+ return $this->manufacturer;
304
+ }
305
+
306
+ /**
307
+ * @inheritDoc
308
+ */
309
+ public function setCost($cost)
310
+ {
311
+ $this->cost = $cost;
312
+
313
+ return $this;
314
+ }
315
+
316
+ /**
317
+ * @inheritDoc
318
+ */
319
+ public function getCost()
320
+ {
321
+ return $this->cost;
322
+ }
323
+ }
app/code/community/Converdo/Common/Query/Models/EcommerceSearch.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Models;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceSearchInterface;
6
+
7
+ class EcommerceSearch implements EcommerceSearchInterface
8
+ {
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $keyword;
13
+
14
+ /**
15
+ * @var string|false
16
+ */
17
+ protected $category = false;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $count;
23
+
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ public function setKeyword($keyword)
28
+ {
29
+ $this->keyword = $keyword;
30
+
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ public function getKeyword()
38
+ {
39
+ return $this->keyword;
40
+ }
41
+
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ public function setCategory($category)
46
+ {
47
+ $this->category = $category;
48
+
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ public function getCategory()
56
+ {
57
+ return $this->category;
58
+ }
59
+
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ public function setResultCount($count)
64
+ {
65
+ $this->count = $count;
66
+
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * @inheritDoc
72
+ */
73
+ public function getResultCount()
74
+ {
75
+ return $this->count;
76
+ }
77
+ }
app/code/community/Converdo/Common/Query/Queries/AbstractQuery.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryMetadata;
6
+ use Converdo\Common\Query\Queries\Contracts\QueryInterface;
7
+ use Converdo\Common\Support\HasParameters;
8
+
9
+ abstract class AbstractQuery implements QueryInterface
10
+ {
11
+ use HasParameters;
12
+
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ public function responsible()
17
+ {
18
+ return true;
19
+ }
20
+
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ public function process()
25
+ {
26
+ // process data.
27
+ }
28
+
29
+ /**
30
+ * @return QueryMetadata
31
+ */
32
+ public function metadata()
33
+ {
34
+ return cvd_app(QueryMetadata::class);
35
+ }
36
+
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ abstract public function parse();
41
+ }
app/code/community/Converdo/Common/Query/Queries/AddEcommerceItem.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class AddEcommerceItem extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function responsible()
13
+ {
14
+ return cvd_config()->platform()->hasActiveCart();
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function process()
21
+ {
22
+ $this->set('products', cvd_config()->platform()->getActiveCartProducts());
23
+ }
24
+
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ public function parse()
29
+ {
30
+ foreach ($this->get('products') as $key => $product) {
31
+ QueryManager::store(
32
+ $this->position() + $key,
33
+ "_paq.push(['addEcommerceItem', '{$product->getSku()}', '{$product->getName()}', '{$product->getCategoriesAsString()}', {$product->getPrice()}, {$product->getQuantity()}]);"
34
+ );
35
+ }
36
+ }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ public function position()
42
+ {
43
+ return 20;
44
+ }
45
+ }
app/code/community/Converdo/Common/Query/Queries/CategoryView.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class CategoryView extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function responsible()
13
+ {
14
+ return cvd_config()->platform()->isCategoryPage();
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function process()
21
+ {
22
+ $this->set('category', cvd_config()->platform()->getViewedCategory());
23
+ }
24
+
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ public function parse()
29
+ {
30
+ QueryManager::store(
31
+ $this->position(),
32
+ "_paq.push(['setEcommerceView', false, false, '{$this->get('category')->getCategory()}']);"
33
+ );
34
+ }
35
+
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ public function position()
40
+ {
41
+ return 10;
42
+ }
43
+ }
app/code/community/Converdo/Common/Query/Queries/Contracts/QueryInterface.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries\Contracts;
4
+
5
+ interface QueryInterface
6
+ {
7
+ /**
8
+ * Determines whether the query should process on the tracker.
9
+ *
10
+ * @return bool
11
+ */
12
+ public function responsible();
13
+
14
+ /**
15
+ * Determines the position of the query in the output.
16
+ *
17
+ * @return int
18
+ */
19
+ public function position();
20
+
21
+ /**
22
+ * Processes the data required for the tracker query.
23
+ *
24
+ * @return mixed
25
+ */
26
+ public function process();
27
+
28
+ /**
29
+ * Parses the query string and stores it in the QueryManager.
30
+ *
31
+ * @return string
32
+ */
33
+ public function parse();
34
+ }
app/code/community/Converdo/Common/Query/Queries/CustomVariable.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class CustomVariable extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function process()
13
+ {
14
+ $this->set('configuration', QueryManager::metadata()->toEncryptedJsonString());
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function parse()
21
+ {
22
+ QueryManager::store(
23
+ $this->position(),
24
+ "_paq.push(['setCustomVariable', 1, 'configuration', '{$this->get('configuration')}', 'page']);"
25
+ );
26
+ }
27
+
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ public function position()
32
+ {
33
+ return 50;
34
+ }
35
+ }
app/code/community/Converdo/Common/Query/Queries/EcommerceView.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class EcommerceView extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function responsible()
13
+ {
14
+ return cvd_config()->platform()->isProductPage();
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function process()
21
+ {
22
+ $product = cvd_config()->platform()->getViewedProduct();
23
+
24
+ $this->set('product', $product);
25
+
26
+ $this->metadata()->set('sku', $product->getSKU());
27
+ $this->metadata()->set('pti', $product->getName());
28
+ $this->metadata()->set('pri', $product->getPrice());
29
+ $this->metadata()->set('ima', $product->getImageUrl());
30
+ $this->metadata()->set('cat', $product->getCategories());
31
+ $this->metadata()->set('rid', $product->getId());
32
+ $this->metadata()->set('tid', $product->getChildrenIds());
33
+ $this->metadata()->set('typ', $product->getType());
34
+ $this->metadata()->set('att', null);
35
+ $this->metadata()->set('stb', $product->getIsInStock());
36
+ $this->metadata()->set('sqn', $product->getStockQuantity());
37
+ $this->metadata()->set('bra', $product->getManufacturer());
38
+ $this->metadata()->set('cos', $product->getCost());
39
+ }
40
+
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ public function parse()
45
+ {
46
+ QueryManager::store(
47
+ $this->position(),
48
+ "_paq.push(['setEcommerceView', '{$this->get('product')->getSku()}', '{$this->get('product')->getName()}', '{$this->get('product')->getCategoriesAsString()}', {$this->get('product')->getPrice()}]);"
49
+ );
50
+ }
51
+
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ public function position()
56
+ {
57
+ return 10;
58
+ }
59
+ }
app/code/community/Converdo/Common/Query/Queries/EnableHeartBeatTimer.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class EnableHeartBeatTimer extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function parse()
13
+ {
14
+ QueryManager::store(
15
+ $this->position(),
16
+ "_paq.push(['enableHeartBeatTimer']);"
17
+ );
18
+ }
19
+
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ public function position()
24
+ {
25
+ return 120;
26
+ }
27
+ }
app/code/community/Converdo/Common/Query/Queries/EnableLinkTracking.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class EnableLinkTracking extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function parse()
13
+ {
14
+ QueryManager::store(
15
+ $this->position(),
16
+ "_paq.push(['enableLinkTracking']);"
17
+ );
18
+ }
19
+
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ public function position()
24
+ {
25
+ return 110;
26
+ }
27
+ }
app/code/community/Converdo/Common/Query/Queries/SiteId.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class SiteId extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function process()
13
+ {
14
+ $this->set('website', cvd_config()->platform()->website());
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function parse()
21
+ {
22
+ QueryManager::store(
23
+ $this->position(),
24
+ "_paq.push(['setSiteId', '{$this->get('website')}']);"
25
+ );
26
+ }
27
+
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ public function position()
32
+ {
33
+ return 0;
34
+ }
35
+ }
app/code/community/Converdo/Common/Query/Queries/TrackEcommerceCart.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class TrackEcommerceCart extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function responsible()
13
+ {
14
+ return cvd_config()->platform()->hasActiveCart();
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function process()
21
+ {
22
+ $this->set('cart', cvd_config()->platform()->getActiveCart());
23
+ }
24
+
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ public function parse()
29
+ {
30
+ QueryManager::store(
31
+ $this->position(),
32
+ "_paq.push(['trackEcommerceCartUpdate', {$this->get('cart')->getTotal()}]);"
33
+ );
34
+ }
35
+
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ public function position()
40
+ {
41
+ return 30;
42
+ }
43
+ }
app/code/community/Converdo/Common/Query/Queries/TrackPageView.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class TrackPageView extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function responsible()
13
+ {
14
+ return ! cvd_config()->platform()->isSearchPage();
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function process()
21
+ {
22
+ $page = cvd_config()->route()->current();
23
+
24
+ $this->metadata()->set('pt1', $page->getType());
25
+ $this->metadata()->set('pt2', $page->getSubtype());
26
+ }
27
+
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ public function parse()
32
+ {
33
+ QueryManager::store(
34
+ $this->position(),
35
+ "_paq.push(['trackPageView']);"
36
+ );
37
+ }
38
+
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ public function position()
43
+ {
44
+ return 100;
45
+ }
46
+ }
app/code/community/Converdo/Common/Query/Queries/TrackSiteSearch.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class TrackSiteSearch extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function responsible()
13
+ {
14
+ return cvd_config()->platform()->isSearchPage();
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function process()
21
+ {
22
+ $this->set('search', cvd_config()->platform()->getSearch());
23
+
24
+ $page = cvd_config()->route()->current();
25
+
26
+ $this->metadata()->set('pt1', $page->getType());
27
+ $this->metadata()->set('pt2', $page->getSubtype());
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ public function parse()
34
+ {
35
+ QueryManager::store(
36
+ $this->position(),
37
+ "_paq.push(['trackSiteSearch', '{$this->get('search')->getKeyword()}', false, {$this->get('search')->getResultCount()}]);"
38
+ );
39
+ }
40
+
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ public function position()
45
+ {
46
+ return 10;
47
+ }
48
+ }
app/code/community/Converdo/Common/Query/Queries/TrackerUrl.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Query\Queries;
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+
7
+ class TrackerUrl extends AbstractQuery
8
+ {
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ public function process()
13
+ {
14
+ $this->set('url', cvd_config()->url('tracker.php'));
15
+ }
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ public function parse()
21
+ {
22
+ QueryManager::store(
23
+ $this->position(),
24
+ "_paq.push(['setTrackerUrl', '{$this->get('url')}']);"
25
+ );
26
+ }
27
+
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ public function position()
32
+ {
33
+ return 1;
34
+ }
35
+ }
app/code/community/Converdo/Common/Response/JsonResponse.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Response;
4
+
5
+ class JsonResponse extends Response
6
+ {
7
+ /**
8
+ * Returns a JSON response.
9
+ *
10
+ * @param array $data
11
+ * @param int $status
12
+ * @param array $headers
13
+ * @return string
14
+ */
15
+ public function json(array $data, $status = 200, array $headers = [])
16
+ {
17
+ $headers[] = 'Content-Type: application/json;charset=utf-8';
18
+
19
+ $this->setHeaders($headers);
20
+
21
+ $this->setStatusCode($status);
22
+
23
+ return $this->output($data);
24
+ }
25
+
26
+ public function output($data)
27
+ {
28
+ echo json_encode($data);
29
+ }
30
+ }
app/code/community/Converdo/Common/Response/Response.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Response;
4
+
5
+ class Response
6
+ {
7
+ /**
8
+ * Sets the status code of the Response.
9
+ *
10
+ * @param int $status
11
+ * @return $this
12
+ */
13
+ public function setStatusCode($status)
14
+ {
15
+ http_response_code($status);
16
+
17
+ return $this;
18
+ }
19
+
20
+ /**
21
+ * Sets the headers of the Response.
22
+ *
23
+ * @param array $headers
24
+ * @return $this
25
+ */
26
+ public function setHeaders(array $headers)
27
+ {
28
+ foreach ($headers as $header) {
29
+ header($header);
30
+ }
31
+
32
+ return $this;
33
+ }
34
+ }
{lib/Converdo/Analytics/Support → app/code/community/Converdo/Common/Security}/Crypt.php RENAMED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- class Converdo_Analytics_Support_Crypt
 
 
4
  {
5
  /**
6
  * Encrypts a given input.
@@ -8,9 +10,9 @@ class Converdo_Analytics_Support_Crypt
8
  * @param string $input
9
  * @return string
10
  */
11
- public static function encrypt($input)
12
  {
13
- return @openssl_encrypt(base64_encode($input), 'AES-256-CFB', self::key());
14
  }
15
 
16
  /**
@@ -19,9 +21,9 @@ class Converdo_Analytics_Support_Crypt
19
  * @param string $input
20
  * @return string
21
  */
22
- public static function decrypt($input)
23
  {
24
- return @base64_decode(openssl_decrypt($input, 'AES-256-CFB', self::key()));
25
  }
26
 
27
  /**
@@ -29,8 +31,8 @@ class Converdo_Analytics_Support_Crypt
29
  *
30
  * @return string
31
  */
32
- public static function key()
33
  {
34
- return (string) Mage::getStoreConfig('converdo/analytics/encryption');
35
  }
36
- }
1
  <?php
2
 
3
+ namespace Converdo\Common\Security;
4
+
5
+ class Crypt
6
  {
7
  /**
8
  * Encrypts a given input.
10
  * @param string $input
11
  * @return string
12
  */
13
+ public function encrypt($input)
14
  {
15
+ return @openssl_encrypt(base64_encode($input), 'AES-256-CFB', $this->key());
16
  }
17
 
18
  /**
21
  * @param string $input
22
  * @return string
23
  */
24
+ public function decrypt($input)
25
  {
26
+ return @base64_decode(openssl_decrypt($input, 'AES-256-CFB', $this->key()));
27
  }
28
 
29
  /**
31
  *
32
  * @return string
33
  */
34
+ protected function key()
35
  {
36
+ return cvd_config()->platform()->encryption();
37
  }
38
+ }
app/code/community/Converdo/Common/Support/Arrayable.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Support;
4
+
5
+ trait Arrayable
6
+ {
7
+ /**
8
+ * Returns instance properties as an array.
9
+ *
10
+ * @param null $key
11
+ * @return array|null
12
+ */
13
+ public function toArray($key = null)
14
+ {
15
+ $properties = get_object_vars($this);
16
+
17
+ if (! $key) {
18
+ return $properties;
19
+ }
20
+
21
+ if (! isset($properties[$key])) {
22
+ return null;
23
+ }
24
+
25
+ return (array) $properties[$key];
26
+ }
27
+
28
+ /**
29
+ * Returns the instance property keys.
30
+ *
31
+ * @return array
32
+ */
33
+ public function keys()
34
+ {
35
+ return array_keys(get_object_vars($this));
36
+ }
37
+ }
app/code/community/Converdo/Common/Support/HasParameters.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Support;
4
+
5
+ trait HasParameters
6
+ {
7
+ /**
8
+ * The parameter bag.
9
+ *
10
+ * @var array
11
+ */
12
+ protected $parameters = [];
13
+
14
+ /**
15
+ * Sets a parameter by name.
16
+ *
17
+ * @param string $key
18
+ * @param mixed $value
19
+ */
20
+ public function set($key, $value)
21
+ {
22
+ $this->parameters[$key] = $value;
23
+ }
24
+
25
+ /**
26
+ * Returns a parameter by name.
27
+ *
28
+ * @param string $key
29
+ * @return mixed
30
+ */
31
+ public function get($key)
32
+ {
33
+ return $this->has($key) ? $this->parameters[$key] : null;
34
+ }
35
+
36
+ /**
37
+ * Returns true if the parameter is defined.
38
+ *
39
+ * @param string $key
40
+ * @return mixed
41
+ */
42
+ public function has($key)
43
+ {
44
+ return isset($this->parameters[$key]);
45
+ }
46
+
47
+ /**
48
+ * Returns the parameters.
49
+ *
50
+ * @return array
51
+ */
52
+ public function all()
53
+ {
54
+ return $this->parameters;
55
+ }
56
+
57
+ /**
58
+ * Returns the parameter keys.
59
+ *
60
+ * @return array
61
+ */
62
+ public function keys()
63
+ {
64
+ return array_keys($this->parameters);
65
+ }
66
+ }
app/code/community/Converdo/Common/Support/UsesInput.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Common\Support;
4
+
5
+ use Converdo\Common\Input\InputManager;
6
+
7
+ trait UsesInput
8
+ {
9
+ /**
10
+ * Returns the Input.
11
+ *
12
+ * @return \Converdo\Common\Input\Input
13
+ */
14
+ public function input()
15
+ {
16
+ return InputManager::get();
17
+ }
18
+ }
app/code/community/Converdo/Common/autoload.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $classmap = [
4
+ '/Common/Support/HasParameters.php',
5
+ '/Common/Security/Crypt.php',
6
+ '/Common/API/Factories/OrderFactory.php',
7
+ '/Common/API/Models/Contracts/OrderInterface.php',
8
+ '/Common/API/Models/Order.php',
9
+ '/Common/API/Sections/ConverdoOrderAPI.php',
10
+ '/Common/API/ConverdoAPI.php',
11
+ '/Common/API/ConverdoClient.php',
12
+ '/Common/API/Requests.php',
13
+ '/Common/Cookie/Models/Contracts/CookieInterface.php',
14
+ '/Common/Cookie/Models/Cookie.php',
15
+ '/Common/Cookie/Factories/CookieFactory.php',
16
+ '/Common/Cookie/Managers/CookieManager.php',
17
+ '/Common/Input/InputManager.php',
18
+ '/Common/Input/Input.php',
19
+ '/Common/Config/Configuration.php',
20
+ '/Common/Config/Contracts/PlatformConfigurationContract.php',
21
+ '/Common/Container/Container.php',
22
+ '/Common/Log/LoggerAwareInterface.php',
23
+ '/Common/Log/LoggerInterface.php',
24
+ '/Common/Log/Logger.php',
25
+ '/Common/Log/LogReader.php',
26
+ '/Common/Page/Models/Contracts/PageInterface.php',
27
+ '/Common/Page/Models/Page.php',
28
+ '/Common/Page/Factories/PageFactory.php',
29
+ '/Common/Page/Support/PageTypes.php',
30
+ '/Common/Page/Support/Contracts/RouteResolverInterface.php',
31
+ '/Common/Query/Managers/QueryManager.php',
32
+ '/Common/Query/Managers/QueryMetadata.php',
33
+ '/Common/Query/Models/Contracts/EcommerceCartInterface.php',
34
+ '/Common/Query/Models/Contracts/EcommerceCategoryInterface.php',
35
+ '/Common/Query/Models/Contracts/EcommerceItemInterface.php',
36
+ '/Common/Query/Models/Contracts/EcommerceSearchInterface.php',
37
+ '/Common/Query/Models/EcommerceCategory.php',
38
+ '/Common/Query/Models/EcommerceCart.php',
39
+ '/Common/Query/Models/EcommerceItem.php',
40
+ '/Common/Query/Models/EcommerceSearch.php',
41
+ '/Common/Query/Queries/Contracts/QueryInterface.php',
42
+ '/Common/Query/Queries/AbstractQuery.php',
43
+ '/Common/Query/Queries/EcommerceView.php',
44
+ '/Common/Query/Queries/CategoryView.php',
45
+ '/Common/Query/Queries/AddEcommerceItem.php',
46
+ '/Common/Query/Queries/TrackEcommerceCart.php',
47
+ '/Common/Query/Queries/SiteId.php',
48
+ '/Common/Query/Queries/TrackerUrl.php',
49
+ '/Common/Query/Queries/TrackPageView.php',
50
+ '/Common/Query/Queries/TrackSiteSearch.php',
51
+ '/Common/Query/Queries/EnableLinkTracking.php',
52
+ '/Common/Query/Queries/EnableHeartBeatTimer.php',
53
+ '/Common/Query/Queries/CustomVariable.php',
54
+ '/Magento/Page/RouteResolver.php',
55
+ '/Magento/Config/Configuration.php',
56
+ '/Magento/Factories/EcommerceCartFactory.php',
57
+ '/Magento/Factories/EcommerceCategoryFactory.php',
58
+ '/Magento/Factories/EcommerceItemFactory.php',
59
+ '/Magento/Factories/EcommerceSearchFactory.php',
60
+ '/Magento/Support/PriceHelper.php',
61
+ ];
62
+
63
+ foreach ($classmap as $class) {
64
+ $class = MAGENTO_ROOT . '/app/code/community/Converdo/' . $class;
65
+
66
+ if (! file_exists($class)) {
67
+ return false;
68
+ }
69
+
70
+ require_once $class;
71
+ }
app/code/community/Converdo/Common/bootstrap.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define('CONVERDO_ANALYTICS_START', microtime(true));
4
+
5
+ $autoload = require_once __DIR__ . '/autoload.php';
6
+
7
+ $functions = require_once __DIR__ . '/functions.php';
8
+
9
+ $dependencies = require_once __DIR__ . '/dependencies.php';
10
+
11
+ $config = cvd_config();
12
+
13
+ if (! $autoload || ! $dependencies) {
14
+ cvd_config()->platform()->terminate();
15
+ }
16
+
17
+ \Converdo\Common\Input\InputManager::read();
app/code/community/Converdo/Common/config.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ return [
4
+
5
+ 'name' => 'production',
6
+ 'tracker_url' => '//tracker.converdo.com/',
7
+ 'log_file' => 'ConverdoAnalytics.log',
8
+
9
+ ];
app/code/community/Converdo/Common/dependencies.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $dependencies = [
4
+ 'openssl',
5
+ 'curl',
6
+ ];
7
+
8
+ foreach ($dependencies as $dependency) {
9
+ if (! extension_loaded($dependency)) {
10
+ return false;
11
+ }
12
+ }
app/code/community/Converdo/Common/functions.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (! function_exists('cvd_app')) {
4
+ /**
5
+ * Get the available container instance.
6
+ *
7
+ * @param string $abstract
8
+ * @return mixed
9
+ */
10
+ function cvd_app($abstract = null)
11
+ {
12
+ if ($abstract) {
13
+ return cvd_app()->make($abstract);
14
+ }
15
+
16
+ return \Converdo\Common\Container\Container::instance();
17
+ }
18
+ }
19
+
20
+ if (! function_exists('cvd_logger'))
21
+ {
22
+ /**
23
+ * Returns the Logger instance.
24
+ *
25
+ * @return \Converdo\Common\Log\Logger::class
26
+ */
27
+ function cvd_logger()
28
+ {
29
+ return cvd_app(\Converdo\Common\Log\Logger::class);
30
+ }
31
+ }
32
+
33
+ if (! function_exists('cvd_config'))
34
+ {
35
+ /**
36
+ * Returns the Configuration instance.
37
+ *
38
+ * @return \Converdo\Common\Config\Configuration
39
+ */
40
+ function cvd_config()
41
+ {
42
+ return cvd_app(\Converdo\Common\Config\Configuration::class);
43
+ }
44
+ }
app/code/community/Converdo/Magento/Block/Tracker.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once __DIR__ . '/../../Common/bootstrap.php';
4
+
5
+ use Converdo\Common\Managers\QueryManager;
6
+ use Converdo\Common\Query\Queries\SiteId;
7
+ use Converdo\Common\Query\Queries\TrackerUrl;
8
+ use Converdo\Common\Query\Queries\TrackSiteSearch;
9
+ use Converdo\Common\Query\Queries\CategoryView;
10
+ use Converdo\Common\Query\Queries\EcommerceView;
11
+ use Converdo\Common\Query\Queries\AddEcommerceItem;
12
+ use Converdo\Common\Query\Queries\TrackEcommerceCart;
13
+ use Converdo\Common\Query\Queries\TrackPageView;
14
+ use Converdo\Common\Query\Queries\EnableLinkTracking;
15
+ use Converdo\Common\Query\Queries\EnableHeartBeatTimer;
16
+ use Converdo\Common\Query\Queries\CustomVariable;
17
+
18
+ class Converdo_Magento_Block_Tracker extends Mage_Core_Block_Template
19
+ {
20
+ /**
21
+ * @var array
22
+ */
23
+ protected $orderedIds = [];
24
+
25
+ /**
26
+ * Render Converdo tracking scripts
27
+ *
28
+ * @return string
29
+ */
30
+ protected function trackers()
31
+ {
32
+ if (cvd_config()->platform()->disabled()) {
33
+ return null;
34
+ }
35
+
36
+ QueryManager::register(cvd_app(SiteId::class));
37
+ QueryManager::register(cvd_app(TrackerUrl::class));
38
+ QueryManager::register(cvd_app(TrackSiteSearch::class));
39
+ QueryManager::register(cvd_app(CategoryView::class));
40
+ QueryManager::register(cvd_app(EcommerceView::class));
41
+ QueryManager::register(cvd_app(AddEcommerceItem::class));
42
+ QueryManager::register(cvd_app(TrackEcommerceCart::class));
43
+ QueryManager::register(cvd_app(TrackPageView::class));
44
+ QueryManager::register(cvd_app(EnableLinkTracking::class));
45
+ QueryManager::register(cvd_app(EnableHeartBeatTimer::class));
46
+ QueryManager::register(cvd_app(CustomVariable::class));
47
+
48
+ foreach (QueryManager::registered() as $query) {
49
+ if (! $query->responsible()) {
50
+ continue;
51
+ }
52
+
53
+ $query->process();
54
+
55
+ $query->parse();
56
+
57
+ QueryManager::push($query->position(), $query);
58
+ }
59
+
60
+ echo QueryManager::render();
61
+ }
62
+
63
+ /**
64
+ * Renders the queries as strings, only for development.
65
+ */
66
+ protected function debugbar()
67
+ {
68
+ if (! cvd_config()->environment('development')) {
69
+ return;
70
+ }
71
+
72
+ dump(array_values(QueryManager::parsed()));
73
+ }
74
+ }
app/code/community/Converdo/Magento/Config/Configuration.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Config;
4
+
5
+ use Converdo\Common\Config\Contracts\PlatformConfigurationContract;
6
+ use Converdo\Magento\Container\Bindings;
7
+ use Converdo\Magento\Factories\EcommerceCartFactory;
8
+ use Converdo\Magento\Factories\EcommerceCategoryFactory;
9
+ use Converdo\Magento\Factories\EcommerceItemFactory;
10
+ use Converdo\Magento\Factories\EcommerceSearchFactory;
11
+ use Mage;
12
+
13
+ class Configuration implements PlatformConfigurationContract
14
+ {
15
+ /**
16
+ * @var bool
17
+ */
18
+ protected $enabled = true;
19
+
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ public function enabled($store = null)
24
+ {
25
+ return Mage::getStoreConfig('converdo/analytics/site', $store)
26
+ && Mage::getStoreConfigFlag('converdo/analytics/active', $store)
27
+ && Mage::getStoreConfigFlag('converdo/analytics/token', $store)
28
+ && $this->enabled;
29
+ }
30
+
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ public function disabled($store = null)
35
+ {
36
+ return ! $this->enabled($store);
37
+ }
38
+
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ public function terminate()
43
+ {
44
+ return $this->enabled = false;
45
+ }
46
+
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ public function version($check = null)
51
+ {
52
+ $version = Mage::getConfig()->getNode('modules/Converdo_Magento/version')->asArray();
53
+
54
+ return $check ? $version === $check : $version;
55
+ }
56
+
57
+ /**
58
+ * @inheritDoc
59
+ */
60
+ public function website($store = null)
61
+ {
62
+ return (string) Mage::getStoreConfig('converdo/analytics/site', $store);
63
+ }
64
+
65
+ /**
66
+ * @inheritDoc
67
+ */
68
+ public function user($store = null)
69
+ {
70
+ return Mage::getStoreConfig('converdo/analytics/token', $store);
71
+ }
72
+
73
+ /**
74
+ * @inheritDoc
75
+ */
76
+ public function encryption($store = null)
77
+ {
78
+ return Mage::getStoreConfig('converdo/analytics/encryption', $store);
79
+ }
80
+
81
+ /**
82
+ * @inheritDoc
83
+ */
84
+ public function hasActiveCart()
85
+ {
86
+ return (bool) Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
87
+ }
88
+
89
+ /**
90
+ * @inheritDoc
91
+ */
92
+ public function getActiveCart()
93
+ {
94
+ return EcommerceCartFactory::build(Mage::getModel('checkout/cart'));
95
+ }
96
+
97
+ /**
98
+ * @inheritDoc
99
+ */
100
+ public function getSearch()
101
+ {
102
+ return EcommerceSearchFactory::build(Mage::helper('catalogsearch'));
103
+ }
104
+
105
+ /**
106
+ * @inheritDoc
107
+ */
108
+ public function getActiveCartProducts()
109
+ {
110
+ $products = [];
111
+
112
+ foreach (Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems() as $product) {
113
+ $original = Mage::getModel('catalog/product')->load($product->product_id);
114
+ $product = EcommerceItemFactory::build($original, $product);
115
+
116
+ if ($product->getPrice() < 0.01) {
117
+ continue;
118
+ }
119
+
120
+ $products[] = $product;
121
+ }
122
+
123
+ return $products;
124
+ }
125
+
126
+ /**
127
+ * @inheritDoc
128
+ */
129
+ public function getViewedProduct()
130
+ {
131
+ return EcommerceItemFactory::build(Mage::registry('current_product'));
132
+ }
133
+
134
+ /**
135
+ * @inheritDoc
136
+ */
137
+ public function getViewedCategory()
138
+ {
139
+ return EcommerceCategoryFactory::build(Mage::registry('current_category'));
140
+ }
141
+
142
+ /**
143
+ * @inheritDoc
144
+ */
145
+ public function getActionName()
146
+ {
147
+ return Mage::app()->getFrontController()->getAction()->getFullActionName();
148
+ }
149
+
150
+ /**
151
+ * @inheritDoc
152
+ */
153
+ public function getRouteName()
154
+ {
155
+ return Mage::app()->getFrontController()->getRequest()->getRouteName();
156
+ }
157
+
158
+ /**
159
+ * @inheritDoc
160
+ */
161
+ public function isSearchPage()
162
+ {
163
+ return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'result';
164
+ }
165
+
166
+ /**
167
+ * @inheritDoc
168
+ */
169
+ public function isProductPage()
170
+ {
171
+ return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'product'
172
+ && Mage::registry('current_product');
173
+ }
174
+
175
+ /**
176
+ * @inheritDoc
177
+ */
178
+ public function isCategoryPage()
179
+ {
180
+ return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'category'
181
+ && Mage::registry('current_category');
182
+ }
183
+
184
+ /**
185
+ * @inheritDoc
186
+ */
187
+ public function bindings()
188
+ {
189
+ return cvd_app(Bindings::class)->toArray('map');
190
+ }
191
+ }
app/code/community/Converdo/Magento/Container/Bindings.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Container;
4
+
5
+ use Converdo\Common\Config\Contracts\PlatformConfigurationContract;
6
+ use Converdo\Common\Page\Support\Contracts\RouteResolverInterface;
7
+ use Converdo\Common\Support\Arrayable;
8
+ use Converdo\Magento\Config\Configuration;
9
+ use Converdo\Magento\Page\RouteResolver;
10
+
11
+ class Bindings
12
+ {
13
+ use Arrayable;
14
+
15
+ /**
16
+ * Defines all bindings.
17
+ *
18
+ * @var array
19
+ */
20
+ protected $map = [
21
+ RouteResolverInterface::class => RouteResolver::class,
22
+ PlatformConfigurationContract::class => Configuration::class,
23
+ ];
24
+ }
app/code/community/Converdo/Magento/Factories/EcommerceCartFactory.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Factories;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceCartInterface;
6
+ use Converdo\Common\Query\Models\EcommerceCart;
7
+ use Mage_Checkout_Model_Cart;
8
+
9
+ class EcommerceCartFactory
10
+ {
11
+ /**
12
+ * @param Mage_Checkout_Model_Cart $cart
13
+ * @return EcommerceCartInterface
14
+ */
15
+ public static function build(Mage_Checkout_Model_Cart $cart)
16
+ {
17
+ return (new EcommerceCart())
18
+ ->setSubtotal($cart->getQuote()->getSubtotal())
19
+ ->setTotal($cart->getQuote()->getGrandTotal());
20
+ }
21
+ }
app/code/community/Converdo/Magento/Factories/EcommerceCategoryFactory.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Factories;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceCategoryInterface;
6
+ use Converdo\Common\Query\Models\EcommerceCategory;
7
+ use Mage_Catalog_Model_Category;
8
+
9
+ class EcommerceCategoryFactory
10
+ {
11
+ /**
12
+ * @param Mage_Catalog_Model_Category $category
13
+ * @return EcommerceCategoryInterface
14
+ */
15
+ public static function build(Mage_Catalog_Model_Category $category)
16
+ {
17
+ return (new EcommerceCategory())
18
+ ->setCategory($category->getName());
19
+ }
20
+ }
app/code/community/Converdo/Magento/Factories/EcommerceItemFactory.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Factories;
4
+
5
+ use Converdo\Common\Query\Models\EcommerceItem;
6
+ use Converdo\Common\Query\Models\Contracts\EcommerceItemInterface;
7
+ use Converdo\Magento\Support\PriceHelper;
8
+ use Mage;
9
+ use Mage_Catalog_Model_Product;
10
+ use Mage_Sales_Model_Quote_Item;
11
+
12
+ class EcommerceItemFactory
13
+ {
14
+ /**
15
+ * @param Mage_Catalog_Model_Product $original
16
+ * @param Mage_Sales_Model_Quote_Item|null $product
17
+ * @return EcommerceItemInterface
18
+ */
19
+ public static function build(Mage_Catalog_Model_Product $original, Mage_Sales_Model_Quote_Item $product = null)
20
+ {
21
+ return (new EcommerceItem())
22
+ ->setId($product ? $product->getId() : $original->getId())
23
+ ->setSKU($product ? $product->getSku() : $original->getSku())
24
+ ->setName($product ? $product->getName() : $original->getName())
25
+ ->setCategories(self::categories($original->getCategoryIds()))
26
+ ->setChildrenIds(self::children($original))
27
+ ->setPrice($product ? $product->getPrice() : PriceHelper::resolve($original))
28
+ ->setQuantity($product ? $product->getQty() : 1)
29
+ ->setImageUrl($original->getImageUrl())
30
+ ->setType($original->getTypeId())
31
+ ->setIsInStock($original->getStockItem()->getIsInStock())
32
+ ->setStockQuantity($original->getStockItem()->getQty())
33
+ ->setManufacturer($original->getData('manufacturer'))
34
+ ->setCost($original->getData('cost'))
35
+ ;
36
+ }
37
+
38
+ /**
39
+ * Loads up to five product categories.
40
+ *
41
+ * @param array $ids
42
+ * @return array
43
+ */
44
+ protected static function categories(array $ids)
45
+ {
46
+ $categories = array_splice(array_filter($ids), 0, 5);
47
+
48
+ foreach ($ids as $key => $id) {
49
+ $category = Mage::getModel('catalog/category')->load($id);
50
+ $categories[$key] = addslashes($category->getName());
51
+ }
52
+
53
+ return (array) $categories;
54
+ }
55
+
56
+ /**
57
+ * Fetches the IDs for all children products.
58
+ *
59
+ * @param Mage_Catalog_Model_Product $product
60
+ * @return array
61
+ */
62
+ protected static function children(Mage_Catalog_Model_Product $product)
63
+ {
64
+ if ($product->getType() !== 'configurable') {
65
+ return [];
66
+ }
67
+
68
+ $children = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
69
+
70
+ if (count($children) <= 0) {
71
+ return [];
72
+ }
73
+
74
+ return array_keys($children[0]);
75
+ }
76
+ }
app/code/community/Converdo/Magento/Factories/EcommerceSearchFactory.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Factories;
4
+
5
+ use Converdo\Common\Query\Models\Contracts\EcommerceSearchInterface;
6
+ use Converdo\Common\Query\Models\EcommerceSearch;
7
+ use Mage_CatalogSearch_Helper_Data;
8
+
9
+ class EcommerceSearchFactory
10
+ {
11
+ /**
12
+ * @param Mage_CatalogSearch_Helper_Data $search
13
+ * @return EcommerceSearchInterface
14
+ */
15
+ public static function build(Mage_CatalogSearch_Helper_Data $search)
16
+ {
17
+ return (new EcommerceSearch())
18
+ ->setKeyword($search->getQueryText())
19
+ ->setResultCount(
20
+ $search->getEngine()->getResultCollection()->addSearchFilter(
21
+ $search->getQuery()->getQueryText()
22
+ )->getSize()
23
+ );
24
+ }
25
+ }
app/code/community/Converdo/Magento/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Converdo_Magento_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Converdo/Magento/Model/Observer.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once __DIR__ . '/../../Common/bootstrap.php';
4
+
5
+ class Converdo_Magento_Model_Observer
6
+ {
7
+ /**
8
+ * Listens to placed orders. Sends the order to the Converdo Analytics API.
9
+ *
10
+ * @param Varien_Event_Observer $observer
11
+ * @throws Exception
12
+ */
13
+ public function onOrderPlacedEvent(Varien_Event_Observer $observer)
14
+ {
15
+ /* @var $order Mage_Sales_Model_Order */
16
+
17
+ if (cvd_config()->platform()->enabled()) {
18
+ $order = $observer->getEvent()->getOrder();
19
+
20
+ if ($order) {
21
+ \Converdo\Common\API\Requests::orderCreate(
22
+ \Converdo\Common\Page\Factories\OrderFactory::build($order)
23
+ );
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Listens to changed orders. Sends the new order status to the Converdo Analytics API.
30
+ *
31
+ * @param Varien_Event_Observer $observer
32
+ * @throws Exception
33
+ */
34
+ public function onOrderStatusChangedEvent(Varien_Event_Observer $observer)
35
+ {
36
+ /* @var $order Mage_Sales_Model_Order */
37
+
38
+ if (cvd_config()->platform()->enabled()) {
39
+ $order = $observer->getEvent()->getOrder();
40
+
41
+ if ($order && $order->getStatus()) {
42
+ \Converdo\Common\API\Requests::orderStatusUpdate(
43
+ \Converdo\Common\Page\Factories\OrderFactory::build($order)
44
+ );
45
+ }
46
+ }
47
+ }
48
+ }
app/code/community/Converdo/Magento/Page/RouteResolver.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Page;
4
+
5
+ use Converdo\Common\Page\Support\PageTypes;
6
+ use Converdo\Common\Page\Support\Contracts\RouteResolverInterface;
7
+
8
+ class RouteResolver extends PageTypes implements RouteResolverInterface
9
+ {
10
+ /**
11
+ * Maps the Magento routes to normalized names.
12
+ *
13
+ * @var array
14
+ */
15
+ protected $map = [
16
+ PageTypes::PAGE_ACCOUNT => [
17
+ 'customer_account_login' => PageTypes::ACCOUNT_LOGIN,
18
+ 'customer_account_logoutSuccess' => PageTypes::ACCOUNT_LOGOUT,
19
+ 'customer_account_create' => PageTypes::ACCOUNT_CREATE,
20
+ 'customer_account_index' => PageTypes::ACCOUNT_INDEX,
21
+ 'customer_account_forgotpassword' => PageTypes::ACCOUNT_PASSWORD_FORGOT,
22
+ 'customer_account_edit' => PageTypes::ACCOUNT_EDIT_INFO,
23
+ 'customer_address_form' => PageTypes::ACCOUNT_EDIT_ADDRESS,
24
+ 'sales_order_history' => PageTypes::ACCOUNT_ORDERS,
25
+ 'sales_billing_agreement_index' => PageTypes::ACCOUNT_BILLING_AGREEMENT,
26
+ 'sales_recurring_profile_index' => PageTypes::ACCOUNT_RECURRING,
27
+ 'review_customer_index' => PageTypes::ACCOUNT_REVIEWS,
28
+ 'wishlist_index_index' => PageTypes::ACCOUNT_WISHLIST,
29
+ 'oauth_customer_token_index' => PageTypes::ACCOUNT_APPS,
30
+ 'newsletter_manage_index' => PageTypes::ACCOUNT_NEWSLETTER_MANAGE,
31
+ 'account_newsletters' => PageTypes::ACCOUNT_NEWSLETTER,
32
+ 'downloadable_customer_products' => PageTypes::ACCOUNT_DOWNLOADS,
33
+ ],
34
+
35
+ PageTypes::PAGE_CART => [
36
+ 'cart_index' => PageTypes::CART_VIEW,
37
+ ],
38
+
39
+ PageTypes::PAGE_CATEGORY => [
40
+ 'catalog_category_view' => PageTypes::CATEGORY_VIEW,
41
+ ],
42
+
43
+ PageTypes::PAGE_CHECKOUT => [
44
+ 'checkout_onepage_index' => PageTypes::CHECKOUT_VIEW,
45
+ 'firecheckout_index_index' => PageTypes::CHECKOUT_VIEW,
46
+ 'aw_onestepcheckout_index_index' => PageTypes::CHECKOUT_VIEW,
47
+ 'opc_index_index' => PageTypes::CHECKOUT_VIEW,
48
+ 'gomage_checkout_onepage_index' => PageTypes::CHECKOUT_VIEW,
49
+ 'anattadesign_awesomecheckout_onepage_index' => PageTypes::CHECKOUT_VIEW,
50
+ 'checkout_onestep_index' => PageTypes::CHECKOUT_VIEW,
51
+ 'onestepcheckout_index_index' => PageTypes::CHECKOUT_VIEW,
52
+ ],
53
+
54
+ PageTypes::PAGE_ADMIN => [
55
+ 'cms_page_view' => PageTypes::ADMIN_VIEW,
56
+ 'cms_index_index' => PageTypes::HOMEPAGE_VIEW,
57
+ ],
58
+
59
+ PageTypes::PAGE_CONTACT => [
60
+ 'contact_index' => PageTypes::CONTACT_VIEW,
61
+ ],
62
+
63
+ PageTypes::PAGE_HOMEPAGE => [
64
+ 'homepage_index' => PageTypes::HOMEPAGE_VIEW,
65
+ ],
66
+
67
+ PageTypes::PAGE_PRODUCT => [
68
+ 'catalog_product_view' => PageTypes::PRODUCT_VIEW,
69
+ ],
70
+ ];
71
+ }
app/code/community/Converdo/Magento/Support/PriceHelper.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Converdo\Magento\Support;
4
+
5
+ use Mage_Catalog_Model_Product;
6
+ use Mage_Catalog_Model_Product_Type;
7
+
8
+ class PriceHelper
9
+ {
10
+ /**
11
+ * Returns the final product price.
12
+ *
13
+ * @param Mage_Catalog_Model_Product $product
14
+ * @return float
15
+ */
16
+ public static function resolve(Mage_Catalog_Model_Product $product)
17
+ {
18
+ // Returns the minimum value of the bundled product.
19
+ if ($product->getTypeId() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
20
+ $minmax = $product->getPriceModel()->getTotalPrices($product, null, null, false);
21
+
22
+ return is_array($minmax) ? reset($minmax) : 0;
23
+ }
24
+
25
+ // Returns the default final price of the product.
26
+ return (float) $product->getFinalPrice();
27
+ }
28
+ }
app/code/community/Converdo/Magento/controllers/PingController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once __DIR__ . '/../../Common/bootstrap.php';
4
+
5
+ class Converdo_Magento_PingController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ /**
8
+ * Returns information about the plugin and website.
9
+ *
10
+ * @return string
11
+ */
12
+ public function pingerAction()
13
+ {
14
+ $this->getResponse()
15
+ ->setHeader('Content-type', 'application/json')
16
+ ->setBody((new \Converdo\Common\Controllers\PingController())->ping());
17
+ }
18
+ }
app/code/community/Converdo/{Analytics → Magento}/etc/adminhtml.xml RENAMED
File without changes
app/code/community/Converdo/{Analytics → Magento}/etc/config.xml RENAMED
@@ -2,35 +2,35 @@
2
 
3
  <config>
4
  <modules>
5
- <Converdo_Analytics>
6
- <version>2.1.0.0</version>
7
- </Converdo_Analytics>
8
  </modules>
9
  <global>
10
  <models>
11
  <analytics>
12
- <class>Converdo_Analytics_Model</class>
13
  </analytics>
14
  </models>
15
  <blocks>
16
  <analytics>
17
- <class>Converdo_Analytics_Block</class>
18
  </analytics>
19
  </blocks>
20
  <helpers>
21
  <analytics>
22
- <class>Converdo_Analytics_Helper</class>
23
  </analytics>
24
  </helpers>
25
  </global>
26
  <frontend>
27
  <translate>
28
  <modules>
29
- <Converdo_Analytics>
30
  <files>
31
  <default>Converdo_Analytics.csv</default>
32
  </files>
33
- </Converdo_Analytics>
34
  </modules>
35
  </translate>
36
  <events>
@@ -61,23 +61,23 @@
61
  </updates>
62
  </layout>
63
  <routers>
64
- <Converdo_Analytics>
65
  <use>standard</use>
66
  <args>
67
- <module>Converdo_Analytics</module>
68
  <frontName>converdoanalytics</frontName>
69
  </args>
70
- </Converdo_Analytics>
71
  </routers>
72
  </frontend>
73
  <adminhtml>
74
  <translate>
75
  <modules>
76
- <Converdo_Analytics>
77
  <files>
78
  <default>Converdo_Analytics.csv</default>
79
  </files>
80
- </Converdo_Analytics>
81
  </modules>
82
  </translate>
83
  <events>
@@ -101,13 +101,13 @@
101
  </adminhtml>
102
  <admin>
103
  <routers>
104
- <Converdo_Analytics>
105
  <use>admin</use>
106
  <args>
107
- <module>Converdo_Analytics</module>
108
  <frontName>analytics</frontName>
109
  </args>
110
- </Converdo_Analytics>
111
  </routers>
112
  </admin>
113
  <default>
2
 
3
  <config>
4
  <modules>
5
+ <Converdo_Magento>
6
+ <version>2.1.5.0</version>
7
+ </Converdo_Magento>
8
  </modules>
9
  <global>
10
  <models>
11
  <analytics>
12
+ <class>Converdo_Magento_Model</class>
13
  </analytics>
14
  </models>
15
  <blocks>
16
  <analytics>
17
+ <class>Converdo_Magento_Block</class>
18
  </analytics>
19
  </blocks>
20
  <helpers>
21
  <analytics>
22
+ <class>Converdo_Magento_Helper</class>
23
  </analytics>
24
  </helpers>
25
  </global>
26
  <frontend>
27
  <translate>
28
  <modules>
29
+ <Converdo_Magento>
30
  <files>
31
  <default>Converdo_Analytics.csv</default>
32
  </files>
33
+ </Converdo_Magento>
34
  </modules>
35
  </translate>
36
  <events>
61
  </updates>
62
  </layout>
63
  <routers>
64
+ <Converdo_Magento>
65
  <use>standard</use>
66
  <args>
67
+ <module>Converdo_Magento</module>
68
  <frontName>converdoanalytics</frontName>
69
  </args>
70
+ </Converdo_Magento>
71
  </routers>
72
  </frontend>
73
  <adminhtml>
74
  <translate>
75
  <modules>
76
+ <Converdo_Magento>
77
  <files>
78
  <default>Converdo_Analytics.csv</default>
79
  </files>
80
+ </Converdo_Magento>
81
  </modules>
82
  </translate>
83
  <events>
101
  </adminhtml>
102
  <admin>
103
  <routers>
104
+ <Converdo_Magento>
105
  <use>admin</use>
106
  <args>
107
+ <module>Converdo_Magento</module>
108
  <frontName>analytics</frontName>
109
  </args>
110
+ </Converdo_Magento>
111
  </routers>
112
  </admin>
113
  <default>
app/code/community/Converdo/{Analytics → Magento}/etc/system.xml RENAMED
File without changes
app/design/frontend/base/default/template/analytics/analytics.phtml CHANGED
@@ -1,4 +1,4 @@
1
- <?php if (Mage::helper('analytics')->isEnabled()) { ?>
2
 
3
  <!-- START CONVERDO TRACKING CODE -->
4
  <script type="text/javascript">
@@ -6,11 +6,14 @@
6
  (function(){
7
  <?php $this->trackers(); ?>
8
 
9
- var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src='<?= Mage::helper('analytics')->getJsTracker(true); ?>';
 
10
  s.parentNode.insertBefore(g,s);
11
  })();
12
  </script>
13
- <noscript><p><img src="<?= Mage::helper('analytics')->getPhpTracker(true) ?>?idsite=<?= Mage::helper('analytics')->getSiteId() ?>" style="border:0" alt="" /></p></noscript>
14
  <!-- END CONVERDO TRACKING CODE -->
15
 
 
 
16
  <?php } ?>
1
+ <?php if (cvd_config()->platform()->enabled()) { ?>
2
 
3
  <!-- START CONVERDO TRACKING CODE -->
4
  <script type="text/javascript">
6
  (function(){
7
  <?php $this->trackers(); ?>
8
 
9
+
10
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src='<?= cvd_config()->url('tracker.js'); ?>';
11
  s.parentNode.insertBefore(g,s);
12
  })();
13
  </script>
14
+ <noscript><p><img src="<?= cvd_config()->url('tracker.php'); ?>?idsite=<?= cvd_config()->platform()->website(); ?>" style="border:0" alt="" /></p></noscript>
15
  <!-- END CONVERDO TRACKING CODE -->
16
 
17
+ <?php $this->debugbar(); ?>
18
+
19
  <?php } ?>
app/etc/modules/Converdo_Analytics.xml CHANGED
@@ -2,12 +2,12 @@
2
 
3
  <config>
4
  <modules>
5
- <Converdo_Analytics>
6
  <active>true</active>
7
  <codePool>community</codePool>
8
  <depends>
9
  <Mage_Core/>
10
  </depends>
11
- </Converdo_Analytics>
12
  </modules>
13
  </config>
2
 
3
  <config>
4
  <modules>
5
+ <Converdo_Magento>
6
  <active>true</active>
7
  <codePool>community</codePool>
8
  <depends>
9
  <Mage_Core/>
10
  </depends>
11
+ </Converdo_Magento>
12
  </modules>
13
  </config>
lib/Converdo/Analytics/API/ConverdoAPI.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_API_ConverdoAPI
4
- {
5
- public static function order()
6
- {
7
- return new Converdo_Analytics_API_Sections_ConverdoOrderAPI();
8
- }
9
- }
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/API/Factories/Order.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_API_Factories_Order
4
- {
5
- /**
6
- * @var Mage_Sales_Model_Order
7
- */
8
- protected $order;
9
-
10
- /**
11
- * @var Converdo_Analytics_API_Models_Order
12
- */
13
- protected $model;
14
-
15
- /**
16
- * @param Mage_Sales_Model_Order $order
17
- * @return Converdo_Analytics_API_Models_Order
18
- */
19
- public function make(Mage_Sales_Model_Order $order)
20
- {
21
- $this->order = $order;
22
- $this->model = (new Converdo_Analytics_API_Models_Order())
23
- ->setOrderId($order->getRealOrderId())
24
- ->setCustomer($this->customer())
25
- ->setProducts($this->products())
26
- ->setSubtotal($order->getSubtotal())
27
- ->setTax($order->getBaseTaxAmount())
28
- ->setShipping($order->getBaseShippingAmount())
29
- ->setStatus($order->getState())
30
- ;
31
-
32
- return $this->model;
33
- }
34
-
35
- /**
36
- * Retrieve all customer data.
37
- *
38
- * @return array
39
- */
40
- protected function customer()
41
- {
42
- $billing = $this->order->getBillingAddress();
43
-
44
- return [
45
- 'prefix' => $billing->getPrefix(),
46
- 'name' => $billing->getName(),
47
- 'address' => $billing->getStreet(-1),
48
- 'postal_code' => $billing->getPostcode(),
49
- 'city' => $billing->getCity(),
50
- 'country' => $billing->getCountryModel()->getName(),
51
- 'email' => $billing->getEmail() ?: $this->order->getCustomerEmail(),
52
- 'telephone' => $billing->getTelephone(),
53
- ];
54
- }
55
-
56
- /**
57
- * Retrieve all (parent) products in the cart.
58
- *
59
- * @return array
60
- */
61
- protected function products()
62
- {
63
- $products = [];
64
-
65
- foreach (Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems() as $item) {
66
- if ($item->getPrice() < 0.01) {
67
- continue;
68
- }
69
-
70
- $product = Mage::getModel('catalog/product')->load($item->product_id);
71
-
72
- $products[] = [
73
- 'name' => $product->getName(),
74
- 'sku' => $product->getSku(),
75
- 'price' => $item->getPrice(),
76
- 'quantity' => $item->getQtyOrdered(),
77
- ];
78
- }
79
-
80
- return $products;
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/CategoryView.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_CategoryView
4
- {
5
- use Converdo_Analytics_Support_Arrayable;
6
-
7
- /**
8
- * @var string
9
- */
10
- protected $category;
11
-
12
- /**
13
- * Sets the Category Name.
14
- *
15
- * @param string $category
16
- * @return $this
17
- */
18
- public function setCategory($category)
19
- {
20
- $this->category = $category;
21
-
22
- return $this;
23
- }
24
-
25
- /**
26
- * Gets the Category Name.
27
- *
28
- * @return string
29
- */
30
- public function getCategory()
31
- {
32
- return (string) $this->category;
33
- }
34
-
35
- /**
36
- * Gets whether the Category Name is set.
37
- *
38
- * @return bool
39
- */
40
- public function hasCategory()
41
- {
42
- return (bool) $this->category;
43
- }
44
-
45
- /**
46
- * Returns the data as an array.
47
- *
48
- * @return array
49
- */
50
- public function toArray()
51
- {
52
- return [
53
- "_paq.push(['setEcommerceView', false, false, '" . $this->getCategory() . "']);",
54
- ];
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/Configuration.php DELETED
@@ -1,170 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_Configuration
4
- {
5
- use Converdo_Analytics_Support_Arrayable;
6
-
7
- /**
8
- * @var string
9
- */
10
- protected $token;
11
-
12
- /**
13
- * @var string
14
- */
15
- protected $linkTracking;
16
-
17
- /**
18
- * @var string
19
- */
20
- protected $pageTracking;
21
-
22
- /**
23
- * @var string
24
- */
25
- protected $heartBeat;
26
-
27
- /**
28
- * @var null
29
- */
30
- protected $ecommerce;
31
-
32
- /**
33
- * @var null
34
- */
35
- protected $view;
36
-
37
- /**
38
- * Sets the Converdo Analytics Website Token.
39
- *
40
- * @param string $token
41
- * @return $this
42
- */
43
- public function setToken($token)
44
- {
45
- $this->token = (string) $token;
46
-
47
- return $this;
48
- }
49
-
50
- /**
51
- * Retrieves the Converdo Analytics Website Token.
52
- *
53
- * @return string
54
- */
55
- public function getToken()
56
- {
57
- return (string) $this->token;
58
- }
59
-
60
- /**
61
- * Gets whether the Converdo Analytics Website Token is set.
62
- *
63
- * @return bool
64
- */
65
- public function hasToken()
66
- {
67
- return (bool) $this->token;
68
- }
69
-
70
- /**
71
- * Enables the tracking of links.
72
- *
73
- * @param bool $status
74
- * @return $this
75
- */
76
- public function enableLinkTracking($status)
77
- {
78
- $this->linkTracking = (bool) $status;
79
-
80
- return $this;
81
- }
82
-
83
- /**
84
- * Gets whether the tracking of links is enabled.
85
- *
86
- * @return bool
87
- */
88
- public function hasLinkTrackingEnabled()
89
- {
90
- return (bool) $this->linkTracking;
91
- }
92
-
93
- /**
94
- * Enables the tracking of pages.
95
- *
96
- * @param bool $status
97
- * @return $this
98
- */
99
- public function enablePageTracking($status)
100
- {
101
- $this->pageTracking = (bool) $status;
102
-
103
- return $this;
104
- }
105
-
106
- /**
107
- * Gets whether the tracking of pages is enabled.
108
- *
109
- * @return bool
110
- */
111
- public function hasPageTrackingEnabled()
112
- {
113
- return (bool) $this->pageTracking;
114
- }
115
-
116
- /**
117
- * Enables HeartBeat.
118
- *
119
- * @param bool $status
120
- * @return $this
121
- */
122
- public function enableHeartBeat($status)
123
- {
124
- $this->heartBeat = (bool) $status;
125
-
126
- return $this;
127
- }
128
-
129
- /**
130
- * Gets whether the HeartBeat is enabled.
131
- *
132
- * @return bool
133
- */
134
- public function hasHeartBeatEnabled()
135
- {
136
- return (bool) $this->heartBeat;
137
- }
138
-
139
- /**
140
- * Returns the data as an array.
141
- *
142
- * @return array
143
- */
144
- public function toConfigurationArray()
145
- {
146
- return [
147
- "_paq.push(['setSiteId', '" . $this->getToken() . "']);",
148
- "_paq.push(['setTrackerUrl', '" . Mage::helper('analytics')->getPhpTracker(true) . "']);",
149
- ];
150
- }
151
-
152
- public function toOptionsArray()
153
- {
154
- $output = [];
155
-
156
- if ($this->hasPageTrackingEnabled() && ! Mage::helper('analytics')->isSearchPage()) {
157
- $output[] = "_paq.push(['trackPageView']);";
158
- }
159
-
160
- if ($this->hasLinkTrackingEnabled()) {
161
- $output[] = "_paq.push(['enableLinkTracking']);";
162
- }
163
-
164
- if ($this->hasHeartBeatEnabled()) {
165
- $output[] = "_paq.push(['enableHeartBeatTimer']);";
166
- }
167
-
168
- return $output;
169
- }
170
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/EcommerceCartUpdate.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_EcommerceCartUpdate
4
- {
5
- use Converdo_Analytics_Support_Arrayable;
6
-
7
- /**
8
- * @var float
9
- */
10
- protected $total;
11
-
12
- /**
13
- * Sets the Cart Total.
14
- *
15
- * @param float $total
16
- * @return $this
17
- */
18
- public function setTotal($total)
19
- {
20
- $this->total = (float) $total;
21
-
22
- return $this;
23
- }
24
-
25
- /**
26
- * Gets the Product Sku.
27
- *
28
- * @return string
29
- */
30
- public function getTotal()
31
- {
32
- return (float) $this->total;
33
- }
34
-
35
- /**
36
- * Returns the data as an array.
37
- *
38
- * @return array
39
- */
40
- public function toArray()
41
- {
42
- return [
43
- "_paq.push(['trackEcommerceCartUpdate', " . $this->getTotal() . "]);",
44
- ];
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/EcommerceOrder.php DELETED
@@ -1,158 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_EcommerceOrder
4
- {
5
- use Converdo_Analytics_Support_Arrayable;
6
-
7
- /**
8
- * @var int
9
- */
10
- protected $orderId;
11
-
12
- /**
13
- * @var float
14
- */
15
- protected $total;
16
-
17
- /**
18
- * @var float
19
- */
20
- protected $subtotal;
21
-
22
- /**
23
- * @var float
24
- */
25
- protected $tax;
26
-
27
- /**
28
- * @var float
29
- */
30
- protected $shipping;
31
-
32
- /**
33
- * Sets the Order ID.
34
- *
35
- * @param int $orderId
36
- * @return $this
37
- */
38
- public function setOrderId($orderId)
39
- {
40
- $this->orderId = $orderId;
41
-
42
- return $this;
43
- }
44
-
45
- /**
46
- * Gets the Order ID.
47
- *
48
- * @return int
49
- */
50
- public function getOrderId()
51
- {
52
- return (int) $this->orderId;
53
- }
54
-
55
- /**
56
- * Sets the Order Total.
57
- *
58
- * @param float $total
59
- * @return $this
60
- */
61
- public function setTotal($total)
62
- {
63
- $this->total = $total;
64
-
65
- return $this;
66
- }
67
-
68
- /**
69
- * Gets the Order Total.
70
- *
71
- * @return float
72
- */
73
- public function getTotal()
74
- {
75
- return (float) $this->total;
76
- }
77
-
78
- /**
79
- * Sets the Order Subtotal.
80
- *
81
- * @param float $subtotal
82
- * @return $this
83
- */
84
- public function setSubtotal($subtotal)
85
- {
86
- $this->subtotal = $subtotal;
87
-
88
- return $this;
89
- }
90
-
91
- /**
92
- * Gets the Order Subtotal.
93
- *
94
- * @return float
95
- */
96
- public function getSubtotal()
97
- {
98
- return (float) $this->subtotal;
99
- }
100
-
101
- /**
102
- * Sets the Order Tax.
103
- *
104
- * @param float $tax
105
- * @return $this
106
- */
107
- public function setTax($tax)
108
- {
109
- $this->tax = $tax;
110
-
111
- return $this;
112
- }
113
-
114
- /**
115
- * Gets the Order Tax.
116
- *
117
- * @return float
118
- */
119
- public function getTax()
120
- {
121
- return (float) $this->tax;
122
- }
123
-
124
- /**
125
- * Sets the Order Shipping.
126
- *
127
- * @param float $shipping
128
- * @return $this
129
- */
130
- public function setShipping($shipping)
131
- {
132
- $this->shipping = $shipping;
133
-
134
- return $this;
135
- }
136
-
137
- /**
138
- * Gets the Order Shipping.
139
- *
140
- * @return float
141
- */
142
- public function getShipping()
143
- {
144
- return (float) $this->shipping;
145
- }
146
-
147
- /**
148
- * Returns the data as an array.
149
- *
150
- * @return array
151
- */
152
- public function toArray()
153
- {
154
- return [
155
- "_paq.push(['trackEcommerceOrder', '" . $this->getOrderId() . "', " . $this->getTotal() . ", " . $this->getSubtotal() . ", " . $this->getTax() . ", " . $this->getShipping() . ", false]);",
156
- ];
157
- }
158
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/EcommerceProduct.php DELETED
@@ -1,159 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_EcommerceProduct
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * @var string
10
- */
11
- protected $sku;
12
-
13
- /**
14
- * @var string
15
- */
16
- protected $name;
17
-
18
- /**
19
- * @var string
20
- */
21
- protected $category;
22
-
23
- /**
24
- * @var float
25
- */
26
- protected $price;
27
-
28
- /**
29
- * @var float
30
- */
31
- protected $quantity;
32
-
33
- /**
34
- * Sets the Product Sku.
35
- *
36
- * @param string $sku
37
- * @return $this
38
- */
39
- public function setSku($sku)
40
- {
41
- $this->sku = (string) $sku;
42
-
43
- return $this;
44
- }
45
-
46
- /**
47
- * Gets the Product Sku.
48
- *
49
- * @return string
50
- */
51
- public function getSku()
52
- {
53
- return (string) $this->sku;
54
- }
55
-
56
- /**
57
- * Sets the Product Name.
58
- *
59
- * @param string $name
60
- * @return $this
61
- */
62
- public function setName($name)
63
- {
64
- $this->name = $name;
65
-
66
- return $this;
67
- }
68
-
69
- /**
70
- * Gets the Product Name.
71
- *
72
- * @return string
73
- */
74
- public function getName()
75
- {
76
- return (string) $this->name;
77
- }
78
-
79
- /**
80
- * Sets the Product Category.
81
- *
82
- * @param string $category
83
- * @return $this
84
- */
85
- public function setCategory($category)
86
- {
87
- $this->category = $category;
88
-
89
- return $this;
90
- }
91
-
92
- /**
93
- * Gets the Product Category.
94
- *
95
- * @return string
96
- */
97
- public function getCategory()
98
- {
99
- return $this->category;
100
- }
101
-
102
- /**
103
- * Sets the Product Price.
104
- *
105
- * @param float $price
106
- * @return $this
107
- */
108
- public function setPrice($price)
109
- {
110
- $this->price = $price;
111
-
112
- return $this;
113
- }
114
-
115
- /**
116
- * Gets the Product Price.
117
- *
118
- * @return float|null
119
- */
120
- public function getPrice()
121
- {
122
- return (float) $this->price;
123
- }
124
-
125
- /**
126
- * Sets the Product Quantity.
127
- *
128
- * @param float $quantity
129
- * @return $this
130
- */
131
- public function setQuantity($quantity)
132
- {
133
- $this->quantity = $quantity;
134
-
135
- return $this;
136
- }
137
-
138
- /**
139
- * Gets the Product Quantity.
140
- *
141
- * @return float
142
- */
143
- public function getQuantity()
144
- {
145
- return (float) $this->quantity;
146
- }
147
-
148
- /**
149
- * Returns the data as an array.
150
- *
151
- * @return array
152
- */
153
- public function toArray()
154
- {
155
- return [
156
- "_paq.push(['addEcommerceItem', '" . $this->getSku() . "', '" . $this->getName() . "', '" . $this->getCategory() . "', " . $this->getPrice() .", " . $this->getQuantity() . "]);",
157
- ];
158
- }
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/EcommerceView.php DELETED
@@ -1,401 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_EcommerceView
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * @var int
10
- */
11
- protected $id;
12
-
13
- /**
14
- * @var string
15
- */
16
- protected $sku;
17
-
18
- /**
19
- * @var string
20
- */
21
- protected $name;
22
-
23
- /**
24
- * @var mixed
25
- */
26
- protected $categories = [];
27
-
28
- /**
29
- * @var float|null
30
- */
31
- protected $price;
32
-
33
- /**
34
- * @var string
35
- */
36
- protected $imageUrl;
37
-
38
- /**
39
- * @var string
40
- */
41
- protected $type;
42
-
43
- /**
44
- * @var bool
45
- */
46
- protected $isInStock;
47
-
48
- /**
49
- * @var int
50
- */
51
- protected $stockQuantity;
52
-
53
- /**
54
- * @var string
55
- */
56
- protected $manufacturer;
57
-
58
- /**
59
- * @var float
60
- */
61
- protected $cost;
62
-
63
- /**
64
- * Sets the product id.
65
- *
66
- * @param int $id
67
- * @return $this
68
- */
69
- public function setId($id)
70
- {
71
- $this->id = $id;
72
-
73
- return $this;
74
- }
75
-
76
- /**
77
- * Gets the product id.
78
- *
79
- * @return int
80
- */
81
- public function getId()
82
- {
83
- return (int) $this->id;
84
- }
85
-
86
- /**
87
- * Sets the product sku.
88
- *
89
- * @param string $sku
90
- * @return $this
91
- */
92
- public function setSku($sku)
93
- {
94
- $this->sku = (string) $sku;
95
-
96
- return $this;
97
- }
98
-
99
- /**
100
- * Gets the product sku.
101
- *
102
- * @return string
103
- */
104
- public function getSku()
105
- {
106
- return (string) $this->sku;
107
- }
108
-
109
- /**
110
- * Sets the product name.
111
- *
112
- * @param string $name
113
- * @return $this
114
- */
115
- public function setName($name)
116
- {
117
- $this->name = $name;
118
-
119
- return $this;
120
- }
121
-
122
- /**
123
- * Gets the product name.
124
- *
125
- * @return string
126
- */
127
- public function getName()
128
- {
129
- return (string) $this->name;
130
- }
131
-
132
- /**
133
- * Sets the product categories (up to five).
134
- *
135
- * @param array $categories
136
- * @return $this
137
- */
138
- public function setCategories($categories)
139
- {
140
- foreach ($categories as $category) {
141
- $category = Mage::getModel('catalog/category')->load($category);
142
- $this->categories[] = addslashes($category->getName());
143
- }
144
-
145
- $this->categories = array_filter($this->categories);
146
- $this->categories = array_splice($this->categories, 0, 5);
147
-
148
- return $this;
149
- }
150
-
151
- /**
152
- * Gets the product categories.
153
- *
154
- * @return string
155
- */
156
- public function getCategories()
157
- {
158
- return (array) $this->categories;
159
- }
160
-
161
- /**
162
- * Sets the product price.
163
- *
164
- * @param float $price
165
- * @return $this
166
- */
167
- public function setPrice($price)
168
- {
169
- $this->price = $price;
170
-
171
- return $this;
172
- }
173
-
174
- /**
175
- * Gets the product price.
176
- *
177
- * @return float|null
178
- */
179
- public function getPrice()
180
- {
181
- return $this->price;
182
- }
183
-
184
- /**
185
- * Sets the product image url.
186
- *
187
- * @param string $imageUrl
188
- * @return $this
189
- */
190
- public function setImageUrl($imageUrl)
191
- {
192
- $this->imageUrl = $imageUrl;
193
-
194
- return $this;
195
- }
196
-
197
- /**
198
- * Gets the product image url.
199
- *
200
- * @return string
201
- */
202
- public function getImageUrl()
203
- {
204
- return (string) $this->imageUrl;
205
- }
206
-
207
- /**
208
- * Sets the product type.
209
- *
210
- * @param int $type
211
- * @return $this
212
- */
213
- public function setType($type)
214
- {
215
- $this->type = $type;
216
-
217
- return $this;
218
- }
219
-
220
- /**
221
- * Gets the product type.
222
- *
223
- * @return int
224
- */
225
- public function getType()
226
- {
227
- return (string) $this->type;
228
- }
229
-
230
- /**
231
- * Sets the product stock.
232
- *
233
- * @param bool $isInStock
234
- * @return $this
235
- */
236
- public function setIsInStock($isInStock)
237
- {
238
- $this->isInStock = $isInStock;
239
-
240
- return $this;
241
- }
242
-
243
- /**
244
- * Gets the product stock.
245
- *
246
- * @return bool
247
- */
248
- public function getIsInStock()
249
- {
250
- return (bool) $this->isInStock;
251
- }
252
-
253
- /**
254
- * Sets the product stock quantity.
255
- *
256
- * @param int $quantity
257
- * @return $this
258
- */
259
- public function setStockQuantity($quantity)
260
- {
261
- $this->stockQuantity = $quantity;
262
-
263
- return $this;
264
- }
265
-
266
- /**
267
- * Gets the product stock quantity.
268
- *
269
- * @return bool
270
- */
271
- public function getStockQuantity()
272
- {
273
- return (float) $this->stockQuantity;
274
- }
275
-
276
- /**
277
- * Sets the manufacturer.
278
- *
279
- * @param string $manufacturer
280
- * @return $this
281
- */
282
- public function setManufacturer($manufacturer)
283
- {
284
- $this->manufacturer = $manufacturer;
285
-
286
- return $this;
287
- }
288
-
289
- /**
290
- * Gets the manufacturer.
291
- *
292
- * @return string
293
- */
294
- public function getManufacturer()
295
- {
296
- return (string) $this->manufacturer;
297
- }
298
-
299
- /**
300
- * Sets the product cost.
301
- *
302
- * @param float $cost
303
- * @return $this
304
- */
305
- public function setCost($cost)
306
- {
307
- $this->cost = $cost;
308
-
309
- return $this;
310
- }
311
-
312
- /**
313
- * Gets the Product cost.
314
- *
315
- * @return float
316
- */
317
- public function getCost()
318
- {
319
- return (float) $this->cost;
320
- }
321
-
322
- /**
323
- * Retrieves the Product IDs of children for a configurable product.
324
- *
325
- * @return array
326
- */
327
- protected function resolveChildren()
328
- {
329
- if ($this->getType() !== 'configurable') {
330
- return [];
331
- }
332
-
333
- $children = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($this->getId());
334
-
335
- if (count($children) <= 0) {
336
- return [];
337
- }
338
-
339
- return array_keys($children[0]);
340
- }
341
-
342
- /**
343
- * Adds attributes to the stack.
344
- *
345
- * @return array
346
- */
347
- public function attributes()
348
- {
349
- return [
350
- 'pti' => $this->getName(),
351
-
352
- // Product Sku
353
- 'sku' => $this->getSku(),
354
-
355
- // Product Price
356
- 'pri' => $this->getPrice(),
357
-
358
- // Product Image
359
- 'ima' => $this->getImageUrl(),
360
-
361
- // Product categories
362
- 'cat' => implode(', ', $this->getCategories()),
363
-
364
- // Product Id
365
- 'rid' => $this->getId(),
366
-
367
- // Product Children Id
368
- 'tid' => $this->resolveChildren(),
369
-
370
- // Product Type
371
- 'typ' => $this->getType(),
372
-
373
- // Product Attributes
374
- 'att' => null,
375
-
376
- // Product Is In Stock
377
- 'stb' => $this->getIsInStock(),
378
-
379
- // Product Brand
380
- 'bra' => $this->getManufacturer(),
381
-
382
- // Product Cost
383
- 'cos' => $this->getCost(),
384
-
385
- // Product Stock Quantity
386
- 'sqn' => $this->getStockQuantity(),
387
- ];
388
- }
389
-
390
- /**
391
- * Returns the data as an array.
392
- *
393
- * @return array
394
- */
395
- public function toArray()
396
- {
397
- return [
398
- "_paq.push(['setEcommerceView', '" . $this->getSku() . "', '" . $this->getName() . "', '" . implode(', ', $this->getCategories()) . "', " . $this->getPrice() . "]);",
399
- ];
400
- }
401
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/PageView.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_PageView
4
- {
5
- use Converdo_Analytics_Support_Arrayable;
6
-
7
- /**
8
- * Returns the data as an array.
9
- *
10
- * @return array
11
- */
12
- public function toArray()
13
- {
14
- return [
15
- "_paq.push(['setCustomVariable', 1, 'configuration', '" . Converdo_Analytics_Support_Crypt::encrypt(json_encode(Converdo_Analytics_Tracker::attributes(), true)) . "', 'page']);",
16
- ];
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Models/SearchView.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Models_SearchView
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * @var string
10
- */
11
- protected $keyword;
12
-
13
- /**
14
- * @var string|false
15
- */
16
- protected $category;
17
-
18
- /**
19
- * @var int
20
- */
21
- protected $results;
22
-
23
- /**
24
- * Sets the Search Keywords.
25
- *
26
- * @param string $keyword
27
- * @return $this
28
- */
29
- public function setKeyword($keyword)
30
- {
31
- $this->keyword = $keyword;
32
-
33
- return $this;
34
- }
35
-
36
- /**
37
- * Gets the Search Keywords.
38
- *
39
- * @return bool
40
- */
41
- public function getKeyword()
42
- {
43
- return (string) $this->keyword;
44
- }
45
-
46
- /**
47
- * Sets the selected Category to search in, false if no Category was selected.
48
- *
49
- * @param string $category
50
- * @return $this
51
- */
52
- public function setCategory($category)
53
- {
54
- $this->category = $category;
55
-
56
- return $this;
57
- }
58
-
59
- /**
60
- * Gets the selected Search Category.
61
- *
62
- * @return bool
63
- */
64
- public function getCategory()
65
- {
66
- return $this->category;
67
- }
68
-
69
- /**
70
- * Sets the Search Result count.
71
- *
72
- * @param int $results
73
- * @return $this
74
- */
75
- public function setResultCount($results)
76
- {
77
- $this->results = $results;
78
-
79
- return $this;
80
- }
81
-
82
- /**
83
- * Gets the Search Keywords.
84
- *
85
- * @return bool
86
- */
87
- public function getResultCount()
88
- {
89
- return (int) $this->results;
90
- }
91
-
92
- /**
93
- * Returns the data as an array.
94
- *
95
- * @return array
96
- */
97
- public function toArray()
98
- {
99
- return [
100
- "_paq.push(['trackSiteSearch', '" . $this->getKeyword() . "', null, " . $this->getResultCount() . "]);",
101
- ];
102
- }
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Support/AbstractTracker.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- abstract class Converdo_Analytics_Support_AbstractTracker
4
- {
5
- /**
6
- * Determines whether the Tracker is responsible during the Request.
7
- *
8
- * @return bool
9
- */
10
- public function responsible()
11
- {
12
- return false;
13
- }
14
-
15
- /**
16
- * Parses the JavaScript using the collected data.
17
- *
18
- * @return array
19
- */
20
- public function parse()
21
- {
22
- return [];
23
- }
24
-
25
- /**
26
- * Track data for the Request.
27
- *
28
- * @return void
29
- */
30
- abstract public function track();
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Support/Arrayable.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- trait Converdo_Analytics_Support_Arrayable
4
- {
5
- /**
6
- * Returns the data as an array.
7
- *
8
- * @return array
9
- */
10
- public function toArray()
11
- {
12
- return [];
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Support/Cookie.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Support_Cookie
4
- {
5
- public static function find()
6
- {
7
- foreach ($_COOKIE as $key => $cookie) {
8
- if (strpos($key, '_pk_id_' . Mage::getStoreConfig('converdo/analytics/site')) === false) {
9
- continue;
10
- }
11
-
12
- return $cookie;
13
- }
14
-
15
- return null;
16
- }
17
-
18
- protected static function factory($cookie)
19
- {
20
-
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Support/HoldsAttributes.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- trait Converdo_Analytics_Support_HoldsAttributes
4
- {
5
- /**
6
- * Adds attributes to the stack.
7
- *
8
- * @return array
9
- */
10
- public function attributes()
11
- {
12
- return [];
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Tracker.php DELETED
@@ -1,200 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Tracker
4
- {
5
- /**
6
- * @var Converdo_Analytics_Models_Configuration
7
- */
8
- protected static $configuration;
9
-
10
- /**
11
- * @var Converdo_Analytics_Models_EcommerceView
12
- */
13
- protected static $ecommerceView;
14
-
15
- /**
16
- * @var Converdo_Analytics_Models_CategoryView
17
- */
18
- protected static $categoryView;
19
-
20
- /**
21
- * @var Converdo_Analytics_Models_PageView
22
- */
23
- protected static $pageView;
24
-
25
- /**
26
- * @var Converdo_Analytics_Models_SearchView
27
- */
28
- protected static $searchView;
29
-
30
- /**
31
- * @var Converdo_Analytics_Models_EcommerceCartUpdate
32
- */
33
- protected static $ecommerceCartUpdate;
34
-
35
- /**
36
- * @var array
37
- */
38
- protected static $ecommerceProducts = [];
39
-
40
- /**
41
- * @var Converdo_Analytics_Models_EcommerceOrder
42
- */
43
- protected static $ecommerceOrder;
44
-
45
- /**
46
- * @var array
47
- */
48
- protected static $query = [];
49
-
50
- /**
51
- * @var Converdo_Analytics_Models_EcommerceProduct[]
52
- */
53
- protected static $attributes = [];
54
-
55
- protected static $collected = [];
56
-
57
- /**
58
- * Retrieves the Converdo Analytics Tracker Configuration.
59
- *
60
- * @return Converdo_Analytics_Models_Configuration
61
- */
62
- public static function configuration()
63
- {
64
- if (! self::$configuration) {
65
- self::$configuration = new Converdo_Analytics_Models_Configuration();
66
- }
67
-
68
- return self::$configuration;
69
- }
70
-
71
- /**
72
- * Manages the Ecommerce View.
73
- *
74
- * @return Converdo_Analytics_Models_EcommerceView
75
- */
76
- public static function ecommerceView()
77
- {
78
- if (! self::$ecommerceView) {
79
- self::$ecommerceView = new Converdo_Analytics_Models_EcommerceView();
80
- }
81
-
82
- return self::$ecommerceView;
83
- }
84
-
85
- /**
86
- * Manages the Category View.
87
- *
88
- * @return Converdo_Analytics_Models_CategoryView
89
- */
90
- public static function categoryView()
91
- {
92
- if (! self::$categoryView) {
93
- self::$categoryView = new Converdo_Analytics_Models_CategoryView();
94
- }
95
-
96
- return self::$categoryView;
97
- }
98
-
99
- /**
100
- * Manages the Page View.
101
- *
102
- * @return Converdo_Analytics_Models_PageView
103
- */
104
- public static function pageView()
105
- {
106
- if (! self::$pageView) {
107
- self::$pageView = new Converdo_Analytics_Models_PageView();
108
- }
109
-
110
- return self::$pageView;
111
- }
112
-
113
- /**
114
- * Manages the Search View.
115
- *
116
- * @return Converdo_Analytics_Models_SearchView
117
- */
118
- public static function searchView()
119
- {
120
- if (! self::$searchView) {
121
- self::$searchView = new Converdo_Analytics_Models_SearchView();
122
- }
123
-
124
- return self::$searchView;
125
- }
126
-
127
- /**
128
- * Manages the Ecommerce Product.
129
- *
130
- * @return Converdo_Analytics_Models_EcommerceProduct
131
- */
132
- public static function ecommerceProduct()
133
- {
134
- return new Converdo_Analytics_Models_EcommerceProduct();
135
- }
136
-
137
- /**
138
- * Manages the Ecommerce Cart.
139
- *
140
- * @return Converdo_Analytics_Models_EcommerceCartUpdate
141
- */
142
- public static function ecommerceCartUpdate()
143
- {
144
- if (! self::$ecommerceCartUpdate) {
145
- self::$ecommerceCartUpdate = new Converdo_Analytics_Models_EcommerceCartUpdate();
146
- }
147
-
148
- return self::$ecommerceCartUpdate;
149
- }
150
-
151
- /**
152
- * Manages the Ecommerce Order.
153
- *
154
- * @return Converdo_Analytics_Models_EcommerceOrder
155
- */
156
- public static function ecommerceOrder()
157
- {
158
- if (! self::$ecommerceOrder) {
159
- self::$ecommerceOrder = new Converdo_Analytics_Models_EcommerceOrder();
160
- }
161
-
162
- return self::$ecommerceOrder;
163
- }
164
-
165
-
166
- /**
167
- * @param array $collected
168
- * @return Converdo_Analytics_Support_AbstractTracker[]
169
- */
170
- public static function query(array $collected = [])
171
- {
172
- if (count($collected)) {
173
- self::$query = array_merge(self::$query, $collected);
174
- return null;
175
- }
176
-
177
- return self::$query;
178
- }
179
-
180
- public static function attributes($attributes = null)
181
- {
182
- if (! $attributes) {
183
- return self::$attributes;
184
- }
185
-
186
- self::$attributes = (array) $attributes + self::$attributes;
187
-
188
- return self::$attributes;
189
- }
190
-
191
- public static function collect(array $data)
192
- {
193
- self::$collected = $data + self::$collected;
194
- }
195
-
196
- public static function parse()
197
- {
198
- return self::$collected;
199
- }
200
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/Cart.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_Cart extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- protected $products = [];
9
-
10
- /**
11
- * Determines whether the Tracker is responsible during the Request.
12
- *
13
- * @return bool
14
- */
15
- public function responsible()
16
- {
17
- return Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
18
- }
19
-
20
- /**
21
- * Track data for the Request.
22
- *
23
- * @return void
24
- */
25
- public function track()
26
- {
27
- $cart = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
28
-
29
- foreach ($cart as $cartItem) {
30
- $product = Mage::getModel('catalog/product')->load($cartItem->product_id);
31
- $category = false;
32
-
33
- if (count($product->getCategoryIds())) {
34
- $category = Mage::getModel('catalog/category')->load($product->getCategoryIds()[0]);
35
- $category = $category->getName();
36
- }
37
-
38
- $this->products[] = Converdo_Analytics_Tracker::ecommerceProduct()
39
- ->setSku($product->getSku())
40
- ->setName($product->getName())
41
- ->setCategory($category)
42
- ->setPrice($cartItem->getPrice())
43
- ->setQuantity($cartItem->getQty());
44
- }
45
-
46
- Converdo_Analytics_Tracker::ecommerceCartUpdate()
47
- ->setTotal(Mage::getModel('checkout/cart')->getQuote()->getGrandTotal());
48
- }
49
-
50
- /**
51
- * Returns the data as an array.
52
- *
53
- * @return array
54
- */
55
- public function toArray()
56
- {
57
- $output = [];
58
-
59
- foreach ($this->products as $product) {
60
- $output = array_merge($product->toArray(), $output);
61
- }
62
-
63
- $output = array_merge($output, Converdo_Analytics_Tracker::ecommerceCartUpdate()->toArray());
64
-
65
- return $output;
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/CategoryView.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_CategoryView extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * Determines whether the Tracker is responsible during the Request.
10
- *
11
- * @return bool
12
- */
13
- public function responsible()
14
- {
15
- return Mage::helper('analytics')->isCategoryPage();
16
- }
17
-
18
- /**
19
- * Track data for the Request.
20
- *
21
- * @return void
22
- */
23
- public function track()
24
- {
25
- Converdo_Analytics_Tracker::categoryView()
26
- ->setCategory(Mage::registry('current_category')->getName());
27
- }
28
-
29
- /**
30
- * Returns the data as an array.
31
- *
32
- * @return array
33
- */
34
- public function toArray()
35
- {
36
- return Converdo_Analytics_Tracker::categoryView()->toArray();
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/Configuration.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_Configuration extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * Determines whether the Tracker is responsible during the Request.
10
- *
11
- * @return bool
12
- */
13
- public function responsible()
14
- {
15
- return true;
16
- }
17
-
18
- /**
19
- * Track data for the Request.
20
- *
21
- * @return void
22
- */
23
- public function track()
24
- {
25
- Converdo_Analytics_Tracker::configuration()
26
- ->setToken(Mage::helper('analytics')->getSiteId());
27
- }
28
-
29
- /**
30
- * Returns the data as an array.
31
- *
32
- * @return array
33
- */
34
- public function toArray()
35
- {
36
- return Converdo_Analytics_Tracker::configuration()->toConfigurationArray();
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/EcommerceView.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_EcommerceView extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * Determines whether the Tracker is responsible during the Request.
10
- *
11
- * @return bool
12
- */
13
- public function responsible()
14
- {
15
- return Mage::helper('analytics')->isProductPage();
16
- }
17
-
18
- /**
19
- * Track data for the Request.
20
- *
21
- * @return void
22
- */
23
- public function track()
24
- {
25
- Converdo_Analytics_Tracker::ecommerceView()
26
- ->setSku(Mage::registry('current_product')->getSku())
27
- ->setName(Mage::registry('current_product')->getName())
28
- ->setCategories(Mage::registry('current_product')->getCategoryIds())
29
- ->setPrice(Mage::registry('current_product')->getFinalPrice())
30
- ->setImageUrl(Mage::registry('current_product')->getImageUrl())
31
- ->setId(Mage::registry('current_product')->getId())
32
- ->setType(Mage::registry('current_product')->getTypeID())
33
- ->setIsInStock(Mage::registry('current_product')->getStockItem()->getIsInStock())
34
- ->setStockQuantity(Mage::registry('current_product')->getStockItem()->getQty())
35
- ->setManufacturer(Mage::registry('current_product')->getData('manufacturer'))
36
- ->setCost(Mage::registry('current_product')->getData('cost'))
37
- ;
38
- }
39
-
40
- /**
41
- * Returns the data as an array.
42
- *
43
- * @return array
44
- */
45
- public function toArray()
46
- {
47
- return Converdo_Analytics_Tracker::ecommerceView()->toArray();
48
- }
49
-
50
- /**
51
- * Adds attributes to the stack.
52
- *
53
- * @return array
54
- */
55
- public function attributes()
56
- {
57
- return Converdo_Analytics_Tracker::ecommerceView()->attributes();
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/Options.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_Options extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * Determines whether the Tracker is responsible during the Request.
10
- *
11
- * @return bool
12
- */
13
- public function responsible()
14
- {
15
- return true;
16
- }
17
-
18
- /**
19
- * Track data for the Request.
20
- *
21
- * @return void
22
- */
23
- public function track()
24
- {
25
- Converdo_Analytics_Tracker::configuration()
26
- ->enablePageTracking(true)
27
- ->enableLinkTracking(true)
28
- ->enableHeartBeat(true);
29
- }
30
-
31
- /**
32
- * Returns the data as an array.
33
- *
34
- * @return array
35
- */
36
- public function toArray()
37
- {
38
- return array_merge(
39
- Converdo_Analytics_Tracker::pageView()->toArray(),
40
- Converdo_Analytics_Tracker::configuration()->toOptionsArray()
41
- );
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/Order.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_Order extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- protected $products = [];
9
-
10
- /**
11
- * Determines whether the Tracker is responsible during the Request.
12
- *
13
- * @return bool
14
- */
15
- public function responsible()
16
- {
17
- return false;
18
- return Mage::helper('analytics')->isSuccessPage();
19
- }
20
-
21
- /**
22
- * Track data for the Request.
23
- *
24
- * @return void
25
- */
26
- public function track()
27
- {
28
- $quoteId = Mage::getSingleton('checkout/session')->getLastQuoteId();
29
-
30
- if (! $quoteId) {
31
- return;
32
- }
33
-
34
- $order = Mage::getModel('sales/order')->loadByAttribute('quote_id', $quoteId);
35
-
36
- foreach ($order->getAllItems() as $orderProduct) {
37
- $product = Mage::getModel('catalog/product')->load($orderProduct->product_id);
38
- $category = false;
39
-
40
- if (count($product->getCategoryIds())) {
41
- $category = Mage::getModel('catalog/category')->load($product->getCategoryIds()[0]);
42
- $category = $category->getName();
43
- }
44
-
45
- $this->products[] = Converdo_Analytics_Tracker::ecommerceProduct()
46
- ->setSku($product->getSku())
47
- ->setName($product->getName())
48
- ->setCategory($category)
49
- ->setPrice($product->getFinalPrice())
50
- ->setQuantity($orderProduct->getQty());
51
- }
52
-
53
- Converdo_Analytics_Tracker::ecommerceOrder()
54
- ->setOrderId($order->getIncrementId())
55
- ->setTotal($order->getBaseGrandTotal())
56
- ->setSubtotal($order->getGrandTotal() - $order->getShippingAmount() - $order->getShippingTaxAmount())
57
- ->setTax($order->getBaseTaxAmount())
58
- ->setShipping($order->getBaseShippingAmount());
59
- }
60
-
61
- /**
62
- * Returns the data as an array.
63
- *
64
- * @return array
65
- */
66
- public function toArray()
67
- {
68
- $output = [];
69
-
70
- foreach ($this->products as $product) {
71
- $output = array_merge($product->toArray(), $output);
72
- }
73
-
74
- $output = array_merge($output, Converdo_Analytics_Tracker::ecommerceOrder()->toArray());
75
-
76
- return $output;
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/PageView.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_PageView extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * Determines whether the Tracker is responsible during the Request.
10
- *
11
- * @return bool
12
- */
13
- public function responsible()
14
- {
15
- return true;
16
- }
17
-
18
- /**
19
- * Track data for the Request.
20
- *
21
- * @return void
22
- */
23
- public function track()
24
- {
25
-
26
- }
27
-
28
- /**
29
- * Adds attributes to the stack.
30
- *
31
- * @return array
32
- */
33
- public function attributes()
34
- {
35
- $pageType = Mage::app()->getFrontController()->getAction()->getFullActionName();
36
- $route = Mage::app()->getFrontController()->getRequest()->getRouteName();
37
-
38
- switch (true) {
39
- // Account
40
- case ($route == 'customer'):
41
- $configPageType = 'account';
42
- if ($pageType == 'customer_account_login')
43
- $configPageTypeSub = 'account_login';
44
- else if ($pageType == 'customer_account_create')
45
- $configPageTypeSub = 'account_create';
46
- else if ($pageType == 'customer_account_index')
47
- $configPageTypeSub = 'account_profile';
48
- else if ($pageType == 'customer_account_forgotpassword')
49
- $configPageTypeSub = 'account_forgot_password';
50
- else if ($pageType == 'customer_account_edit')
51
- $configPageTypeSub = 'account_edit_info';
52
- else if ($pageType == 'customer_address_form')
53
- $configPageTypeSub = 'account_edit_address';
54
- else if ($pageType == 'sales_order_history')
55
- $configPageTypeSub = 'account_orders';
56
- else if ($pageType == 'sales_billing_agreement_index')
57
- $configPageTypeSub = 'account_billing_agreement';
58
- else if ($pageType == 'sales_recurring_profile_index')
59
- $configPageTypeSub = 'account_recurring';
60
- else if ($pageType == 'review_customer_index')
61
- $configPageTypeSub = 'account_reviews';
62
- else if ($pageType == 'wishlist_index_index')
63
- $configPageTypeSub = 'account_wishlist';
64
- else if ($pageType == 'oauth_customer_token_index')
65
- $configPageTypeSub = 'account_apps';
66
- else if ($pageType == 'newsletter_manage_index')
67
- $configPageTypeSub = 'account_newsletters';
68
- else if ($pageType == 'downloadable_customer_products')
69
- $configPageTypeSub = 'account_downloads';
70
- else if ($pageType == 'customer_account_logoutSuccess')
71
- $configPageTypeSub = 'account_logout';
72
- else
73
- $configPageTypeSub = (string) $pageType;
74
- break;
75
-
76
- // Cart
77
- case ($pageType == 'checkout_cart_index'):
78
- $configPageType = 'cart';
79
- $configPageTypeSub = 'cart_index';
80
- break;
81
-
82
- // Category
83
- case ($pageType == 'catalog_category_view'):
84
- $configPageType = 'category';
85
- $configPageTypeSub = 'category_view';
86
- break;
87
-
88
- // Checkout
89
- case ($pageType == 'checkout_onepage_index'):
90
- $configPageType = 'checkout';
91
- $configPageTypeSub = 'checkout_onepage_index';
92
- break;
93
-
94
- // CMS
95
- case ($pageType == 'cms_page_view'):
96
- $configPageType = 'cms';
97
- $configPageTypeSub = (string) $pageType;
98
- break;
99
-
100
- // Contact
101
- case ($route == 'contacts'):
102
- $configPageType = 'contact';
103
- $configPageTypeSub = 'contact_index';
104
- break;
105
-
106
- // Homepage
107
- case ($pageType == 'cms_index_index'):
108
- $configPageType = 'homepage';
109
- $configPageTypeSub = 'homepage_index';
110
- break;
111
-
112
- // Product
113
- case ($pageType == 'catalog_product_view'):
114
- $configPageType = 'product';
115
- $configPageTypeSub = 'product_view';
116
- break;
117
-
118
- // Search
119
- case ($route == 'catalogsearch'):
120
- $configPageType = 'search';
121
- if ($pageType == 'catalogsearch_result_index')
122
- $configPageTypeSub = 'search_results';
123
- else if ($pageType == 'catalogsearch_advanced_index')
124
- $configPageTypeSub = 'search_advanced';
125
- else if ($pageType == 'catalogsearch_advanced_result')
126
- $configPageTypeSub = 'search_results_advanced';
127
- else if ($pageType == 'catalogsearch_term_popular')
128
- $configPageTypeSub = 'search_terms';
129
- else
130
- $configPageTypeSub = (string) $pageType;
131
- break;
132
-
133
- // Success
134
- case ($pageType == 'checkout_onepage_success'):
135
- case ($pageType == 'checkout_multishipping_success'):
136
- case ($pageType == 'firecheckout'):
137
- $configPageType = 'success';
138
- $configPageTypeSub = 'success_index';
139
- break;
140
-
141
- default:
142
- $configPageType = (string) $route;
143
- $configPageTypeSub = (string) $pageType;
144
- break;
145
- }
146
-
147
- return [
148
- 'pt1' => $configPageType,
149
- 'pt2' => $configPageTypeSub,
150
- ];
151
- }
152
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Converdo/Analytics/Trackers/SearchView.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- class Converdo_Analytics_Trackers_SearchView extends Converdo_Analytics_Support_AbstractTracker
4
- {
5
- use Converdo_Analytics_Support_Arrayable,
6
- Converdo_Analytics_Support_HoldsAttributes;
7
-
8
- /**
9
- * Determines whether the Tracker is responsible during the Request.
10
- *
11
- * @return bool
12
- */
13
- public function responsible()
14
- {
15
- return Mage::helper('analytics')->isSearchPage();
16
- }
17
-
18
- /**
19
- * Track data for the Request.
20
- *
21
- * @return void
22
- */
23
- public function track()
24
- {
25
- Converdo_Analytics_Tracker::searchView()
26
- ->setKeyword(Mage::helper('catalogsearch')->getQueryText())
27
- ->setCategory(false)
28
- ->setResultCount(
29
- Mage::helper('catalogsearch')
30
- ->getEngine()
31
- ->getResultCollection()
32
- ->addSearchFilter(
33
- Mage::helper('catalogsearch')
34
- ->getQuery()
35
- ->getQueryText())
36
- ->getSize()
37
- );
38
- }
39
-
40
- /**
41
- * Returns the data as an array.
42
- *
43
- * @return array
44
- */
45
- public function toArray()
46
- {
47
- return Converdo_Analytics_Tracker::searchView()->toArray();
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Converdo_Analytics</name>
4
- <version>2.1.0.0</version>
5
  <stability>stable</stability>
6
  <license>MITL</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Better E-commerce Analytics. Clear, actionable insight in the behavior of your visitors. Improve your campaigns and conversion rate easily. This plugin, installed in a minute, is all you need to have a complete and powerfull Analytics Suite. View your KPI's and sales funnels, segmented on dozens of dimensions like page type, device, landing page, campaign, etc. This plugin collects your users behaviour so you can view the insights on your dashboard on converdo.com. You can use Converdo Analytics side by side with Google Analytics without a problem. It works asynchronous so it will never impact your user experience. This extension is made especially for Magento ecommerce stores, which provides you powerfull insights out of the box.</description>
11
  <notes>More reliable way to track orders and product metadata.</notes>
12
  <authors><author><name>Roeland van Oostenbrugge</name><user>converdo</user><email>roeland@converdo.nl</email></author></authors>
13
- <date>2017-03-13</date>
14
- <time>15:42:53</time>
15
- <contents><target name="magecommunity"><dir name="Converdo"><dir name="Analytics"><dir name="Block"><file name="Tracker.php" hash="d161b6c297bd69574efb0452a388be27"/></dir><dir name="Helper"><file name="Data.php" hash="8d503153b0ac6a7e2e379c7594d4bce1"/></dir><dir name="Model"><file name="Logger.php" hash="a669303f59f6a6c10122e36186c29098"/><file name="Observer.php" hash="20fba145d19dc010dbac77830ddfe4ff"/></dir><dir name="controllers"><file name="PingController.php" hash="98437b8791e27b3ad1db915c805b5063"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9923bfe8c0f4aa318166e15cd373cf09"/><file name="config.xml" hash="b32ee34f1bffe8db352b01fe98255bae"/><file name="system.xml" hash="7f90adaa9874a50b30e7d65cb8eb173b"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="analytics.xml" hash="d3f9d35df1981968a55a331c2b92d473"/></dir><dir name="template"><dir name="analytics"><file name="analytics.phtml" hash="59d017e5f7e71cc59a638a9dd2056a42"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Converdo_Analytics.xml" hash="119a038ca81bdf03767b1b12d81414ad"/></dir></target><target name="magelib"><dir name="Converdo"><dir name="Analytics"><dir name="API"><file name="ConverdoAPI.php" hash="8166a448775739c9fd74064876dbae39"/><file name="ConverdoClient.php" hash="b213e99759f3c74ce1829d7315ce3d03"/><dir name="Factories"><file name="Order.php" hash="461d0e0f02a3af4d01f2204e1bb2782a"/></dir><dir name="Models"><file name="Order.php" hash="34c21bda31b8903781a873954a641305"/></dir><dir name="Sections"><file name="ConverdoOrderAPI.php" hash="e19c13ce4ad709b242cfa5f6a8a286aa"/></dir></dir><dir name="Cookie"><file name="Manager.php" hash="a20e47d660dc48acda4183d7778bc79b"/><file name="Model.php" hash="511393f751b2bec27252d1122b84645b"/></dir><dir name="Models"><file name="CategoryView.php" hash="4807abcd95dc03913f50d7a659af2ceb"/><file name="Configuration.php" hash="27c2b1af7cab96602b1ce16d78d3d26f"/><file name="EcommerceCartUpdate.php" hash="1b3bf769de5f89745850232737157e3a"/><file name="EcommerceOrder.php" hash="0fba70eb9260c602de6ac4ce6bab68b4"/><file name="EcommerceProduct.php" hash="f51778a075e4b37c169675db94f3692c"/><file name="EcommerceView.php" hash="1e39c7fcb5586a2be37c460a25ff5e4a"/><file name="PageView.php" hash="3ddba9f413ddd669f704c7a8bb9bdca2"/><file name="SearchView.php" hash="1af494ba379a47d9354de5a9cc1a8a1f"/></dir><dir name="Support"><file name="AbstractTracker.php" hash="a109cd7691e62ed66e268de9a4d2f4d5"/><file name="Arrayable.php" hash="6f4f522e26ff9c327f4ae764fb4bb4bf"/><file name="Cookie.php" hash="db533e757e48b67a49fdf69adcf8afd3"/><file name="Crypt.php" hash="5b703e96f4173f4ebfe69286246ca916"/><file name="HoldsAttributes.php" hash="0600d8c3d15c327e07de31679a79aa6c"/></dir><file name="Tracker.php" hash="0bb1a1e9a7590ca67ccc9ff8f62dbeda"/><dir name="Trackers"><file name="Cart.php" hash="258ebc1d35e6cc51b56f39674625feeb"/><file name="CategoryView.php" hash="11b3c23dd27da3db5e62827d183475f7"/><file name="Configuration.php" hash="c9fa8d249ebd86035e4b442bb4b9c5d9"/><file name="EcommerceView.php" hash="a89624ac686af194e9b6dcd9484cd51c"/><file name="Options.php" hash="7fb970c74dd4f1ee9373cd63136b67d4"/><file name="Order.php" hash="c14db50faf80ffa3035ccf802dae65d1"/><file name="PageView.php" hash="18fa62007a9d19df3e176c0291fddedc"/><file name="SearchView.php" hash="fe1b6ae46a52e0464536b6187ef69595"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Converdo_Magento.csv" hash=""/></dir><dir name="nl_NL"><file name="Converdo_Magento.csv" hash=""/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="converdoanalytics"><dir name="css"><file name="system_config_edit.css" hash="fd6f5337fd9a9b69b85079e17aa0e40b"/></dir><dir name="images"><file name="favicon.png" hash="674c9388eba1ea89e200fe6b1a62fc24"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="converdoanalytics.xml" hash="b949a1ad4594eeb82ae7138c60afc19e"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.5.37</min><max>7.0.5</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Converdo_Analytics</name>
4
+ <version>2.1.5.0</version>
5
  <stability>stable</stability>
6
  <license>MITL</license>
7
  <channel>community</channel>
10
  <description>Better E-commerce Analytics. Clear, actionable insight in the behavior of your visitors. Improve your campaigns and conversion rate easily. This plugin, installed in a minute, is all you need to have a complete and powerfull Analytics Suite. View your KPI's and sales funnels, segmented on dozens of dimensions like page type, device, landing page, campaign, etc. This plugin collects your users behaviour so you can view the insights on your dashboard on converdo.com. You can use Converdo Analytics side by side with Google Analytics without a problem. It works asynchronous so it will never impact your user experience. This extension is made especially for Magento ecommerce stores, which provides you powerfull insights out of the box.</description>
11
  <notes>More reliable way to track orders and product metadata.</notes>
12
  <authors><author><name>Roeland van Oostenbrugge</name><user>converdo</user><email>roeland@converdo.nl</email></author></authors>
13
+ <date>2017-03-31</date>
14
+ <time>08:19:11</time>
15
+ <contents><target name="magecommunity"><dir name="Converdo"><dir name="Common"><dir name="API"><file name="ConverdoAPI.php" hash="432539ea2f6388eb6e067dd689676054"/><file name="ConverdoClient.php" hash="225a611b5f2c5523a40ee20749c71b72"/><dir name="Factories"><file name="OrderFactory.php" hash="f3718d7811896d18ade13c77826fc910"/></dir><dir name="Models"><dir name="Contracts"><file name="OrderInterface.php" hash="426e172166014f03cfe4d44bf4041711"/></dir><file name="Order.php" hash="fc528438a5f74c8e3689189a4c305627"/></dir><file name="Requests.php" hash="7b9a3341c1db50b44eac0d7f207f35f0"/><dir name="Sections"><file name="ConverdoOrderAPI.php" hash="0865ae8e4c4d49b60e96e73c62e7c59a"/></dir></dir><dir name="Config"><file name="Configuration.php" hash="3a049fae7651c4a99b718b8f407001ec"/><dir name="Contracts"><file name="PlatformConfigurationContract.php" hash="a81b3b6f3d95a1d295aa4655d89ea4c7"/></dir></dir><dir name="Container"><file name="Container.php" hash="b5397c8e26370c051cc78d6e6f1fd1d9"/></dir><dir name="Controllers"><file name="PingController.php" hash="1861ec8c9201fb61ee77e53edc56beb4"/></dir><dir name="Cookie"><dir name="Factories"><file name="CookieFactory.php" hash="a2f67fc875f3bead010019f0ca9c8562"/></dir><dir name="Managers"><file name="CookieManager.php" hash="7c47484c5c0bb99c11f67a1adbfacad5"/></dir><dir name="Models"><dir name="Contracts"><file name="CookieInterface.php" hash="87c4d60b8cd462d41256b536b950d6f4"/></dir><file name="Cookie.php" hash="f4281cb4f6cf64739c47934089787e28"/></dir></dir><dir name="Input"><file name="Input.php" hash="dff17aa36ebff1249828ef849a7f6b3d"/><file name="InputManager.php" hash="ba9c61bb2a5d9e762c405f68b3773e45"/></dir><dir name="Log"><file name="LogReader.php" hash="8d1e48c646aebbacc9d22d37e3c42a71"/><file name="Logger.php" hash="51f3a0097798660f2cc0e24064a7c7d7"/><file name="LoggerAwareInterface.php" hash="75abd91a001bcf77df81ba4b487dadf4"/><file name="LoggerInterface.php" hash="9fd1a50cac6d243e5886df81aabf9794"/></dir><dir name="Page"><dir name="Factories"><file name="PageFactory.php" hash="aa982ee69889e676f67abd564279fde2"/></dir><dir name="Models"><dir name="Contracts"><file name="PageInterface.php" hash="ba745e11e0372dda50981143cb1d1570"/></dir><file name="Page.php" hash="7b75835e5737b69cf46ea77644cfa851"/></dir><dir name="Support"><dir name="Contracts"><file name="RouteResolverInterface.php" hash="400bfe4611b9e732d9fdd4fef86575fe"/></dir><file name="PageTypes.php" hash="c00d29114e972a7dc24a666a110f1dbf"/></dir></dir><dir name="Query"><dir name="Managers"><file name="QueryManager.php" hash="84426e2fe1bd199d2138cb5b160b2eb3"/><file name="QueryMetadata.php" hash="f1d4df587d00c72c1979194e2cad652c"/></dir><dir name="Models"><dir name="Contracts"><file name="EcommerceCartInterface.php" hash="7b18db590c782d99f7b9514c5d375348"/><file name="EcommerceCategoryInterface.php" hash="159b1bb3a4248c67e46dd6201064ed2c"/><file name="EcommerceItemInterface.php" hash="9be3da4668044b3fb0609bb496371da6"/><file name="EcommerceSearchInterface.php" hash="6aad67169123749733737e2b0104ffba"/></dir><file name="EcommerceCart.php" hash="d569b0d2ecb4421b9e06c4de03b1a31a"/><file name="EcommerceCategory.php" hash="d704a2ef710fb7b7bf07d582db2e0611"/><file name="EcommerceItem.php" hash="90efad4308237bfbdb11e67f562d0e8d"/><file name="EcommerceSearch.php" hash="0165c34cab7c3d0a73694d50a26dd77a"/></dir><dir name="Queries"><file name="AbstractQuery.php" hash="fc17566a13fbb5dbada30d4a484b1c10"/><file name="AddEcommerceItem.php" hash="6967e962792586c1fe5eea2eacf5bd90"/><file name="CategoryView.php" hash="ef1ea971183dd860f3691a04a17a29a5"/><dir name="Contracts"><file name="QueryInterface.php" hash="fb92b5d11d99cfbff66af5596032fc13"/></dir><file name="CustomVariable.php" hash="6da73fa0855929c82b48832665304478"/><file name="EcommerceView.php" hash="2bdbd899b67f4c57007ae2e16b2a6dcc"/><file name="EnableHeartBeatTimer.php" hash="ae8f29109aa092e5df3219806e20e3a5"/><file name="EnableLinkTracking.php" hash="16eb04587eb0bb1874b1c2bc3b1a3f3e"/><file name="SiteId.php" hash="b1d7890e673d8c958c763e7a3f5d1119"/><file name="TrackEcommerceCart.php" hash="801ad3399b238cc947d51da246dc4755"/><file name="TrackPageView.php" hash="e554c9f7b893148985a6e93772afa760"/><file name="TrackSiteSearch.php" hash="06446020dae5ff4e2d9b4f1e612f9c70"/><file name="TrackerUrl.php" hash="7813ff69d8f76921c442895bdd9d4f5f"/></dir></dir><dir name="Response"><file name="JsonResponse.php" hash="d3a4ff6984e2378d74f8afe007ea1d8d"/><file name="Response.php" hash="a4fb3927099ee5e69ea869b464039fd6"/></dir><dir name="Security"><file name="Crypt.php" hash="d0f67307ef26d6691c72c702b7fcf3f2"/></dir><dir name="Support"><file name="Arrayable.php" hash="cd34de85cce8e6b7ca3f5585dfa631e9"/><file name="HasParameters.php" hash="0821ecb3fd95c56e34880e86d1afb246"/><file name="UsesInput.php" hash="e4c019693f821df634361955a24d056d"/></dir><file name="autoload.php" hash="ab5e7698d1103d324ce6f93a76c73235"/><file name="bootstrap.php" hash="2ddcf1ff10a3cb32f3613b806f0d4427"/><file name="config.php" hash="13de96b66211ba832d0c359bacd2bc4c"/><file name="dependencies.php" hash="e35bc74ed0d628cc007581178881854c"/><file name="functions.php" hash="1ec63ac646838220bfd7c04e536a5fd4"/></dir><dir name="Magento"><dir name="Block"><file name="Tracker.php" hash="6d883c0fdc6d8768bfe4465b7006d570"/></dir><dir name="Config"><file name="Configuration.php" hash="8872732a1e15fe6e77359770abd8d4fb"/></dir><dir name="Container"><file name="Bindings.php" hash="25bfa222ea8ce66da2b50a6cc9c48ac0"/></dir><dir name="Factories"><file name="EcommerceCartFactory.php" hash="43ce610668ad865ddaaa5dfce6420e93"/><file name="EcommerceCategoryFactory.php" hash="7d21cba8d68be5bccb4f6387badb8674"/><file name="EcommerceItemFactory.php" hash="bedf9b354ee73443170e2310433f3734"/><file name="EcommerceSearchFactory.php" hash="ea08378e24f27567abb3ae85f500e658"/></dir><dir name="Helper"><file name="Data.php" hash="5b2572fbbd9d6acfe1907830ab883a19"/></dir><dir name="Model"><file name="Observer.php" hash="798074982172e7d8c14a13b5e7ee7c9f"/></dir><dir name="Page"><file name="RouteResolver.php" hash="fe9952398586e39679c85092ea03f013"/></dir><dir name="Support"><file name="PriceHelper.php" hash="375c5f44c2c9b90618919412e235e961"/></dir><dir name="controllers"><file name="PingController.php" hash="7649748a504168df69239daed1a96418"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9923bfe8c0f4aa318166e15cd373cf09"/><file name="config.xml" hash="70efd7841ee81f9b3e0d608b8ad7885e"/><file name="system.xml" hash="7f90adaa9874a50b30e7d65cb8eb173b"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="analytics.xml" hash="d3f9d35df1981968a55a331c2b92d473"/></dir><dir name="template"><dir name="analytics"><file name="analytics.phtml" hash="30a9a5e06b7f8e8c8dc5d73249f1e172"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Converdo_Analytics.xml" hash="c1e39f4e5886e1a22dc078ddebca8ee3"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Converdo_Magento.csv" hash=""/></dir><dir name="nl_NL"><file name="Converdo_Magento.csv" hash=""/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="converdoanalytics"><dir name="css"><file name="system_config_edit.css" hash="fd6f5337fd9a9b69b85079e17aa0e40b"/></dir><dir name="images"><file name="favicon.png" hash="674c9388eba1ea89e200fe6b1a62fc24"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="converdoanalytics.xml" hash="b949a1ad4594eeb82ae7138c60afc19e"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.5.37</min><max>7.0.5</max></php></required></dependencies>
18
  </package>