Targetbay_Tracking - Version 5.1.3

Version Notes

Making every interaction count and engaging customers with relevant messages will improve the chances of conversion exponentially. You can profile and segment users based on various parameters and actions, the data from which will form the basis for your customer engagement objectives.You can create triggers based on customer engagement objectives to deliver personalized messages. Your newsletter campaigns can also be personalized to deliver better customer engagement results. And all of this can be achieved with the help of our ecommerce-based email personalization platform.

Download this release

Release Info

Developer Targetbay
Extension Targetbay_Tracking
Version 5.1.3
Comparing to
See all releases


Code changes from version 5.1.2 to 5.1.3

Files changed (98) hide show
  1. app/code/community/Targetbay/Tracking/Block/Product/Inventary.php +42 -0
  2. app/code/community/Targetbay/Tracking/Block/Product/Product.php +100 -101
  3. app/code/community/Targetbay/Tracking/Block/Product/Review.php +4 -0
  4. app/code/community/Targetbay/Tracking/Block/Product/Richsnippets.php +57 -0
  5. app/code/community/Targetbay/Tracking/Block/Recommended.php +24 -0
  6. app/code/community/Targetbay/Tracking/Block/Session/Tracking.php +3 -1
  7. app/code/community/Targetbay/Tracking/Block/Tracking.php +20 -0
  8. app/code/community/Targetbay/Tracking/Helper/Data.php +1026 -938
  9. app/code/community/Targetbay/Tracking/Model/Api2/Cartitem.php +2 -0
  10. app/code/community/Targetbay/Tracking/Model/Api2/Cartitem/Rest/Admin/V1.php +57 -52
  11. app/code/community/Targetbay/Tracking/Model/Api2/Cartitem/Rest/Guest/V1.php +58 -52
  12. app/code/community/Targetbay/Tracking/Model/Api2/Category.php +2 -0
  13. app/code/community/Targetbay/Tracking/Model/Api2/Category/Rest/Admin/V1.php +33 -29
  14. app/code/community/Targetbay/Tracking/Model/Api2/Category/Rest/Guest/V1.php +33 -29
  15. app/code/community/Targetbay/Tracking/Model/Api2/Createsubscription.php +2 -0
  16. app/code/community/Targetbay/Tracking/Model/Api2/Createsubscription/Rest/Admin/V1.php +84 -81
  17. app/code/community/Targetbay/Tracking/Model/Api2/Createsubscription/Rest/Guest/V1.php +84 -81
  18. app/code/community/Targetbay/Tracking/Model/Api2/Customer.php +2 -0
  19. app/code/community/Targetbay/Tracking/Model/Api2/Customer/Rest/Admin/V1.php +26 -22
  20. app/code/community/Targetbay/Tracking/Model/Api2/Customer/Rest/Guest/V1.php +26 -22
  21. app/code/community/Targetbay/Tracking/Model/Api2/Orders/Rest/Admin/V1.php +78 -33
  22. app/code/community/Targetbay/Tracking/Model/Api2/Orders/Rest/Guest/V1.php +78 -33
  23. app/code/community/Targetbay/Tracking/Model/Api2/Product/Rest/Admin/V1.php +125 -88
  24. app/code/community/Targetbay/Tracking/Model/Api2/Product/Rest/Admin/V1.php~ +0 -102
  25. app/code/community/Targetbay/Tracking/Model/Api2/Product/Rest/Guest/V1.php +199 -161
  26. app/code/community/Targetbay/Tracking/Model/Api2/Review.php +2 -0
  27. app/code/community/Targetbay/Tracking/Model/Api2/Review/Rest/Admin/V1.php +61 -62
  28. app/code/community/Targetbay/Tracking/Model/Api2/Review/Rest/Guest/V1.php +61 -62
  29. app/code/community/Targetbay/Tracking/Model/Api2/Shipment.php +2 -0
  30. app/code/community/Targetbay/Tracking/Model/Api2/Shipment/Rest/Admin/V1.php +28 -25
  31. app/code/community/Targetbay/Tracking/Model/Api2/Shipment/Rest/Guest/V1.php +28 -25
  32. app/code/community/Targetbay/Tracking/Model/Api2/Stores.php +2 -0
  33. app/code/community/Targetbay/Tracking/Model/Api2/Stores/Rest/Admin/V1.php +27 -23
  34. app/code/community/Targetbay/Tracking/Model/Api2/Stores/Rest/Guest/V1.php +27 -23
  35. app/code/community/Targetbay/Tracking/Model/Api2/Subscriber.php +2 -0
  36. app/code/community/Targetbay/Tracking/Model/Api2/Subscriber/Rest/Admin/V1.php +28 -24
  37. app/code/community/Targetbay/Tracking/Model/Api2/Subscriber/Rest/Guest/V1.php +28 -24
  38. app/code/community/Targetbay/Tracking/Model/Api2/Tbreviewcount.php +11 -0
  39. app/code/community/Targetbay/Tracking/Model/Api2/Tbreviewcount/Rest/Admin/V1.php +37 -0
  40. app/code/community/Targetbay/Tracking/Model/Api2/Tbreviewcount/Rest/Guest/V1.php +37 -0
  41. app/code/community/Targetbay/Tracking/Model/Api2/Totalcartiteminfo.php +2 -0
  42. app/code/community/Targetbay/Tracking/Model/Api2/Totalcartiteminfo/Rest/Admin/V1.php +27 -24
  43. app/code/community/Targetbay/Tracking/Model/Api2/Totalcartiteminfo/Rest/Guest/V1.php +27 -24
  44. app/code/community/Targetbay/Tracking/Model/Api2/Totalcategoryinfo.php +2 -0
  45. app/code/community/Targetbay/Tracking/Model/Api2/Totalcategoryinfo/Rest/Admin/V1.php +18 -14
  46. app/code/community/Targetbay/Tracking/Model/Api2/Totalcategoryinfo/Rest/Guest/V1.php +18 -14
  47. app/code/community/Targetbay/Tracking/Model/Api2/Totalcustomerinfo.php +2 -0
  48. app/code/community/Targetbay/Tracking/Model/Api2/Totalcustomerinfo/Rest/Admin/V1.php +18 -14
  49. app/code/community/Targetbay/Tracking/Model/Api2/Totalcustomerinfo/Rest/Guest/V1.php +18 -14
  50. app/code/community/Targetbay/Tracking/Model/Api2/Totalinfo.php +2 -0
  51. app/code/community/Targetbay/Tracking/Model/Api2/Totalinfo/Rest/Admin/V1.php +20 -16
  52. app/code/community/Targetbay/Tracking/Model/Api2/Totalinfo/Rest/Guest/V1.php +20 -16
  53. app/code/community/Targetbay/Tracking/Model/Api2/Totalorderinfo.php +2 -0
  54. app/code/community/Targetbay/Tracking/Model/Api2/Totalorderinfo/Rest/Admin/V1.php +18 -14
  55. app/code/community/Targetbay/Tracking/Model/Api2/Totalorderinfo/Rest/Guest/V1.php +18 -14
  56. app/code/community/Targetbay/Tracking/Model/Api2/Totalproductinfo.php +2 -0
  57. app/code/community/Targetbay/Tracking/Model/Api2/Totalproductinfo/Rest/Admin/V1.php +25 -22
  58. app/code/community/Targetbay/Tracking/Model/Api2/Totalproductinfo/Rest/Guest/V1.php +25 -22
  59. app/code/community/Targetbay/Tracking/Model/Api2/Totalreviewinfo.php +2 -0
  60. app/code/community/Targetbay/Tracking/Model/Api2/Totalreviewinfo/Rest/Admin/V1.php +18 -14
  61. app/code/community/Targetbay/Tracking/Model/Api2/Totalreviewinfo/Rest/Guest/V1.php +18 -14
  62. app/code/community/Targetbay/Tracking/Model/Api2/Totalshipmentinfo.php +2 -0
  63. app/code/community/Targetbay/Tracking/Model/Api2/Totalshipmentinfo/Rest/Admin/V1.php +18 -15
  64. app/code/community/Targetbay/Tracking/Model/Api2/Totalshipmentinfo/Rest/Guest/V1.php +18 -15
  65. app/code/community/Targetbay/Tracking/Model/Api2/Totalsubscriberinfo.php +2 -0
  66. app/code/community/Targetbay/Tracking/Model/Api2/Totalsubscriberinfo/Rest/Admin/V1.php +18 -14
  67. app/code/community/Targetbay/Tracking/Model/Api2/Totalsubscriberinfo/Rest/Guest/V1.php +18 -14
  68. app/code/community/Targetbay/Tracking/Model/Api2/Totalwishlistinfo.php +2 -0
  69. app/code/community/Targetbay/Tracking/Model/Api2/Totalwishlistinfo/Rest/Admin/V1.php +29 -25
  70. app/code/community/Targetbay/Tracking/Model/Api2/Totalwishlistinfo/Rest/Guest/V1.php +29 -25
  71. app/code/community/Targetbay/Tracking/Model/Api2/Updatesubscription.php +2 -0
  72. app/code/community/Targetbay/Tracking/Model/Api2/Updatesubscription/Rest/Admin/V1.php +76 -70
  73. app/code/community/Targetbay/Tracking/Model/Api2/Updatesubscription/Rest/Guest/V1.php +76 -70
  74. app/code/community/Targetbay/Tracking/Model/Api2/Wishlist.php +2 -0
  75. app/code/community/Targetbay/Tracking/Model/Api2/Wishlist/Rest/Admin/V1.php +27 -23
  76. app/code/community/Targetbay/Tracking/Model/Api2/Wishlist/Rest/Guest/V1.php +27 -23
  77. app/code/community/Targetbay/Tracking/Model/Customer.php +12 -9
  78. app/code/community/Targetbay/Tracking/Model/Observer.php +359 -326
  79. app/code/community/Targetbay/Tracking/Model/Subscriber.php +23 -20
  80. app/code/community/Targetbay/Tracking/Model/System/Config/Source/Page.php +6 -4
  81. app/code/community/Targetbay/Tracking/Model/System/Config/Source/Snippetstatus.php +37 -0
  82. app/code/community/Targetbay/Tracking/Model/System/Config/Source/Status.php +2 -0
  83. app/code/community/Targetbay/Tracking/Model/System/Config/Source/Tracking.php +2 -0
  84. app/code/community/Targetbay/Tracking/Model/System/Config/Source/Version.php +2 -0
  85. app/code/community/Targetbay/Tracking/Model/System/Config/Source/Yesno.php +5 -3
  86. app/code/community/Targetbay/Tracking/controllers/IndexController.php +63 -112
  87. app/code/community/Targetbay/Tracking/etc/api2.xml +98 -0
  88. app/code/community/Targetbay/Tracking/etc/config.xml +1 -1
  89. app/code/community/Targetbay/Tracking/etc/system.xml +12 -0
  90. app/design/frontend/base/default/layout/tracking.xml +12 -2
  91. app/design/frontend/base/default/template/tracking/product/inventary.phtml +1 -0
  92. app/design/frontend/base/default/template/tracking/product/review.phtml +13 -58
  93. app/design/frontend/base/default/template/tracking/product/richsnippets.phtml +48 -0
  94. app/design/frontend/base/default/template/tracking/recommended.phtml +7 -0
  95. app/design/frontend/base/default/template/tracking/session/tracking.phtml +0 -2
  96. app/design/frontend/base/default/template/tracking/tracking.phtml +37 -25
  97. app/etc/modules/Targetbay_Tracking.xml +1 -1
  98. package.xml +7 -7
app/code/community/Targetbay/Tracking/Block/Product/Inventary.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Targetbay
5
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
+ * @package Targetbay_Tracking
7
+ */
8
+
9
+ class Targetbay_Tracking_Block_Product_Inventary extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Rendered the tracking review template if tracking enabled
13
+ *
14
+ * @see Mage_Core_Block_Template::_construct()
15
+ */
16
+ public function _construct()
17
+ {
18
+ parent::_construct();
19
+ if (Mage::helper('tracking')->trackingEnabled()) {
20
+ $this->setTemplate('tracking/product/inventary.phtml');
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Get the current product
26
+ * @return Mage_Catalog_Model_Product
27
+ */
28
+ public function getProduct()
29
+ {
30
+ return Mage::registry('current_product');
31
+ }
32
+
33
+ public function getBackOrderStatus() {
34
+ $managekStatus = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
35
+ $backOrderStatus = Mage::getStoreConfig('cataloginventory/item_options/backorders');
36
+ $html = '';
37
+ if($managekStatus == 0 || $backOrderStatus > 0) {
38
+ $html .= '<div id="backorders"></div>';
39
+ }
40
+ return $html;
41
+ }
42
+ }
app/code/community/Targetbay/Tracking/Block/Product/Product.php CHANGED
@@ -4,114 +4,113 @@
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- if(class_exists("TM_RichSnippets_Block_Product", true)) {
8
- class Targetbay_Tracking_Block_Product_Product extends TM_RichSnippets_Block_Product
9
- {
10
- /*JSON code*/
11
-
12
- public function getJsonSnippetsProduct()
13
  {
14
- $data = array(
15
- '@context' => 'http://schema.org',
16
- '@type' => 'Product',
17
- 'name' => $this->getProduct()->getName(),
18
- 'image' => (string)Mage::helper('catalog/image')->init($this->getProduct(), 'image'),
19
- 'description' => $this->getProduct()->getShortDescription(),
20
- 'sku' => $this->getProduct()->getSku(),
21
- 'offers' => array(
22
- '@type' => 'Offer',
23
- 'availability' => $this->getStockStatusUrl(),
24
- 'price' => $this->getPriceValues(),
25
- 'priceCurrency' => Mage::app()->getStore()->getCurrentCurrency()->getCode()
26
- )
27
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- $richSnippets = Mage::helper('tracking')->getRichSnippets();
30
- if($richSnippets['average_score'] != 0) {
31
- $data['aggregateRating']['@type'] = 'AggregateRating';
32
- $data['aggregateRating']['bestRating'] = 5;
33
- $data['aggregateRating']['worstRating'] = 1;
34
- $data['aggregateRating']['ratingValue'] = $richSnippets['average_score'];
35
- $data['aggregateRating']['reviewCount'] = $richSnippets['reviews_count'];
36
- $data['aggregateRating']['ratingCount'] = $richSnippets['reviews_count'];
37
- }
38
 
39
- if($richSnippets['reviews_count'] > 0) {
40
- foreach($richSnippets['reviews'] as $key => $aggregateReviewDetails) {
41
- $reviewId = $aggregateReviewDetails->_id;
42
- $reviewTitle = $aggregateReviewDetails->_source->review_title;
43
- $review = $aggregateReviewDetails->_source->review;
44
- $timestamp = $aggregateReviewDetails->_source->timestamp;
45
- $reviewRating = $aggregateReviewDetails->_source->review_rating;
46
- $userName = $aggregateReviewDetails->_source->user_name;
47
-
48
- $reviewData['@type'] = 'Review';
49
- $reviewData['name'] = $reviewTitle;
50
- $reviewData['description'] = $review;
51
- $reviewData['datePublished'] = date('m/d/Y', $timestamp);
52
- $reviewData['ratingCount'] = $aggregateRating['reviews_count'];
53
- $reviewData['author'] = $userName;
54
- $revRating['@type'] = 'Rating';
55
- $revRating['ratingValue'] = $reviewRating;
56
- $revRating['worstRating'] = 1;
57
- $revRating['bestRating'] = 5;
58
- $reviewData['reviewRating'] = $revRating;
59
- $data['review'][] = $reviewData;
60
- }
61
- }
62
 
63
- /*$questionSnippets = Mage::helper('tracking')->getQuestionSnippets();
64
 
65
- if(!empty($questionSnippets) && $questionSnippets['qa_count'] > 0) {
66
- $authorName = $questionSnippets['qa_author'];
67
- $i = 1;
68
- foreach($questionSnippets['qa_details'] as $key => $qasDetails) {
69
- $qasId = $qasDetails->_id;
70
- $productName = $qasDetails->_source->product_name;
71
- $questionName = $qasDetails->_source->questions;
72
- $qasCreatedDate = $qasDetails->_source->timestamp;
73
- $qasUsername = $qasDetails->_source->user_name;
74
- $answerArray = $qasDetails->_source->question_answers;
75
-
76
- $data['@type'] = 'Question';
77
- $data['name'] = $productName;
78
- $data['text'] = $questionName;
79
- $data['dateCreated'] = date('m/d/Y', $qasCreatedDate);
80
- $data['author']['@type'] = 'Person';
81
- $data['author']['name'] = $qasUsername;
82
- $data['answerCount'] = count($answerArray);
83
- if(count($answerArray) > 0) {
84
- $acceptedAnswer['@type'] = 'Answer';
85
- $acceptedAnswer['upvoteCount'] = $answerArray[0]->upvotes;
86
- $acceptedAnswer['text'] = $answerArray[0]->answers;
87
- $acceptedAnswer['dateCreated'] = date('m/d/Y', $answerArray[0]->answer_timestamp);
88
- $acceptedAnswer['author']['@type'] = 'Person';
89
- $acceptedAnswer['author']['name'] = $authorName;
90
- $data['acceptedAnswer'] = $acceptedAnswer;
91
- foreach($answerArray as $key => $answers) {
92
- $suggestedAnswer[$i]['@type'] = 'Answer';
93
- $suggestedAnswer[$i]['upvoteCount'] = $answerArray->upvotes;
94
- $suggestedAnswer[$i]['text'] = $answerArray->answers;
95
- $suggestedAnswer[$i]['dateCreated'] = date('m/d/Y', $answerArray->answer_timestamp);
96
- $suggestedAnswer[$i]['author']['@type'] = 'Person';
97
- $suggestedAnswer[$i]['author']['name'] = $authorName;
98
- $data['suggestedAnswer'] = $suggestedAnswer;
99
- }
100
- }
101
- }
102
- }*/
103
 
104
- if (is_array($this->getPriceValues())) {
105
- unset($data['offers']['price']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
- $getPriceValues = $this->getPriceValues();
108
- $data['offers']['@type'] = 'AggregateOffer';
109
- $data['offers']['lowPrice'] = $getPriceValues[0];
110
- $data['offers']['highPrice'] = $getPriceValues[1];
111
-
112
- }
113
 
114
- return Mage::helper('core')->jsonEncode($data);
 
 
 
 
 
 
 
115
  }
116
  }
117
- }
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
+ if (class_exists("TM_RichSnippets_Block_Product", true)) {
8
+ class Targetbay_Tracking_Block_Product_Product extends TM_RichSnippets_Block_Product
 
 
 
 
9
  {
10
+ /*JSON code*/
11
+
12
+ public function getJsonSnippetsProduct()
13
+ {
14
+ $data = array(
15
+ '@context' => 'http://schema.org',
16
+ '@type' => 'Product',
17
+ 'name' => $this->getProduct()->getName(),
18
+ 'image' => (string) Mage::helper('catalog/image')->init($this->getProduct(), 'image'),
19
+ 'description' => $this->getProduct()->getShortDescription(),
20
+ 'sku' => $this->getProduct()->getSku(),
21
+ 'offers' => array(
22
+ '@type' => 'Offer',
23
+ 'availability' => $this->getStockStatusUrl(),
24
+ 'price' => $this->getPriceValues(),
25
+ 'priceCurrency' => Mage::app()->getStore()->getCurrentCurrency()->getCode()
26
+ )
27
+ );
28
+
29
+ $richSnippets = Mage::helper('tracking')->getRichSnippets();
30
+ if ($richSnippets['average_score'] != 0) {
31
+ $data['aggregateRating']['@type'] = 'AggregateRating';
32
+ $data['aggregateRating']['bestRating'] = 5;
33
+ $data['aggregateRating']['worstRating'] = 1;
34
+ $data['aggregateRating']['ratingValue'] = $richSnippets['average_score'];
35
+ $data['aggregateRating']['reviewCount'] = $richSnippets['reviews_count'];
36
+ $data['aggregateRating']['ratingCount'] = $richSnippets['reviews_count'];
37
+ }
38
 
39
+ if ($richSnippets['reviews_count'] > 0) {
40
+ foreach ($richSnippets['reviews'] as $key => $aggregateReviewDetails) {
41
+ $reviewId = $aggregateReviewDetails->_id;
42
+ $reviewTitle = $aggregateReviewDetails->_source->review_title;
43
+ $review = $aggregateReviewDetails->_source->review;
44
+ $timestamp = $aggregateReviewDetails->_source->timestamp;
45
+ $reviewRating = $aggregateReviewDetails->_source->review_rating;
46
+ $userName = $aggregateReviewDetails->_source->user_name;
 
47
 
48
+ $reviewData['@type'] = 'Review';
49
+ $reviewData['name'] = $reviewTitle;
50
+ $reviewData['description'] = $review;
51
+ $reviewData['datePublished'] = date('m/d/Y', $timestamp);
52
+ $reviewData['ratingCount'] = $aggregateRating['reviews_count'];
53
+ $reviewData['author'] = $userName;
54
+ $revRating['@type'] = 'Rating';
55
+ $revRating['ratingValue'] = $reviewRating;
56
+ $revRating['worstRating'] = 1;
57
+ $revRating['bestRating'] = 5;
58
+ $reviewData['reviewRating'] = $revRating;
59
+ $data['review'][] = $reviewData;
60
+ }
61
+ }
 
 
 
 
 
 
 
 
 
62
 
63
+ /*$questionSnippets = Mage::helper('tracking')->getQuestionSnippets();
64
 
65
+ if(!empty($questionSnippets) && $questionSnippets['qa_count'] > 0) {
66
+ $authorName = $questionSnippets['qa_author'];
67
+ $i = 1;
68
+ foreach($questionSnippets['qa_details'] as $key => $qasDetails) {
69
+ $qasId = $qasDetails->_id;
70
+ $productName = $qasDetails->_source->product_name;
71
+ $questionName = $qasDetails->_source->questions;
72
+ $qasCreatedDate = $qasDetails->_source->timestamp;
73
+ $qasUsername = $qasDetails->_source->user_name;
74
+ $answerArray = $qasDetails->_source->question_answers;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
+ $data['@type'] = 'Question';
77
+ $data['name'] = $productName;
78
+ $data['text'] = $questionName;
79
+ $data['dateCreated'] = date('m/d/Y', $qasCreatedDate);
80
+ $data['author']['@type'] = 'Person';
81
+ $data['author']['name'] = $qasUsername;
82
+ $data['answerCount'] = count($answerArray);
83
+ if(count($answerArray) > 0) {
84
+ $acceptedAnswer['@type'] = 'Answer';
85
+ $acceptedAnswer['upvoteCount'] = $answerArray[0]->upvotes;
86
+ $acceptedAnswer['text'] = $answerArray[0]->answers;
87
+ $acceptedAnswer['dateCreated'] = date('m/d/Y', $answerArray[0]->answer_timestamp);
88
+ $acceptedAnswer['author']['@type'] = 'Person';
89
+ $acceptedAnswer['author']['name'] = $authorName;
90
+ $data['acceptedAnswer'] = $acceptedAnswer;
91
+ foreach($answerArray as $key => $answers) {
92
+ $suggestedAnswer[$i]['@type'] = 'Answer';
93
+ $suggestedAnswer[$i]['upvoteCount'] = $answerArray->upvotes;
94
+ $suggestedAnswer[$i]['text'] = $answerArray->answers;
95
+ $suggestedAnswer[$i]['dateCreated'] = date('m/d/Y', $answerArray->answer_timestamp);
96
+ $suggestedAnswer[$i]['author']['@type'] = 'Person';
97
+ $suggestedAnswer[$i]['author']['name'] = $authorName;
98
+ $data['suggestedAnswer'] = $suggestedAnswer;
99
+ }
100
+ }
101
+ }
102
+ }*/
103
 
104
+ if (is_array($this->getPriceValues())) {
105
+ unset($data['offers']['price']);
 
 
 
 
106
 
107
+ $getPriceValues = $this->getPriceValues();
108
+ $data['offers']['@type'] = 'AggregateOffer';
109
+ $data['offers']['lowPrice'] = $getPriceValues[0];
110
+ $data['offers']['highPrice'] = $getPriceValues[1];
111
+ }
112
+
113
+ return Mage::helper('core')->jsonEncode($data);
114
+ }
115
  }
116
  }
 
app/code/community/Targetbay/Tracking/Block/Product/Review.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Block_Product_Review extends Mage_Core_Block_Template
8
  {
9
  /**
@@ -14,6 +16,8 @@ class Targetbay_Tracking_Block_Product_Review extends Mage_Core_Block_Template
14
  public function _construct()
15
  {
16
  parent::_construct();
 
17
  $this->setTemplate('tracking/product/review.phtml');
 
18
  }
19
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Block_Product_Review extends Mage_Core_Block_Template
10
  {
11
  /**
16
  public function _construct()
17
  {
18
  parent::_construct();
19
+ if (Mage::helper('tracking')->trackingEnabled()) {
20
  $this->setTemplate('tracking/product/review.phtml');
21
+ }
22
  }
23
  }
app/code/community/Targetbay/Tracking/Block/Product/Richsnippets.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Targetbay
5
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
+ * @package Targetbay_Tracking
7
+ */
8
+
9
+ class Targetbay_Tracking_Block_Product_Richsnippets extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Rendered the tracking review template if tracking enabled
13
+ *
14
+ * @see Mage_Core_Block_Template::_construct()
15
+ */
16
+ public function _construct()
17
+ {
18
+ parent::_construct();
19
+ if((int)Mage::helper('tracking')->getRichsnippetType()) {
20
+ $this->setTemplate('tracking/product/richsnippets.phtml');
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Get the current product
26
+ * @return Mage_Catalog_Model_Product
27
+ */
28
+ public function getProduct()
29
+ {
30
+ return Mage::registry('current_product');
31
+ }
32
+
33
+ public function getEscapedProductName()
34
+ {
35
+ return $this->escapeHtml($this->getProduct()->getName());
36
+ }
37
+
38
+ public function getEscapedDescription()
39
+ {
40
+ $product = $this->getProduct();
41
+ if (!$product) {
42
+ return '';
43
+ }
44
+
45
+ return $this->escapeHtml($product->getDescription());
46
+ }
47
+
48
+ public function getSku()
49
+ {
50
+ $product = $this->getProduct();
51
+ if (!$product) {
52
+ return '';
53
+ }
54
+
55
+ return $product->getSku();
56
+ }
57
+ }
app/code/community/Targetbay/Tracking/Block/Recommended.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Targetbay
5
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
+ * @package Targetbay_Tracking
7
+ */
8
+
9
+ class Targetbay_Tracking_Block_Recommended extends Mage_Core_Block_Template
10
+ {
11
+
12
+ /**
13
+ * Rendered the tracking template if tracking enabled
14
+ *
15
+ * @see Mage_Core_Block_Template::_construct()
16
+ */
17
+ public function _construct()
18
+ {
19
+ parent::_construct();
20
+ if (Mage::helper('tracking')->trackingEnabled()) {
21
+ $this->setTemplate('tracking/recommended.phtml');
22
+ }
23
+ }
24
+ }
app/code/community/Targetbay/Tracking/Block/Session/Tracking.php CHANGED
@@ -1,12 +1,14 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Block_Session_Tracking extends Mage_Core_Block_Template
8
  {
9
-
10
  /**
11
  * Rendered the tracking template if tracking enabled
12
  *
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Block_Session_Tracking extends Mage_Core_Block_Template
10
  {
11
+
12
  /**
13
  * Rendered the tracking template if tracking enabled
14
  *
app/code/community/Targetbay/Tracking/Block/Tracking.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Block_Tracking extends Mage_Core_Block_Template
8
  {
9
 
@@ -19,4 +21,22 @@ class Targetbay_Tracking_Block_Tracking extends Mage_Core_Block_Template
19
  $this->setTemplate('tracking/tracking.phtml');
20
  }
21
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Block_Tracking extends Mage_Core_Block_Template
10
  {
11
 
21
  $this->setTemplate('tracking/tracking.phtml');
22
  }
23
  }
24
+
25
+ public function getStockAvaliability() {
26
+ $_product = $this->getProduct();
27
+ if(!$_product->isAvailable()) {
28
+ return true;
29
+ } else {
30
+ return 0;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Get the current product
36
+ * @return Mage_Catalog_Model_Product
37
+ */
38
+ public function getProduct()
39
+ {
40
+ return Mage::registry('current_product');
41
+ }
42
  }
app/code/community/Targetbay/Tracking/Helper/Data.php CHANGED
@@ -1,83 +1,85 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
8
  {
9
  public $cookie;
10
  public $date;
11
 
12
- CONST ANONYMOUS_USER = 'anonymous';
13
  // page types
14
- CONST ALL_PAGES = 'all';
15
- CONST PAGE_VISIT = 'page-visit';
16
- CONST PRODUCT_VIEW = 'product-view';
17
- CONST CATEGORY_VIEW = 'category-view';
18
- CONST DELETE_PRODUCT = "delete-product";
19
- CONST UPDATE_PRODUCT = 'update-product';
20
- CONST ADD_PRODUCT = 'add-product';
21
- CONST CREATE_ACCOUNT = 'create-account';
22
- CONST ADMIN_ACTIVATE_ACCOUNT = 'admin-activate-customer-account';
23
- CONST LOGIN = 'login';
24
- CONST LOGOUT = 'logout';
25
- CONST ADDTOCART = 'add-to-cart';
26
- CONST REMOVECART = 'remove-to-cart';
27
- CONST UPDATECART = 'update-cart';
28
- CONST ORDER_ITEMS = 'ordered-items';
29
- CONST BILLING = 'billing';
30
- CONST SHIPPING = 'shipping';
31
- CONST PAGE_REFERRAL = 'referrer';
32
- CONST CHECKOUT = 'checkout';
33
- CONST CATALOG_SEARCH = 'searched';
34
- CONST WISHLIST = 'wishlist';
35
- CONST UPDATE_WISHLIST = 'update-wishlist';
36
- CONST REMOVE_WISHLIST = 'remove-wishlist';
37
- CONST ONESTEPCHECKOUT_ADDRESS = 'onestepcheckout';
38
- CONST CART_INDEX = 'checkout-cart';
39
- CONST SUBSCRIBE_CUSTOMER = 'user-subscribe';
40
- CONST CUSTOMER_ADDRESS = 'change-user-address';
41
- CONST CUSTOMER_ACCOUNT = 'change-user-account-info';
42
- CONST CREATE_ADDRESS = 'new';
43
- CONST UPDATE_ADDRESS = 'edit';
44
- CONST RATINGS_STATS = 'ratings-stats';
45
- CONST QUESTION_STATS = 'qa-stats';
46
-
47
- // subscription status
48
- CONST STATUS_SUBSCRIBED = 1;
49
- CONST STATUS_NOT_ACTIVE = 2;
50
- CONST STATUS_UNSUBSCRIBED = 3;
51
- CONST STATUS_UNCONFIRMED = 4;
52
-
53
  // product stock status
54
- CONST IN_STOCK = 'in-stock';
55
- CONST OUT_OF_STOCK = 'out-stock';
56
-
57
  // order fullfillment process
58
- CONST ORDER_SHIPMENT = 'shipment';
59
- CONST ORDER_INVOICE = 'invoice';
60
- CONST ORDER_REFUND = 'creditmemo';
61
- CONST ORDER_STATUS = 'order-status';
62
-
63
- CONST HOST_STAGE = 'https://stage.targetbay.com/api/v1/webhooks/';
64
- CONST HOST_LIVE = 'https://app.targetbay.com/api/v1/webhooks/';
65
- CONST HOST_DEV = 'https://dev.targetbay.com/api/v1/webhooks/';
66
-
67
- CONST API_STAGE = 'stage';
68
- CONST API_LIVE = 'app';
69
- CONST API_DEV = 'dev';
70
- CONST DEFAULT_TIMEOUT = 30;
71
-
72
  /**
73
  * Initialize object
74
  */
75
  public function __construct()
76
  {
77
  $this->cookie = Mage::getModel('core/cookie');
78
- $this->date = Mage::getModel('core/date');
79
  }
80
-
81
  /**
82
  * Check module is enabled or not
83
  *
@@ -85,9 +87,9 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
85
  */
86
  public function trackingEnabled()
87
  {
88
- return (bool)Mage::getStoreConfig('targetbay_tracking/tracking_groups/enabled');
89
  }
90
-
91
  /**
92
  * Get Target bay Host
93
  *
@@ -97,7 +99,7 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
97
  {
98
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/hostname');
99
  }
100
-
101
  /**
102
  * Get TargetbayToken
103
  *
@@ -107,7 +109,7 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
107
  {
108
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/api_token');
109
  }
110
-
111
  /**
112
  * Get TargetBayIndex
113
  *
@@ -117,7 +119,7 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
117
  {
118
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/api_index');
119
  }
120
-
121
  /**
122
  * Get getApiStatus
123
  *
@@ -125,46 +127,43 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
125
  */
126
  public function getApiStatus()
127
  {
128
- $apiStatus = Mage::getStoreConfig('targetbay_tracking/tracking_groups/api_status');
129
- if($apiStatus) {
130
- return $apiStatus;
131
- } else {
132
- return self::API_LIVE;
133
- }
134
  }
135
-
136
  /**
137
  * Get the Session Tracking Js
138
  *
139
  * @return mixed
140
  */
141
  public function getReviewPageSize()
142
- {
143
- $reviewSize = Mage::getStoreConfig('targetbay_tracking/tracking_groups/reviews_per_page');
144
- if($reviewSize){
145
- $reviewSize = $reviewSize;
146
- } else {
147
- $reviewSize = 10;
148
- }
149
- return $reviewSize;
 
150
  }
151
-
152
  /**
153
  * Get the email status
154
  *
155
  * @return mixed
156
  */
157
  public function getEmailStatus()
158
- {
159
- $emailStatus = Mage::getStoreConfig('targetbay_tracking/tracking_groups/disable_email');
160
- if($emailStatus){
161
- $emailStatus = $emailStatus;
162
- } else {
163
- $emailStatus = 1;
164
- }
165
- return $emailStatus;
 
166
  }
167
-
168
  /**
169
  * Get TargetBay tracking type
170
  *
@@ -174,7 +173,17 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
174
  {
175
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/tracking_type');
176
  }
177
-
 
 
 
 
 
 
 
 
 
 
178
  /**
179
  * Print the log or not
180
  *
@@ -184,7 +193,7 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
184
  {
185
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/debug');
186
  }
187
-
188
  /**
189
  * Get the log file name from configurations
190
  */
@@ -192,19 +201,20 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
192
  {
193
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/debug_file');
194
  }
195
-
196
  /**
197
- * Get the availabe pages from configurations
198
  *
199
- * @return multitype:
200
  */
201
  public function availablePageTypes()
202
  {
203
- $types = (string) Mage::getStoreConfig('targetbay_tracking/tracking_groups/page_types');
204
- $typesArray = explode(',', $types);
205
- return $typesArray;
 
206
  }
207
-
208
  /**
209
  * Get Tracking Code
210
  *
@@ -214,192 +224,199 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
214
  {
215
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/tracking_script');
216
  }
217
-
218
  /**
219
  * Check the page configurations
220
  *
221
- * @param unknown $pageType
222
  * @return boolean
223
  */
224
  public function canTrackPages($pageType)
225
  {
226
  if (!$this->trackingEnabled()) {
227
- $this->debug('Tracking Module is Not Enabled. Please enable a Module');
 
228
  return false;
229
  }
230
- $availabelPages = $this->availablePageTypes();
231
- if (in_array(self::ALL_PAGES, $availabelPages)) {
232
  return true;
233
  }
234
- if (!in_array($pageType, $availabelPages)) {
235
- $this->debug("'$pageType'" . 'page is not enabled');
 
236
  return false;
237
  }
 
238
  return true;
239
  }
240
-
241
  /**
242
  * Get the customer data based on the action
243
  *
244
- * @param unknown $customer
245
- * @param unknown $action
246
- * @return unknown
247
  */
248
  public function getCustomerData($customer, $action)
249
  {
250
- try {
251
- switch ($action) {
252
- case self::LOGIN:
253
- $data = $this->getCustomerSessionId($customer);
254
- $data['login_date'] = $this->date->date('Y-m-d');
255
- break;
256
- case self::LOGOUT:
257
- $data['session_id'] = Mage::getSingleton('core/session')->getCustomerSessionId();
258
- $data['logout_date'] = $this->date->date('Y-m-d');
259
- Mage::getSingleton('core/session')->unsTrackingSessionId();
260
- Mage::getSingleton('core/session')->unsCustomerSessionId();
261
- break;
262
- case self::CREATE_ACCOUNT:
263
- $data = $this->getCustomerSessionId($customer);
264
- $data['firstname'] = $customer->getFirstname();
265
- $data['lastname'] = $customer->getLastname();
266
- $data['subscription_status'] = $this->getSubscriptionStatus($customer->getId());
267
- $data['account_created'] = $this->date->date('Y-m-d');
268
- break;
269
- }
270
- $data['user_id'] = $customer->getId();
271
- $data['user_name'] = $customer->getName();
272
- $data['user_mail'] = $customer->getEmail();
273
- $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
274
- $data['ip_address'] = Mage::helper('core/http')->getRemoteAddr();
275
- return $data;
276
- } catch (Exception $e) {
277
- $this->debug('Error message:'.$e->getMessage());
278
- return;
 
 
279
  }
280
  }
281
-
282
  /**
283
  * Get the customer subscription status
284
  *
285
- * @param unknown $customerId
286
  * @return string
287
  */
288
  public function getSubscriptionStatus($customerId)
289
  {
290
- try {
291
- $customerData = Mage::getModel('customer/customer')->load($customerId);
292
- $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
293
- if ($subscriber->getSubscriberStatus() == self::STATUS_UNSUBSCRIBED) {
294
- $status = 'Unsubscribed';
295
- } elseif ($subscriber->getSubscriberStatus() == self::STATUS_SUBSCRIBED) {
296
- $status = 'Subscribed';
297
- } elseif ($subscriber->getSubscriberStatus() == self::STATUS_UNCONFIRMED) {
298
- $status = 'Unconfirmed';
299
- } elseif ($subscriber->getSubscriberStatus() == self::STATUS_NOT_ACTIVE) {
300
- $status = 'Not Activated';
301
- } else {
302
- $status = '';
303
- }
304
- return $status;
305
- } catch (Exception $e) {
306
- $this->debug('Error message:'.$e->getMessage());
307
- return;
308
  }
309
- }
310
-
311
  /**
312
  * Get the customer session info
313
  *
314
- * @param unknown $customerId
315
- * @return string
316
  */
317
  public function getCustomerSessionId($customer)
318
  {
319
- $data = array();
320
- try {
321
- $visitorData = Mage::getSingleton('core/session')->getVisitorData();
322
- $session = $visitorData['session_id'] . strtotime(date('Y-m-d H:i:s'));
323
- $data['session_id'] = $session;
324
-
325
- $trackingType = $this->getTrackingType();
326
- if ($trackingType == 1):
327
- $data['previous_session_id'] = $this->cookie->get('targetbay_session_id');
328
- else:
329
- $data['previous_session_id'] = $this->cookie->get('trackingsession');
330
- endif;
331
-
332
- Mage::getSingleton('core/session')->setCustomerSessionId($session);
333
- return $data;
334
- } catch (Exception $e) {
335
- $this->debug('Error message:'.$e->getMessage());
336
- return;
337
  }
 
 
338
  }
339
-
340
  /**
341
  * Check the order placed by registered user or not
342
  *
343
- * @param unknown $quoteId
344
  * @return boolean|Mage_Core_Model_Abstract
345
  */
346
  public function isRegisterCheckout($order)
347
  {
348
  $checkoutMethod = Mage::getModel('sales/quote')->load($order->getQuoteId())->getCheckoutMethod(true);
349
- if ($checkoutMethod != 'register')
350
  return false;
 
351
  return Mage::getModel('customer/customer')->load($order->getCustomerId());
352
  }
353
-
354
  /**
355
  * Basic visit info
356
  *
357
- * @return string
358
  */
359
  public function visitInfo()
360
  {
361
- $data = array();
362
- try {
363
- $customer = Mage::getSingleton('customer/session');
364
- $data['user_name'] = $customer->isLoggedIn() ? $customer->getCustomer()->getName() : self::ANONYMOUS_USER;
365
- $data['user_email'] = $customer->isLoggedIn() ? $customer->getCustomer()->getEmail() : self::ANONYMOUS_USER;
366
- $trackingType = $this->getTrackingType();
367
- $moduleName = Mage::app()->getRequest()->getModuleName();
368
-
369
- if (($moduleName == 'catalogsearch') && ($customer->isLoggedIn())) {
370
- $user_id = $customer->getCustomer()->getId();
371
- } else {
372
- $user_id = $customer->isLoggedIn() ? $customer->getCustomer()->getId() : $this->cookie->get('targetbay_session_id');
373
- }
374
-
375
- if ($trackingType == 1):
376
- $data['already_tracked'] = true;
377
- $data['user_id'] = $user_id;
378
- $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : $this->cookie->get('targetbay_session_id');
379
- else:
380
- if (!$this->cookie->get('trackingsession')) {
381
- $userId = Mage::getSingleton('core/session')->getTrackingSessionId();
382
- } else {
383
- $userId = $this->cookie->get('trackingsession');
384
- }
385
- $data['user_id'] = $customer->isLoggedIn() ? $customer->getCustomer()->getId() : $userId;
386
- $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : Mage::getSingleton('core/session')->getTrackingSessionId();
387
- endif;
388
-
389
- $data['page_url'] = Mage::helper('core/url')->getCurrentUrl();
390
- $data['ip_address'] = Mage::helper('core/http')->getRemoteAddr();
391
- $data['user_agent'] = Mage::helper('core/http')->getHttpUserAgent();
392
- $data['utm_sources'] = $this->cookie->get('utm_source') ? $this->cookie->get('utm_source') : '';
393
- $data['utm_token'] = $this->cookie->get('utm_token') ? $this->cookie->get('utm_token') : '';
394
- $pageTitle = Mage::app()->getLayout()->getBlock('head') ? Mage::app()->getLayout()->getBlock('head')->getTitle() : Mage::getSingleton('checkout/session')->getTitle();
395
- $data['page_title'] = str_replace("'", " ", $pageTitle);
396
- return $data;
397
- } catch (Exception $e) {
398
- $this->debug('Error message:'.$e->getMessage());
399
- return;
400
  }
 
 
401
  }
402
-
403
  /**
404
  * Push the referer url
405
  *
@@ -407,26 +424,25 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
407
  */
408
  public function getRefererData()
409
  {
410
- try {
411
- $isSecure = Mage::app()->getFrontController()->getRequest()->isSecure();
412
- if($isSecure) {
413
- $currentUrl = Mage::getUrl('', array('_secure'=>true));
414
- } else {
415
- $currentUrl = Mage::getUrl('');
416
- }
417
- $referer = Mage::helper('core/http')->getHttpReferer() ? Mage::helper('core/http')->getHttpReferer() : $currentUrl;
418
- if (strpos($referer, $currentUrl) !== false) {
419
- return false; // base url and referer url matches.
420
- }
421
- $data = $this->visitInfo();
422
- $data['referrer_url'] = $referer;
423
- return $data;
424
- } catch (Exception $e) {
425
- $this->debug('Error message:'.$e->getMessage());
426
- return;
427
  }
428
  }
429
-
430
  /**
431
  * Push the page info using Varien_Http_Client
432
  *
@@ -441,21 +457,16 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
441
  'timeout' => 1
442
  ));
443
  $client->setRawData(utf8_encode($jsondata));
444
-
445
  try {
446
- $this->debug("Endpoint Url =>$url");
447
- $this->debug("Request =>");
448
- $this->debug($jsondata);
449
  $response = $client->request(Varien_Http_Client::POST)->getBody();
450
- $this->debug("Response =>");
451
- $this->debug ( print_r($response, true) );
452
  return $response;
453
  } catch (Exception $e) {
454
- $this->debug('Error message '.$e->getMessage());
 
455
  return;
456
  }
457
  }
458
-
459
  /**
460
  * Remove the cookies
461
  */
@@ -472,479 +483,507 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
472
  $this->cookie->delete('user_loggedin');
473
  $this->cookie->delete('afterlogin_session_id');
474
  }
475
-
476
  /**
477
  * Get the cart info
478
  *
479
- * @return string
480
  */
481
  public function getCartInfo()
482
  {
483
- $data = array();
484
- try {
485
- $customer = Mage::getSingleton('customer/session');
486
- $checkout = Mage::getSingleton('checkout/session')->getQuote();
487
- $trackingType = $this->getTrackingType();
488
- if ($trackingType == 1):
489
- $data['user_id'] = $customer->isLoggedIn() ? $customer->getCustomer()->getId() : $this->cookie->get('targetbay_session_id');
490
- $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : $this->cookie->get('targetbay_session_id');
491
- else:
492
- $data['user_id'] = $customer->isLoggedIn() ? $customer->getId() : Mage::getSingleton('core/session')->getTrackingSessionId();
493
- $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : Mage::getSingleton('core/session')->getTrackingSessionId();
494
- endif;
495
-
496
- $data['user_name'] = $customer->isLoggedIn() ? $customer->getCustomer()->getName() : Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
497
- $data['user_mail'] = $customer->isLoggedIn() ? $customer->getCustomer()->getEmail() : Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
498
-
499
- $data['order_id'] = Mage::getSingleton('checkout/session')->getQuoteId();
500
- $data['utm_sources'] = $this->cookie->get('utm_source') ? $this->cookie->get('utm_source') : '';
501
- $data['utm_token'] = $this->cookie->get('utm_token') ? $this->cookie->get('utm_token') : '';
502
- $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
503
- $pageTitle = Mage::app()->getLayout()->getBlock('head') ? Mage::app()->getLayout()->getBlock('head')->getTitle() : Mage::getSingleton('checkout/session')->getTitle();
504
- $data['page_title'] = addslashes($pageTitle);
505
- return $data;
506
  } catch (Exception $e) {
507
- $this->debug('Error message '.$e->getMessage());
508
- return;
509
  }
 
 
510
  }
511
-
512
  /**
513
  * Get the common info for quote or order, billing and shipping
514
  *
515
- * @param unknown $order
516
- * @return string
517
  */
518
  public function getSessionInfo($object)
519
  {
520
- $data = array();
521
- try {
522
- $trackingType = $this->getTrackingType();
523
- if ($trackingType == 1):
524
- $data['user_id'] = $object->getCustomerId() ? $object->getCustomerId() : $this->cookie->get('targetbay_session_id');
525
- $data['session_id'] = Mage::getSingleton('customer/session')->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : $this->cookie->get('targetbay_session_id');
526
- else:
527
- $data['user_id'] = $object->getCustomerId() ? $object->getCustomerId() : Mage::getSingleton('core/session')->getTrackingSessionId();
528
- $data['session_id'] = Mage::getSingleton('customer/session')->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : Mage::getSingleton('core/session')->getTrackingSessionId();
529
- endif;
530
-
531
- $data['utm_sources'] = $this->cookie->get('utm_source') ? $this->cookie->get('utm_source') : '';
532
- $data['utm_token'] = $this->cookie->get('utm_token') ? $this->cookie->get('utm_token') : '';
533
- $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
534
- $pageTitle = Mage::app()->getLayout()->getBlock('head') ? Mage::app()->getLayout()->getBlock('head')->getTitle() : Mage::getSingleton('checkout/session')->getTitle();
535
- $data['page_title'] = addslashes($pageTitle);
536
- return $data;
537
  } catch (Exception $e) {
538
- $this->debug('Error message '.$e->getMessage());
539
- return;
540
  }
 
 
541
  }
542
-
543
  /**
544
  * Get the Order data
545
  *
546
- * @param unknown $object
547
- * @return string
548
  */
549
  public function getInfo($object)
550
- {
551
- try {
552
- $customer = $object->getCustomer();
553
- $items = $object->getAllVisibleItems();
554
- $data = $this->getSessionInfo($object);
555
- $data['first_name'] = $object->getCustomerFirstname();
556
- $data['last_name'] = $object->getCustomerLastname();
557
- $guestUsername = $object->getCustomerFirstname().' '.$object->getCustomerLastname();
558
- $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
559
- $data['user_name'] = $object->getCustomerIsGuest() ? $gName : $data['first_name'] . ' ' . $data['last_name'];
560
- $data['user_mail'] = $object->getCustomerEmail();
561
- $data['order_id'] = $object->getId();
562
- $data['order_price'] = $object->getSubtotal();
563
- $data['order_quantity'] = $object->getData('total_qty_ordered');
564
- $data['shipping_method'] = $object->getData('shipping_description');
565
- $data['shipping_price'] = $object->getData('shipping_amount');
566
- $data['tax_amount'] = $object->getData('tax_amount');
567
- $data['payment_method'] = $object->getPayment()->getMethodInstance()->getTitle();
568
- $data['cart_items'] = $this->getOrderItemsInfo($object);
569
- return $data;
570
  } catch (Exception $e) {
571
- $this->debug('Error message '.$e->getMessage());
572
- return;
573
  }
 
 
574
  }
575
-
576
  /**
577
  * Get the Order data
578
  *
579
- * @param unknown $object
580
- * @return string
581
  */
582
  public function getOrderInfo($object)
583
- {
 
584
  try {
585
- $customer = $object->getCustomer();
586
- $items = $object->getAllVisibleItems();
587
- $data['user_id'] = $object->getCustomerIsGuest() ? self::ANONYMOUS_USER : $object->getCustomerId();
588
- $data['first_name'] = $object->getCustomerFirstname();
589
- $data['last_name'] = $object->getCustomerLastname();
590
- $guestUsername = $object->getCustomerFirstname().' '.$object->getCustomerLastname();
 
591
  $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
592
- $data['user_name'] = $object->getCustomerIsGuest() ? $gName : $data['first_name'] . ' ' . $data['last_name'];
593
- $data['user_mail'] = $object->getCustomerEmail();
594
- $data['order_id'] = $object->getId();
595
- $data['order_status'] = $object->getStatus();
596
- $data['order_price'] = $object->getSubtotal();
597
- $data['order_quantity'] = $object->getData('total_qty_ordered');
598
  $data['shipping_method'] = $object->getData('shipping_description');
599
- $data['shipping_price'] = $object->getData('shipping_amount');
600
- $data['tax_amount'] = $object->getData('tax_amount');
601
- $data['payment_method'] = $object->getPayment()->getMethodInstance()->getTitle();
602
- $data['cart_items'] = $this->getOrderItemsInfo($object);
603
- return $data;
604
  } catch (Exception $e) {
605
- $this->debug('Error message '.$e->getMessage());
606
- return;
607
  }
 
 
608
  }
609
-
610
  /**
611
  * Collect the order items info
612
  *
613
- * @param unknown $order
614
- * @return multitype:unknown
 
615
  */
616
  public function getOrderItemsInfo($order, $orderExportApi = false)
617
- {
618
- $dataItems = array();
619
- try {
620
- $items = $order->getAllVisibleItems();
621
- foreach ($items as $orderItem) {
622
- $dataItem = $this->getItemInfo($orderItem);
623
- if ($customOptions = $this->getCustomOptionsInfo($orderItem, $orderExportApi))
624
- $dataItem['attributes'] = $customOptions;
625
- $dataItems[] = $dataItem;
626
- }
627
- return $dataItems;
628
  } catch (Exception $e) {
629
- $this->debug('Error message '.$e->getMessage());
630
- return;
631
  }
 
 
632
  }
633
-
634
  /**
635
- * Collect the order payment info
636
  *
637
- * @param unknown $order
638
- * @return multitype:unknown
 
639
  */
640
  public function getPaymentInfo($orderId, $orderExportApi = false)
641
  {
642
- $paymentTitle = '';$paymentMethod = '';
643
- try {
644
- $paymentCollection = Mage::getModel('sales/order_payment')->getCollection()->addFieldToFilter('parent_id', $orderId);
645
- foreach ($paymentCollection as $paymentDetails) {
646
- $paymentMethod = $paymentDetails->getMethod();
647
- }
648
-
649
- $store = Mage::app()->getStore();
650
- $path = 'payment/' . $paymentMethod . '/title';
651
- $paymentTitle = Mage::getStoreConfig($path, $store);
652
- return $paymentTitle;
653
  } catch (Exception $e) {
654
- $this->debug('Error message '.$e->getMessage());
655
- return;
656
  }
 
 
657
  }
658
-
659
  /**
660
  * Get the item info
661
  *
662
- * @param unknown $item
663
- * @return unknown
 
664
  */
665
  public function getItemInfo($item, $actionType = false)
666
  {
667
- $dataItem = array();
668
- try {
669
- $product = Mage::getModel('catalog/product')->load($item->getData('product_id'));
670
- $dataItem['type'] = $item->getProductType();
671
- $dataItem['product_id'] = $item->getProductId();
672
- $dataItem['product_sku'] = $item->getSku();
673
- $dataItem['product_name'] = addslashes($item->getName());
674
- $dataItem['price'] = $actionType ? $item->getProduct()->getPrice() : $item->getPrice();
675
- $dataItem['special_price'] = $product->getSpecialPrice();
676
- $qty = $actionType ? $item->getProduct()->getQty() : $item->getQty();
677
- $dataItem['productimg'] = $this->getImageUrl($product, 'image');
678
-
679
- $dataItem['category'] = $this->getProductCategory($product);
680
- $dataItem['category_name'] = $this->getProductCategoryName($product);
681
- $dataItem['quantity'] = ($item->getData('qty_ordered')) ? $item->getData('qty_ordered') : $qty;
682
- $dataItem['page_url'] = Mage::getUrl($product->getUrlPath());
683
- return $dataItem;
684
  } catch (Exception $e) {
685
- $this->debug('Error message '.$e->getMessage());
686
- return;
687
  }
 
 
688
  }
689
-
690
  /**
691
  * Get the product categories
692
  *
693
- * @param unknown $product
694
- * @return unknown
695
- */
696
  public function getProductCategoryName($product)
697
  {
698
  $categoryIds = $product->getCategoryIds();
699
-
700
  $productCategories = array();
701
- $categoryName = '';
702
-
 
 
703
  if (count($categoryIds)) {
704
  foreach ($categoryIds as $categoryId) {
705
- $_category = Mage::getModel('catalog/category')->load($categoryId);
706
- $productCategories[] = str_replace("'", " ", $_category->getName());
707
  }
708
-
709
  $categoryName = implode(',', $productCategories);
710
  }
711
-
712
  return $categoryName;
713
  }
714
-
715
  /**
716
  * Get the product categories
717
  *
718
- * @param unknown $product
719
- * @return unknown
720
- */
721
  public function getProductCategory($product)
722
  {
723
- $categoryIds = $product->getCategoryIds();
724
- $productCategories = array();
725
- $categoryId = '';
726
  if (count($categoryIds)) {
727
-
728
- foreach ($categoryIds as $categoryId) {
729
- $_category = Mage::getModel('catalog/category')->load($categoryId);
730
- $productCategories[] = $_category->getName();
731
- }
732
 
733
  $categoryId = implode(',', $categoryIds);
734
  }
735
-
736
  return $categoryId;
737
  }
738
-
739
  /**
740
  * Get the item custom options
741
  *
742
- * @param unknown $item
743
- * @return boolean|unknown|number
 
744
  */
745
  public function getCustomOptionsInfo($item, $orderExportApi)
746
  {
747
- try {
748
- $customOptions = $orderExportApi ? $item->getProductOptions() : $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
749
-
750
- if (empty($customOptions['options']) && empty($customOptions['attributes_info']))
751
- return false;
752
- $superAttributeInfo = isset($customOptions['attributes_info']) ? $this->getOptionValues($customOptions['attributes_info']) : array();
753
- $customOptionInfo = isset($customOptions['options']) ? $this->getOptionValues($customOptions['options']) : array();
754
- $optionsData = array_merge($superAttributeInfo, $customOptionInfo);
755
- return $optionsData;
 
756
  } catch (Exception $e) {
757
- $this->debug('Error message '.$e->getMessage());
758
- return;
759
  }
 
 
760
  }
761
-
762
  /**
763
  * Get the options values
764
  *
765
- * @param unknown $options
766
- * @return multitype:unknown
767
  */
768
  public function getOptionValues($options)
769
  {
770
  $optionData = array();
771
- try {
772
- foreach ($options as $option) {
773
- $data['label'] = $option['label'];
774
- $data['value'] = $option['value'];
775
- $optionData[] = $data;
776
- }
777
- return $optionData;
778
  } catch (Exception $e) {
779
- $this->debug('Error message '.$e->getMessage());
780
- return;
781
  }
 
 
782
  }
783
-
784
  /**
785
  * Get the order or quote address by address type.
786
  *
787
- * @param unknown $object
788
- * @param unknown $type
789
- * @return string
790
  */
791
  public function getAddressData($object, $type)
792
  {
793
- try {
794
- $address = ($type == self::SHIPPING) ? $object->getShippingAddress() : $object->getBillingAddress();
795
- $addressData = $this->getSessionInfo($object);
796
- $addressData['first_name'] = $address->getFirstname();
797
- $addressData['last_name'] = $address->getLastname();
798
- $guestUsername = $address->getFirstname().' '.$address->getLastname();
799
- $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
800
- $addressData['user_name'] = $object->getCustomerIsGuest() ? $gName : $addressData['first_name'] . ' ' . $addressData['last_name'];
801
- $addressData['order_id'] = $object->getId();
802
- $addressData['user_mail'] = $object->getCustomerEmail();
803
- $addressData['address1'] = $address->getStreet(1);
804
- $addressData['address2'] = $address->getStreet(2);
805
- $addressData['city'] = $address->getCity();
806
- $addressData['state'] = $address->getRegion();
807
- $addressData['zipcode'] = $address->getPostcode();
808
- if($address->getCountryId()) {
809
- $countryName = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
810
- } else {
811
- $countryName = '';
812
- }
813
- $addressData['country'] = isset($countryName) ? $countryName : $address->getCountryId();
814
- $addressData['phone'] = $address->getTelephone();
815
- return $addressData;
816
  } catch (Exception $e) {
817
- $this->debug('Error message '.$e->getMessage());
818
- return;
819
  }
 
 
820
  }
821
-
822
  /**
823
  * Get the product info
824
  *
825
- * @param unknown $product
826
- * @return string
827
  */
828
  public function getProductData($product)
829
- {
830
- $configOptions = array();$customOptions = array();$data = array();
831
- try {
832
- $data['image_url'][] = $this->getProductImages($product);
833
- $data['entity_id'] = $product->getId();
834
- $data['attribute_set_id'] = $product->getEntityTypeId();
835
- $data['type_id'] = $product->getTypeId();
836
- $data['sku'] = $product->getSku();
837
- $data['product_status'] = $product->getStatus();
838
- $data['currency_type'] = Mage::app()->getStore()->getCurrentCurrencyCode();
839
-
840
- $data['stock_count'] = -1;
841
-
842
- if($stock = $product->getData('stock_data')) {
843
- $data['stock_count'] = !empty($stock['is_in_stock']) ? $stock['qty'] : -1;
844
- }
845
-
846
- $data['visibility'] = $product->getVisibility();
847
- $data['description'] = $product->getDescription();
848
- $data['price'] = $product->getPrice();
849
- $data['special_price'] = $product->getSpecialPrice();
850
- $data['weight'] = $product->getWeight();
851
- $data['name'] = addslashes($product->getName());
852
-
853
- $data['category'] = $this->getProductCategory($product);
854
- $data['url_key'] = $product->getUrlKey();
855
- $data['full_url_key'] = $product->getProductUrl();
856
-
857
- if($configData = $product->getData('configurable_attributes_data')) {
858
- $configOptions = $this->productOptions($configData, 'label');
859
- }
860
- if($custOptions = $product->getData('product_options')) {
861
- $customOptions = $this->productOptions($custOptions);
862
- }
863
- $options = array_merge($configOptions, $customOptions);
864
- if(!empty($options)) {
865
- $data['attributes'] = $options;
 
 
 
 
 
 
 
866
  }
867
- return $data;
868
  } catch (Exception $e) {
869
- $this->debug('Error message '.$e->getMessage());
870
- return;
871
  }
 
 
872
  }
873
-
874
  /**
875
  * Get the product options when saving product
876
  *
877
- * @param unknown $configData
878
- * @param string $customOption
879
- * @return multitype:multitype:unknown
880
  */
881
  public function productOptions($configData, $customOption = 'title')
882
  {
883
  $options = array();
884
- try {
885
- foreach($configData as $cdata) {
886
- $attrLabel = $cdata[$customOption];
887
- if(!isset($cdata['values'])) {
888
- $options[] = array(
889
- 'label' => $attrLabel,
890
- 'value' => $attrLabel
891
- );
892
- continue;
893
- }
894
- foreach($cdata['values'] as $val) {
895
- $attrVal = $val[$customOption];
896
- $options[] = array(
897
- 'label' => $attrLabel,
898
- 'value' => $attrVal
899
- );
900
- }
901
- }
902
- return $options;
903
  } catch (Exception $e) {
904
- $this->debug('Error message '.$e->getMessage());
905
- return;
906
  }
 
 
907
  }
908
-
909
  /**
910
  * Get the product images
911
  *
912
- * @param unknown $product
913
  * @return string
914
  */
915
  public function getProductImages($product)
916
  {
917
  $images = array();
918
  try {
919
- $images['url'] = $this->getImageUrl($product, 'image');
920
- $images['position'] = 1;
921
- $images['thumbnail_image'] = $this->getImageUrl($product, 'small_image');
922
- $images['medium_image'] = $this->getImageUrl($product, 'thumbnail');
923
- return $images;
 
 
 
 
 
 
 
 
 
924
  } catch (Exception $e) {
925
- $this->debug('Error message '.$e->getMessage());
926
  return;
927
  }
928
  }
929
-
930
  /**
931
  * Get the Product image url
932
  *
933
- * @param unknown $product
934
- * @param unknown $imageType
935
  * @return string
936
  */
937
  public function getImageUrl($product, $imageType)
938
  {
939
- if($product->getData($imageType)) {
940
- $imgPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getData($imageType);
941
- } else {
942
- $imgPath = '';
 
 
943
  }
944
 
945
  return $imgPath;
946
  }
947
-
948
  /**
949
  * Check the order full fillment
950
  *
@@ -952,147 +991,147 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
952
  */
953
  public function isFullFillmentProcess($params)
954
  {
955
- if(isset($params[self::ORDER_SHIPMENT]) ||
956
- isset($params[self::ORDER_INVOICE]) ||
957
  isset($params[self::ORDER_REFUND])
958
  ) {
959
  return true;
960
  }
961
  return false;
962
  }
963
-
964
  /**
965
  * Get the wishlist product info
966
  *
967
- * @param unknown $productId
968
  * @return string
969
  */
970
  public function getWishlistProductInfo($productId)
971
  {
972
- $data = array();
973
- try {
974
- $product = Mage::getModel('catalog/product')->load($productId);
975
- $qty = 1;
976
-
977
- $data['type'] = $product->getTypeId();
978
- $data['product_id'] = $product->getId();
979
- $data['product_sku'] = $product->getSku();
980
- $data['name'] = addslashes($product->getName());
981
- $data['price'] = $product->getPrice();
982
- $data['special_price'] = $product->getSpecialPrice();
983
- $data['productimg'] = $this->getImageUrl($product, 'image');
984
-
985
- $data['category'] = $this->getProductCategory($product);
986
- $data['category_name'] = $this->getProductCategoryName($product);
987
- $data['quantity'] = (Mage::app()->getRequest()->getParam('qty')) ? Mage::app()->getRequest()->getParam('qty') : $qty;
988
- $data['page_url'] = Mage::getUrl($product->getUrlPath());
989
-
990
- return $data;
991
  } catch (Exception $e) {
992
- $this->debug('Error message '.$e->getMessage());
993
- return;
994
  }
 
 
995
  }
996
-
997
  /**
998
  * Collect the wishlist items info
999
  *
1000
- * @param unknown $productIds
1001
  * @return multitype:unknown
1002
  */
1003
  public function getWishlistItemsInfo($wishlistInfo)
1004
- {
1005
- $dataItems = array();
1006
- try {
1007
- $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
1008
-
1009
- foreach ($wishlistItemCollection as $id => $wishlistItem) {
1010
- $product = $wishlistItem->getProduct();
1011
- $dataItem = $this->wishlistProductInfo($product);
1012
- $dataItems[$id] = $dataItem;
1013
- }
1014
- return $dataItems;
1015
  } catch (Exception $e) {
1016
- $this->debug('Error message '.$e->getMessage());
1017
- return;
1018
  }
 
 
1019
  }
1020
-
1021
  /**
1022
  * Collect the wishlist items product info
1023
  *
1024
- * @param unknown $productIds
1025
- * @return multitype:unknown
1026
- */
1027
  public function wishlistProductInfo($product)
1028
  {
1029
- $dataItem = array();
1030
- try {
1031
- $product = Mage::getModel('catalog/product')->load($product->getData('entity_id'));
1032
- $dataItem['type'] = $product->getTypeId();
1033
- $dataItem['product_id'] = $product->getId();
1034
- $dataItem['product_name'] = addslashes($product->getName());
1035
- $dataItem['price'] = $product->getPrice();
1036
- $dataItem['special_price'] = $product->getSpecialPrice();
1037
- $dataItem['productimg'] = $this->getImageUrl($product, 'image');
1038
- $dataItem['category'] = $this->getProductCategory($product);
1039
- $dataItem['category_name'] = $this->getProductCategoryName($product);
1040
- $dataItem['page_url'] = Mage::getUrl($product->getUrlPath());
1041
- return $dataItem;
1042
  } catch (Exception $e) {
1043
- $this->debug('Error message '.$e->getMessage());
1044
- return;
1045
  }
1046
-
 
1047
  }
1048
-
1049
  /**
1050
  *
1051
- * @param unknown $order
1052
- * @param unknown $params
1053
- * @return unknown|boolean
1054
  */
1055
  public function getFullFillmentData($order, $params)
1056
  {
1057
- $shipmetItems = array();
1058
- $shipmentsInfo = array();
1059
- try {
1060
- if (isset($params[self::ORDER_SHIPMENT])) {
1061
- $shipmentsInfo['order_id'] = $order->getId();
1062
- $shipmentsInfo['order_status'] = $order->getStatus();
1063
- $shipmentsInfo['total_ordered_qty'] = (int)$order->getData('total_qty_ordered');
1064
- $shipmentsInfo['user_id'] = $order->getData('customer_is_guest') ? self::ANONYMOUS_USER : $order->getData('customer_id');
1065
- $shipmentsInfo['user_mail'] = $order->getData('customer_is_guest') ? $order->getData('customer_email') : $order->getData('customer_email');
1066
- $shipmentsInfo['created_at'] = $order->getData('updated_at');
1067
-
1068
- foreach ($order->getAllVisibleItems() as $item) {
1069
- if ($item->getQtyShipped() == '')
1070
- continue;
1071
- $shipmentItemInfo['product_id'] = $item->getProductId();
1072
- $shipmentItemInfo['name'] = addslashes($item->getName());
1073
- $shipmentItemInfo['sku'] = $item->getSku();
1074
- $shipmentItemInfo['qty_ordered'] = (int)$item->getQtyOrdered();
1075
- $shipmentItemInfo['qty_shipped'] = (int)$item->getQtyShipped();
1076
- $shipmetItems[] = $shipmentItemInfo;
1077
- }
1078
- $shipmentsInfo['shipment_items'] = $shipmetItems;
1079
- return $shipmentsInfo;
1080
- }
1081
  } catch (Exception $e) {
1082
- $this->debug('Error message '.$e->getMessage());
1083
- return;
1084
  }
 
 
1085
  }
1086
-
1087
  /**
1088
- * Stop the page visit for already tracked events
1089
  *
1090
- * @return multitype:string
 
1091
  */
1092
  public function eventAlreadyTracked($eventName)
1093
  {
1094
  $stopAction = array(
1095
- 'cms_index_index',
1096
  'catalog_category_view',
1097
  'catalog_product_view',
1098
  'catalogsearch_result_index',
@@ -1117,455 +1156,504 @@ class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
1117
  'checkout_onepage_progress',
1118
  'checkout_onepage_saveOrder'
1119
  );
1120
- return in_array($eventName, $stopAction);
 
1121
  }
1122
-
1123
  /**
1124
  * debugging
1125
  *
1126
- * @param unknown $mess
1127
  */
1128
  public function debug($mess, $logFile = null)
1129
  {
1130
- if ($this->logEnabled())
1131
  Mage::log($mess, null, $logFile ? $logFile : $this->getLogFileName());
 
1132
  }
1133
-
1134
  /**
1135
  * debugging
1136
  *
1137
- * @param unknown $mess
1138
  */
1139
  public function getProductVersion()
1140
  {
1141
- return (string)Mage::getConfig()->getModuleConfig('Targetbay_Tracking')->version;
1142
  }
1143
-
1144
  /**
1145
  * Visiting page info
1146
  *
1147
- * @param Varien_Event_Observer $observer
1148
- *
1149
- * @return void
1150
  */
1151
  public function getPageVisitData()
1152
- {
1153
  Mage::getModel('tracking/observer')->setCookieValues();
1154
-
1155
- // Set Token Values
1156
  if (isset($_GET['utm_source']) && !$this->cookie->get('utm_source')) {
1157
  $this->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
1158
  }
1159
-
1160
  if (isset($_GET['token']) && !$this->cookie->get('utm_token')) {
1161
  $this->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
1162
  }
1163
-
1164
- // Page Visit Tracking
1165
- $data = $this->visitInfo();
1166
 
1167
- return $data;
 
1168
  }
1169
-
1170
  /**
1171
  * Category view page
1172
  *
1173
- * @param Varien_Event_Observer $observer
1174
- *
1175
- * @return void
1176
  */
1177
  public function getCategoryViewData()
1178
- {
1179
- $category = Mage::registry('current_category');
1180
- $data = $this->visitInfo();
1181
- $data['category_id'] = $category->getId();
1182
- $data['category_url'] = $category->getUrl();
1183
- $data['category_name'] = $category->getName();
 
 
1184
 
1185
  return $data;
1186
  }
1187
-
1188
  /**
1189
  * Product view page
1190
  *
1191
- * @param Varien_Event_Observer $observer
1192
  *
1193
  * @return void
1194
  */
1195
  public function getProductViewData()
1196
  {
1197
- $data = array();
1198
- // Get the base visit info
1199
- try {
1200
- $data = $this->visitInfo();
1201
- $product = Mage::registry('product');
1202
- $categoryIds = $product->getCategoryIds();
1203
- if (count($categoryIds)) {
1204
- $firstCategoryId = $categoryIds[0];
1205
- $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
1206
- $data['category'] = $_category->getName();
1207
- }
1208
- $data['product_id'] = $product->getId();
1209
- $data['product_name'] = addslashes($product->getName());
1210
- $data['price'] = $product->getPrice();
1211
- $data['special_price'] = $product->getSpecialPrice();
1212
- $data['productimg'] = $product->getImageUrl();
1213
- $data['stock'] = self::OUT_OF_STOCK;
1214
- $stock = $product->getStockItem();
1215
- if ($stock->getIsInStock()) {
1216
- $data['stock'] = self::IN_STOCK;
1217
- }
1218
- return $data;
 
 
1219
  } catch (Exception $e) {
1220
- $this->debug('Error message '.$e->getMessage());
1221
- return;
1222
  }
 
 
1223
  }
1224
-
1225
  /**
1226
  * Catalog search result page
1227
  *
1228
- * @param Varien_Event_Observer $observer
1229
  *
1230
  * @return void
1231
  */
1232
  public function getCatalogSearchResultData()
1233
  {
1234
- $data = array();
1235
-
1236
  try {
 
 
1237
  $keyword = Mage::app()->getRequest()->getParam('q');
1238
  if (empty($keyword)) {
1239
  return false;
1240
  }
1241
- $data = $this->visitInfo();
1242
- $data['keyword'] = $keyword;
1243
- return $data;
1244
  } catch (Exception $e) {
1245
- $this->debug('Error message '.$e->getMessage());
1246
- return;
1247
  }
 
 
1248
  }
1249
-
1250
  /**
1251
  * Get the page info for static page
1252
- *
1253
  * @return string
1254
- */
1255
  public function getPageInfo()
1256
- {
1257
- $controllername = Mage::app()->getRequest()->getControllerName();
1258
- $moduleName = Mage::app()->getRequest()->getModuleName();
1259
 
1260
- if ($moduleName == 'cms') {
1261
  $data = $this->getPageVisitData();
1262
- } elseif ($controllername == 'category') {
1263
  $data = $this->getCategoryViewData();
1264
- } elseif ($controllername == 'product') {
1265
  $data = $this->getProductViewData();
1266
- } elseif ($moduleName == 'catalogsearch') {
1267
  $data = $this->getCatalogSearchResultData();
1268
  }
1269
  $data['index_name'] = $this->getApiIndex();
1270
-
1271
  return $data;
1272
  }
1273
-
1274
  /**
1275
  * Get the api url for static pages
1276
- *
1277
  * @return string
1278
- */
1279
  public function getApiUrl()
1280
- {
1281
- $controllername = Mage::app()->getRequest()->getControllerName();
1282
- $moduleName = Mage::app()->getRequest()->getModuleName();
1283
- $endPointUrl = '';
1284
-
1285
- if ($moduleName == 'cms') {
1286
- $type = 'page-visit';
1287
- $endPointUrl = $this->getHostname() . $type . '?api_token=' . $this->getApiToken();
1288
- } elseif ($controllername == 'category') {
1289
- $type = 'category-view';
1290
- $endPointUrl = $this->getHostname() . $type . '?api_token=' . $this->getApiToken();
1291
- } elseif ($controllername == 'product') {
1292
- $type = 'product-view';
1293
- $endPointUrl = $this->getHostname() . $type . '?api_token=' . $this->getApiToken();
1294
- } elseif ($moduleName == 'catalogsearch') {
1295
- $type = 'searched';
1296
- $endPointUrl = $this->getHostname() . $type . '?api_token=' . $this->getApiToken();
1297
  }
1298
-
1299
- return $endPointUrl;
1300
  }
1301
-
1302
  /**
1303
  * Get the quote items
1304
  *
1305
- * @param $items
1306
- * @param $orderExportApi
1307
  * @return unknown
1308
- */
1309
  public function getQuoteItems($items, $orderExportApi = false)
1310
  {
1311
  $dataItems = array();
1312
- try {
1313
- foreach ($items as $item) {
1314
- $dataItem = $this->getItemInfo($item);
1315
- if ($customOptions = $this->getCustomOptionsInfo($item, $orderExportApi))
1316
- $dataItem['attributes'] = $customOptions;
1317
- $dataItems[$item->getId()] = $dataItem;
1318
- }
1319
- return $dataItems;
1320
  } catch (Exception $e) {
1321
- $this->debug('Error message '.$e->getMessage());
1322
- return;
1323
  }
 
 
1324
  }
1325
-
1326
  /**
1327
  * Get the customer address data based on the action
1328
  *
1329
- * @param unknown $addressId
1330
- * @return unknown
1331
  */
1332
  public function getCustomerAddressData($addressId)
1333
  {
1334
- $data = array();
1335
- try {
1336
- $address = Mage::getModel('customer/address');
1337
- $customer = Mage::getSingleton('customer/session')->getCustomer();
1338
- $data['user_id'] = $customer->getId();
1339
- $data['user_name'] = $customer->getName();
1340
- $data['user_mail'] = $customer->getEmail();
1341
- if ($addressId) {
1342
- $existsAddress = $address->load($addressId);
1343
- $data['address_id'] = $addressId;
1344
- $data['old_address'] = $this->getExistingAddressData($existsAddress);
1345
- }
1346
- $data['new_address'] = $this->getNewAddressData();
1347
- $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
1348
- $data['ip_address'] = Mage::helper('core/http')->getRemoteAddr();
1349
- $data['user_agent'] = Mage::helper('core/http')->getHttpUserAgent();
1350
- return $data;
1351
  } catch (Exception $e) {
1352
- $this->debug('Error message '.$e->getMessage());
1353
- return;
1354
  }
 
 
1355
  }
1356
-
1357
  /**
1358
  * Get the customer address data based on the action
1359
- *
1360
- * @return multitype:unknown
1361
- */
1362
  public function getNewAddressData()
1363
  {
1364
- $request = Mage::app()->getRequest();
1365
- $addressData = array();
1366
- try {
1367
- $addressData['firstname'] = $request->getParam('firstname');
1368
- $addressData['lastname'] = $request->getParam('lastname');
1369
- $addressData['company'] = $request->getParam('company');
1370
- $addressData['street'] = implode('', $request->getParam('street'));
1371
- $addressData['city'] = $request->getParam('city');
1372
- $addressData['region_id'] = $request->getParam('region_id');
1373
- $addressData['region'] = $request->getParam('region');
1374
- $addressData['postcode'] = $request->getParam('postcode');
1375
- $addressData['country_id'] = $request->getParam('country_id');
1376
- $addressData['telephone'] = $request->getParam('telephone');
1377
- return $addressData;
1378
  } catch (Exception $e) {
1379
- $this->debug('Error message '.$e->getMessage());
1380
- return;
1381
  }
 
 
1382
  }
1383
-
1384
  /**
1385
  * Get the customer existing address data
1386
- *
1387
  * @return multitype:unknown
1388
- */
1389
  public function getExistingAddressData($existsAddress)
1390
  {
1391
- $addressData = array();
1392
- try {
1393
- $addressData['firstname'] = $existsAddress->getFirstname();
1394
- $addressData['lastname'] = $existsAddress->getLastname();
1395
- $addressData['company'] = $existsAddress->getCompany();
1396
- $addressData['street'] = $existsAddress->getStreet();
1397
- $addressData['city'] = $existsAddress->getCity();
1398
- $addressData['region_id'] = $existsAddress->getRegionId();
1399
- $addressData['region'] = $existsAddress->getRegion();
1400
- $addressData['postcode'] = $existsAddress->getPostcode();
1401
- $addressData['country_id'] = $existsAddress->getCountryId();
1402
- $addressData['telephone'] = $existsAddress->getTelephone();
1403
- return $addressData;
1404
  } catch (Exception $e) {
1405
- $this->debug('Error message '.$e->getMessage());
1406
- return;
1407
  }
 
 
1408
  }
1409
-
1410
  /**
1411
  * Get the targetbay review count and rating for product
1412
- *
1413
  * @return array
1414
- */
1415
  public function getRichSnippets()
1416
- {
 
 
 
 
1417
  $data = array();
1418
- $responseData = '';
1419
- $controllername = Mage::app()->getRequest()->getControllerName();
1420
- $moduleName = Mage::app()->getRequest()->getModuleName();
1421
- $productReviewCount = Mage::getSingleton('core/session')->getProductReview();
 
 
1422
  try {
1423
- $type = self::RATINGS_STATS;
1424
- $apiToken = '?api_token=' . $this->getApiToken();
1425
- $feedUrl = $this->getHostname() . $type . $apiToken;
1426
- $data['index_name'] = $this->getApiIndex();
1427
- if($moduleName == 'catalog' && $controllername == 'product') {
1428
- $productId = Mage::registry('product')->getId();
1429
- $data['product_id'] = $productId;
1430
- }
1431
-
1432
- if($productReviewCount < 1 || $productReviewCount == '') {
1433
- $jsondata = json_encode($data);
1434
- $response = $this->postPageInfo($feedUrl, $jsondata);
1435
- $body = json_decode($response);
1436
-
1437
- if($body->reviews_count > 1) {
1438
- $_SESSION['last_session'] = time();
1439
- Mage::getSingleton('core/session')->setProductReview($body->reviews_count);
1440
- Mage::getSingleton('core/session')->setProductReviewResponse($body);
1441
  }
1442
  }
1443
 
1444
- $responseBody = Mage::getSingleton('core/session')->getProductReviewResponse();
1445
- if(!empty($responseBody)) {
1446
- $averageScore = $responseBody->reviews_average;
1447
- $reviewsCount = $responseBody->reviews_count;
1448
- $reviewsDetails = $responseBody->reviews;
1449
- $responseData = array( "average_score" => $averageScore, "reviews_count" => $reviewsCount, "reviews" => $reviewsDetails);
1450
- return $responseData;
1451
- }
1452
- } catch(Exception $e) {
1453
- $this->debug('Error message '.$e->getMessage());
1454
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1455
  }
1456
  }
1457
-
1458
  /**
1459
  * Get the targetbay review count and dynamic ids
1460
- *
1461
  * @return array
1462
- */
1463
  public function getTargetbayReviewId()
1464
- {
1465
  $itemRefData = array();
1466
  $itemRef = '';
1467
  try {
1468
- $trackingSnippet = $this->getRichSnippets();
1469
- if($trackingSnippet['reviews_count'] > 0) {
1470
- foreach($trackingSnippet['reviews'] as $key => $aggregateReviewDetails) {
1471
- $itemRefData[]= 'tb-review-'.$key;
1472
- }
1473
- $itemRef = implode(' ', $itemRefData);
1474
- }
1475
- return $itemRef;
1476
- } catch(Exception $e) {
1477
- $this->debug('Error message '.$e->getMessage());
1478
- return;
1479
  }
1480
  }
1481
-
1482
  /**
1483
  * Get the targetbay review count and rating for product
1484
- *
1485
  * @return array
1486
- */
1487
  public function getSiteReviewSnippets()
1488
- {
1489
- $data = array();
1490
- $responseData = '';
1491
- $siteReviewCount = Mage::getSingleton('core/session')->getSiteReview();
 
 
 
 
1492
  try {
1493
- $type = self::RATINGS_STATS;
1494
- $apiToken = '?api_token=' . $this->getApiToken();
1495
- $feedUrl = $this->getHostname() . $type . $apiToken;
1496
- $data['index_name'] = $this->getApiIndex();
1497
-
1498
- if($siteReviewCount < 1 || $siteReviewCount == '') {
1499
- $jsondata = json_encode($data);
1500
- $response = $this->postPageInfo($feedUrl, $jsondata);
1501
- $body = json_decode($response);
1502
-
1503
- if($body->reviews_count > 1) {
1504
- Mage::getSingleton('core/session')->setSiteReview($body->reviews_count);
1505
- Mage::getSingleton('core/session')->setSiteReviewResponse($body);
1506
  $_SESSION['last_session'] = time();
 
1507
  }
 
 
1508
  }
1509
-
1510
- $responseBody = Mage::getSingleton('core/session')->getSiteReviewResponse();
1511
- if(!empty($responseBody)) {
1512
- $averageScore = $responseBody->reviews_average;
1513
- $reviewsCount = $responseBody->reviews_count;
1514
- $reviewsDetails = $responseBody->reviews;
1515
- $responseData = array( "average_score" => $averageScore, "reviews_count" => $reviewsCount, "reviews" => $reviewsDetails);
1516
- return $responseData;
1517
- }
1518
- } catch(Exception $e) {
1519
- $this->debug('Error message '.$e->getMessage());
1520
- return;
 
 
1521
  }
1522
  }
1523
 
1524
  /**
1525
  * Get the targetbay review count and rating for product
1526
- *
1527
  * @return array
1528
- */
1529
  public function getQuestionSnippets()
1530
- {
 
 
 
1531
  $data = array();
1532
- $responseData = '';
1533
- $controllername = Mage::app()->getRequest()->getControllerName();
1534
- $moduleName = Mage::app()->getRequest()->getModuleName();
1535
- $qaReviewCount = Mage::getSingleton('core/session')->getQaReview();
 
 
1536
  try {
1537
  $type = self::QUESTION_STATS;
1538
  $apiToken = '?api_token=' . $this->getApiToken();
1539
  $feedUrl = $this->getHostname() . $type . $apiToken;
1540
  $data['index_name'] = $this->getApiIndex();
1541
- if($moduleName == 'catalog' && $controllername == 'product') {
1542
  $productId = Mage::registry('product')->getId();
1543
  $data['product_id'] = $productId;
 
 
 
 
 
 
 
1544
  }
 
 
 
 
1545
 
1546
- if($qaReviewCount < 1 || $qaReviewCount == '') {
1547
- $jsondata = json_encode($data);
1548
- $response = $this->postPageInfo($feedUrl, $jsondata);
1549
- $body = json_decode($response);
1550
-
1551
- if($body->qa_count > 1) {
1552
- Mage::getSingleton('core/session')->setQaReview($body->qa_count);
1553
- Mage::getSingleton('core/session')->setQaReviewResponse($body);
1554
  $_SESSION['last_session'] = time();
 
 
 
 
 
 
1555
  }
 
 
1556
  }
1557
-
1558
- $responseBody = Mage::getSingleton('core/session')->getQaReviewResponse();
1559
- if(!empty($responseBody)) {
1560
  $qaCount = $responseBody->qa_count;
1561
  $qaDetails = $responseBody->qas;
1562
  $qaAuthor = $responseBody->client;
1563
- $responseData = array("qa_count" => $qaCount, "qa_details" => $qaDetails, "qa_author" => $qaAuthor);
 
 
 
 
1564
  return $responseData;
1565
  }
1566
- } catch(Exception $e) {
1567
- $this->debug('Error message '.$e->getMessage());
1568
  return;
1569
  }
1570
  }
1571
- }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Helper_Data extends Mage_Core_Helper_Abstract
10
  {
11
  public $cookie;
12
  public $date;
13
 
14
+ const ANONYMOUS_USER = 'anonymous';
15
  // page types
16
+ const ALL_PAGES = 'all';
17
+ const PAGE_VISIT = 'page-visit';
18
+ const PRODUCT_VIEW = 'product-view';
19
+ const CATEGORY_VIEW = 'category-view';
20
+ const DELETE_PRODUCT = "delete-product";
21
+ const UPDATE_PRODUCT = 'update-product';
22
+ const ADD_PRODUCT = 'add-product';
23
+ const CREATE_ACCOUNT = 'create-account';
24
+ const ADMIN_ACTIVATE_ACCOUNT = 'admin-activate-customer-account';
25
+ const LOGIN = 'login';
26
+ const LOGOUT = 'logout';
27
+ const ADDTOCART = 'add-to-cart';
28
+ const REMOVECART = 'remove-to-cart';
29
+ const UPDATECART = 'update-cart';
30
+ const ORDER_ITEMS = 'ordered-items';
31
+ const BILLING = 'billing';
32
+ const SHIPPING = 'shipping';
33
+ const PAGE_REFERRAL = 'referrer';
34
+ const CHECKOUT = 'checkout';
35
+ const CATALOG_SEARCH = 'searched';
36
+ const WISHLIST = 'wishlist';
37
+ const UPDATE_WISHLIST = 'update-wishlist';
38
+ const REMOVE_WISHLIST = 'remove-wishlist';
39
+ const ONESTEPCHECKOUT_ADDRESS = 'onestepcheckout';
40
+ const CART_INDEX = 'checkout-cart';
41
+ const SUBSCRIBE_CUSTOMER = 'user-subscribe';
42
+ const CUSTOMER_ADDRESS = 'change-user-address';
43
+ const CUSTOMER_ACCOUNT = 'change-user-account-info';
44
+ const CREATE_ADDRESS = 'new';
45
+ const UPDATE_ADDRESS = 'edit';
46
+ const RATINGS_STATS = 'ratings-stats';
47
+ const QUESTION_STATS = 'qa-stats';
48
+
49
+ // subscription status
50
+ const STATUS_SUBSCRIBED = 1;
51
+ const STATUS_NOT_ACTIVE = 2;
52
+ const STATUS_UNSUBSCRIBED = 3;
53
+ const STATUS_UNCONFIRMED = 4;
54
+
55
  // product stock status
56
+ const IN_STOCK = 'in-stock';
57
+ const OUT_OF_STOCK = 'out-stock';
58
+
59
  // order fullfillment process
60
+ const ORDER_SHIPMENT = 'shipment';
61
+ const ORDER_INVOICE = 'invoice';
62
+ const ORDER_REFUND = 'creditmemo';
63
+ const ORDER_STATUS = 'order-status';
64
+
65
+ const HOST_STAGE = 'https://stage.targetbay.com/api/v1/webhooks/';
66
+ const HOST_LIVE = 'https://app.targetbay.com/api/v1/webhooks/';
67
+ const HOST_DEV = 'https://dev.targetbay.com/api/v1/webhooks/';
68
+
69
+ const API_STAGE = 'stage';
70
+ const API_LIVE = 'app';
71
+ const API_DEV = 'dev';
72
+ const DEFAULT_TIMEOUT = 30;
73
+
74
  /**
75
  * Initialize object
76
  */
77
  public function __construct()
78
  {
79
  $this->cookie = Mage::getModel('core/cookie');
80
+ $this->date = Mage::getModel('core/date');
81
  }
82
+
83
  /**
84
  * Check module is enabled or not
85
  *
87
  */
88
  public function trackingEnabled()
89
  {
90
+ return (bool) Mage::getStoreConfig('targetbay_tracking/tracking_groups/enabled');
91
  }
92
+
93
  /**
94
  * Get Target bay Host
95
  *
99
  {
100
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/hostname');
101
  }
102
+
103
  /**
104
  * Get TargetbayToken
105
  *
109
  {
110
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/api_token');
111
  }
112
+
113
  /**
114
  * Get TargetBayIndex
115
  *
119
  {
120
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/api_index');
121
  }
122
+
123
  /**
124
  * Get getApiStatus
125
  *
127
  */
128
  public function getApiStatus()
129
  {
130
+ return Mage::getStoreConfig('targetbay_tracking/tracking_groups/api_status');
 
 
 
 
 
131
  }
132
+
133
  /**
134
  * Get the Session Tracking Js
135
  *
136
  * @return mixed
137
  */
138
  public function getReviewPageSize()
139
+ {
140
+ $reviewSize = Mage::getStoreConfig('targetbay_tracking/tracking_groups/reviews_per_page');
141
+ if ($reviewSize) {
142
+ $reviewSize = $reviewSize;
143
+ } else {
144
+ $reviewSize = 10;
145
+ }
146
+
147
+ return $reviewSize;
148
  }
149
+
150
  /**
151
  * Get the email status
152
  *
153
  * @return mixed
154
  */
155
  public function getEmailStatus()
156
+ {
157
+ $emailStatus = Mage::getStoreConfig('targetbay_tracking/tracking_groups/disable_email');
158
+ if ($emailStatus) {
159
+ $emailStatus = $emailStatus;
160
+ } else {
161
+ $emailStatus = 1;
162
+ }
163
+
164
+ return $emailStatus;
165
  }
166
+
167
  /**
168
  * Get TargetBay tracking type
169
  *
173
  {
174
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/tracking_type');
175
  }
176
+
177
+ /**
178
+ * Get TargetBay richsnippet type
179
+ *
180
+ * @return mixed
181
+ */
182
+ public function getRichsnippetType()
183
+ {
184
+ return Mage::getStoreConfig('targetbay_tracking/tracking_groups/richsnippets_type');
185
+ }
186
+
187
  /**
188
  * Print the log or not
189
  *
193
  {
194
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/debug');
195
  }
196
+
197
  /**
198
  * Get the log file name from configurations
199
  */
201
  {
202
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/debug_file');
203
  }
204
+
205
  /**
206
+ * Get the available pages from configurations
207
  *
208
+ * @return array
209
  */
210
  public function availablePageTypes()
211
  {
212
+ $types = (string) Mage::getStoreConfig('targetbay_tracking/tracking_groups/page_types');
213
+ //$typesArray = explode(',', $types);
214
+
215
+ return explode(',', $types);
216
  }
217
+
218
  /**
219
  * Get Tracking Code
220
  *
224
  {
225
  return Mage::getStoreConfig('targetbay_tracking/tracking_groups/tracking_script');
226
  }
227
+
228
  /**
229
  * Check the page configurations
230
  *
231
+ * @param $pageType
232
  * @return boolean
233
  */
234
  public function canTrackPages($pageType)
235
  {
236
  if (!$this->trackingEnabled()) {
237
+ $this->debug('Tracking Module is not enabled. Please enable a Module');
238
+
239
  return false;
240
  }
241
+ $availablePages = $this->availablePageTypes();
242
+ if (in_array(self::ALL_PAGES, $availablePages, true)) {
243
  return true;
244
  }
245
+ if (!in_array($pageType, $availablePages, true)) {
246
+ $this->debug("'$pageType'" . 'page is not enabled.');
247
+
248
  return false;
249
  }
250
+
251
  return true;
252
  }
253
+
254
  /**
255
  * Get the customer data based on the action
256
  *
257
+ * @param $customer
258
+ * @param $action
259
+ * @return array
260
  */
261
  public function getCustomerData($customer, $action)
262
  {
263
+ try {
264
+ switch ($action) {
265
+ case self::LOGIN:
266
+ $data = $this->getCustomerSessionId($customer);
267
+ $data['login_date'] = $this->date->date('Y-m-d');
268
+ break;
269
+ case self::LOGOUT:
270
+ $data['session_id'] = Mage::getSingleton('core/session')->getCustomerSessionId();
271
+ $data['logout_date'] = $this->date->date('Y-m-d');
272
+ Mage::getSingleton('core/session')->unsTrackingSessionId();
273
+ Mage::getSingleton('core/session')->unsCustomerSessionId();
274
+ break;
275
+ case self::CREATE_ACCOUNT:
276
+ $data = $this->getCustomerSessionId($customer);
277
+ $data['firstname'] = $customer->getFirstname();
278
+ $data['lastname'] = $customer->getLastname();
279
+ $data['subscription_status'] = $this->getSubscriptionStatus($customer->getId());
280
+ $data['account_created'] = $this->date->date('Y-m-d');
281
+ break;
282
+ }
283
+ $data['user_id'] = $customer->getId();
284
+ $data['user_name'] = $customer->getName();
285
+ $data['user_mail'] = $customer->getEmail();
286
+ $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
287
+ $data['ip_address'] = Mage::helper('core/http')->getRemoteAddr();
288
+
289
+ return $data;
290
+ } catch (Exception $e) {
291
+ $this->debug('Error message:' . $e->getMessage());
292
+
293
+ return;
294
  }
295
  }
296
+
297
  /**
298
  * Get the customer subscription status
299
  *
300
+ * @param $customerId
301
  * @return string
302
  */
303
  public function getSubscriptionStatus($customerId)
304
  {
305
+ try {
306
+ $customerData = Mage::getModel('customer/customer')->load($customerId);
307
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
308
+ if ($subscriber->getSubscriberStatus() == self::STATUS_UNSUBSCRIBED) {
309
+ $status = 'Unsubscribed';
310
+ } elseif ($subscriber->getSubscriberStatus() == self::STATUS_SUBSCRIBED) {
311
+ $status = 'Subscribed';
312
+ } elseif ($subscriber->getSubscriberStatus() == self::STATUS_UNCONFIRMED) {
313
+ $status = 'Unconfirmed';
314
+ } elseif ($subscriber->getSubscriberStatus() == self::STATUS_NOT_ACTIVE) {
315
+ $status = 'Not Activated';
316
+ } else {
317
+ $status = '';
318
+ }
319
+ return $status;
320
+ } catch (Exception $e) {
321
+ $this->debug('Error message:' . $e->getMessage());
322
+ return;
323
  }
324
+ }
325
+
326
  /**
327
  * Get the customer session info
328
  *
329
+ * @param $customer
330
+ * @return array
331
  */
332
  public function getCustomerSessionId($customer)
333
  {
334
+ $data = array();
335
+ try {
336
+ $visitorData = Mage::getSingleton('core/session')->getVisitorData();
337
+ $session = $visitorData['session_id'] . strtotime(date('Y-m-d H:i:s'));
338
+ $data['session_id'] = $session;
339
+
340
+ $trackingType = $this->getTrackingType();
341
+ if ($trackingType == 1):
342
+ $data['previous_session_id'] = $this->cookie->get('targetbay_session_id'); else:
343
+ $data['previous_session_id'] = $this->cookie->get('trackingsession');
344
+ endif;
345
+
346
+ Mage::getSingleton('core/session')->setCustomerSessionId($session);
347
+ } catch (Exception $e) {
348
+ $this->debug('Error message:' . $e->getMessage());
 
 
 
349
  }
350
+
351
+ return $data;
352
  }
353
+
354
  /**
355
  * Check the order placed by registered user or not
356
  *
357
+ * @param $quoteId
358
  * @return boolean|Mage_Core_Model_Abstract
359
  */
360
  public function isRegisterCheckout($order)
361
  {
362
  $checkoutMethod = Mage::getModel('sales/quote')->load($order->getQuoteId())->getCheckoutMethod(true);
363
+ if ($checkoutMethod !== 'register') {
364
  return false;
365
+ }
366
  return Mage::getModel('customer/customer')->load($order->getCustomerId());
367
  }
368
+
369
  /**
370
  * Basic visit info
371
  *
372
+ * @return array
373
  */
374
  public function visitInfo()
375
  {
376
+ $data = array();
377
+ try {
378
+ $customer = Mage::getSingleton('customer/session');
379
+ $data['user_name'] = $customer->isLoggedIn() ? $customer->getCustomer()->getName() : self::ANONYMOUS_USER;
380
+ $data['user_email'] = $customer->isLoggedIn() ? $customer->getCustomer()->getEmail() : self::ANONYMOUS_USER;
381
+ $trackingType = $this->getTrackingType();
382
+ $moduleName = Mage::app()->getRequest()->getModuleName();
383
+
384
+ if (($moduleName === 'catalogsearch') && ($customer->isLoggedIn())) {
385
+ $user_id = $customer->getCustomer()->getId();
386
+ } else {
387
+ $user_id = $customer->isLoggedIn() ? $customer->getCustomer()->getId() : $this->cookie->get('targetbay_session_id');
388
+ }
389
+
390
+ if ($trackingType == 1) {
391
+ $data['already_tracked'] = true;
392
+ $data['user_id'] = $user_id;
393
+ $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : $this->cookie->get('targetbay_session_id');
394
+ } else {
395
+ if (!$this->cookie->get('trackingsession')) {
396
+ $userId = Mage::getSingleton('core/session')->getTrackingSessionId();
397
+ } else {
398
+ $userId = $this->cookie->get('trackingsession');
399
+ }
400
+ $data['user_id'] = $customer->isLoggedIn() ? $customer->getCustomer()->getId() : $userId;
401
+ $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : Mage::getSingleton('core/session')->getTrackingSessionId();
402
+ }
403
+
404
+ $data['page_url'] = Mage::helper('core/url')->getCurrentUrl();
405
+ $data['ip_address'] = Mage::helper('core/http')->getRemoteAddr();
406
+ $data['user_agent'] = Mage::helper('core/http')->getHttpUserAgent();
407
+ $data['utm_sources'] = $this->cookie->get('utm_source') ? $this->cookie->get('utm_source') : '';
408
+ $data['utm_token'] = $this->cookie->get('utm_token') ? $this->cookie->get('utm_token') : '';
409
+ $pageTitle = Mage::app()->getLayout()->getBlock('head') ? Mage::app()->getLayout()->getBlock('head')->getTitle() : Mage::getSingleton('checkout/session')->getTitle();
410
+ $quotes = array("'", '"');
411
+ $replace = array('', '');
412
+ $data['page_title'] = str_replace($quotes, $replace, $pageTitle);
413
+ } catch (Exception $e) {
414
+ $this->debug('Error message:' . $e->getMessage());
415
  }
416
+
417
+ return $data;
418
  }
419
+
420
  /**
421
  * Push the referer url
422
  *
424
  */
425
  public function getRefererData()
426
  {
427
+ try {
428
+ $domainName = $_SERVER['SERVER_NAME'];
429
+ $referer = Mage::helper('core/http')->getHttpReferer();
430
+
431
+ if ($referer == '' || strpos($referer, $domainName) !== false) {
432
+ return false; // base url and referer url matches.
433
+ }
434
+
435
+ $data = $this->visitInfo();
436
+ $data['referrer_url'] = $referer;
437
+
438
+ return $data;
439
+ } catch (Exception $e) {
440
+ $this->debug('Error message:' . $e->getMessage());
441
+
442
+ return;
 
443
  }
444
  }
445
+
446
  /**
447
  * Push the page info using Varien_Http_Client
448
  *
457
  'timeout' => 1
458
  ));
459
  $client->setRawData(utf8_encode($jsondata));
 
460
  try {
 
 
 
461
  $response = $client->request(Varien_Http_Client::POST)->getBody();
 
 
462
  return $response;
463
  } catch (Exception $e) {
464
+ $this->debug('Error message ' . $e->getMessage());
465
+
466
  return;
467
  }
468
  }
469
+
470
  /**
471
  * Remove the cookies
472
  */
483
  $this->cookie->delete('user_loggedin');
484
  $this->cookie->delete('afterlogin_session_id');
485
  }
486
+
487
  /**
488
  * Get the cart info
489
  *
490
+ * @return array
491
  */
492
  public function getCartInfo()
493
  {
494
+ $data = array();
495
+ try {
496
+ $customer = Mage::getSingleton('customer/session');
497
+ //$checkout = Mage::getSingleton('checkout/session')->getQuote();
498
+ $trackingType = $this->getTrackingType();
499
+ if ($trackingType == 1):
500
+ $data['user_id'] = $customer->isLoggedIn() ? $customer->getCustomer()->getId() : $this->cookie->get('targetbay_session_id');
501
+ $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : $this->cookie->get('targetbay_session_id'); else:
502
+ $data['user_id'] = $customer->isLoggedIn() ? $customer->getId() : Mage::getSingleton('core/session')->getTrackingSessionId();
503
+ $data['session_id'] = $customer->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : Mage::getSingleton('core/session')->getTrackingSessionId();
504
+ endif;
505
+
506
+ $data['user_name'] = $customer->isLoggedIn() ? $customer->getCustomer()->getName() : Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
507
+ $data['user_mail'] = $customer->isLoggedIn() ? $customer->getCustomer()->getEmail() : Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
508
+
509
+ $data['order_id'] = Mage::getSingleton('checkout/session')->getQuoteId();
510
+ $data['utm_sources'] = $this->cookie->get('utm_source') ? $this->cookie->get('utm_source') : '';
511
+ $data['utm_token'] = $this->cookie->get('utm_token') ? $this->cookie->get('utm_token') : '';
512
+ $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
513
+ $pageTitle = Mage::app()->getLayout()->getBlock('head') ? Mage::app()->getLayout()->getBlock('head')->getTitle() : Mage::getSingleton('checkout/session')->getTitle();
514
+ $data['page_title'] = addslashes($pageTitle);
 
 
515
  } catch (Exception $e) {
516
+ $this->debug('Error message ' . $e->getMessage());
 
517
  }
518
+
519
+ return $data;
520
  }
521
+
522
  /**
523
  * Get the common info for quote or order, billing and shipping
524
  *
525
+ * @param $object
526
+ * @return array
527
  */
528
  public function getSessionInfo($object)
529
  {
530
+ $data = array();
531
+ try {
532
+ $trackingType = $this->getTrackingType();
533
+ if ($trackingType == 1):
534
+ $data['user_id'] = $object->getCustomerId() ? $object->getCustomerId() : $this->cookie->get('targetbay_session_id');
535
+ $data['session_id'] = Mage::getSingleton('customer/session')->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : $this->cookie->get('targetbay_session_id'); else:
536
+ $data['user_id'] = $object->getCustomerId() ? $object->getCustomerId() : Mage::getSingleton('core/session')->getTrackingSessionId();
537
+ $data['session_id'] = Mage::getSingleton('customer/session')->isLoggedIn() ? Mage::getSingleton('core/session')->getCustomerSessionId() : Mage::getSingleton('core/session')->getTrackingSessionId();
538
+ endif;
539
+
540
+ $data['utm_sources'] = $this->cookie->get('utm_source') ? $this->cookie->get('utm_source') : '';
541
+ $data['utm_token'] = $this->cookie->get('utm_token') ? $this->cookie->get('utm_token') : '';
542
+ $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
543
+ $pageTitle = Mage::app()->getLayout()->getBlock('head') ? Mage::app()->getLayout()->getBlock('head')->getTitle() : Mage::getSingleton('checkout/session')->getTitle();
544
+ $data['page_title'] = addslashes($pageTitle);
 
 
545
  } catch (Exception $e) {
546
+ $this->debug('Error message ' . $e->getMessage());
 
547
  }
548
+
549
+ return $data;
550
  }
551
+
552
  /**
553
  * Get the Order data
554
  *
555
+ * @param $object
556
+ * @return array
557
  */
558
  public function getInfo($object)
559
+ {
560
+ try {
561
+ //$customer = $object->getCustomer();
562
+ //$items = $object->getAllVisibleItems();
563
+
564
+ $data = $this->getSessionInfo($object);
565
+ $data['first_name'] = $object->getCustomerFirstname();
566
+ $data['last_name'] = $object->getCustomerLastname();
567
+ $guestUsername = $object->getCustomerFirstname() . ' ' . $object->getCustomerLastname();
568
+ $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
569
+ $data['user_name'] = $object->getCustomerIsGuest() ? $gName : $data['first_name'] . ' ' . $data['last_name'];
570
+ $data['user_mail'] = $object->getCustomerEmail();
571
+ $data['order_id'] = $object->getId();
572
+ $data['order_price'] = $object->getSubtotal();
573
+ $data['order_quantity'] = $object->getData('total_qty_ordered');
574
+ $data['shipping_method'] = $object->getData('shipping_description');
575
+ $data['shipping_price'] = $object->getData('shipping_amount');
576
+ $data['tax_amount'] = $object->getData('tax_amount');
577
+ $data['payment_method'] = $object->getPayment()->getMethodInstance()->getTitle();
578
+ $data['cart_items'] = $this->getOrderItemsInfo($object);
579
  } catch (Exception $e) {
580
+ $this->debug('Error message ' . $e->getMessage());
 
581
  }
582
+
583
+ return $data;
584
  }
585
+
586
  /**
587
  * Get the Order data
588
  *
589
+ * @param $object
590
+ * @return array
591
  */
592
  public function getOrderInfo($object)
593
+ {
594
+ $data = array();
595
  try {
596
+ //$customer = $object->getCustomer();
597
+ //$items = $object->getAllVisibleItems();
598
+
599
+ $data['user_id'] = $object->getCustomerIsGuest() ? self::ANONYMOUS_USER : $object->getCustomerId();
600
+ $data['first_name'] = $object->getCustomerFirstname();
601
+ $data['last_name'] = $object->getCustomerLastname();
602
+ $guestUsername = $object->getCustomerFirstname() . ' ' . $object->getCustomerLastname();
603
  $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
604
+ $data['user_name'] = $object->getCustomerIsGuest() ? $gName : $data['first_name'] . ' ' . $data['last_name'];
605
+ $data['user_mail'] = $object->getCustomerEmail();
606
+ $data['order_id'] = $object->getId();
607
+ $data['order_status'] = $object->getStatus();
608
+ $data['order_price'] = $object->getSubtotal();
609
+ $data['order_quantity'] = $object->getData('total_qty_ordered');
610
  $data['shipping_method'] = $object->getData('shipping_description');
611
+ $data['shipping_price'] = $object->getData('shipping_amount');
612
+ $data['tax_amount'] = $object->getData('tax_amount');
613
+ $data['payment_method'] = $object->getPayment()->getMethodInstance()->getTitle();
614
+ $data['cart_items'] = $this->getOrderItemsInfo($object);
 
615
  } catch (Exception $e) {
616
+ $this->debug('Error message ' . $e->getMessage());
 
617
  }
618
+
619
+ return $data;
620
  }
621
+
622
  /**
623
  * Collect the order items info
624
  *
625
+ * @param $order
626
+ * @param $orderExportApi
627
+ * @return array
628
  */
629
  public function getOrderItemsInfo($order, $orderExportApi = false)
630
+ {
631
+ $dataItems = array();
632
+ try {
633
+ $items = $order->getAllVisibleItems();
634
+ foreach ($items as $orderItem) {
635
+ $dataItem = $this->getItemInfo($orderItem);
636
+ if ($customOptions = $this->getCustomOptionsInfo($orderItem, $orderExportApi)) {
637
+ $dataItem['attributes'] = $customOptions;
638
+ }
639
+ $dataItems[] = $dataItem;
640
+ }
641
  } catch (Exception $e) {
642
+ $this->debug('Error message ' . $e->getMessage());
 
643
  }
644
+
645
+ return $dataItems;
646
  }
647
+
648
  /**
649
+ * Collect the order payment info.
650
  *
651
+ * @param $orderId
652
+ * @param $orderExportApi
653
+ * @return string
654
  */
655
  public function getPaymentInfo($orderId, $orderExportApi = false)
656
  {
657
+ $paymentTitle = '';
658
+ $paymentMethod = '';
659
+ try {
660
+ $paymentCollection = Mage::getModel('sales/order_payment')->getCollection()->addFieldToFilter('parent_id', $orderId);
661
+ foreach ($paymentCollection as $paymentDetails) {
662
+ $paymentMethod = $paymentDetails->getMethod();
663
+ }
664
+
665
+ $store = Mage::app()->getStore();
666
+ $path = 'payment/' . $paymentMethod . '/title';
667
+ $paymentTitle = Mage::getStoreConfig($path, $store);
668
  } catch (Exception $e) {
669
+ $this->debug('Error message ' . $e->getMessage());
 
670
  }
671
+
672
+ return $paymentTitle;
673
  }
674
+
675
  /**
676
  * Get the item info
677
  *
678
+ * @param $item
679
+ * @param $actionType
680
+ * @return array
681
  */
682
  public function getItemInfo($item, $actionType = false)
683
  {
684
+ $dataItem = array();
685
+ try {
686
+ $product = Mage::getModel('catalog/product')->load($item->getData('product_id'));
687
+ $dataItem['type'] = $item->getProductType();
688
+ $dataItem['product_id'] = $item->getProductId();
689
+ $dataItem['product_sku'] = $item->getSku();
690
+ $dataItem['product_name'] = addslashes($item->getName());
691
+ $dataItem['price'] = $actionType ? $item->getProduct()->getPrice() : $item->getPrice();
692
+ $dataItem['special_price'] = $product->getSpecialPrice();
693
+ $qty = $actionType ? $item->getProduct()->getQty() : $item->getQty();
694
+ $dataItem['productimg'] = $this->getImageUrl($product, 'image');
695
+
696
+ $dataItem['category'] = $this->getProductCategory($product);
697
+ $dataItem['category_name'] = $this->getProductCategoryName($product);
698
+ $dataItem['quantity'] = ($item->getData('qty_ordered')) ? $item->getData('qty_ordered') : $qty;
699
+ $dataItem['page_url'] = Mage::getUrl($product->getUrlPath());
 
700
  } catch (Exception $e) {
701
+ $this->debug('Error message ' . $e->getMessage());
 
702
  }
703
+
704
+ return $dataItem;
705
  }
706
+
707
  /**
708
  * Get the product categories
709
  *
710
+ * @param $product
711
+ * @return string
712
+ */
713
  public function getProductCategoryName($product)
714
  {
715
  $categoryIds = $product->getCategoryIds();
 
716
  $productCategories = array();
717
+ $categoryName = '';
718
+ $quotes = array("'", '"');
719
+ $replace = array('', '');
720
+
721
  if (count($categoryIds)) {
722
  foreach ($categoryIds as $categoryId) {
723
+ $_category = Mage::getModel('catalog/category')->load($categoryId);
724
+ $productCategories[] = str_replace($quotes, $replace, $_category->getName());
725
  }
726
+
727
  $categoryName = implode(',', $productCategories);
728
  }
729
+
730
  return $categoryName;
731
  }
732
+
733
  /**
734
  * Get the product categories
735
  *
736
+ * @param $product
737
+ * @return string
738
+ */
739
  public function getProductCategory($product)
740
  {
741
+ $categoryIds = $product->getCategoryIds();
742
+ //$productCategories = [];
743
+ $categoryId = '';
744
  if (count($categoryIds)) {
745
+ //foreach ($categoryIds as $categoryId) {
746
+ // $_category = Mage::getModel('catalog/category')->load($categoryId);
747
+ // $productCategories[] = $_category->getName();
748
+ //}
 
749
 
750
  $categoryId = implode(',', $categoryIds);
751
  }
752
+
753
  return $categoryId;
754
  }
755
+
756
  /**
757
  * Get the item custom options
758
  *
759
+ * @param $item
760
+ * @param $orderExportApi
761
+ * @return array|bool
762
  */
763
  public function getCustomOptionsInfo($item, $orderExportApi)
764
  {
765
+ $optionsData = array();
766
+ try {
767
+ $customOptions = $orderExportApi ? $item->getProductOptions() : $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
768
+
769
+ if (empty($customOptions['options']) && empty($customOptions['attributes_info'])) {
770
+ return false;
771
+ }
772
+ $superAttributeInfo = isset($customOptions['attributes_info']) ? $this->getOptionValues($customOptions['attributes_info']) : array();
773
+ $customOptionInfo = isset($customOptions['options']) ? $this->getOptionValues($customOptions['options']) : array();
774
+ $optionsData = array_merge($superAttributeInfo, $customOptionInfo);
775
  } catch (Exception $e) {
776
+ $this->debug('Error message ' . $e->getMessage());
 
777
  }
778
+
779
+ return $optionsData;
780
  }
781
+
782
  /**
783
  * Get the options values
784
  *
785
+ * @param $options
786
+ * @return array
787
  */
788
  public function getOptionValues($options)
789
  {
790
  $optionData = array();
791
+ try {
792
+ foreach ($options as $option) {
793
+ $data['label'] = $option['label'];
794
+ $data['value'] = $option['value'];
795
+ $optionData[] = $data;
796
+ }
 
797
  } catch (Exception $e) {
798
+ $this->debug('Error message ' . $e->getMessage());
 
799
  }
800
+
801
+ return $optionData;
802
  }
803
+
804
  /**
805
  * Get the order or quote address by address type.
806
  *
807
+ * @param $object
808
+ * @param $type
809
+ * @return array
810
  */
811
  public function getAddressData($object, $type)
812
  {
813
+ try {
814
+ $address = ($type == self::SHIPPING) ? $object->getShippingAddress() : $object->getBillingAddress();
815
+ $addressData = $this->getSessionInfo($object);
816
+ $addressData['first_name'] = $address->getFirstname();
817
+ $addressData['last_name'] = $address->getLastname();
818
+ $guestUsername = $address->getFirstname() . ' ' . $address->getLastname();
819
+ $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
820
+ $addressData['user_name'] = $object->getCustomerIsGuest() ? $gName : $addressData['first_name'] . ' ' . $addressData['last_name'];
821
+ $addressData['order_id'] = $object->getId();
822
+ $addressData['user_mail'] = $object->getCustomerEmail();
823
+ $addressData['address1'] = $address->getStreet(1);
824
+ $addressData['address2'] = $address->getStreet(2);
825
+ $addressData['city'] = $address->getCity();
826
+ $addressData['state'] = $address->getRegion();
827
+ $addressData['zipcode'] = $address->getPostcode();
828
+
829
+ $countryName = '';
830
+ if ($address->getCountryId()) {
831
+ $countryName = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
832
+ }
833
+
834
+ $addressData['country'] = $countryName !== '' ? $countryName : $address->getCountryId();
835
+ $addressData['phone'] = $address->getTelephone();
836
  } catch (Exception $e) {
837
+ $this->debug('Error message ' . $e->getMessage());
 
838
  }
839
+
840
+ return $addressData;
841
  }
842
+
843
  /**
844
  * Get the product info
845
  *
846
+ * @param $product
847
+ * @return array
848
  */
849
  public function getProductData($product)
850
+ {
851
+ $configOptions = array();
852
+ $customOptions = array();
853
+ $data = array();
854
+ try {
855
+ $data['image_url'][] = $this->getProductImages($product);
856
+ $data['entity_id'] = $product->getId();
857
+ $data['attribute_set_id'] = $product->getEntityTypeId();
858
+ $data['type_id'] = $product->getTypeId();
859
+ $data['sku'] = $product->getSku();
860
+ $data['product_status'] = $product->getStatus();
861
+ $data['currency_type'] = Mage::app()->getStore()->getCurrentCurrencyCode();
862
+
863
+ $stockItem = Mage::getModel('cataloginventory/stock_item');
864
+ $stockItem->loadByProduct($product);
865
+ $data['stock_count'] = ($stockItem->getQty() > 0) ? $stockItem->getQty() : $stockItem->getMaxSaleQty();
866
+
867
+ $data['visibility'] = $product->getVisibility();
868
+ $data['description'] = $product->getDescription();
869
+ $data['price'] = $product->getPrice();
870
+ $data['special_price'] = $product->getSpecialPrice();
871
+ $data['weight'] = $product->getWeight();
872
+ $data['name'] = addslashes($product->getName());
873
+
874
+ $data['category'] = $this->getProductCategory($product);
875
+
876
+ // Get product url key
877
+ if($product->getUrlKey() != '') {
878
+ $urlKey = $product->getUrlKey();
879
+ } else {
880
+ $urlKey = $product->getProductUrl();
881
+ }
882
+ $data['url_key'] = $urlKey;
883
+ $data['full_url_key'] = $product->getProductUrl();
884
+
885
+ if ($configData = $product->getData('configurable_attributes_data')) {
886
+ $configOptions = $this->productOptions($configData, 'label');
887
+ }
888
+ if ($custOptions = $product->getData('product_options')) {
889
+ $customOptions = $this->productOptions($custOptions);
890
+ }
891
+ $options = array_merge($configOptions, $customOptions);
892
+ if (!empty($options)) {
893
+ $data['attributes'] = $options;
894
  }
 
895
  } catch (Exception $e) {
896
+ $this->debug('Error message ' . $e->getMessage());
 
897
  }
898
+
899
+ return $data;
900
  }
901
+
902
  /**
903
  * Get the product options when saving product
904
  *
905
+ * @param $configData
906
+ * @param string $customOption
907
+ * @return array
908
  */
909
  public function productOptions($configData, $customOption = 'title')
910
  {
911
  $options = array();
912
+ try {
913
+ foreach ($configData as $cdata) {
914
+ $attrLabel = $cdata[$customOption];
915
+ if (!isset($cdata['values'])) {
916
+ $options[] = array(
917
+ 'label' => $attrLabel,
918
+ 'value' => $attrLabel
919
+ );
920
+ continue;
921
+ }
922
+ foreach ($cdata['values'] as $val) {
923
+ $attrVal = $val[$customOption];
924
+ $options[] = array(
925
+ 'label' => $attrLabel,
926
+ 'value' => $attrVal
927
+ );
928
+ }
929
+ }
 
930
  } catch (Exception $e) {
931
+ $this->debug('Error message ' . $e->getMessage());
 
932
  }
933
+
934
+ return $options;
935
  }
936
+
937
  /**
938
  * Get the product images
939
  *
940
+ * @param $product
941
  * @return string
942
  */
943
  public function getProductImages($product)
944
  {
945
  $images = array();
946
  try {
947
+ $largeImage = $this->getImageUrl($product, 'image');
948
+ $smallImage = $this->getImageUrl($product, 'small_image');
949
+ $thumbImage = $this->getImageUrl($product, 'thumbnail');
950
+ if (!empty($largeImage)) {
951
+ $images['url'] = $this->getImageUrl($product, 'image');
952
+ }
953
+ if (!empty($smallImage)) {
954
+ $images['thumbnail_image'] = $this->getImageUrl($product, 'small_image');
955
+ }
956
+ if (!empty($smallImage)) {
957
+ $images['medium_image'] = $this->getImageUrl($product, 'thumbnail');
958
+ }
959
+ $images['position'] = 1;
960
+ return $images;
961
  } catch (Exception $e) {
962
+ $this->debug('Error message ' . $e->getMessage());
963
  return;
964
  }
965
  }
966
+
967
  /**
968
  * Get the Product image url
969
  *
970
+ * @param $product
971
+ * @param $imageType
972
  * @return string
973
  */
974
  public function getImageUrl($product, $imageType)
975
  {
976
+ $imgPath = '';
977
+ if ($product->getData($imageType)) {
978
+ $productImage = $product->getData($imageType);
979
+ if (!empty($productImage) && $productImage != 'no_selection') {
980
+ $imgPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getData($imageType);
981
+ }
982
  }
983
 
984
  return $imgPath;
985
  }
986
+
987
  /**
988
  * Check the order full fillment
989
  *
991
  */
992
  public function isFullFillmentProcess($params)
993
  {
994
+ if (isset($params[self::ORDER_SHIPMENT]) ||
995
+ isset($params[self::ORDER_INVOICE]) ||
996
  isset($params[self::ORDER_REFUND])
997
  ) {
998
  return true;
999
  }
1000
  return false;
1001
  }
1002
+
1003
  /**
1004
  * Get the wishlist product info
1005
  *
1006
+ * @param $productId
1007
  * @return string
1008
  */
1009
  public function getWishlistProductInfo($productId)
1010
  {
1011
+ $data = array();
1012
+ try {
1013
+ $product = Mage::getModel('catalog/product')->load($productId);
1014
+ $qty = 1;
1015
+
1016
+ $data['type'] = $product->getTypeId();
1017
+ $data['product_id'] = $product->getId();
1018
+ $data['product_sku'] = $product->getSku();
1019
+ $data['name'] = addslashes($product->getName());
1020
+ $data['price'] = $product->getPrice();
1021
+ $data['special_price'] = $product->getSpecialPrice();
1022
+ $data['productimg'] = $this->getImageUrl($product, 'image');
1023
+
1024
+ $data['category'] = $this->getProductCategory($product);
1025
+ $data['category_name'] = $this->getProductCategoryName($product);
1026
+ $data['quantity'] = (Mage::app()->getRequest()->getParam('qty')) ? Mage::app()->getRequest()->getParam('qty') : $qty;
1027
+ $data['page_url'] = Mage::getUrl($product->getUrlPath());
 
 
1028
  } catch (Exception $e) {
1029
+ $this->debug('Error message ' . $e->getMessage());
 
1030
  }
1031
+
1032
+ return $data;
1033
  }
1034
+
1035
  /**
1036
  * Collect the wishlist items info
1037
  *
1038
+ * @param $productIds
1039
  * @return multitype:unknown
1040
  */
1041
  public function getWishlistItemsInfo($wishlistInfo)
1042
+ {
1043
+ $dataItems = array();
1044
+ try {
1045
+ $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
1046
+
1047
+ foreach ($wishlistItemCollection as $id => $wishlistItem) {
1048
+ $product = $wishlistItem->getProduct();
1049
+ $dataItem = $this->wishlistProductInfo($product);
1050
+ $dataItems[$id] = $dataItem;
1051
+ }
 
1052
  } catch (Exception $e) {
1053
+ $this->debug('Error message ' . $e->getMessage());
 
1054
  }
1055
+
1056
+ return $dataItems;
1057
  }
1058
+
1059
  /**
1060
  * Collect the wishlist items product info
1061
  *
1062
+ * @param $product
1063
+ * @return array
1064
+ */
1065
  public function wishlistProductInfo($product)
1066
  {
1067
+ $dataItem = array();
1068
+ try {
1069
+ $product = Mage::getModel('catalog/product')->load($product->getData('entity_id'));
1070
+ $dataItem['type'] = $product->getTypeId();
1071
+ $dataItem['product_id'] = $product->getId();
1072
+ $dataItem['product_name'] = addslashes($product->getName());
1073
+ $dataItem['price'] = $product->getPrice();
1074
+ $dataItem['special_price'] = $product->getSpecialPrice();
1075
+ $dataItem['productimg'] = $this->getImageUrl($product, 'image');
1076
+ $dataItem['category'] = $this->getProductCategory($product);
1077
+ $dataItem['category_name'] = $this->getProductCategoryName($product);
1078
+ $dataItem['page_url'] = Mage::getUrl($product->getUrlPath());
 
1079
  } catch (Exception $e) {
1080
+ $this->debug('Error message ' . $e->getMessage());
 
1081
  }
1082
+
1083
+ return $dataItem;
1084
  }
1085
+
1086
  /**
1087
  *
1088
+ * @param $order
1089
+ * @param $params
1090
+ * @return array
1091
  */
1092
  public function getFullFillmentData($order, $params)
1093
  {
1094
+ $shipmentItems = array();
1095
+ $shipmentsInfo = array();
1096
+ try {
1097
+ if (isset($params[self::ORDER_SHIPMENT])) {
1098
+ $shipmentsInfo['order_id'] = $order->getId();
1099
+ $shipmentsInfo['order_status'] = $order->getStatus();
1100
+ $shipmentsInfo['total_ordered_qty'] = (int) $order->getData('total_qty_ordered');
1101
+ $shipmentsInfo['user_id'] = $order->getData('customer_is_guest') ? self::ANONYMOUS_USER : $order->getData('customer_id');
1102
+ $shipmentsInfo['user_mail'] = $order->getData('customer_is_guest') ? $order->getData('customer_email') : $order->getData('customer_email');
1103
+ $shipmentsInfo['created_at'] = $order->getData('updated_at');
1104
+
1105
+ foreach ($order->getAllVisibleItems() as $item) {
1106
+ if ($item->getQtyShipped() == '') {
1107
+ continue;
1108
+ }
1109
+ $shipmentItemInfo['product_id'] = $item->getProductId();
1110
+ $shipmentItemInfo['name'] = addslashes($item->getName());
1111
+ $shipmentItemInfo['sku'] = $item->getSku();
1112
+ $shipmentItemInfo['qty_ordered'] = (int) $item->getQtyOrdered();
1113
+ $shipmentItemInfo['qty_shipped'] = (int) $item->getQtyShipped();
1114
+ $shipmentItems[] = $shipmentItemInfo;
1115
+ }
1116
+ $shipmentsInfo['shipment_items'] = $shipmentItems;
1117
+ }
1118
  } catch (Exception $e) {
1119
+ $this->debug('Error message ' . $e->getMessage());
 
1120
  }
1121
+
1122
+ return $shipmentsInfo;
1123
  }
1124
+
1125
  /**
1126
+ * Stop the page visit for already tracked events.
1127
  *
1128
+ * @param $eventName
1129
+ * @return bool
1130
  */
1131
  public function eventAlreadyTracked($eventName)
1132
  {
1133
  $stopAction = array(
1134
+ 'cms_index_index',
1135
  'catalog_category_view',
1136
  'catalog_product_view',
1137
  'catalogsearch_result_index',
1156
  'checkout_onepage_progress',
1157
  'checkout_onepage_saveOrder'
1158
  );
1159
+
1160
+ return in_array($eventName, $stopAction, true);
1161
  }
1162
+
1163
  /**
1164
  * debugging
1165
  *
1166
+ * @param $mess
1167
  */
1168
  public function debug($mess, $logFile = null)
1169
  {
1170
+ if ($this->logEnabled()) {
1171
  Mage::log($mess, null, $logFile ? $logFile : $this->getLogFileName());
1172
+ }
1173
  }
1174
+
1175
  /**
1176
  * debugging
1177
  *
1178
+ * @return string
1179
  */
1180
  public function getProductVersion()
1181
  {
1182
+ return (string) Mage::getConfig()->getModuleConfig('Targetbay_Tracking')->version;
1183
  }
1184
+
1185
  /**
1186
  * Visiting page info
1187
  *
1188
+ * @return array
 
 
1189
  */
1190
  public function getPageVisitData()
1191
+ {
1192
  Mage::getModel('tracking/observer')->setCookieValues();
1193
+
1194
+ // Set Token Values.
1195
  if (isset($_GET['utm_source']) && !$this->cookie->get('utm_source')) {
1196
  $this->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
1197
  }
1198
+
1199
  if (isset($_GET['token']) && !$this->cookie->get('utm_token')) {
1200
  $this->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
1201
  }
 
 
 
1202
 
1203
+ // Page Visit Tracking.
1204
+ return $this->visitInfo();
1205
  }
1206
+
1207
  /**
1208
  * Category view page
1209
  *
1210
+ * @return array
 
 
1211
  */
1212
  public function getCategoryViewData()
1213
+ {
1214
+ $category = Mage::registry('current_category');
1215
+ $data = $this->visitInfo();
1216
+ $quotes = array("'", '"');
1217
+ $replace = array('', '');
1218
+ $data['category_id'] = $category->getId();
1219
+ $data['category_url'] = $category->getUrl();
1220
+ $data['category_name'] = str_replace($quotes, $replace, $category->getName());
1221
 
1222
  return $data;
1223
  }
1224
+
1225
  /**
1226
  * Product view page
1227
  *
1228
+ * @param Varien_Event_Observer $observer
1229
  *
1230
  * @return void
1231
  */
1232
  public function getProductViewData()
1233
  {
1234
+ $data = array();
1235
+
1236
+ // Get the base visit info.
1237
+ try {
1238
+ $data = $this->visitInfo();
1239
+ $product = Mage::registry('product');
1240
+ $categoryIds = $product->getCategoryIds();
1241
+ $quotes = array("'", '"');
1242
+ $replace = array('', '');
1243
+ if (count($categoryIds)) {
1244
+ $firstCategoryId = $categoryIds[0];
1245
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
1246
+ $data['category'] = str_replace($quotes, $replace, $_category->getName());
1247
+ }
1248
+ $data['product_id'] = $product->getId();
1249
+ $data['product_name'] = str_replace($quotes, $replace, $product->getName());
1250
+ $data['price'] = $product->getPrice();
1251
+ $data['special_price'] = $product->getSpecialPrice();
1252
+ $data['productimg'] = $product->getImageUrl();
1253
+ $data['stock'] = self::OUT_OF_STOCK;
1254
+ $stock = $product->getStockItem();
1255
+ if ($stock->getIsInStock()) {
1256
+ $data['stock'] = self::IN_STOCK;
1257
+ }
1258
  } catch (Exception $e) {
1259
+ $this->debug('Error message ' . $e->getMessage());
 
1260
  }
1261
+
1262
+ return $data;
1263
  }
1264
+
1265
  /**
1266
  * Catalog search result page
1267
  *
1268
+ * @param Varien_Event_Observer $observer
1269
  *
1270
  * @return void
1271
  */
1272
  public function getCatalogSearchResultData()
1273
  {
1274
+ $data = array();
 
1275
  try {
1276
+ $quotes = array("'", '"');
1277
+ $replace = array('', '');
1278
  $keyword = Mage::app()->getRequest()->getParam('q');
1279
  if (empty($keyword)) {
1280
  return false;
1281
  }
1282
+ $data = $this->visitInfo();
1283
+ $data['keyword'] = str_replace($quotes, $replace, $keyword);
 
1284
  } catch (Exception $e) {
1285
+ $this->debug('Error message ' . $e->getMessage());
 
1286
  }
1287
+
1288
+ return $data;
1289
  }
1290
+
1291
  /**
1292
  * Get the page info for static page
1293
+ *
1294
  * @return string
1295
+ */
1296
  public function getPageInfo()
1297
+ {
1298
+ $controllerName = Mage::app()->getRequest()->getControllerName();
1299
+ $moduleName = Mage::app()->getRequest()->getModuleName();
1300
 
1301
+ if ($moduleName === 'cms') {
1302
  $data = $this->getPageVisitData();
1303
+ } elseif ($controllerName === 'category') {
1304
  $data = $this->getCategoryViewData();
1305
+ } elseif ($controllerName === 'product') {
1306
  $data = $this->getProductViewData();
1307
+ } elseif ($moduleName === 'catalogsearch') {
1308
  $data = $this->getCatalogSearchResultData();
1309
  }
1310
  $data['index_name'] = $this->getApiIndex();
1311
+
1312
  return $data;
1313
  }
1314
+
1315
  /**
1316
  * Get the api url for static pages
1317
+ *
1318
  * @return string
1319
+ */
1320
  public function getApiUrl()
1321
+ {
1322
+ $controllerName = Mage::app()->getRequest()->getControllerName();
1323
+ $moduleName = Mage::app()->getRequest()->getModuleName();
1324
+
1325
+ $type = '';
1326
+ if ($moduleName === 'cms') {
1327
+ $type = 'page-visit';
1328
+ } elseif ($controllerName === 'category') {
1329
+ $type = 'category-view';
1330
+ } elseif ($controllerName === 'product') {
1331
+ $type = 'product-view';
1332
+ } elseif ($moduleName === 'catalogsearch') {
1333
+ $type = 'searched';
 
 
 
 
1334
  }
1335
+
1336
+ return $type !== '' ? $this->getHostname() . $type . '?api_token=' . $this->getApiToken() : '';
1337
  }
1338
+
1339
  /**
1340
  * Get the quote items
1341
  *
1342
+ * @param $items
1343
+ * @param $orderExportApi
1344
  * @return unknown
1345
+ */
1346
  public function getQuoteItems($items, $orderExportApi = false)
1347
  {
1348
  $dataItems = array();
1349
+ try {
1350
+ foreach ($items as $item) {
1351
+ $dataItem = $this->getItemInfo($item);
1352
+ if ($customOptions = $this->getCustomOptionsInfo($item, $orderExportApi)) {
1353
+ $dataItem['attributes'] = $customOptions;
1354
+ }
1355
+ $dataItems[$item->getId()] = $dataItem;
1356
+ }
1357
  } catch (Exception $e) {
1358
+ $this->debug('Error message ' . $e->getMessage());
 
1359
  }
1360
+
1361
+ return $dataItems;
1362
  }
1363
+
1364
  /**
1365
  * Get the customer address data based on the action
1366
  *
1367
+ * @param $addressId
1368
+ * @return array
1369
  */
1370
  public function getCustomerAddressData($addressId)
1371
  {
1372
+ $data = array();
1373
+ try {
1374
+ $address = Mage::getModel('customer/address');
1375
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
1376
+ $data['user_id'] = $customer->getId();
1377
+ $data['user_name'] = $customer->getName();
1378
+ $data['user_mail'] = $customer->getEmail();
1379
+ if ($addressId) {
1380
+ $existsAddress = $address->load($addressId);
1381
+ $data['address_id'] = $addressId;
1382
+ $data['old_address'] = $this->getExistingAddressData($existsAddress);
1383
+ }
1384
+ $data['new_address'] = $this->getNewAddressData();
1385
+ $data['timestamp'] = strtotime($this->date->date('Y-m-d'));
1386
+ $data['ip_address'] = Mage::helper('core/http')->getRemoteAddr();
1387
+ $data['user_agent'] = Mage::helper('core/http')->getHttpUserAgent();
 
1388
  } catch (Exception $e) {
1389
+ $this->debug('Error message ' . $e->getMessage());
 
1390
  }
1391
+
1392
+ return $data;
1393
  }
1394
+
1395
  /**
1396
  * Get the customer address data based on the action
1397
+ *
1398
+ * @return array
1399
+ */
1400
  public function getNewAddressData()
1401
  {
1402
+ $request = Mage::app()->getRequest();
1403
+ $addressData = array();
1404
+ try {
1405
+ $addressData['firstname'] = $request->getParam('firstname');
1406
+ $addressData['lastname'] = $request->getParam('lastname');
1407
+ $addressData['company'] = $request->getParam('company');
1408
+ $addressData['street'] = implode('', $request->getParam('street'));
1409
+ $addressData['city'] = $request->getParam('city');
1410
+ $addressData['region_id'] = $request->getParam('region_id');
1411
+ $addressData['region'] = $request->getParam('region');
1412
+ $addressData['postcode'] = $request->getParam('postcode');
1413
+ $addressData['country_id'] = $request->getParam('country_id');
1414
+ $addressData['telephone'] = $request->getParam('telephone');
 
1415
  } catch (Exception $e) {
1416
+ $this->debug('Error message ' . $e->getMessage());
 
1417
  }
1418
+
1419
+ return $addressData;
1420
  }
1421
+
1422
  /**
1423
  * Get the customer existing address data
1424
+ *
1425
  * @return multitype:unknown
1426
+ */
1427
  public function getExistingAddressData($existsAddress)
1428
  {
1429
+ $addressData = array();
1430
+ try {
1431
+ $addressData['firstname'] = $existsAddress->getFirstname();
1432
+ $addressData['lastname'] = $existsAddress->getLastname();
1433
+ $addressData['company'] = $existsAddress->getCompany();
1434
+ $addressData['street'] = $existsAddress->getStreet();
1435
+ $addressData['city'] = $existsAddress->getCity();
1436
+ $addressData['region_id'] = $existsAddress->getRegionId();
1437
+ $addressData['region'] = $existsAddress->getRegion();
1438
+ $addressData['postcode'] = $existsAddress->getPostcode();
1439
+ $addressData['country_id'] = $existsAddress->getCountryId();
1440
+ $addressData['telephone'] = $existsAddress->getTelephone();
 
1441
  } catch (Exception $e) {
1442
+ $this->debug('Error message ' . $e->getMessage());
 
1443
  }
1444
+
1445
+ return $addressData;
1446
  }
1447
+
1448
  /**
1449
  * Get the targetbay review count and rating for product
1450
+ *
1451
  * @return array
1452
+ */
1453
  public function getRichSnippets()
1454
+ {
1455
+ if (!$this->trackingEnabled()) {
1456
+ return false;
1457
+ }
1458
+
1459
  $data = array();
1460
+ $responseData = '';
1461
+ $controllerName = Mage::app()->getRequest()->getControllerName();
1462
+ $moduleName = Mage::app()->getRequest()->getModuleName();
1463
+ $reviewProductId = Mage::getSingleton('core/session')->getProductReviewId();
1464
+ $tbReviewCount = Mage::getSingleton('core/session')->getProductReviewCacheCount();
1465
+
1466
  try {
1467
+ $type = self::RATINGS_STATS;
1468
+ $apiToken = '?api_token=' . $this->getApiToken();
1469
+ $feedUrl = $this->getHostname() . $type . $apiToken;
1470
+ $data['index_name'] = $this->getApiIndex();
1471
+ $productId = '';
1472
+ if ($moduleName === 'catalog' && $controllerName === 'product') {
1473
+ $productId = Mage::registry('product')->getId();
1474
+ $data['product_id'] = $productId;
1475
+ if ($reviewProductId != $productId) {
1476
+ Mage::getSingleton('core/session')->unsProductReviewCount();
1477
+ Mage::getSingleton('core/session')->unsProductReviewResponse();
1478
+ $productReviewCount = '';
1479
+ } else {
1480
+ $productReviewCount = Mage::getSingleton('core/session')->getProductReviewCount();
 
 
 
 
1481
  }
1482
  }
1483
 
1484
+ if ($productReviewCount != $tbReviewCount || $productReviewCount == '') {
1485
+ $jsondata = json_encode($data);
1486
+ $response = $this->postPageInfo($feedUrl, $jsondata);
1487
+ $responseBody = json_decode($response);
1488
+
1489
+ if (!empty($responseBody) && $responseBody->reviews_count > 0) {
1490
+ $_SESSION['last_session'] = time();
1491
+ Mage::getSingleton('core/session')->setProductReviewCount($responseBody->reviews_count);
1492
+ Mage::getSingleton('core/session')->setProductReviewResponse($responseBody);
1493
+ if (!empty($productId)) {
1494
+ Mage::getSingleton('core/session')->setProductReviewId($productId);
1495
+ }
1496
+ Mage::getSingleton('core/session')->unsProductReviewCacheCount();
1497
+ }
1498
+ } else {
1499
+ $responseBody = Mage::getSingleton('core/session')->getProductReviewResponse();
1500
+ }
1501
+ if (!empty($responseBody)) {
1502
+ $averageScore = $responseBody->reviews_average;
1503
+ $reviewsCount = $responseBody->reviews_count;
1504
+ $reviewsDetails = $responseBody->reviews;
1505
+ $responseData = array(
1506
+ 'average_score' => $averageScore,
1507
+ 'reviews_count' => $reviewsCount,
1508
+ 'reviews' => $reviewsDetails
1509
+ );
1510
+ return $responseData;
1511
+ }
1512
+ } catch (Exception $e) {
1513
+ $this->debug('Error message ' . $e->getMessage());
1514
+ return;
1515
  }
1516
  }
1517
+
1518
  /**
1519
  * Get the targetbay review count and dynamic ids
1520
+ *
1521
  * @return array
1522
+ */
1523
  public function getTargetbayReviewId()
1524
+ {
1525
  $itemRefData = array();
1526
  $itemRef = '';
1527
  try {
1528
+ $trackingSnippet = $this->getRichSnippets();
1529
+ if ($trackingSnippet['reviews_count'] > 0) {
1530
+ foreach ($trackingSnippet['reviews'] as $key => $aggregateReviewDetails) {
1531
+ $itemRefData[] = 'tb-review-' . $key;
1532
+ }
1533
+ $itemRef = implode(' ', $itemRefData);
1534
+ }
1535
+ return $itemRef;
1536
+ } catch (Exception $e) {
1537
+ $this->debug('Error message ' . $e->getMessage());
1538
+ return;
1539
  }
1540
  }
1541
+
1542
  /**
1543
  * Get the targetbay review count and rating for product
1544
+ *
1545
  * @return array
1546
+ */
1547
  public function getSiteReviewSnippets()
1548
+ {
1549
+ if (!$this->trackingEnabled()) {
1550
+ return false;
1551
+ }
1552
+ $data = array();
1553
+ $responseData = '';
1554
+ $siteReviewCount = Mage::getSingleton('core/session')->getSiteReviewCount();
1555
+ $tbSiteReviewCount = Mage::getSingleton('core/session')->getSiteReviewCacheCount();
1556
  try {
1557
+ $type = self::RATINGS_STATS;
1558
+ $apiToken = '?api_token=' . $this->getApiToken();
1559
+ $feedUrl = $this->getHostname() . $type . $apiToken;
1560
+ $data['index_name'] = $this->getApiIndex();
1561
+
1562
+ if ($siteReviewCount != $tbSiteReviewCount || $siteReviewCount == '') {
1563
+ $jsondata = json_encode($data);
1564
+ $response = $this->postPageInfo($feedUrl, $jsondata);
1565
+ $responseBody = json_decode($response);
1566
+
1567
+ if (!empty($responseBody) && $responseBody->reviews_count > 0) {
1568
+ Mage::getSingleton('core/session')->setSiteReviewCount($responseBody->reviews_count);
1569
+ Mage::getSingleton('core/session')->setSiteReviewResponse($responseBody);
1570
  $_SESSION['last_session'] = time();
1571
+ Mage::getSingleton('core/session')->unsSiteReviewCacheCount();
1572
  }
1573
+ } else {
1574
+ $responseBody = Mage::getSingleton('core/session')->getSiteReviewResponse();
1575
  }
1576
+ if (!empty($responseBody)) {
1577
+ $averageScore = $responseBody->reviews_average;
1578
+ $reviewsCount = $responseBody->reviews_count;
1579
+ $reviewsDetails = $responseBody->reviews;
1580
+ $responseData = array(
1581
+ 'average_score' => $averageScore,
1582
+ 'reviews_count' => $reviewsCount,
1583
+ 'reviews' => $reviewsDetails
1584
+ );
1585
+ return $responseData;
1586
+ }
1587
+ } catch (Exception $e) {
1588
+ $this->debug('Error message ' . $e->getMessage());
1589
+ return;
1590
  }
1591
  }
1592
 
1593
  /**
1594
  * Get the targetbay review count and rating for product
1595
+ *
1596
  * @return array
1597
+ */
1598
  public function getQuestionSnippets()
1599
+ {
1600
+ if (!$this->trackingEnabled()) {
1601
+ return false;
1602
+ }
1603
  $data = array();
1604
+ //$responseData = '';
1605
+ $controllerName = Mage::app()->getRequest()->getControllerName();
1606
+ $moduleName = Mage::app()->getRequest()->getModuleName();
1607
+ $reviewProductId = Mage::getSingleton('core/session')->getProductReviewId();
1608
+ $tbQaReviewCount = Mage::getSingleton('core/session')->getQaReviewCacheCount();
1609
+
1610
  try {
1611
  $type = self::QUESTION_STATS;
1612
  $apiToken = '?api_token=' . $this->getApiToken();
1613
  $feedUrl = $this->getHostname() . $type . $apiToken;
1614
  $data['index_name'] = $this->getApiIndex();
1615
+ if ($moduleName === 'catalog' && $controllerName === 'product') {
1616
  $productId = Mage::registry('product')->getId();
1617
  $data['product_id'] = $productId;
1618
+ if ($reviewProductId != $productId) {
1619
+ Mage::getSingleton('core/session')->unsQaReviewCount();
1620
+ Mage::getSingleton('core/session')->unsQaReviewResponse();
1621
+ $qaReviewCount = '';
1622
+ } else {
1623
+ $qaReviewCount = Mage::getSingleton('core/session')->getQaReviewCount();
1624
+ }
1625
  }
1626
+ if ($qaReviewCount != $tbQaReviewCount || $qaReviewCount == '') {
1627
+ $jsonData = json_encode($data);
1628
+ $response = $this->postPageInfo($feedUrl, $jsonData);
1629
+ $responseBody = json_decode($response);
1630
 
1631
+ if (!empty($responseBody) && $responseBody->qa_count > 0) {
 
 
 
 
 
 
 
1632
  $_SESSION['last_session'] = time();
1633
+ Mage::getSingleton('core/session')->setQaReview($responseBody->qa_count);
1634
+ Mage::getSingleton('core/session')->setQaReviewResponse($responseBody);
1635
+ if (!empty($productId)) {
1636
+ Mage::getSingleton('core/session')->setProductReviewId($productId);
1637
+ }
1638
+ Mage::getSingleton('core/session')->unsQaReviewCacheCount();
1639
  }
1640
+ } else {
1641
+ $responseBody = Mage::getSingleton('core/session')->getQaReviewResponse();
1642
  }
1643
+ if (!empty($responseBody)) {
 
 
1644
  $qaCount = $responseBody->qa_count;
1645
  $qaDetails = $responseBody->qas;
1646
  $qaAuthor = $responseBody->client;
1647
+ $responseData = array(
1648
+ 'qa_count' => $qaCount,
1649
+ 'qa_details' => $qaDetails,
1650
+ 'qa_author' => $qaAuthor
1651
+ );
1652
  return $responseData;
1653
  }
1654
+ } catch (Exception $e) {
1655
+ $this->debug('Error message ' . $e->getMessage());
1656
  return;
1657
  }
1658
  }
1659
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Cartitem.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Cartitem extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Cartitem extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Cartitem/Rest/Admin/V1.php CHANGED
@@ -1,59 +1,64 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Cartitem_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Cartitem {
8
-
9
- /**
10
- * Retrieve cart items
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $cartItems = $cartItemData = array();
16
- $quoteCollection = $this->getQuoteCollectionQuery();
17
- $cartItems = array();
18
- foreach ($quoteCollection as $id => $quoteInfo) {
19
- $quoteId = $quoteInfo['entity_id'];
20
- $quote = Mage::getModel('sales/quote')->setId($quoteId);
21
- $items = $quote->getAllVisibleItems();
22
- if(count($items) > 0) {
23
- $cartItems[$id]['entity_id'] = $quoteInfo['entity_id'];
24
- $cartItems[$id]['customer_id'] = $quoteInfo['customer_id'];
25
- $cartItems[$id]['customer_email'] = $quoteInfo['customer_email'];
26
- $cartItems[$id]['abandonded_at'] = $quoteInfo['updated_at'];
27
- $cartItems[$id]['cart_items'] = Mage::helper ( 'tracking' )->getQuoteItems ( $items);
28
- }
29
- }
30
-
31
- return $cartItems;
32
- }
33
-
34
- public function getQuoteCollectionQuery() {
35
-
36
- $page_num = Mage::app()->getRequest()->getParam('page');
37
- $limit = Mage::app()->getRequest()->getParam('limit');
38
- $start = 1;$offset = 100;
39
-
40
- $page_num = ($page_num) ? $page_num : $start;
41
- $limit = ($limit) ? $limit : $offset;
42
-
43
- $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
44
- $collection = Mage::getResourceModel ( 'sales/quote_collection' )
45
- ->addFieldToSelect(array(
46
- 'customer_id',
47
- 'customer_firstname',
48
- 'customer_lastname',
49
- 'customer_email',
50
- 'updated_at'))
51
- ->addFieldToFilter('customer_email', array('neq' => ''))
52
- ->addFieldToFilter('customer_id', array('neq' => ''));
53
- ;
54
- $collection->getSelect()->join(array('Q2'=> $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
55
-
56
- $collection->getSelect()->limit($limit, $page_num);
57
- return $collection;
58
- }
 
 
 
 
59
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Cartitem_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Cartitem
10
+ {
11
+
12
+ /**
13
+ * Retrieve cart items
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $cartItems = $cartItemData = array();
20
+ $quoteCollection = $this->getQuoteCollectionQuery();
21
+ $cartItems = array();
22
+ foreach ($quoteCollection as $id => $quoteInfo) {
23
+ $quoteId = $quoteInfo['entity_id'];
24
+ $quote = Mage::getModel('sales/quote')->setId($quoteId);
25
+ $items = $quote->getAllVisibleItems();
26
+ if (count($items) > 0) {
27
+ $cartItems[$id]['entity_id'] = $quoteInfo['entity_id'];
28
+ $cartItems[$id]['customer_id'] = $quoteInfo['customer_id'];
29
+ $cartItems[$id]['customer_email'] = $quoteInfo['customer_email'];
30
+ $cartItems[$id]['abandonded_at'] = $quoteInfo['updated_at'];
31
+ $cartItems[$id]['cart_items'] = Mage::helper('tracking')->getQuoteItems($items);
32
+ }
33
+ }
34
+
35
+ return $cartItems;
36
+ }
37
+
38
+ public function getQuoteCollectionQuery()
39
+ {
40
+ $page_num = Mage::app()->getRequest()->getParam('page');
41
+ $limit = Mage::app()->getRequest()->getParam('limit');
42
+ $start = 1;
43
+ $offset = 100;
44
+
45
+ $page_num = ($page_num) ? $page_num : $start;
46
+ $limit = ($limit) ? $limit : $offset;
47
+
48
+ $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
49
+ $collection = Mage::getResourceModel('sales/quote_collection')
50
+ ->addFieldToSelect(array(
51
+ 'customer_id',
52
+ 'customer_firstname',
53
+ 'customer_lastname',
54
+ 'customer_email',
55
+ 'updated_at'))
56
+ ->addFieldToFilter('customer_email', array('neq' => ''))
57
+ ->addFieldToFilter('customer_id', array('neq' => ''));
58
+
59
+ $collection->getSelect()->join(array('Q2' => $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
60
+
61
+ $collection->getSelect()->limit($limit, $page_num);
62
+ return $collection;
63
+ }
64
  }
app/code/community/Targetbay/Tracking/Model/Api2/Cartitem/Rest/Guest/V1.php CHANGED
@@ -1,60 +1,66 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Cartitem_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Cartitem {
8
-
9
- /**
10
- * Retrieve cart items
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $cartItems = $cartItemData = array();
16
- $quoteCollection = $this->getQuoteCollectionQuery();
17
- $cartItems = array();
18
- foreach ($quoteCollection as $id => $quoteInfo) {
19
- $quoteId = $quoteInfo['entity_id'];
20
- $quote = Mage::getModel('sales/quote')->setId($quoteId);
21
- $items = $quote->getAllVisibleItems();
22
- if(count($items) > 0) {
23
- $cartItems[$id]['entity_id'] = $quoteInfo['entity_id'];
24
- $cartItems[$id]['customer_id'] = $quoteInfo['customer_id'];
25
- $cartItems[$id]['customer_email'] = $quoteInfo['customer_email'];
26
- $cartItems[$id]['abandonded_at'] = $quoteInfo['updated_at'];
27
- $cartItems[$id]['cart_items'] = Mage::helper ( 'tracking' )->getQuoteItems ( $items);
28
- }
29
- }
30
-
31
- return $cartItems;
32
- }
33
-
34
- public function getQuoteCollectionQuery() {
35
-
36
- $page_num = Mage::app()->getRequest()->getParam('page');
37
- $limit = Mage::app()->getRequest()->getParam('limit');
38
- $start = 1;$offset = 100;
39
-
40
- $page_num = ($page_num) ? $page_num : $start;
41
-
42
- $limit = ($limit) ? $limit : $offset;
43
-
44
- $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
45
- $collection = Mage::getResourceModel ( 'sales/quote_collection' )
46
- ->addFieldToSelect(array(
47
- 'customer_id',
48
- 'customer_firstname',
49
- 'customer_lastname',
50
- 'customer_email',
51
- 'updated_at'))
52
- ->addFieldToFilter('customer_email', array('neq' => ''))
53
- ->addFieldToFilter('customer_id', array('neq' => ''));
54
- ;
55
- $collection->getSelect()->join(array('Q2'=> $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
56
-
 
 
 
 
 
57
  $collection->getSelect()->limit($limit, $page_num);
58
- return $collection;
59
- }
60
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Cartitem_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Cartitem
10
+ {
11
+
12
+ /**
13
+ * Retrieve cart items
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $cartItems = $cartItemData = array();
20
+ $quoteCollection = $this->getQuoteCollectionQuery();
21
+ $cartItems = array();
22
+ foreach ($quoteCollection as $id => $quoteInfo) {
23
+ $quoteId = $quoteInfo['entity_id'];
24
+ $quote = Mage::getModel('sales/quote')->setId($quoteId);
25
+ $items = $quote->getAllVisibleItems();
26
+ if (count($items) > 0) {
27
+ $cartItems[$id]['entity_id'] = $quoteInfo['entity_id'];
28
+ $cartItems[$id]['customer_id'] = $quoteInfo['customer_id'];
29
+ $cartItems[$id]['customer_email'] = $quoteInfo['customer_email'];
30
+ $cartItems[$id]['abandonded_at'] = $quoteInfo['updated_at'];
31
+ $cartItems[$id]['cart_items'] = Mage::helper('tracking')->getQuoteItems($items);
32
+ }
33
+ }
34
+
35
+ return $cartItems;
36
+ }
37
+
38
+ public function getQuoteCollectionQuery()
39
+ {
40
+ $page_num = Mage::app()->getRequest()->getParam('page');
41
+ $limit = Mage::app()->getRequest()->getParam('limit');
42
+ $start = 1;
43
+ $offset = 100;
44
+
45
+ $page_num = ($page_num) ? $page_num : $start;
46
+
47
+ $limit = ($limit) ? $limit : $offset;
48
+
49
+ $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
50
+ $collection = Mage::getResourceModel('sales/quote_collection')
51
+ ->addFieldToSelect(array(
52
+ 'customer_id',
53
+ 'customer_firstname',
54
+ 'customer_lastname',
55
+ 'customer_email',
56
+ 'updated_at'
57
+ ))
58
+ ->addFieldToFilter('customer_email', array('neq' => ''))
59
+ ->addFieldToFilter('customer_id', array('neq' => ''));
60
+
61
+ $collection->getSelect()->join(array('Q2' => $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
62
+
63
  $collection->getSelect()->limit($limit, $page_num);
64
+ return $collection;
65
+ }
66
  }
app/code/community/Targetbay/Tracking/Model/Api2/Category.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Category extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Category extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Category/Rest/Admin/V1.php CHANGED
@@ -1,36 +1,40 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Category_Rest_Admin_V1 extends Mage_Api2_Model_Resource {
8
-
9
- /**
10
- * Retrieve list of categories
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $model = Mage::getModel('catalog/category');
16
- $model->setStoreId($this->_getStore()->getId());
17
- $collection = $model->getCollection()
18
- ->addAttributeToSelect(array_keys(
19
- $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
20
- ));
21
- $this->_applyCollectionModifiers($collection);
22
- $categoryData = array();
23
-
24
- foreach ( $collection as $category ) {
25
- $categoryData[$category->getId()] = $category->toArray();
26
- $categoryDetail = Mage::getModel('catalog/category')->load($category->getId());
27
- $storeIds = $categoryDetail->getStoreIds();
28
- $categoryData[$category->getId()]['store_id'] = $storeIds;
29
- $categoryIds = $categoryDetail->getPathIds();
30
- $storesDetail = Mage::getModel('core/store')->getCollection()->loadByCategoryIds($categoryIds);
31
- $websiteIds = array_unique($storesDetail->getColumnValues('website_id'));
32
- $categoryData[$category->getId()]['website_id'] = $websiteIds;
33
- }
34
- return $categoryData;
35
- }
 
 
 
36
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Category_Rest_Admin_V1 extends Mage_Api2_Model_Resource
10
+ {
11
+
12
+ /**
13
+ * Retrieve list of categories
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $model = Mage::getModel('catalog/category');
20
+ $model->setStoreId($this->_getStore()->getId());
21
+ $collection = $model->getCollection()
22
+ ->addAttributeToSelect(array_keys(
23
+ $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
24
+ ));
25
+ $this->_applyCollectionModifiers($collection);
26
+ $categoryData = array();
27
+
28
+ foreach ($collection as $category) {
29
+ $categoryData[$category->getId()] = $category->toArray();
30
+ $categoryDetail = Mage::getModel('catalog/category')->load($category->getId());
31
+ $storeIds = $categoryDetail->getStoreIds();
32
+ $categoryData[$category->getId()]['store_id'] = $storeIds;
33
+ $categoryIds = $categoryDetail->getPathIds();
34
+ $storesDetail = Mage::getModel('core/store')->getCollection()->loadByCategoryIds($categoryIds);
35
+ $websiteIds = array_unique($storesDetail->getColumnValues('website_id'));
36
+ $categoryData[$category->getId()]['website_id'] = $websiteIds;
37
+ }
38
+ return $categoryData;
39
+ }
40
  }
app/code/community/Targetbay/Tracking/Model/Api2/Category/Rest/Guest/V1.php CHANGED
@@ -1,36 +1,40 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Category_Rest_Guest_V1 extends Mage_Api2_Model_Resource {
8
-
9
- /**
10
- * Retrieve list of categories
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $model = Mage::getModel('catalog/category');
16
- $model->setStoreId($this->_getStore()->getId());
17
- $collection = $model->getCollection()
18
- ->addAttributeToSelect(array_keys(
19
- $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
20
- ));
21
- $this->_applyCollectionModifiers($collection);
22
- $categoryData = array();
23
-
24
- foreach ( $collection as $category ) {
25
- $categoryData[$category->getId()] = $category->toArray();
26
- $categoryDetail = Mage::getModel('catalog/category')->load($category->getId());
27
- $storeIds = $categoryDetail->getStoreIds();
28
- $categoryData[$category->getId()]['store_id'] = $storeIds;
29
- $categoryIds = $categoryDetail->getPathIds();
30
- $storesDetail = Mage::getModel('core/store')->getCollection()->loadByCategoryIds($categoryIds);
31
- $websiteIds = array_unique($storesDetail->getColumnValues('website_id'));
32
- $categoryData[$category->getId()]['website_id'] = $websiteIds;
33
- }
34
- return $categoryData;
35
- }
 
 
 
36
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Category_Rest_Guest_V1 extends Mage_Api2_Model_Resource
10
+ {
11
+
12
+ /**
13
+ * Retrieve list of categories
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $model = Mage::getModel('catalog/category');
20
+ $model->setStoreId($this->_getStore()->getId());
21
+ $collection = $model->getCollection()
22
+ ->addAttributeToSelect(array_keys(
23
+ $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
24
+ ));
25
+ $this->_applyCollectionModifiers($collection);
26
+ $categoryData = array();
27
+
28
+ foreach ($collection as $category) {
29
+ $categoryData[$category->getId()] = $category->toArray();
30
+ $categoryDetail = Mage::getModel('catalog/category')->load($category->getId());
31
+ $storeIds = $categoryDetail->getStoreIds();
32
+ $categoryData[$category->getId()]['store_id'] = $storeIds;
33
+ $categoryIds = $categoryDetail->getPathIds();
34
+ $storesDetail = Mage::getModel('core/store')->getCollection()->loadByCategoryIds($categoryIds);
35
+ $websiteIds = array_unique($storesDetail->getColumnValues('website_id'));
36
+ $categoryData[$category->getId()]['website_id'] = $websiteIds;
37
+ }
38
+ return $categoryData;
39
+ }
40
  }
app/code/community/Targetbay/Tracking/Model/Api2/Createsubscription.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Createsubscription extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Createsubscription extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Createsubscription/Rest/Admin/V1.php CHANGED
@@ -1,99 +1,102 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Createsubscription_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Createsubscription {
8
-
9
- /**
10
- * Get the newsletter subscription
11
- *
12
- * @param array $data
13
- * @see Mage_Api2_Model_Resource::_create()
14
- */
15
- public function _create(array $data) {
16
- $session = Mage::getSingleton('core/session');
17
- $customerSession = Mage::getSingleton('customer/session');
18
 
19
- if (Mage::app()->getRequest()->getParam('email')) {
 
20
 
21
- $email = (string) Mage::app()->getRequest()->getParam('email');
22
- $message = array();
23
- try {
24
- if (!Zend_Validate::is($email, 'EmailAddress')) {
25
- return 'Please enter a valid email address.';
26
- }
 
 
 
 
27
 
28
- if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
29
- !$customerSession->isLoggedIn()) {
30
- return 'Sorry, but administrator denied subscription for guests. Please register.';
31
- }
 
 
 
32
 
33
- $ownerId = Mage::getModel('newsletter/subscriber')
34
- ->loadByEmail($email)
35
- ->getId();
36
- if ($ownerId !== null && $ownerId != $customerSession->getId()) {
37
- return 'This email address is already exists.';
38
- }
39
 
40
- $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
41
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
42
- return 'Confirmation request has been sent.';
43
- }
44
- else {
45
- return 'Thank you for your subscription.';
46
- }
47
- } catch (\Exception $e) {
48
- Mage::helper('tracking')->debug($e->getMessage());
49
- }
50
- } else {
51
- return 'Please enter a valid email address.';
52
- }
53
- }
54
 
55
- /**
56
- * Get the newsletter subscription
57
- *
58
- * @return array
59
- */
60
- public function _retrieveCollection() {
61
- $session = Mage::getSingleton('core/session');
62
- $customerSession = Mage::getSingleton('customer/session');
 
 
 
 
 
63
 
64
- if (Mage::app()->getRequest()->getParam('email')) {
 
 
 
 
 
 
 
 
65
 
66
- $email = (string) Mage::app()->getRequest()->getParam('email');
67
- $message = array();
68
- try {
69
- if (!Zend_Validate::is($email, 'EmailAddress')) {
70
- return 'Please enter a valid email address.';
71
- }
 
72
 
73
- if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
74
- !$customerSession->isLoggedIn()) {
75
- return 'Sorry, but administrator denied subscription for guests. Please register.';
76
- }
 
77
 
78
- $ownerId = Mage::getModel('newsletter/subscriber')
79
- ->loadByEmail($email)
80
- ->getId();
81
- if ($ownerId !== null && $ownerId != $customerSession->getId()) {
82
- return 'This email address is already exists.';
83
- }
84
 
85
- $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
86
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
87
- return 'Confirmation request has been sent.';
88
- }
89
- else {
90
- return 'Thank you for your subscription.';
91
- }
92
- } catch (\Exception $e) {
93
- Mage::helper('tracking')->debug($e->getMessage());
94
- }
95
- } else {
96
- return 'Please enter a valid email address.';
97
- }
98
- }
99
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Createsubscription_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Createsubscription
10
+ {
11
 
12
+ /**
13
+ * Get the newsletter subscription
14
+ *
15
+ * @param array $data
16
+ * @see Mage_Api2_Model_Resource::_create()
17
+ */
18
+ public function _create(array $data)
19
+ {
20
+ $session = Mage::getSingleton('core/session');
21
+ $customerSession = Mage::getSingleton('customer/session');
22
 
23
+ if (Mage::app()->getRequest()->getParam('email')) {
24
+ $email = (string) Mage::app()->getRequest()->getParam('email');
25
+ $message = array();
26
+ try {
27
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
28
+ return 'Please enter a valid email address.';
29
+ }
30
 
31
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
32
+ !$customerSession->isLoggedIn()
33
+ ) {
34
+ return 'Sorry, but administrator denied subscription for guests. Please register.';
35
+ }
 
36
 
37
+ $ownerId = Mage::getModel('newsletter/subscriber')
38
+ ->loadByEmail($email)
39
+ ->getId();
40
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
41
+ return 'This email address is already exists.';
42
+ }
 
 
 
 
 
 
 
 
43
 
44
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
45
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
46
+ return 'Confirmation request has been sent.';
47
+ } else {
48
+ return 'Thank you for your subscription.';
49
+ }
50
+ } catch (\Exception $e) {
51
+ Mage::helper('tracking')->debug($e->getMessage());
52
+ }
53
+ } else {
54
+ return 'Please enter a valid email address.';
55
+ }
56
+ }
57
 
58
+ /**
59
+ * Get the newsletter subscription
60
+ *
61
+ * @return array
62
+ */
63
+ public function _retrieveCollection()
64
+ {
65
+ $session = Mage::getSingleton('core/session');
66
+ $customerSession = Mage::getSingleton('customer/session');
67
 
68
+ if (Mage::app()->getRequest()->getParam('email')) {
69
+ $email = (string) Mage::app()->getRequest()->getParam('email');
70
+ $message = array();
71
+ try {
72
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
73
+ return 'Please enter a valid email address.';
74
+ }
75
 
76
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
77
+ !$customerSession->isLoggedIn()
78
+ ) {
79
+ return 'Sorry, but administrator denied subscription for guests. Please register.';
80
+ }
81
 
82
+ $ownerId = Mage::getModel('newsletter/subscriber')
83
+ ->loadByEmail($email)
84
+ ->getId();
85
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
86
+ return 'This email address is already exists.';
87
+ }
88
 
89
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
90
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
91
+ return 'Confirmation request has been sent.';
92
+ } else {
93
+ return 'Thank you for your subscription.';
94
+ }
95
+ } catch (\Exception $e) {
96
+ Mage::helper('tracking')->debug($e->getMessage());
97
+ }
98
+ } else {
99
+ return 'Please enter a valid email address.';
100
+ }
101
+ }
 
102
  }
app/code/community/Targetbay/Tracking/Model/Api2/Createsubscription/Rest/Guest/V1.php CHANGED
@@ -1,99 +1,102 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Createsubscription_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Createsubscription {
8
-
9
- /**
10
- * Get the newsletter subscription
11
- *
12
- * @param array $data
13
- * @see Mage_Api2_Model_Resource::_create()
14
- */
15
- public function _create(array $data) {
16
- $session = Mage::getSingleton('core/session');
17
- $customerSession = Mage::getSingleton('customer/session');
18
 
19
- if (Mage::app()->getRequest()->getParam('email')) {
 
20
 
21
- $email = (string) Mage::app()->getRequest()->getParam('email');
22
- $message = array();
23
- try {
24
- if (!Zend_Validate::is($email, 'EmailAddress')) {
25
- return 'Please enter a valid email address.';
26
- }
 
 
 
 
27
 
28
- if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
29
- !$customerSession->isLoggedIn()) {
30
- return 'Sorry, but administrator denied subscription for guests. Please register.';
31
- }
 
 
 
32
 
33
- $ownerId = Mage::getModel('newsletter/subscriber')
34
- ->loadByEmail($email)
35
- ->getId();
36
- if ($ownerId !== null && $ownerId != $customerSession->getId()) {
37
- return 'This email address is already exists.';
38
- }
39
 
40
- $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
41
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
42
- return 'Confirmation request has been sent.';
43
- }
44
- else {
45
- return 'Thank you for your subscription.';
46
- }
47
- } catch (\Exception $e) {
48
- Mage::helper('tracking')->debug($e->getMessage());
49
- }
50
- } else {
51
- return 'Please enter a valid email address.';
52
- }
53
- }
54
 
55
- /**
56
- * Get the newsletter subscription
57
- *
58
- * @return array
59
- */
60
- public function _retrieveCollection() {
61
- $session = Mage::getSingleton('core/session');
62
- $customerSession = Mage::getSingleton('customer/session');
 
 
 
 
 
63
 
64
- if (Mage::app()->getRequest()->getParam('email')) {
 
 
 
 
 
 
 
 
65
 
66
- $email = (string) Mage::app()->getRequest()->getParam('email');
67
- $message = array();
68
- try {
69
- if (!Zend_Validate::is($email, 'EmailAddress')) {
70
- return 'Please enter a valid email address.';
71
- }
 
72
 
73
- if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
74
- !$customerSession->isLoggedIn()) {
75
- return 'Sorry, but administrator denied subscription for guests. Please register.';
76
- }
 
77
 
78
- $ownerId = Mage::getModel('newsletter/subscriber')
79
- ->loadByEmail($email)
80
- ->getId();
81
- if ($ownerId !== null && $ownerId != $customerSession->getId()) {
82
- return 'This email address is already exists.';
83
- }
84
 
85
- $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
86
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
87
- return 'Confirmation request has been sent.';
88
- }
89
- else {
90
- return 'Thank you for your subscription.';
91
- }
92
- } catch (\Exception $e) {
93
- Mage::helper('tracking')->debug($e->getMessage());
94
- }
95
- } else {
96
- return 'Please enter a valid email address.';
97
- }
98
- }
99
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Createsubscription_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Createsubscription
10
+ {
11
 
12
+ /**
13
+ * Get the newsletter subscription
14
+ *
15
+ * @param array $data
16
+ * @see Mage_Api2_Model_Resource::_create()
17
+ */
18
+ public function _create(array $data)
19
+ {
20
+ $session = Mage::getSingleton('core/session');
21
+ $customerSession = Mage::getSingleton('customer/session');
22
 
23
+ if (Mage::app()->getRequest()->getParam('email')) {
24
+ $email = (string) Mage::app()->getRequest()->getParam('email');
25
+ $message = array();
26
+ try {
27
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
28
+ return 'Please enter a valid email address.';
29
+ }
30
 
31
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
32
+ !$customerSession->isLoggedIn()
33
+ ) {
34
+ return 'Sorry, but administrator denied subscription for guests. Please register.';
35
+ }
 
36
 
37
+ $ownerId = Mage::getModel('newsletter/subscriber')
38
+ ->loadByEmail($email)
39
+ ->getId();
40
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
41
+ return 'This email address is already exists.';
42
+ }
 
 
 
 
 
 
 
 
43
 
44
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
45
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
46
+ return 'Confirmation request has been sent.';
47
+ } else {
48
+ return 'Thank you for your subscription.';
49
+ }
50
+ } catch (\Exception $e) {
51
+ Mage::helper('tracking')->debug($e->getMessage());
52
+ }
53
+ } else {
54
+ return 'Please enter a valid email address.';
55
+ }
56
+ }
57
 
58
+ /**
59
+ * Get the newsletter subscription
60
+ *
61
+ * @return array
62
+ */
63
+ public function _retrieveCollection()
64
+ {
65
+ $session = Mage::getSingleton('core/session');
66
+ $customerSession = Mage::getSingleton('customer/session');
67
 
68
+ if (Mage::app()->getRequest()->getParam('email')) {
69
+ $email = (string) Mage::app()->getRequest()->getParam('email');
70
+ $message = array();
71
+ try {
72
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
73
+ return 'Please enter a valid email address.';
74
+ }
75
 
76
+ if (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 &&
77
+ !$customerSession->isLoggedIn()
78
+ ) {
79
+ return 'Sorry, but administrator denied subscription for guests. Please register.';
80
+ }
81
 
82
+ $ownerId = Mage::getModel('newsletter/subscriber')
83
+ ->loadByEmail($email)
84
+ ->getId();
85
+ if ($ownerId !== null && $ownerId != $customerSession->getId()) {
86
+ return 'This email address is already exists.';
87
+ }
88
 
89
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
90
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
91
+ return 'Confirmation request has been sent.';
92
+ } else {
93
+ return 'Thank you for your subscription.';
94
+ }
95
+ } catch (\Exception $e) {
96
+ Mage::helper('tracking')->debug($e->getMessage());
97
+ }
98
+ } else {
99
+ return 'Please enter a valid email address.';
100
+ }
101
+ }
 
102
  }
app/code/community/Targetbay/Tracking/Model/Api2/Customer.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Customer extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Customer extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Customer/Rest/Admin/V1.php CHANGED
@@ -1,31 +1,35 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Customer_Rest_Admin_V1 extends Mage_Customer_Model_Api2_Customer {
8
-
9
- /**
10
- * Retrieve list of categories
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $page = Mage::app()->getRequest()->getParam('page');
16
- $limit = Mage::app()->getRequest()->getParam('limit');
17
 
18
- $pageSize = ($page) ? $page : '';
19
- $pageLimit = ($limit) ? $limit : '';
20
-
21
- $pageSize = (($page-1)*$limit);
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- $collection = Mage::getResourceModel('customer/customer_collection');
24
- $collection->addAttributeToSelect(array_keys(
25
- $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
26
- ));
27
- $collection->getSelect()->limit($pageLimit, $pageSize);
28
- $customers = $collection->load()->toArray();
29
- return $customers;
30
- }
31
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Customer_Rest_Admin_V1 extends Mage_Customer_Model_Api2_Customer
10
+ {
11
+
12
+ /**
13
+ * Retrieve list of categories
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $page = Mage::app()->getRequest()->getParam('page');
20
+ $limit = Mage::app()->getRequest()->getParam('limit');
21
+
22
+ $pageSize = ($page) ? $page : '';
23
+ $pageLimit = ($limit) ? $limit : '';
24
+
25
+ $pageSize = (($page - 1) * $limit);
26
 
27
+ $collection = Mage::getResourceModel('customer/customer_collection');
28
+ $collection->addAttributeToSelect(array_keys(
29
+ $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
30
+ ));
31
+ $collection->getSelect()->limit($pageLimit, $pageSize);
32
+ $customers = $collection->load()->toArray();
33
+ return $customers;
34
+ }
35
  }
app/code/community/Targetbay/Tracking/Model/Api2/Customer/Rest/Guest/V1.php CHANGED
@@ -1,31 +1,35 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Customer_Rest_Guest_V1 extends Mage_Customer_Model_Api2_Customer {
8
-
9
- /**
10
- * Retrieve list of categories
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $page = Mage::app()->getRequest()->getParam('page');
16
- $limit = Mage::app()->getRequest()->getParam('limit');
17
 
18
- $pageSize = ($page) ? $page : '';
19
- $pageLimit = ($limit) ? $limit : '';
20
-
21
- $pageSize = (($page-1)*$limit);
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- $collection = Mage::getResourceModel('customer/customer_collection');
24
- $collection->addAttributeToSelect(array_keys(
25
- $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
26
- ));
27
- $collection->getSelect()->limit($pageLimit, $pageSize);
28
- $customers = $collection->load()->toArray();
29
- return $customers;
30
- }
31
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Customer_Rest_Guest_V1 extends Mage_Customer_Model_Api2_Customer
10
+ {
11
+
12
+ /**
13
+ * Retrieve list of categories
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $page = Mage::app()->getRequest()->getParam('page');
20
+ $limit = Mage::app()->getRequest()->getParam('limit');
21
+
22
+ $pageSize = ($page) ? $page : '';
23
+ $pageLimit = ($limit) ? $limit : '';
24
+
25
+ $pageSize = (($page - 1) * $limit);
26
 
27
+ $collection = Mage::getResourceModel('customer/customer_collection');
28
+ $collection->addAttributeToSelect(array_keys(
29
+ $this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)
30
+ ));
31
+ $collection->getSelect()->limit($pageLimit, $pageSize);
32
+ $customers = $collection->load()->toArray();
33
+ return $customers;
34
+ }
35
  }
app/code/community/Targetbay/Tracking/Model/Api2/Orders/Rest/Admin/V1.php CHANGED
@@ -1,40 +1,85 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Orders_Rest_Admin_V1 extends Mage_Sales_Model_Api2_Order_Rest {
8
-
9
- /**
10
- * Get orders list
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $collection = $this->_getCollectionForRetrieve ();
16
-
17
- if ($this->_isPaymentMethodAllowed ()) {
18
- $this->_addPaymentMethodInfo ( $collection );
19
- }
20
- if ($this->_isGiftMessageAllowed ()) {
21
- $this->_addGiftMessageInfo ( $collection );
22
- }
23
- $this->_addTaxInfo ( $collection );
24
-
25
- $ordersData = array ();
26
-
27
- foreach ( $collection->getItems () as $order ) {
28
- $ordersData [$order->getId ()] = $order->toArray ();
29
- $storeId = $order->getStoreId();
30
- $ordersData [$order->getId ()]['store_id'] = $storeId;
31
- $ordersData [$order->getId ()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
32
- $ordersData [$order->getId ()] ['payment_method'] = Mage::helper ( 'tracking' )->getPaymentInfo ( $order->getId (), true );
33
- $ordersData [$order->getId ()] [Targetbay_Tracking_Helper_Data::BILLING] = Mage::helper ( 'tracking' )->getAddressData ( $order, Targetbay_Tracking_Helper_Data::BILLING );
34
- $ordersData [$order->getId ()] [Targetbay_Tracking_Helper_Data::SHIPPING] = Mage::helper ( 'tracking' )->getAddressData ( $order, Targetbay_Tracking_Helper_Data::SHIPPING );
35
- $ordersData [$order->getId ()] ['cart_items'] = Mage::helper ( 'tracking' )->getOrderItemsInfo ( $order, true );
36
- }
37
- return $ordersData;
38
- }
39
- }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Orders_Rest_Admin_V1 extends Mage_Sales_Model_Api2_Order_Rest
10
+ {
11
+ const ORDER_COMPLETE = 'complete';
12
+
13
+ /**
14
+ * Get orders list
15
+ *
16
+ * @return array
17
+ */
18
+ public function _retrieveCollection()
19
+ {
20
+ $collection = $this->_getCollectionForRetrieve();
21
+
22
+ if ($this->_isPaymentMethodAllowed()) {
23
+ $this->_addPaymentMethodInfo($collection);
24
+ }
25
+ if ($this->_isGiftMessageAllowed()) {
26
+ $this->_addGiftMessageInfo($collection);
27
+ }
28
+ $this->_addTaxInfo($collection);
29
+
30
+ $ordersData = array();
31
+
32
+ foreach ($collection->getItems() as $order) {
33
+ $ordersData [$order->getId()] = $order->toArray();
34
+ $storeId = $order->getStoreId();
35
+ $ordersData [$order->getId()]['store_id'] = $storeId;
36
+ $ordersData [$order->getId()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
37
+ $ordersData [$order->getId()] ['payment_method'] = Mage::helper('tracking')->getPaymentInfo($order->getId(), true);
38
+ $ordersData [$order->getId()] [Targetbay_Tracking_Helper_Data::BILLING] = $this->getUserAddressData($order, Targetbay_Tracking_Helper_Data::BILLING);
39
+ if ($order->getShippingAddress()) {
40
+ $ordersData [$order->getId()] [Targetbay_Tracking_Helper_Data::SHIPPING] = $this->getUserAddressData($order, Targetbay_Tracking_Helper_Data::SHIPPING);
41
+ if ($order->getStatus() == self::ORDER_COMPLETE) {
42
+ //order shipped date
43
+ foreach ($order->getShipmentsCollection() as $shipment) {
44
+ /** @var $shipment Mage_Sales_Model_Order_Shipment */
45
+ //$shipmentDate = Mage::getModel('core/date')->timestamp(strtotime($shipment->getCreatedAt()));
46
+ //$ordersData[$order->getId()]['shipped_at'] = date('F j, Y g:i a', strtotime($actualDate . " UTC"));
47
+ $ordersData[$order->getId()]['shipped_at']=$shipment->getCreatedAt();
48
+ $ordersData[$order->getId()]['timezone'] = Mage::getStoreConfig('general/locale/timezone');
49
+ }
50
+ }
51
+ } else {
52
+ $ordersData [$order->getId()] [Targetbay_Tracking_Helper_Data::SHIPPING] = '';
53
+ }
54
+ $ordersData [$order->getId()] ['cart_items'] = Mage::helper('tracking')->getOrderItemsInfo($order, true);
55
+ }
56
+ return $ordersData;
57
+ }
58
+
59
+ public function getUserAddressData($object, $type)
60
+ {
61
+ $address = ($type == Targetbay_Tracking_Helper_Data::SHIPPING) ? $object->getShippingAddress() : $object->getBillingAddress();
62
+ $addressData['first_name'] = $address->getFirstname();
63
+ $addressData['last_name'] = $address->getLastname();
64
+ $guestUsername = $address->getFirstname() . ' ' . $address->getLastname();
65
+ $gName = !empty($guestUsername) ? $guestUsername : Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
66
+ $addressData['user_name'] = $object->getCustomerIsGuest() ? $gName : $addressData['first_name'] . ' ' . $addressData['last_name'];
67
+ $addressData['order_id'] = $object->getId();
68
+ $addressData['user_mail'] = $object->getCustomerEmail();
69
+ $addressData['address1'] = $address->getStreet(1);
70
+ $addressData['address2'] = $address->getStreet(2);
71
+ $addressData['city'] = $address->getCity();
72
+ $addressData['state'] = $address->getRegion();
73
+ $addressData['zipcode'] = $address->getPostcode();
74
+ if ($address->getCountryId()) {
75
+ $countryName = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
76
+ } else {
77
+ $countryName = '';
78
+ }
79
+ $addressData['country'] = isset($countryName) ? $countryName : $address->getCountryId();
80
+ $addressData['phone'] = $address->getTelephone();
81
+ if (!empty($addressData)) {
82
+ return $addressData;
83
+ }
84
+ }
85
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Orders/Rest/Guest/V1.php CHANGED
@@ -1,40 +1,85 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Orders_Rest_Guest_V1 extends Mage_Sales_Model_Api2_Order_Rest {
8
-
9
- /**
10
- * Get orders list
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $collection = $this->_getCollectionForRetrieve ();
16
-
17
- if ($this->_isPaymentMethodAllowed ()) {
18
- $this->_addPaymentMethodInfo ( $collection );
19
- }
20
- if ($this->_isGiftMessageAllowed ()) {
21
- $this->_addGiftMessageInfo ( $collection );
22
- }
23
- $this->_addTaxInfo ( $collection );
24
-
25
- $ordersData = array ();
26
-
27
- foreach ( $collection->getItems () as $order ) {
28
- $ordersData [$order->getId ()] = $order->toArray ();
29
- $storeId = $order->getStoreId();
30
- $ordersData [$order->getId ()]['store_id'] = $storeId;
31
- $ordersData [$order->getId ()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
32
- $ordersData [$order->getId ()] ['payment_method'] = Mage::helper ( 'tracking' )->getPaymentInfo ( $order->getId (), true );
33
- $ordersData [$order->getId ()] [Targetbay_Tracking_Helper_Data::BILLING] = Mage::helper ( 'tracking' )->getAddressData ( $order, Targetbay_Tracking_Helper_Data::BILLING );
34
- $ordersData [$order->getId ()] [Targetbay_Tracking_Helper_Data::SHIPPING] = Mage::helper ( 'tracking' )->getAddressData ( $order, Targetbay_Tracking_Helper_Data::SHIPPING );
35
- $ordersData [$order->getId ()] ['cart_items'] = Mage::helper ( 'tracking' )->getOrderItemsInfo ( $order, true );
36
- }
37
- return $ordersData;
38
- }
39
- }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Orders_Rest_Guest_V1 extends Mage_Sales_Model_Api2_Order_Rest
10
+ {
11
+ const ORDER_COMPLETE = 'complete';
12
+
13
+ /**
14
+ * Get orders list
15
+ *
16
+ * @return array
17
+ */
18
+ public function _retrieveCollection()
19
+ {
20
+ $collection = $this->_getCollectionForRetrieve();
21
+
22
+ if ($this->_isPaymentMethodAllowed()) {
23
+ $this->_addPaymentMethodInfo($collection);
24
+ }
25
+ if ($this->_isGiftMessageAllowed()) {
26
+ $this->_addGiftMessageInfo($collection);
27
+ }
28
+ $this->_addTaxInfo($collection);
29
+
30
+ $ordersData = array();
31
+
32
+ foreach ($collection->getItems() as $order) {
33
+ $ordersData [$order->getId()] = $order->toArray();
34
+ $storeId = $order->getStoreId();
35
+ $ordersData [$order->getId()]['store_id'] = $storeId;
36
+ $ordersData [$order->getId()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
37
+ $ordersData [$order->getId()] ['payment_method'] = Mage::helper('tracking')->getPaymentInfo($order->getId(), true);
38
+ $ordersData [$order->getId()] [Targetbay_Tracking_Helper_Data::BILLING] = $this->getUserAddressData($order, Targetbay_Tracking_Helper_Data::BILLING);
39
+ if ($order->getShippingAddress()) {
40
+ $ordersData [$order->getId()] [Targetbay_Tracking_Helper_Data::SHIPPING] = $this->getUserAddressData($order, Targetbay_Tracking_Helper_Data::SHIPPING);
41
+ if ($order->getStatus() == self::ORDER_COMPLETE) {
42
+ //order shipped date
43
+ foreach ($order->getShipmentsCollection() as $shipment) {
44
+ /** @var $shipment Mage_Sales_Model_Order_Shipment */
45
+ //$shipmentDate = Mage::getModel('core/date')->timestamp(strtotime($shipment->getCreatedAt()));
46
+ // $ordersData[$order->getId()]['shipped_at'] = date('F j, Y g:i a', strtotime($actualDate . " UTC"));
47
+ $ordersData[$order->getId()]['shipped_at']=$shipment->getCreatedAt();
48
+ $ordersData[$order->getId()]['timezone'] = Mage::getStoreConfig('general/locale/timezone');
49
+ }
50
+ }
51
+ } else {
52
+ $ordersData [$order->getId()] [Targetbay_Tracking_Helper_Data::SHIPPING] = '';
53
+ }
54
+ $ordersData [$order->getId()] ['cart_items'] = Mage::helper('tracking')->getOrderItemsInfo($order, true);
55
+ }
56
+ return $ordersData;
57
+ }
58
+
59
+ public function getUserAddressData($object, $type)
60
+ {
61
+ $address = ($type == Targetbay_Tracking_Helper_Data::SHIPPING) ? $object->getShippingAddress() : $object->getBillingAddress();
62
+ $addressData['first_name'] = $address->getFirstname();
63
+ $addressData['last_name'] = $address->getLastname();
64
+ $guestUsername = $address->getFirstname() . ' ' . $address->getLastname();
65
+ $gName = !empty($guestUsername) ? $guestUsername : Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
66
+ $addressData['user_name'] = $object->getCustomerIsGuest() ? $gName : $addressData['first_name'] . ' ' . $addressData['last_name'];
67
+ $addressData['order_id'] = $object->getId();
68
+ $addressData['user_mail'] = $object->getCustomerEmail();
69
+ $addressData['address1'] = $address->getStreet(1);
70
+ $addressData['address2'] = $address->getStreet(2);
71
+ $addressData['city'] = $address->getCity();
72
+ $addressData['state'] = $address->getRegion();
73
+ $addressData['zipcode'] = $address->getPostcode();
74
+ if ($address->getCountryId()) {
75
+ $countryName = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getName();
76
+ } else {
77
+ $countryName = '';
78
+ }
79
+ $addressData['country'] = isset($countryName) ? $countryName : $address->getCountryId();
80
+ $addressData['phone'] = $address->getTelephone();
81
+ if (!empty($addressData)) {
82
+ return $addressData;
83
+ }
84
+ }
85
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Product/Rest/Admin/V1.php CHANGED
@@ -4,98 +4,135 @@
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Product_Rest_Admin_V1 extends Mage_Catalog_Model_Api2_Product_Rest {
8
-
9
- // Product type configurable.
10
- CONST CONFIGURABLE_PRODUCT = 'configurable';
11
- CONST BUNDLE_PRODUCT = 'bundle';
12
-
13
- /**
14
- * Retrieve list of products
15
- *
16
- * @return array
17
- */
18
- protected function _retrieveCollection() {
19
- /**
20
- *
21
- * @var $collection Mage_Catalog_Model_Resource_Product_Collection
22
- */
23
- $collection = Mage::getResourceModel('catalog/product_collection');
24
- $store = $this->_getStore();
25
- $collection->setStoreId($store->getId());
26
- $collection->addAttributeToSelect(array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)));
27
-
28
- $collection->addStoreFilter($store->getId())->addPriceData($this->_getCustomerGroupId(), $store->getWebsiteId())->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
29
 
30
- $this->_applyCategoryFilter($collection);
31
- $this->_applyCollectionModifiers( $collection);
32
- $products = $collection->load()->toArray();
33
-
34
- foreach($products as $id => $data) {
35
- $product = Mage::getModel('catalog/product')->load($id);
36
- $stockItem = Mage::getModel('cataloginventory/stock_item');
37
- $stockItem->loadByProduct($product);
38
- $products[$id]['qty'] = $stockItem->getQty();
39
 
40
- /**
41
- *
42
- * @var $category Get product categories
43
- */
44
- $products[$id]['meta_keyword'] = (string) Mage::helper('tracking')->getProductCategory($product);
45
- $products[$id]['category_id'] = (string) Mage::helper('tracking')->getProductCategory($product);
46
- $products[$id]['related_product_id'] = implode(',', $product->getRelatedProductIds());
47
- $products[$id]['upsell_product_id'] = implode(',', $product->getUpSellProductIds());
48
- $products[$id]['crosssell_product_id'] = implode(',', $product->getCrossSellProducts());
49
- $products[$id]['visibility'] = $product->getVisibility();
50
- $products[$id]['status'] = $product->getStatus();
51
- $products[$id]['website_id'] = $product->getWebsiteIds();
52
- $products[$id]['store_id'] = $product->getStoreIds();
53
- $products[$id]['price'] = $product->getFinalPrice();
54
- $products[$id]['special_price'] = $product->getSpecialPrice();
55
- $products[$id]['image_url'] = (string) Mage::helper('catalog/image')->init($product, 'image');
56
 
57
- $configOptions = array();
58
- $customOptions = array();
59
- $childProductData = array();
60
-
61
- if($product->getTypeId() == self::CONFIGURABLE_PRODUCT) {
62
- if($productAttributeOptions = Mage::getModel('catalog/product')->load($product->getId())->getTypeInstance (true)->getConfigurableAttributesAsArray($product)) {
63
- $configOptions = Mage::helper('tracking')->productOptions($productAttributeOptions, 'label');
64
- }
65
-
66
- $childProducts = $product->getTypeInstance()->getUsedProductIds();
67
- foreach($childProducts as $childProductId) {
68
- $childProductDetails = Mage::getModel('catalog/product')->load($childProductId);
69
- $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
70
- $childProductData[$childProductId]['parent_id'] = $product->getId();
71
- }
72
- $products[$id]['child_items'] = $childProductData;
73
- $products[$id]['parent_id'] = $product->getId();
74
- }
75
 
76
- if($product->getTypeId() == self::BUNDLE_PRODUCT) {
77
- $collection = $product->getTypeInstance(true)
78
- ->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
79
 
80
- foreach($collection as $item) {
81
- $childProductId = $item->getId();
82
- $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
83
- $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
84
- $childProductData[$childProductId]['parent_id'] = $product->getId();
85
- }
86
- $products[$id]['child_items'] = $childProductData;
87
- $products[$id]['parent_id'] = $product->getId();
88
- }
89
 
90
- if($custOptions = Mage::getModel('catalog/product')->load($product->getId())->getOptions()) {
91
- $customOptions = Mage::helper('tracking')->productOptions($custOptions);
92
- }
93
- $options = array_merge($configOptions, $customOptions);
94
-
95
- if (!empty($options))
96
- $products[$id]['attributes'] = $options;
97
- }
98
-
99
- return $products;
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
+ class Targetbay_Tracking_Model_Api2_Product_Rest_Admin_V1 extends Mage_Catalog_Model_Api2_Product_Rest
8
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ // Product type configurable.
11
+ const CONFIGURABLE_PRODUCT = 'configurable';
12
+ const BUNDLE_PRODUCT = 'bundle';
13
+ const GROUPED_PRODUCT = 'grouped';
 
 
 
 
 
14
 
15
+ /**
16
+ * Retrieve list of products
17
+ *
18
+ * @return array
19
+ */
20
+ protected function _retrieveCollection()
21
+ {
22
+ /**
23
+ *
24
+ * @var $collection Mage_Catalog_Model_Resource_Product_Collection
25
+ */
26
+ $collection = Mage::getResourceModel('catalog/product_collection');
27
+ $store = $this->_getStore();
 
 
 
28
 
29
+ $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(),
30
+ Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
31
+ $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(),
32
+ Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
33
+ // available attributes not contain image attribute, but it needed for get image_url
34
+ $availableAttributes[] = 'image';
35
+ $collection->addStoreFilter($store->getId())
36
+ ->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
 
 
 
 
 
 
 
 
 
 
37
 
38
+ $this->_applyCategoryFilter($collection);
39
+ $this->_applyCollectionModifiers($collection);
40
+ $products = $collection->load()->toArray();
41
 
42
+ foreach ($products as $id => $data) {
43
+ $product = Mage::getModel('catalog/product')->load($id);
44
+ $stockItem = Mage::getModel('cataloginventory/stock_item');
45
+ $stockItem->loadByProduct($product);
46
+ $products[$id]['qty'] = $stockItem->getQty();
 
 
 
 
47
 
48
+ // Get product url key
49
+ if ($product->getUrlKey() != '') {
50
+ $urlKey = $product->getUrlKey();
51
+ } else {
52
+ $urlKey = $product->getProductUrl();
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @var $category Get product categories
58
+ */
59
+ $products[$id]['meta_keyword'] = (string) Mage::helper('tracking')->getProductCategory($product);
60
+ $products[$id]['category_id'] = (string) Mage::helper('tracking')->getProductCategory($product);
61
+ if(count($product->getRelatedProductIds()) > 0) {
62
+ $products[$id]['related_product_id'] = implode(',', $product->getRelatedProductIds());
63
+ }
64
+ if(count($product->getUpSellProductIds()) > 0) {
65
+ $products[$id]['upsell_product_id'] = implode(',', $product->getUpSellProductIds());
66
+ }
67
+ if(count($product->getCrossSellProductIds()) > 0) {
68
+ $products[$id]['crosssell_product_id'] = implode(',', $product->getCrossSellProductIds());
69
+ }
70
+ $products[$id]['visibility'] = $product->getVisibility();
71
+ $products[$id]['status'] = $product->getStatus();
72
+ $products[$id]['website_id'] = $product->getWebsiteIds();
73
+ $products[$id]['store_id'] = $product->getStoreIds();
74
+ $products[$id]['url_key'] = $urlKey;
75
+ $products[$id]['price'] = $product->getFinalPrice();
76
+ $products[$id]['special_price'] = $product->getSpecialPrice();
77
+ $products[$id]['image_url'] = (string) Mage::helper('catalog/image')->init($product, 'image');
78
+ $products[$id]['stock_count'] = ($stockItem->getQty() > 0) ? $stockItem->getQty() : $stockItem->getMaxSaleQty();
79
+
80
+ $configOptions = array();
81
+ $customOptions = array();
82
+ $childProductData = array();
83
+
84
+ switch ($product->getTypeId()) {
85
+ case self::CONFIGURABLE_PRODUCT:
86
+ if ($productAttributeOptions = Mage::getModel('catalog/product')->load($product->getId())->getTypeInstance(true)->getConfigurableAttributesAsArray($product)) {
87
+ $configOptions = Mage::helper('tracking')->productOptions($productAttributeOptions, 'label');
88
+ }
89
+
90
+ $childProducts = $product->getTypeInstance()->getUsedProductIds();
91
+ foreach ($childProducts as $childProductId) {
92
+ $childProductDetails = Mage::getModel('catalog/product')->load($childProductId);
93
+ $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
94
+ $childProductData[$childProductId]['parent_id'] = $product->getId();
95
+ }
96
+ $products[$id]['child_items'] = $childProductData;
97
+ $products[$id]['parent_id'] = $product->getId();
98
+ break;
99
+ case self::BUNDLE_PRODUCT:
100
+ $collection = $product->getTypeInstance(true)
101
+ ->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
102
+
103
+ foreach ($collection as $item) {
104
+ $childProductId = $item->getId();
105
+ $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
106
+ $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
107
+ $childProductData[$childProductId]['parent_id'] = $product->getId();
108
+ }
109
+ $products[$id]['child_items'] = $childProductData;
110
+ $products[$id]['parent_id'] = $product->getId();
111
+ break;
112
+ case self::GROUPED_PRODUCT:
113
+ $collection = $product->getTypeInstance(true)->getAssociatedProducts($product);
114
+
115
+ foreach ($collection as $item) {
116
+ $childProductId = $item->getId();
117
+ $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
118
+ $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
119
+ $childProductData[$childProductId]['parent_id'] = $product->getId();
120
+ }
121
+ $products[$id]['child_items'] = $childProductData;
122
+ $products[$id]['parent_id'] = $product->getId();
123
+ break;
124
+ }
125
+
126
+ if ($custOptions = Mage::getModel('catalog/product')->load($product->getId())->getOptions()) {
127
+ $customOptions = Mage::helper('tracking')->productOptions($custOptions);
128
+ }
129
+ $options = array_merge($configOptions, $customOptions);
130
+
131
+ if (!empty($options)) {
132
+ $products[$id]['attributes'] = $options;
133
+ }
134
+ }
135
+
136
+ return $products;
137
+ }
138
  }
app/code/community/Targetbay/Tracking/Model/Api2/Product/Rest/Admin/V1.php~ DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
- /*
3
- * @author Targetbay
4
- * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
- * @package Targetbay_Tracking
6
- */
7
- class Targetbay_Tracking_Model_Api2_Product_Rest_Admin_V1 extends Mage_Catalog_Model_Api2_Product_Rest {
8
-
9
- // Product type configurable.
10
- CONST CONFIGURABLE_PRODUCT = 'configurable';
11
- CONST BUNDLE_PRODUCT = 'bundle';
12
-
13
- /**
14
- * Retrieve list of products
15
- *
16
- * @return array
17
- */
18
- protected function _retrieveCollection() {
19
- /**
20
- *
21
- * @var $collection Mage_Catalog_Model_Resource_Product_Collection
22
- */
23
- $collection = Mage::getResourceModel('catalog/product_collection');
24
- $store = $this->_getStore();
25
- $collection->setStoreId($store->getId());
26
- $collection->addAttributeToSelect(array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ)));
27
- $collection->addStoreFilter($store->getId())->addPriceData($this->_getCustomerGroupId(), $store->getWebsiteId())->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes))->addAttributeToFilter('visibility', array(
28
- 'neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
29
- ))->addAttributeToFilter('status', array(
30
- 'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
31
- ));
32
- $this->_applyCategoryFilter($collection);
33
- $this->_applyCollectionModifiers( $collection);
34
- $products = $collection->load()->toArray();
35
-
36
- foreach($products as $id => $data) {
37
- $product = Mage::getModel('catalog/product')->load($id);
38
- $stockItem = Mage::getModel('cataloginventory/stock_item');
39
- $stockItem->loadByProduct($product);
40
- $products[$id]['qty'] = $stockItem->getQty();
41
-
42
- /**
43
- *
44
- * @var $category Get product categories
45
- */
46
- $products[$id]['meta_keyword'] = (string) Mage::helper('tracking')->getProductCategory($product);
47
- $products[$id]['category_id'] = (string) Mage::helper('tracking')->getProductCategory($product);
48
- $products[$id]['related_product_id'] = implode(',', $product->getRelatedProductIds());
49
- $products[$id]['upsell_product_id'] = implode(',', $product->getUpSellProductIds());
50
- $products[$id]['crosssell_product_id'] = implode(',', $product->getCrossSellProducts());
51
- $products[$id]['visibility'] = $product->getVisibility();
52
- $products[$id]['status'] = $product->getStatus();
53
- $products[$id]['website_id'] = $product->getWebsiteIds();
54
- $products[$id]['store_id'] = $product->getStoreIds();
55
- $products[$id]['special_price'] = Mage::helper('core')->currency($product->getSpecialPrice(), true, false);
56
- $products[$id]['image_url'] = (string) Mage::helper('catalog/image')->init($product, 'image');
57
-
58
- $configOptions = array();
59
- $customOptions = array();
60
- $childProductData = array();
61
-
62
- if($product->getTypeId() == self::CONFIGURABLE_PRODUCT) {
63
- if($productAttributeOptions = Mage::getModel('catalog/product')->load($product->getId())->getTypeInstance (true)->getConfigurableAttributesAsArray($product)) {
64
- $configOptions = Mage::helper('tracking')->productOptions($productAttributeOptions, 'label');
65
- }
66
-
67
- $childProducts = $product->getTypeInstance()->getUsedProductIds();
68
- foreach($childProducts as $childProductId) {
69
- $childProductDetails = Mage::getModel('catalog/product')->load($childProductId);
70
- $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
71
- $childProductData[$childProductId]['parent_id'] = $product->getId();
72
- }
73
- $products[$id]['child_items'] = $childProductData;
74
- $products[$id]['parent_id'] = $product->getId();
75
- }
76
-
77
- if($product->getTypeId() == self::BUNDLE_PRODUCT) {
78
- $collection = $product->getTypeInstance(true)
79
- ->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
80
-
81
- foreach($collection as $item) {
82
- $childProductId = $item->getId();
83
- $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
84
- $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
85
- $childProductData[$childProductId]['parent_id'] = $product->getId();
86
- }
87
- $products[$id]['child_items'] = $childProductData;
88
- $products[$id]['parent_id'] = $product->getId();
89
- }
90
- s
91
- if($custOptions = Mage::getModel('catalog/product')->load($product->getId())->getOptions()) {
92
- $customOptions = Mage::helper('tracking')->productOptions($custOptions);
93
- }
94
- $options = array_merge($configOptions, $customOptions);
95
-
96
- if (!empty($options))
97
- $products[$id]['attributes'] = $options;
98
- }
99
-
100
- return $products;
101
- }
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Targetbay/Tracking/Model/Api2/Product/Rest/Guest/V1.php CHANGED
@@ -1,168 +1,206 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Product_Rest_Guest_V1 extends Mage_Catalog_Model_Api2_Product_Rest {
8
-
9
- // Product type configurable.
10
- CONST CONFIGURABLE_PRODUCT = 'configurable';
11
- CONST BUNDLE_PRODUCT = 'bundle';
12
-
13
- /**
14
- * Retrieve list of products
15
- *
16
- * @return array
17
- */
18
- protected function _retrieveCollection() {
19
- /**
20
- *
21
- * @var $collection Mage_Catalog_Model_Resource_Product_Collection
22
- */
23
- $collection = Mage::getResourceModel('catalog/product_collection');
24
- $store = $this->_getStore();
25
- $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
26
- $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
27
-
28
- // available attributes not contain image attribute, but it needed for get image_url
29
- $availableAttributes[] = 'image';
30
- $collection->addStoreFilter($store->getId())->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
31
-
32
- $this->_applyCategoryFilter($collection);
33
- $this->_applyCollectionModifiers($collection);
34
- Mage::helper('tracking')->debug($collection->getSelect()->__toString());
35
- $products = $collection->load();
36
- /**
37
- *
38
- * @var Mage_Catalog_Model_Product $product
39
- */
40
- foreach($products as $product) {
41
- $this->_setProduct($product);
42
- $this->_prepareProductForResponse($product);
43
- }
44
- return $products->toArray();
45
- }
46
-
47
- /**
48
- * Add special fields to product get response
49
- *
50
- * @param Mage_Catalog_Model_Product $product
51
- */
52
- protected function _prepareProductForResponse(Mage_Catalog_Model_Product $product) {
53
- /**
54
- *
55
- * @var $productHelper Mage_Catalog_Helper_Product
56
- */
57
- $productHelper = Mage::helper('catalog/product');
58
- $productData = $product->getData();
59
- $product->setWebsiteId($this->_getStore()->getWebsiteId());
60
- // customer group is required in product for correct prices calculation
61
- $product->setCustomerGroupId($this->_getCustomerGroupId());
62
- // calculate prices
63
- $finalPrice = $product->getFinalPrice();
64
- $productData['regular_price_with_tax'] = $this->_applyTaxToPrice($product->getPrice(), true);
65
- $productData['regular_price_without_tax'] = $this->_applyTaxToPrice($product->getPrice(), false);
66
- $productData['final_price_with_tax'] = $this->_applyTaxToPrice($finalPrice, true);
67
- $productData['final_price_without_tax'] = $this->_applyTaxToPrice($finalPrice, false);
68
-
69
- $productData['is_saleable'] = $product->getIsSalable();
70
- $productData['image_url'] = (string) Mage::helper('catalog/image')->init($product, 'image');
71
- $productData['visibility'] = $product->getVisibility();
72
- $productData['status'] = $product->getStatus();
73
- $productData['website_id'] = $product->getWebsiteIds();
74
- $productData['store_id'] = $product->getStoreIds();
75
- $productData['url'] = $product->getUrlKey();
76
- $productData['url_key'] = $product->getUrlKey();
77
- $productData['price'] = $product->getFinalPrice();
78
- $productData['special_price'] = $product->getSpecialPrice();
79
-
80
- /**
81
- *
82
- * @var $category Get product categories
83
- */
84
- $productData['meta_keyword'] = (string) Mage::helper('tracking')->getProductCategory($product);
85
- $productData['category_id'] = (string) Mage::helper('tracking')->getProductCategory($product);
86
- $productData['related_product_id'] = implode(',', $product->getRelatedProductIds());
87
- $productData['upsell_product_id'] = implode(',', $product->getUpSellProductIds());
88
- $productData['crosssell_product_id'] = implode(',', $product->getCrossSellProducts());
89
-
90
- if($this->getActionType() == self::ACTION_TYPE_ENTITY) {
91
- // define URLs
92
- $productData['url'] = $productHelper->getProductUrl($product->getId());
93
-
94
- /**
95
- *
96
- * @var $cartHelper Mage_Checkout_Helper_Cart
97
- */
98
- $cartHelper = Mage::helper('checkout/cart');
99
- $productData['buy_now_url'] = $cartHelper->getAddUrl($product);
100
-
101
- /**
102
- *
103
- * @var $stockItem Mage_CatalogInventory_Model_Stock_Item
104
- */
105
- $stockItem = $product->getStockItem();
106
- if(!$stockItem) {
107
- $stockItem = Mage::getModel('cataloginventory/stock_item');
108
- $stockItem->loadByProduct($product);
109
- }
110
- $productData['is_in_stock'] = $stockItem->getIsInStock();
111
-
112
- /**
113
- *
114
- * @var $reviewModel Mage_Review_Model_Review
115
- */
116
- $reviewModel = Mage::getModel('review/review');
117
- $productData['total_reviews_count'] = $reviewModel->getTotalReviews($product->getId(), true, $this->_getStore()->getId());
118
- $productData['tier_price'] = $this->_getTierPrice();
119
- $productData['has_custom_options'] = count($product->getOptions()) > 0;
120
- } else {
121
- // remove tier price from response
122
- $product->unsetData('tier_price');
123
- unset($productData['tier_price']);
124
- }
125
-
126
- // Added the custom options and configurable products options
127
- $configOptions = array();
128
- $customOptions = array();
129
- $childProductData = array();
130
-
131
- if($product->getTypeId() == self::CONFIGURABLE_PRODUCT) {
132
- if($productAttributeOptions = Mage::getModel('catalog/product')->load($product->getId())->getTypeInstance(true)->getConfigurableAttributesAsArray($product)) {
133
- $configOptions = Mage::helper('tracking')->productOptions($productAttributeOptions, 'label');
134
- }
135
-
136
- $childProducts = $product->getTypeInstance()->getUsedProductIds();
137
- foreach($childProducts as $childProductId) {
138
- $childProductDetails = Mage::getModel('catalog/product')->load($childProductId);
139
- $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
140
- $childProductData[$childProductId]['parent_id'] = $product->getId();
141
- }
142
- $productData['child_items'] = $childProductData;
143
- $productData['parent_id'] = $product->getId();
144
- }
145
- if($product->getTypeId() == self::BUNDLE_PRODUCT) {
146
- $collection = $product->getTypeInstance(true)
147
- ->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
148
-
149
- foreach($collection as $item) {
150
- $childProductId = $item->getId();
151
- $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
152
- $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
153
- $childProductData[$childProductId]['parent_id'] = $product->getId();
154
- }
155
- $productData['child_items'] = $childProductData;
156
- $productData['parent_id'] = $product->getId();
157
- }
158
- if($custOptions = Mage::getModel('catalog/product')->load($product->getId())->getOptions()) {
159
- $customOptions = Mage::helper('tracking')->productOptions($custOptions);
160
- }
161
- $options = array_merge($configOptions, $customOptions);
162
-
163
- if(!empty ($options)) {
164
- $productData['attributes'] = $options;
165
- }
166
- $product->addData($productData);
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Product_Rest_Guest_V1 extends Mage_Catalog_Model_Api2_Product_Rest
10
+ {
11
+
12
+ // Product type configurable.
13
+ const CONFIGURABLE_PRODUCT = 'configurable';
14
+ const BUNDLE_PRODUCT = 'bundle';
15
+ const GROUPED_PRODUCT = 'grouped';
16
+
17
+ /**
18
+ * Retrieve list of products
19
+ *
20
+ * @return array
21
+ */
22
+ protected function _retrieveCollection()
23
+ {
24
+ /**
25
+ *
26
+ * @var $collection Mage_Catalog_Model_Resource_Product_Collection
27
+ */
28
+ $collection = Mage::getResourceModel('catalog/product_collection');
29
+ $store = $this->_getStore();
30
+ $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
31
+ $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
32
+
33
+ // available attributes not contain image attribute, but it needed for get image_url
34
+ $availableAttributes[] = 'image';
35
+ $collection->addStoreFilter($store->getId())->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
36
+
37
+ $this->_applyCategoryFilter($collection);
38
+ $this->_applyCollectionModifiers($collection);
39
+ $products = $collection->load();
40
+
41
+ /**
42
+ *
43
+ * @var Mage_Catalog_Model_Product $product
44
+ */
45
+ foreach ($products as $product) {
46
+ $this->_setProduct($product);
47
+ $this->_prepareProductForResponse($product);
48
+ }
49
+ return $products->toArray();
50
+ }
51
+
52
+ /**
53
+ * Add special fields to product get response
54
+ *
55
+ * @param Mage_Catalog_Model_Product $product
56
+ */
57
+ protected function _prepareProductForResponse(Mage_Catalog_Model_Product $product)
58
+ {
59
+ /**
60
+ *
61
+ * @var $productHelper Mage_Catalog_Helper_Product
62
+ */
63
+ $productHelper = Mage::helper('catalog/product');
64
+ $productData = $product->getData();
65
+ $product->setWebsiteId($this->_getStore()->getWebsiteId());
66
+ // customer group is required in product for correct prices calculation
67
+ $product->setCustomerGroupId($this->_getCustomerGroupId());
68
+
69
+ // Get Stock product
70
+ $stockItem = Mage::getModel('cataloginventory/stock_item');
71
+ $stockItem->loadByProduct($product);
72
+
73
+ // Get product url key
74
+ if ($product->getUrlKey() != '') {
75
+ $urlKey = $product->getUrlKey();
76
+ } else {
77
+ $urlKey = $product->getProductUrl();
78
+ }
79
+
80
+ // calculate prices
81
+ $finalPrice = $product->getFinalPrice();
82
+ $productData['regular_price_with_tax'] = $this->_applyTaxToPrice($product->getPrice(), true);
83
+ $productData['regular_price_without_tax'] = $this->_applyTaxToPrice($product->getPrice(), false);
84
+ $productData['final_price_with_tax'] = $this->_applyTaxToPrice($finalPrice, true);
85
+ $productData['final_price_without_tax'] = $this->_applyTaxToPrice($finalPrice, false);
86
+
87
+ $productData['is_saleable'] = $product->getIsSalable();
88
+ $productData['image_url'] = (string) Mage::helper('catalog/image')->init($product, 'image');
89
+ $productData['visibility'] = $product->getVisibility();
90
+ $productData['status'] = $product->getStatus();
91
+ $productData['website_id'] = $product->getWebsiteIds();
92
+ $productData['store_id'] = $product->getStoreIds();
93
+ $productData['url_key'] = $urlKey;
94
+ $productData['price'] = $product->getFinalPrice();
95
+ $productData['special_price'] = $product->getSpecialPrice();
96
+ $productData['stock_count'] = ($stockItem->getQty() > 0) ? $stockItem->getQty() : $stockItem->getMaxSaleQty();
97
+
98
+ /**
99
+ *
100
+ * @var $category Get product categories
101
+ */
102
+ $productData['meta_keyword'] = (string) Mage::helper('tracking')->getProductCategory($product);
103
+ $productData['category_id'] = (string) Mage::helper('tracking')->getProductCategory($product);
104
+ if(count($product->getRelatedProductIds()) > 0) {
105
+ $productData['related_product_id'] = implode(',', $product->getRelatedProductIds());
106
+ }
107
+ if(count($product->getUpSellProductIds()) > 0) {
108
+ $productData['upsell_product_id'] = implode(',', $product->getUpSellProductIds());
109
+ }
110
+ if(count($product->getCrossSellProductIds()) > 0) {
111
+ $productData['crosssell_product_id'] = implode(',', $product->getCrossSellProductIds());
112
+ }
113
+
114
+ if ($this->getActionType() == self::ACTION_TYPE_ENTITY) {
115
+ // define URLs
116
+ $productData['url'] = $productHelper->getProductUrl($product->getId());
117
+
118
+ /**
119
+ *
120
+ * @var $cartHelper Mage_Checkout_Helper_Cart
121
+ */
122
+ $cartHelper = Mage::helper('checkout/cart');
123
+ $productData['buy_now_url'] = $cartHelper->getAddUrl($product);
124
+
125
+ /**
126
+ *
127
+ * @var $stockItem Mage_CatalogInventory_Model_Stock_Item
128
+ */
129
+ $stockItem = $product->getStockItem();
130
+ if (!$stockItem) {
131
+ $stockItem = Mage::getModel('cataloginventory/stock_item');
132
+ $stockItem->loadByProduct($product);
133
+ }
134
+ $productData['is_in_stock'] = $stockItem->getIsInStock();
135
+
136
+ /**
137
+ *
138
+ * @var $reviewModel Mage_Review_Model_Review
139
+ */
140
+ $reviewModel = Mage::getModel('review/review');
141
+ $productData['total_reviews_count'] = $reviewModel->getTotalReviews($product->getId(), true, $this->_getStore()->getId());
142
+ $productData['tier_price'] = $this->_getTierPrice();
143
+ $productData['has_custom_options'] = count($product->getOptions()) > 0;
144
+ } else {
145
+ // remove tier price from response
146
+ $product->unsetData('tier_price');
147
+ unset($productData['tier_price']);
148
+ }
149
+
150
+ // Added the custom options and configurable products options
151
+ $configOptions = array();
152
+ $customOptions = array();
153
+ $childProductData = array();
154
+
155
+ switch ($product->getTypeId()) {
156
+ case self::CONFIGURABLE_PRODUCT:
157
+ if ($productAttributeOptions = Mage::getModel('catalog/product')->load($product->getId())->getTypeInstance(true)->getConfigurableAttributesAsArray($product)) {
158
+ $configOptions = Mage::helper('tracking')->productOptions($productAttributeOptions, 'label');
159
+ }
160
+
161
+ $childProducts = $product->getTypeInstance()->getUsedProductIds();
162
+ foreach ($childProducts as $childProductId) {
163
+ $childProductDetails = Mage::getModel('catalog/product')->load($childProductId);
164
+ $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
165
+ $childProductData[$childProductId]['parent_id'] = $product->getId();
166
+ }
167
+ $productData['child_items'] = $childProductData;
168
+ $productData['parent_id'] = $product->getId();
169
+ break;
170
+ case self::BUNDLE_PRODUCT:
171
+ $collection = $product->getTypeInstance(true)
172
+ ->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
173
+
174
+ foreach ($collection as $item) {
175
+ $childProductId = $item->getId();
176
+ $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
177
+ $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
178
+ $childProductData[$childProductId]['parent_id'] = $product->getId();
179
+ }
180
+ $productData['child_items'] = $childProductData;
181
+ $productData['parent_id'] = $product->getId();
182
+ break;
183
+ case self::GROUPED_PRODUCT:
184
+ $collection = $product->getTypeInstance(true)->getAssociatedProducts($product);
185
+
186
+ foreach ($collection as $item) {
187
+ $childProductId = $item->getId();
188
+ $childProductDetails = Mage::getModel('catalog/product')->load($item->getId());
189
+ $childProductData[$childProductId] = Mage::helper('tracking')->getProductData($childProductDetails);
190
+ $childProductData[$childProductId]['parent_id'] = $product->getId();
191
+ }
192
+ $productData['child_items'] = $childProductData;
193
+ $productData['parent_id'] = $product->getId();
194
+ break;
195
+ }
196
+ if ($custOptions = Mage::getModel('catalog/product')->load($product->getId())->getOptions()) {
197
+ $customOptions = Mage::helper('tracking')->productOptions($custOptions);
198
+ }
199
+ $options = array_merge($configOptions, $customOptions);
200
+
201
+ if (!empty($options)) {
202
+ $productData['attributes'] = $options;
203
+ }
204
+ $product->addData($productData);
205
+ }
206
  }
app/code/community/Targetbay/Tracking/Model/Api2/Review.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Review extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Review extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Review/Rest/Admin/V1.php CHANGED
@@ -1,74 +1,73 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Review_Rest_Admin_V1 extends Mage_Api2_Model_Resource {
8
-
9
- /**
10
- * Retrieve review
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
 
16
- $page_num = Mage::app()->getRequest()->getParam('page');
17
- $limit = Mage::app()->getRequest()->getParam('limit');
18
-
19
- $reviewCollection = Mage::getModel('review/review')->getResourceCollection()
20
- ->setPageSize($limit)
21
- ->setCurPage($page_num)
22
- ->setDateOrder()
23
- ->addRateVotes()
24
- ->load();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- $review_data = array();
27
- $review_datas = array();
28
- $sku = '';
29
- foreach($reviewCollection as $review)
30
- {
31
- $storeId = Mage::getModel('review/review')->load($review->getId())->getStoreId();
32
- $product = Mage::getModel ( 'catalog/product' )->load($review->getEntityPkValue());
33
- $sku = $product->getSku();
34
 
35
- if($sku) {
36
- $ratingCollection = Mage::getModel('rating/rating_option_vote')
37
- ->getResourceCollection()
38
- ->setReviewFilter($review->getId());
 
 
39
 
40
-
41
- $rating_val = "";
42
- $option = "";
43
- $option_value = '';
44
- foreach($ratingCollection as $rating)
45
- {
46
-
47
- $option = $rating->getOptionId();
48
- $rating_val = $rating->getRatingId();
49
-
50
- if(!empty($option_value) && $option_value != '')
51
- $option_value = $option_value."@".$rating_val.":".$option;
52
- else
53
- $option_value = $rating_val.":".$option;
54
-
55
- }
56
 
57
- $review_data['entity_id'] = $review->getId();
58
- $review_data['product_id'] = $review->getEntityPkValue();
59
- $review_data['sku'] = $sku;
60
- $review_data['title'] = $review->getTitle();
61
- $review_data['detail'] = $review->getDetail();
62
- $review_data['nickname'] = $review->getNickname();
63
- $review_data['store_id'] = $storeId;
64
- $review_data['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
65
- $review_data['customer_id'] = $review->getCustomer_id();
66
- $review_data['option_id'] = $option_value;
67
- $review_data['created_at'] = Mage::helper('core')->formatDate($review->getCreated_at(), 'long');
68
- $review_data['status_id'] = $review->getStatus_id();
69
- $review_datas[$review->getId()][] = $review_data;
70
- }
71
- }
72
- return $review_datas;
73
- }
74
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Review_Rest_Admin_V1 extends Mage_Api2_Model_Resource
10
+ {
11
+
12
+ /**
13
+ * Retrieve review
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $page_num = Mage::app()->getRequest()->getParam('page');
20
+ $limit = Mage::app()->getRequest()->getParam('limit');
21
+
22
+ $reviewCollection = Mage::getModel('review/review')->getResourceCollection()
23
+ ->setPageSize($limit)
24
+ ->setCurPage($page_num)
25
+ ->setDateOrder()
26
+ ->addRateVotes()
27
+ ->load();
28
+
29
+ $review_data = array();
30
+ $review_datas = array();
31
+ $sku = '';
32
+ foreach ($reviewCollection as $review) {
33
+ $storeId = Mage::getModel('review/review')->load($review->getId())->getStoreId();
34
+ $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
35
+ $sku = $product->getSku();
36
 
37
+ if ($sku) {
38
+ $ratingCollection = Mage::getModel('rating/rating_option_vote')
39
+ ->getResourceCollection()
40
+ ->setReviewFilter($review->getId());
 
 
 
 
41
 
42
+ $rating_val = "";
43
+ $option = "";
44
+ $option_value = '';
45
+ foreach ($ratingCollection as $rating) {
46
+ $option = $rating->getOptionId();
47
+ $rating_val = $rating->getRatingId();
48
 
49
+ if (!empty($option_value) && $option_value != '') {
50
+ $option_value = $option_value . "@" . $rating_val . ":" . $option;
51
+ } else {
52
+ $option_value = $rating_val . ":" . $option;
53
+ }
54
+ }
 
 
 
 
 
 
 
 
 
 
55
 
56
+ $review_data['entity_id'] = $review->getId();
57
+ $review_data['product_id'] = $review->getEntityPkValue();
58
+ $review_data['sku'] = $sku;
59
+ $review_data['title'] = $review->getTitle();
60
+ $review_data['detail'] = $review->getDetail();
61
+ $review_data['nickname'] = $review->getNickname();
62
+ $review_data['store_id'] = $storeId;
63
+ $review_data['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
64
+ $review_data['customer_id'] = $review->getCustomer_id();
65
+ $review_data['option_id'] = $option_value;
66
+ $review_data['created_at'] = Mage::helper('core')->formatDate($review->getCreated_at(), 'long');
67
+ $review_data['status_id'] = $review->getStatus_id();
68
+ $review_datas[$review->getId()][] = $review_data;
69
+ }
70
+ }
71
+ return $review_datas;
72
+ }
73
  }
app/code/community/Targetbay/Tracking/Model/Api2/Review/Rest/Guest/V1.php CHANGED
@@ -1,75 +1,74 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Review_Rest_Guest_V1 extends Mage_Api2_Model_Resource {
8
-
9
- /**
10
- * Retrieve review
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
 
16
- $page_num = Mage::app()->getRequest()->getParam('page');
17
- $limit = Mage::app()->getRequest()->getParam('limit');
18
-
19
- $reviewCollection = Mage::getModel('review/review')->getResourceCollection()
20
- ->setPageSize($limit)
21
- ->setCurPage($page_num)
22
- ->setDateOrder()
23
- ->addRateVotes()
24
- ->load();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- $review_data = array();
27
- $review_datas = array();
28
- $sku = '';
 
29
 
30
- foreach($reviewCollection as $review)
31
- {
32
- $storeId = Mage::getModel('review/review')->load($review->getId())->getStoreId();
33
- $product = Mage::getModel ( 'catalog/product' )->load($review->getEntityPkValue());
34
- $sku = $product->getSku();
35
 
36
- if($sku) {
37
- $ratingCollection = Mage::getModel('rating/rating_option_vote')
38
- ->getResourceCollection()
39
- ->setReviewFilter($review->getId());
 
 
40
 
41
-
42
- $rating_val = "";
43
- $option = "";
44
- $option_value = '';
45
- foreach($ratingCollection as $rating)
46
- {
47
-
48
- $option = $rating->getOptionId();
49
- $rating_val = $rating->getRatingId();
50
-
51
- if(!empty($option_value) && $option_value != '')
52
- $option_value = $option_value."@".$rating_val.":".$option;
53
- else
54
- $option_value = $rating_val.":".$option;
55
-
56
- }
57
- $review_data['entity_id'] = $review->getId();
58
- $review_data['product_id'] = $review->getEntityPkValue();
59
- $review_data['sku'] = $sku;
60
- $review_data['title'] = $review->getTitle();
61
- $review_data['detail'] = $review->getDetail();
62
- $review_data['nickname'] = $review->getNickname();
63
- $review_data['store_id'] = $storeId;
64
- $review_data['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
65
- $review_data['customer_id'] = $review->getCustomer_id();
66
- $review_data['option_id'] = $option_value;
67
- $review_data['created_at'] = Mage::helper('core')->formatDate($review->getCreated_at(), 'long');
68
- $review_data['status_id'] = $review->getStatus_id();
69
- $review_datas[$review->getId()][] = $review_data;
70
- }
71
- }
72
 
73
- return $review_datas;
74
- }
75
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Review_Rest_Guest_V1 extends Mage_Api2_Model_Resource
10
+ {
11
+
12
+ /**
13
+ * Retrieve review
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $page_num = Mage::app()->getRequest()->getParam('page');
20
+ $limit = Mage::app()->getRequest()->getParam('limit');
21
+
22
+ $reviewCollection = Mage::getModel('review/review')->getResourceCollection()
23
+ ->setPageSize($limit)
24
+ ->setCurPage($page_num)
25
+ ->setDateOrder()
26
+ ->addRateVotes()
27
+ ->load();
28
+
29
+ $review_data = array();
30
+ $review_datas = array();
31
+ $sku = '';
32
 
33
+ foreach ($reviewCollection as $review) {
34
+ $storeId = Mage::getModel('review/review')->load($review->getId())->getStoreId();
35
+ $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
36
+ $sku = $product->getSku();
37
 
38
+ if ($sku) {
39
+ $ratingCollection = Mage::getModel('rating/rating_option_vote')
40
+ ->getResourceCollection()
41
+ ->setReviewFilter($review->getId());
 
42
 
43
+ $rating_val = "";
44
+ $option = "";
45
+ $option_value = '';
46
+ foreach ($ratingCollection as $rating) {
47
+ $option = $rating->getOptionId();
48
+ $rating_val = $rating->getRatingId();
49
 
50
+ if (!empty($option_value) && $option_value != '') {
51
+ $option_value = $option_value . "@" . $rating_val . ":" . $option;
52
+ } else {
53
+ $option_value = $rating_val . ":" . $option;
54
+ }
55
+ }
56
+ $review_data['entity_id'] = $review->getId();
57
+ $review_data['product_id'] = $review->getEntityPkValue();
58
+ $review_data['sku'] = $sku;
59
+ $review_data['title'] = $review->getTitle();
60
+ $review_data['detail'] = $review->getDetail();
61
+ $review_data['nickname'] = $review->getNickname();
62
+ $review_data['store_id'] = $storeId;
63
+ $review_data['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
64
+ $review_data['customer_id'] = $review->getCustomer_id();
65
+ $review_data['option_id'] = $option_value;
66
+ $review_data['created_at'] = Mage::helper('core')->formatDate($review->getCreated_at(), 'long');
67
+ $review_data['status_id'] = $review->getStatus_id();
68
+ $review_datas[$review->getId()][] = $review_data;
69
+ }
70
+ }
 
 
 
 
 
 
 
 
 
 
71
 
72
+ return $review_datas;
73
+ }
74
  }
app/code/community/Targetbay/Tracking/Model/Api2/Shipment.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Shipment extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Shipment extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Shipment/Rest/Admin/V1.php CHANGED
@@ -1,33 +1,36 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Shipment_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Shipment {
8
-
9
- /**
10
- * Get orders list
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $collection = Mage::getModel('sales/order_shipment')->getCollection();
16
- $collection->addAttributeToFilter('created_at', array(
17
- 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
18
 
19
- $shipmentData = array ();
20
- $params['shipment'] = true;
21
- foreach ($collection->getItems() as $order) {
22
- //$shipmentData [$order->getId()] = $order->toArray();
23
- $orderId = $order->getOrderId();
24
- $orderInfo = Mage::getModel('sales/order')->load($orderId);
25
- $storeId = $orderInfo->getStoreId();
26
- $shipmentData[$order->getId()] = Mage::helper('tracking')->getFullFillmentData($orderInfo, $params);
27
- $shipmentData[$order->getId()]['store_id'] = $storeId;
28
- $shipmentData[$order->getId()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
29
- }
30
- return $shipmentData;
31
- }
32
- }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Shipment_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Shipment
10
+ {
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ /**
13
+ * Get orders list
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $collection = Mage::getModel('sales/order_shipment')->getCollection();
20
+ $collection->addAttributeToFilter('created_at', array(
21
+ 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
22
+
23
+ $shipmentData = array();
24
+ $params['shipment'] = true;
25
+ foreach ($collection->getItems() as $order) {
26
+ //$shipmentData [$order->getId()] = $order->toArray();
27
+ $orderId = $order->getOrderId();
28
+ $orderInfo = Mage::getModel('sales/order')->load($orderId);
29
+ $storeId = $orderInfo->getStoreId();
30
+ $shipmentData[$order->getId()] = Mage::helper('tracking')->getFullFillmentData($orderInfo, $params);
31
+ $shipmentData[$order->getId()]['store_id'] = $storeId;
32
+ $shipmentData[$order->getId()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
33
+ }
34
+ return $shipmentData;
35
+ }
36
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Shipment/Rest/Guest/V1.php CHANGED
@@ -1,33 +1,36 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Shipment_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Shipment {
8
-
9
- /**
10
- * Get orders list
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $collection = Mage::getModel('sales/order_shipment')->getCollection();
16
- $collection->addAttributeToFilter('created_at', array(
17
- 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
18
 
19
- $shipmentData = array ();
20
- $params['shipment']=true;
21
- foreach ($collection->getItems() as $order) {
22
- //$shipmentData [$order->getId()] = $order->toArray();
23
- $orderId = $order->getOrderId();
24
- $orderInfo = Mage::getModel('sales/order')->load($orderId);
25
- $storeId = $orderInfo->getStoreId();
26
- $shipmentData[$order->getId()] = Mage::helper('tracking')->getFullFillmentData($orderInfo, $params);
27
- $shipmentData[$order->getId()]['store_id'] = $storeId;
28
- $shipmentData[$order->getId()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
29
- }
30
- return $shipmentData;
31
- }
32
- }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Shipment_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Shipment
10
+ {
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ /**
13
+ * Get orders list
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $collection = Mage::getModel('sales/order_shipment')->getCollection();
20
+ $collection->addAttributeToFilter('created_at', array(
21
+ 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
22
+
23
+ $shipmentData = array();
24
+ $params['shipment'] = true;
25
+ foreach ($collection->getItems() as $order) {
26
+ //$shipmentData [$order->getId()] = $order->toArray();
27
+ $orderId = $order->getOrderId();
28
+ $orderInfo = Mage::getModel('sales/order')->load($orderId);
29
+ $storeId = $orderInfo->getStoreId();
30
+ $shipmentData[$order->getId()] = Mage::helper('tracking')->getFullFillmentData($orderInfo, $params);
31
+ $shipmentData[$order->getId()]['store_id'] = $storeId;
32
+ $shipmentData[$order->getId()]['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
33
+ }
34
+ return $shipmentData;
35
+ }
36
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Stores.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Stores extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Stores extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Stores/Rest/Admin/V1.php CHANGED
@@ -1,30 +1,34 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Stores_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Stores {
8
-
9
- /**
10
- * Retrieve stores
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $storeData = array();
16
- $storeVal = array();
17
- $storeCollection = Mage::getModel('core/store')->getCollection();
18
- foreach($storeCollection as $store) {
19
- $storeId = $store->getStoreId();
20
- $storeVal['store_id'] = Mage::app()->getStore($storeId)->getId();
21
- $storeVal['store_name'] = Mage::app()->getStore($storeId)->getName();
22
- $storeVal['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
23
- $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
24
- $website = Mage::getModel('core/website')->load($websiteId);
25
- $storeVal['website_name'] = $website->getName();
26
- $storeData[] = $storeVal;
27
- }
28
- return $storeData;
29
- }
 
 
 
30
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Stores_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Stores
10
+ {
11
+
12
+ /**
13
+ * Retrieve stores
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $storeData = array();
20
+ $storeVal = array();
21
+ $storeCollection = Mage::getModel('core/store')->getCollection();
22
+ foreach ($storeCollection as $store) {
23
+ $storeId = $store->getStoreId();
24
+ $storeVal['store_id'] = Mage::app()->getStore($storeId)->getId();
25
+ $storeVal['store_name'] = Mage::app()->getStore($storeId)->getName();
26
+ $storeVal['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
27
+ $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
28
+ $website = Mage::getModel('core/website')->load($websiteId);
29
+ $storeVal['website_name'] = $website->getName();
30
+ $storeData[] = $storeVal;
31
+ }
32
+ return $storeData;
33
+ }
34
  }
app/code/community/Targetbay/Tracking/Model/Api2/Stores/Rest/Guest/V1.php CHANGED
@@ -1,30 +1,34 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Stores_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Stores {
8
-
9
- /**
10
- * Retrieve wishlist items
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $storeData = array();
16
- $storeVal = array();
17
- $storeCollection = Mage::getModel('core/store')->getCollection();
18
- foreach($storeCollection as $store) {
19
- $storeId = $store->getStoreId();
20
- $storeVal['store_id'] = Mage::app()->getStore($storeId)->getId();
21
- $storeVal['store_name'] = Mage::app()->getStore($storeId)->getName();
22
- $storeVal['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
23
- $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
24
- $website = Mage::getModel('core/website')->load($websiteId);
25
- $storeVal['website_name'] = $website->getName();
26
- $storeData[] = $storeVal;
27
- }
28
- return $storeData;
29
- }
 
 
 
30
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Stores_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Stores
10
+ {
11
+
12
+ /**
13
+ * Retrieve wishlist items
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $storeData = array();
20
+ $storeVal = array();
21
+ $storeCollection = Mage::getModel('core/store')->getCollection();
22
+ foreach ($storeCollection as $store) {
23
+ $storeId = $store->getStoreId();
24
+ $storeVal['store_id'] = Mage::app()->getStore($storeId)->getId();
25
+ $storeVal['store_name'] = Mage::app()->getStore($storeId)->getName();
26
+ $storeVal['website_id'] = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
27
+ $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
28
+ $website = Mage::getModel('core/website')->load($websiteId);
29
+ $storeVal['website_name'] = $website->getName();
30
+ $storeData[] = $storeVal;
31
+ }
32
+ return $storeData;
33
+ }
34
  }
app/code/community/Targetbay/Tracking/Model/Api2/Subscriber.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Subscriber extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Subscriber extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Subscriber/Rest/Admin/V1.php CHANGED
@@ -1,34 +1,38 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Subscriber_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Subscriber {
8
-
9
- /**
10
- * Retrieve susbcriber list
11
- *
12
- * @return array
13
- */
14
- public function _retrieveCollection() {
15
- $subscribers = array();
16
- $subscriberData = array();
17
 
18
- $page_num = Mage::app()->getRequest()->getParam('page');
19
- $limit = Mage::app()->getRequest()->getParam('limit');
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- $subscriptionCollection = Mage::getModel('newsletter/subscriber')->getCollection();
22
- $subscriptionCollection->getSelect()->limit($limit, $page_num);
23
 
24
- foreach($subscriptionCollection as $subscriber) {
25
- $subscribers['subscriber_id'] = $subscriber->getSubscriberId();
26
- $subscribers['store_id'] = $subscriber->getStoreId();
27
- $subscribers['customer_id'] = $subscriber->getCustomerId();
28
- $subscribers['subscriber_email'] = $subscriber->getSubscriberEmail();
29
- $subscribers['subscriber_status'] = $subscriber->getSubscriberStatus();
30
- $subscriberData[] = $subscribers;
31
- }
32
- return $subscriberData;
33
- }
34
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Subscriber_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Subscriber
10
+ {
11
+
12
+ /**
13
+ * Retrieve susbcriber list
14
+ *
15
+ * @return array
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $subscribers = array();
20
+ $subscriberData = array();
21
+
22
+ $page_num = Mage::app()->getRequest()->getParam('page');
23
+ $limit = Mage::app()->getRequest()->getParam('limit');
24
 
25
+ $subscriptionCollection = Mage::getModel('newsletter/subscriber')->getCollection();
26
+ $subscriptionCollection->getSelect()->limit($limit, $page_num);
27
 
28
+ foreach ($subscriptionCollection as $subscriber) {
29
+ $subscribers['subscriber_id'] = $subscriber->getSubscriberId();
30
+ $subscribers['store_id'] = $subscriber->getStoreId();
31
+ $subscribers['customer_id'] = $subscriber->getCustomerId();
32
+ $subscribers['subscriber_email'] = $subscriber->getSubscriberEmail();
33
+ $subscribers['subscriber_status'] = $subscriber->getSubscriberStatus();
34
+ $subscriberData[] = $subscribers;
35
+ }
36
+ return $subscriberData;
37
+ }
38
  }
app/code/community/Targetbay/Tracking/Model/Api2/Subscriber/Rest/Guest/V1.php CHANGED
@@ -1,34 +1,38 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Subscriber_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Subscriber {
8
-
9
- /**
10
- * Retrieve susbcriber list
11
- *
12
- * @return array
13
- */
14
- public function _retrieveCollection() {
15
- $subscribers = array();
16
- $subscriberData = array();
17
 
18
- $page_num = Mage::app()->getRequest()->getParam('page');
19
- $limit = Mage::app()->getRequest()->getParam('limit');
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- $subscriptionCollection = Mage::getModel('newsletter/subscriber')->getCollection();
22
- $subscriptionCollection->getSelect()->limit($limit, $page_num);
23
 
24
- foreach($subscriptionCollection as $subscriber) {
25
- $subscribers['subscriber_id'] = $subscriber->getSubscriberId();
26
- $subscribers['store_id'] = $subscriber->getStoreId();
27
- $subscribers['customer_id'] = $subscriber->getCustomerId();
28
- $subscribers['subscriber_email'] = $subscriber->getSubscriberEmail();
29
- $subscribers['subscriber_status'] = $subscriber->getSubscriberStatus();
30
- $subscriberData[] = $subscribers;
31
- }
32
- return $subscriberData;
33
- }
34
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Subscriber_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Subscriber
10
+ {
11
+
12
+ /**
13
+ * Retrieve susbcriber list
14
+ *
15
+ * @return array
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $subscribers = array();
20
+ $subscriberData = array();
21
+
22
+ $page_num = Mage::app()->getRequest()->getParam('page');
23
+ $limit = Mage::app()->getRequest()->getParam('limit');
24
 
25
+ $subscriptionCollection = Mage::getModel('newsletter/subscriber')->getCollection();
26
+ $subscriptionCollection->getSelect()->limit($limit, $page_num);
27
 
28
+ foreach ($subscriptionCollection as $subscriber) {
29
+ $subscribers['subscriber_id'] = $subscriber->getSubscriberId();
30
+ $subscribers['store_id'] = $subscriber->getStoreId();
31
+ $subscribers['customer_id'] = $subscriber->getCustomerId();
32
+ $subscribers['subscriber_email'] = $subscriber->getSubscriberEmail();
33
+ $subscribers['subscriber_status'] = $subscriber->getSubscriberStatus();
34
+ $subscriberData[] = $subscribers;
35
+ }
36
+ return $subscriberData;
37
+ }
38
  }
app/code/community/Targetbay/Tracking/Model/Api2/Tbreviewcount.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Targetbay
5
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
+ * @package Targetbay_Tracking
7
+ */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Tbreviewcount extends Mage_Api2_Model_Resource
10
+ {
11
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Tbreviewcount/Rest/Admin/V1.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @author Targetbay
4
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
+ * @package Targetbay_Tracking
6
+ */
7
+ class Targetbay_Tracking_Model_Api2_Tbreviewcount_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Tbreviewcount
8
+ {
9
+
10
+ /**
11
+ * Get the Review count from Targetbay
12
+ *
13
+ * @return array
14
+ */
15
+ public function _retrieveCollection()
16
+ {
17
+ $pageReference = Mage::app()->getRequest()->getParam('page_identifier') ? Mage::app()->getRequest()->getParam('page_identifier') : '';
18
+
19
+ $reviewCount = Mage::app()->getRequest()->getParam('review_count') ? Mage::app()->getRequest()->getParam('review_count') : '';
20
+
21
+ $productId = Mage::app()->getRequest()->getParam('product_id') ? Mage::app()->getRequest()->getParam('product_id') : '';
22
+ if (!empty($pageReference) && $reviewCount > 0) {
23
+ try {
24
+ if ($pageReference == Targetbay_Tracking_Helper_Data::RATINGS_STATS) {
25
+ Mage::getSingleton('core/session')->setProductReviewCacheCount($reviewCount);
26
+ } elseif ($pageReference == Targetbay_Tracking_Helper_Data::QUESTION_STATS) {
27
+ Mage::getSingleton('core/session')->setQaReviewCacheCount($reviewCount);
28
+ } elseif ($pageReference == Targetbay_Tracking_Helper_Data::RATINGS_STATS
29
+ && $productId == '') {
30
+ Mage::getSingleton('core/session')->setSiteReviewCacheCount($reviewCount);
31
+ }
32
+ } catch (\Exception $e) {
33
+ Mage::helper('tracking')->debug($e->getMessage());
34
+ }
35
+ }
36
+ }
37
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Tbreviewcount/Rest/Guest/V1.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @author Targetbay
4
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
+ * @package Targetbay_Tracking
6
+ */
7
+ class Targetbay_Tracking_Model_Api2_Tbreviewcount_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Tbreviewcount
8
+ {
9
+
10
+ /**
11
+ * Get the Review count from Targetbay
12
+ *
13
+ * @return array
14
+ */
15
+ public function _retrieveCollection()
16
+ {
17
+ $pageReference = Mage::app()->getRequest()->getParam('page_identifier') ? Mage::app()->getRequest()->getParam('page_identifier') : '';
18
+
19
+ $reviewCount = Mage::app()->getRequest()->getParam('review_count') ? Mage::app()->getRequest()->getParam('review_count') : '';
20
+
21
+ $productId = Mage::app()->getRequest()->getParam('product_id') ? Mage::app()->getRequest()->getParam('product_id') : '';
22
+ if (!empty($pageReference) && $reviewCount > 0) {
23
+ try {
24
+ if ($pageReference == Targetbay_Tracking_Helper_Data::RATINGS_STATS) {
25
+ Mage::getSingleton('core/session')->setProductReviewCacheCount($reviewCount);
26
+ } elseif ($pageReference == Targetbay_Tracking_Helper_Data::QUESTION_STATS) {
27
+ Mage::getSingleton('core/session')->setQaReviewCacheCount($reviewCount);
28
+ } elseif ($pageReference == Targetbay_Tracking_Helper_Data::RATINGS_STATS
29
+ && $productId == '') {
30
+ Mage::getSingleton('core/session')->setSiteReviewCacheCount($reviewCount);
31
+ }
32
+ } catch (\Exception $e) {
33
+ Mage::helper('tracking')->debug($e->getMessage());
34
+ }
35
+ }
36
+ }
37
+ }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcartiteminfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalcartiteminfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalcartiteminfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcartiteminfo/Rest/Admin/V1.php CHANGED
@@ -1,33 +1,36 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalcartiteminfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalcartiteminfo {
8
-
9
- /**
10
- * Get the total count info of cartitem
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
17
- $collection = Mage::getResourceModel( 'sales/quote_collection' )
18
- ->addFieldToSelect(array(
19
- 'customer_id',
20
- 'customer_firstname',
21
- 'customer_lastname',
22
- 'customer_email',
23
- 'updated_at'))
24
- ->addFieldToFilter('customer_email', array('neq' => ''))
25
- ->addFieldToFilter('customer_id', array('neq' => ''));
26
- ;
27
- $collection->getSelect()->join(array('Q2'=> $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- $totals = array('total_cartitems' => count($collection));
30
-
31
- return json_encode($totals);
32
- }
33
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalcartiteminfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalcartiteminfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of cartitem
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
20
+ $collection = Mage::getResourceModel('sales/quote_collection')
21
+ ->addFieldToSelect(array(
22
+ 'customer_id',
23
+ 'customer_firstname',
24
+ 'customer_lastname',
25
+ 'customer_email',
26
+ 'updated_at'))
27
+ ->addFieldToFilter('customer_email', array('neq' => ''))
28
+ ->addFieldToFilter('customer_id', array('neq' => ''));
29
+
30
+ $collection->getSelect()->join(array('Q2' => $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
31
+
32
+ $totals = array('total_cartitems' => count($collection));
33
 
34
+ return json_encode($totals);
35
+ }
 
 
36
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcartiteminfo/Rest/Guest/V1.php CHANGED
@@ -1,33 +1,36 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalcartiteminfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalcartiteminfo {
8
-
9
- /**
10
- * Get the total count info of cartitem
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
17
- $collection = Mage::getResourceModel( 'sales/quote_collection' )
18
- ->addFieldToSelect(array(
19
- 'customer_id',
20
- 'customer_firstname',
21
- 'customer_lastname',
22
- 'customer_email',
23
- 'updated_at'))
24
- ->addFieldToFilter('customer_email', array('neq' => ''))
25
- ->addFieldToFilter('customer_id', array('neq' => ''));
26
- ;
27
- $collection->getSelect()->join(array('Q2'=> $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- $totals = array('total_cartitems' => count($collection));
30
-
31
- return json_encode($totals);
32
- }
33
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalcartiteminfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalcartiteminfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of cartitem
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $quoteTable = Mage::getSingleton('core/resource')->getTableName('sales/quote_item');
20
+ $collection = Mage::getResourceModel('sales/quote_collection')
21
+ ->addFieldToSelect(array(
22
+ 'customer_id',
23
+ 'customer_firstname',
24
+ 'customer_lastname',
25
+ 'customer_email',
26
+ 'updated_at'))
27
+ ->addFieldToFilter('customer_email', array('neq' => ''))
28
+ ->addFieldToFilter('customer_id', array('neq' => ''));
29
+
30
+ $collection->getSelect()->join(array('Q2' => $quoteTable), '`main_table`.`entity_id` = `Q2`.`quote_id`', array('*'))->group('Q2.quote_id');
31
+
32
+ $totals = array('total_cartitems' => count($collection));
33
 
34
+ return json_encode($totals);
35
+ }
 
 
36
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcategoryinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalcategoryinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalcategoryinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcategoryinfo/Rest/Admin/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalcategoryinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalcategoryinfo {
8
-
9
- /**
10
- * Get the total count info of category
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_category' => Mage::getModel( 'catalog/category' )->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalcategoryinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalcategoryinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of category
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_category' => Mage::getModel('catalog/category')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcategoryinfo/Rest/Guest/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalcategoryinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalcategoryinfo {
8
-
9
- /**
10
- * Get the total count info of category
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array(
16
- 'total_category' => Mage::getModel( 'catalog/category' )->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalcategoryinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalcategoryinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of category
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_category' => Mage::getModel('catalog/category')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcustomerinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalcustomerinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalcustomerinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcustomerinfo/Rest/Admin/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalcustomerinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalcustomerinfo {
8
-
9
- /**
10
- * Get the total count info of Customer
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalcustomerinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalcustomerinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of Customer
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalcustomerinfo/Rest/Guest/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalcustomerinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalcustomerinfo {
8
-
9
- /**
10
- * Get the total count info of Customer
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalcustomerinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalcustomerinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of Customer
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalinfo/Rest/Admin/V1.php CHANGED
@@ -1,23 +1,27 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalinfo {
8
-
9
- /**
10
- * Get the total count info of orders,products and customers
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_products' => Mage::getModel('catalog/product')->getCollection()->getSize(),
17
- 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize(),
18
- 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
19
- );
20
-
21
- return json_encode($totals);
22
- }
 
 
 
23
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of orders,products and customers
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_products' => Mage::getModel('catalog/product')->getCollection()->getSize(),
21
+ 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize(),
22
+ 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
23
+ );
24
+
25
+ return json_encode($totals);
26
+ }
27
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalinfo/Rest/Guest/V1.php CHANGED
@@ -1,23 +1,27 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalinfo {
8
-
9
- /**
10
- * Get the total count info of orders,products and customers
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_products' => Mage::getModel('catalog/product')->getCollection()->getSize(),
17
- 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize(),
18
- 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
19
- );
20
-
21
- return json_encode($totals);
22
- }
 
 
 
23
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of orders,products and customers
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_products' => Mage::getModel('catalog/product')->getCollection()->getSize(),
21
+ 'total_customers' => Mage::getModel('customer/customer')->getCollection()->getSize(),
22
+ 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
23
+ );
24
+
25
+ return json_encode($totals);
26
+ }
27
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalorderinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalorderinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalorderinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalorderinfo/Rest/Admin/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalorderinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalorderinfo {
8
-
9
- /**
10
- * Get the total count info of orders
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalorderinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalorderinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of orders
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalorderinfo/Rest/Guest/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalorderinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalorderinfo {
8
-
9
- /**
10
- * Get the total count info of orders
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalorderinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalorderinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of orders
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_orders' => Mage::getModel('sales/order')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalproductinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalproductinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalproductinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalproductinfo/Rest/Admin/V1.php CHANGED
@@ -1,31 +1,34 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalproductinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalproductinfo {
8
-
9
- /**
10
- * Get the total count info of Products
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $collection = Mage::getResourceModel('catalog/product_collection');
17
- $store = $this->_getStore();
18
- $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
19
- $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
20
-
21
- // available attributes not contain image attribute, but it needed for get image_url
22
- $availableAttributes[] = 'image';
23
- $collection->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- $totals = array (
26
- 'total_products' => $collection->getSize()
27
- );
28
-
29
- return json_encode ( $totals );
30
- }
31
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalproductinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalproductinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of Products
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $collection = Mage::getResourceModel('catalog/product_collection');
20
+ $store = $this->_getStore();
21
+ $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
22
+ $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
23
+
24
+ // available attributes not contain image attribute, but it needed for get image_url
25
+ $availableAttributes[] = 'image';
26
+ $collection->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
27
+
28
+ $totals = array(
29
+ 'total_products' => $collection->getSize()
30
+ );
31
 
32
+ return json_encode($totals);
33
+ }
 
 
 
 
34
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalproductinfo/Rest/Guest/V1.php CHANGED
@@ -1,31 +1,34 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalproductinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalproductinfo {
8
-
9
- /**
10
- * Get the total count info of Products
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $collection = Mage::getResourceModel('catalog/product_collection');
17
- $store = $this->_getStore();
18
- $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
19
- $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
20
-
21
- // available attributes not contain image attribute, but it needed for get image_url
22
- $availableAttributes[] = 'image';
23
- $collection->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- $totals = array (
26
- 'total_products' => $collection->getSize()
27
- );
28
-
29
- return json_encode ( $totals );
30
- }
31
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalproductinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalproductinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of Products
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $collection = Mage::getResourceModel('catalog/product_collection');
20
+ $store = $this->_getStore();
21
+ $entityOnlyAttributes = $this->getEntityOnlyAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ);
22
+ $availableAttributes = array_keys($this->getAvailableAttributes($this->getUserType(), Mage_Api2_Model_Resource::OPERATION_ATTRIBUTE_READ));
23
+
24
+ // available attributes not contain image attribute, but it needed for get image_url
25
+ $availableAttributes[] = 'image';
26
+ $collection->addAttributeToSelect(array_diff($availableAttributes, $entityOnlyAttributes));
27
+
28
+ $totals = array(
29
+ 'total_products' => $collection->getSize()
30
+ );
31
 
32
+ return json_encode($totals);
33
+ }
 
 
 
 
34
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalreviewinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalreviewinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalreviewinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalreviewinfo/Rest/Admin/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalreviewinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalreviewinfo {
8
-
9
- /**
10
- * Get the total count of reviews
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_reviews' => Mage::getModel('review/review')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalreviewinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalreviewinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count of reviews
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_reviews' => Mage::getModel('review/review')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalreviewinfo/Rest/Guest/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalreviewinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalreviewinfo {
8
-
9
- /**
10
- * Get the total count of reviews
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array (
16
- 'total_reviews' => Mage::getModel('review/review')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalreviewinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalreviewinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count of reviews
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_reviews' => Mage::getModel('review/review')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalshipmentinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalshipmentinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalshipmentinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalshipmentinfo/Rest/Admin/V1.php CHANGED
@@ -1,24 +1,27 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalshipmentinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalshipmentinfo {
8
-
9
- /**
10
- * Get the total count info of shipment orders
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $shipmentCollection = Mage::getModel('sales/order_shipment')->getCollection();
17
- $shipmentCollection->addAttributeToFilter('created_at', array(
18
- 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- $totals = array('total_shipped_orders' => count($shipmentCollection));
21
-
22
- return json_encode($totals);
23
- }
24
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalshipmentinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalshipmentinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of shipment orders
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $shipmentCollection = Mage::getModel('sales/order_shipment')->getCollection();
20
+ $shipmentCollection->addAttributeToFilter('created_at', array(
21
+ 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
22
+
23
+ $totals = array('total_shipped_orders' => count($shipmentCollection));
24
 
25
+ return json_encode($totals);
26
+ }
 
 
27
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalshipmentinfo/Rest/Guest/V1.php CHANGED
@@ -1,24 +1,27 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalshipmentinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalshipmentinfo {
8
-
9
- /**
10
- * Get the total count info of shipment orders
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $shipmentCollection = Mage::getModel('sales/order_shipment')->getCollection();
17
- $shipmentCollection->addAttributeToFilter('created_at', array(
18
- 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- $totals = array('total_shipped_orders' => count($shipmentCollection));
21
-
22
- return json_encode($totals);
23
- }
24
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalshipmentinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalshipmentinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of shipment orders
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $shipmentCollection = Mage::getModel('sales/order_shipment')->getCollection();
20
+ $shipmentCollection->addAttributeToFilter('created_at', array(
21
+ 'gt' => new Zend_Db_Expr('SUBDATE(CURRENT_TIMESTAMP, INTERVAL 6 HOUR)')));
22
+
23
+ $totals = array('total_shipped_orders' => count($shipmentCollection));
24
 
25
+ return json_encode($totals);
26
+ }
 
 
27
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalsubscriberinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalsubscriberinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalsubscriberinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalsubscriberinfo/Rest/Admin/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalsubscriberinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalsubscriberinfo {
8
-
9
- /**
10
- * Get the total count info of subscriber
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array(
16
- 'total_subscriber' => Mage::getModel('newsletter/subscriber')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalsubscriberinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalsubscriberinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of subscriber
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_subscriber' => Mage::getModel('newsletter/subscriber')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalsubscriberinfo/Rest/Guest/V1.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalsubscriberinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalsubscriberinfo {
8
-
9
- /**
10
- * Get the total count info of subscriber
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
- $totals = array(
16
- 'total_subscriber' => Mage::getModel('newsletter/subscriber')->getCollection()->getSize()
17
- );
18
-
19
- return json_encode($totals);
20
- }
 
 
 
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Totalsubscriberinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalsubscriberinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of subscriber
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $totals = array(
20
+ 'total_subscriber' => Mage::getModel('newsletter/subscriber')->getCollection()->getSize()
21
+ );
22
+
23
+ return json_encode($totals);
24
+ }
25
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalwishlistinfo.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Totalwishlistinfo extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Totalwishlistinfo extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalwishlistinfo/Rest/Admin/V1.php CHANGED
@@ -1,34 +1,38 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalwishlistinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalwishlistinfo {
8
-
9
- /**
10
- * Get the total count info of wishlist
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
17
- $i = 0; $count = '';
18
-
19
- foreach($wishlistCollection as $id => $wishlist) {
20
- $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
21
- $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
22
- if ($wishlistItemCollection->getSize() > 0) {
23
- $count = $i+1;
24
- $i++;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- $totals = array (
29
- 'total_wishlist' => $count
30
- );
31
-
32
- return json_encode($totals);
33
- }
34
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalwishlistinfo_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Totalwishlistinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of wishlist
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
20
+ $i = 0;
21
+ $count = '';
22
+
23
+ foreach ($wishlistCollection as $id => $wishlist) {
24
+ $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
25
+ $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
26
+ if ($wishlistItemCollection->getSize() > 0) {
27
+ $count = $i + 1;
28
+ $i++;
29
+ }
30
+ }
31
+
32
+ $totals = array(
33
+ 'total_wishlist' => $count
34
+ );
35
 
36
+ return json_encode($totals);
37
+ }
 
 
 
 
38
  }
app/code/community/Targetbay/Tracking/Model/Api2/Totalwishlistinfo/Rest/Guest/V1.php CHANGED
@@ -1,34 +1,38 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Totalwishlistinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalwishlistinfo {
8
-
9
- /**
10
- * Get the total count info of wishlist
11
- *
12
- * @see Mage_Api2_Model_Resource::_retrieveCollection()
13
- */
14
- public function _retrieveCollection() {
15
 
16
- $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
17
- $i = 0; $count = '';
18
-
19
- foreach($wishlistCollection as $id => $wishlist) {
20
- $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
21
- $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
22
- if ($wishlistItemCollection->getSize() > 0) {
23
- $count = $i+1;
24
- $i++;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- $totals = array (
29
- 'total_wishlist' => $count
30
- );
31
-
32
- return json_encode($totals);
33
- }
34
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Totalwishlistinfo_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Totalwishlistinfo
10
+ {
11
+
12
+ /**
13
+ * Get the total count info of wishlist
14
+ *
15
+ * @see Mage_Api2_Model_Resource::_retrieveCollection()
16
+ */
17
+ public function _retrieveCollection()
18
+ {
19
+ $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
20
+ $i = 0;
21
+ $count = '';
22
+
23
+ foreach ($wishlistCollection as $id => $wishlist) {
24
+ $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
25
+ $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
26
+ if ($wishlistItemCollection->getSize() > 0) {
27
+ $count = $i + 1;
28
+ $i++;
29
+ }
30
+ }
31
+
32
+ $totals = array(
33
+ 'total_wishlist' => $count
34
+ );
35
 
36
+ return json_encode($totals);
37
+ }
 
 
 
 
38
  }
app/code/community/Targetbay/Tracking/Model/Api2/Updatesubscription.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Updatesubscription extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Updatesubscription extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Updatesubscription/Rest/Admin/V1.php CHANGED
@@ -1,78 +1,84 @@
1
  <?php
2
- class Targetbay_Tracking_Model_Api2_Updatesubscription_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Updatesubscription {
3
-
4
- /**
5
- * Get the newsletter subscription
6
- *
7
- * @param array $data
8
- * @see Mage_Api2_Model_Resource::_create()
9
- */
10
- public function _create(array $data) {
11
- $email = Mage::app()->getRequest()->getParam('email');
12
- $status = Mage::app()->getRequest()->getParam('status');
13
 
14
- if($email == '' || $status == '')
15
- return false;
16
 
17
- if ($email != '' && $status != '') {
18
- try {
19
- $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
20
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
21
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
22
- ->save();
23
- Mage::helper('newsletter')->sendConfirmationSuccessEmail();
24
- return 'Thank you for your subscription.';
25
- } else {
26
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
27
- ->save();
28
- Mage::helper('newsletter')->sendUnsubscriptionEmail();
29
- return 'You have been unsubscribed';
30
- }
31
- } catch (Exception $e) {
32
- Mage::helper('tracking')->debug($e->getMessage());
33
- }
34
- }
35
- }
36
 
37
- /**
38
- * Get the newsletter subscription
39
- *
40
- * @return array
41
- */
42
- public function _retrieveCollection() {
43
- $email = Mage::app()->getRequest()->getParam('email');
44
- $status = Mage::app()->getRequest()->getParam('status');
45
 
46
- if($email == '' || $status == '')
47
- return false;
48
- if ($email != '' && $status != '') {
49
- try {
50
- $customerData = Mage::getModel('customer/customer')
51
- ->setWebsiteId(1)
52
- ->loadByEmail($email);
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
- $newsletterCustomer = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
55
- if($newsletterCustomer->getId()) {
56
- $newsletterCustomer->setCustomerId($newsletterCustomer->getId());
57
- $newsletterCustomer->setStatus($status);
58
- $newsletterCustomer->save();
59
- }
 
 
 
60
 
61
- $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
62
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
63
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
64
- ->save();
65
- Mage::getModel('newsletter/subscriber')->sendConfirmationSuccessEmail();
66
- return 'Thank you for your subscription.';
67
- } else {
68
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
69
- ->save();
70
- Mage::getModel('newsletter/subscriber')->sendUnsubscriptionEmail();
71
- return 'You have been unsubscribed';
72
- }
73
- } catch (Exception $e) {
74
- Mage::helper('tracking')->debug($e->getMessage());
75
- }
76
- }
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ class Targetbay_Tracking_Model_Api2_Updatesubscription_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Updatesubscription
4
+ {
5
 
6
+ /**
7
+ * Get the newsletter subscription
8
+ *
9
+ * @param array $data
10
+ * @see Mage_Api2_Model_Resource::_create()
11
+ */
12
+ public function _create(array $data)
13
+ {
14
+ $email = Mage::app()->getRequest()->getParam('email');
15
+ $status = Mage::app()->getRequest()->getParam('status');
 
 
 
 
 
 
 
 
 
16
 
17
+ if ($email == '' || $status == '') {
18
+ return false;
19
+ }
 
 
 
 
 
20
 
21
+ if ($email != '' && $status != '') {
22
+ try {
23
+ $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
24
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
25
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
26
+ ->save();
27
+ Mage::helper('newsletter')->sendConfirmationSuccessEmail();
28
+ return 'Thank you for your subscription.';
29
+ } else {
30
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
31
+ ->save();
32
+ Mage::helper('newsletter')->sendUnsubscriptionEmail();
33
+ return 'You have been unsubscribed';
34
+ }
35
+ } catch (Exception $e) {
36
+ Mage::helper('tracking')->debug($e->getMessage());
37
+ }
38
+ }
39
+ }
40
 
41
+ /**
42
+ * Get the newsletter subscription
43
+ *
44
+ * @return array
45
+ */
46
+ public function _retrieveCollection()
47
+ {
48
+ $email = Mage::app()->getRequest()->getParam('email');
49
+ $status = Mage::app()->getRequest()->getParam('status');
50
 
51
+ if ($email == '' || $status == '') {
52
+ return false;
53
+ }
54
+ if ($email != '' && $status != '') {
55
+ try {
56
+ $customerData = Mage::getModel('customer/customer')
57
+ ->setWebsiteId(1)
58
+ ->loadByEmail($email);
59
+
60
+ $newsletterCustomer = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
61
+ if ($newsletterCustomer->getId()) {
62
+ $newsletterCustomer->setCustomerId($newsletterCustomer->getId());
63
+ $newsletterCustomer->setStatus($status);
64
+ $newsletterCustomer->save();
65
+ }
66
+
67
+ $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
68
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
69
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
70
+ ->save();
71
+ Mage::getModel('newsletter/subscriber')->sendConfirmationSuccessEmail();
72
+ return 'Thank you for your subscription.';
73
+ } else {
74
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
75
+ ->save();
76
+ Mage::getModel('newsletter/subscriber')->sendUnsubscriptionEmail();
77
+ return 'You have been unsubscribed';
78
+ }
79
+ } catch (Exception $e) {
80
+ Mage::helper('tracking')->debug($e->getMessage());
81
+ }
82
+ }
83
+ }
84
  }
app/code/community/Targetbay/Tracking/Model/Api2/Updatesubscription/Rest/Guest/V1.php CHANGED
@@ -1,85 +1,91 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Updatesubscription_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Updatesubscription {
8
-
9
- /**
10
- * Get the newsletter subscription
11
- *
12
- * @param array $data
13
- * @see Mage_Api2_Model_Resource::_create()
14
- */
15
- public function _create(array $data) {
16
- $email = Mage::app()->getRequest()->getParam('email');
17
- $status = Mage::app()->getRequest()->getParam('status');
18
 
19
- if($email == '' || $status == '')
20
- return false;
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- if ($email != '' && $status != '') {
23
- try {
24
- $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
25
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
26
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
27
- ->save();
28
- Mage::helper('newsletter')->sendConfirmationSuccessEmail();
29
- return 'Thank you for your subscription.';
30
- } else {
31
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
32
- ->save();
33
- Mage::helper('newsletter')->sendUnsubscriptionEmail();
34
- return 'You have been unsubscribed';
35
- }
36
- } catch (Exception $e) {
37
- Mage::helper('tracking')->debug($e->getMessage());
38
- }
39
- }
40
- }
41
 
42
- /**
43
- * Get the newsletter subscription
44
- *
45
- * @return array
46
- */
47
- public function _retrieveCollection() {
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- $email = Mage::app()->getRequest()->getParam('email');
50
- $status = Mage::app()->getRequest()->getParam('status');
 
 
 
 
 
 
 
51
 
52
- if($email == '' || $status == '')
53
- return false;
 
54
 
55
- if ($email != '' && $status != '') {
56
- try {
57
- $customerData = Mage::getModel('customer/customer')
58
- ->setWebsiteId(1)
59
- ->loadByEmail($email);
60
 
61
- $newsletterCustomer = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
62
- if($newsletterCustomer->getId()) {
63
- $newsletterCustomer->setCustomerId($newsletterCustomer->getId());
64
- $newsletterCustomer->setStatus($status);
65
- $newsletterCustomer->save();
66
- }
67
 
68
- $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
69
- if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
70
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
71
- ->save();
72
- Mage::getModel('newsletter/subscriber')->sendConfirmationSuccessEmail();
73
- return 'Thank you for your subscription.';
74
- } else {
75
- $subscriberTable = $subscriberData->setSubscriberStatus($status)
76
- ->save();
77
- Mage::getModel('newsletter/subscriber')->sendUnsubscriptionEmail();
78
- return 'You have been unsubscribed';
79
- }
80
- } catch (Exception $e) {
81
- Mage::helper('tracking')->debug($e->getMessage());
82
- }
83
- }
84
- }
85
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ class Targetbay_Tracking_Model_Api2_Updatesubscription_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Updatesubscription
10
+ {
11
+
12
+ /**
13
+ * Get the newsletter subscription
14
+ *
15
+ * @param array $data
16
+ * @see Mage_Api2_Model_Resource::_create()
17
+ */
18
+ public function _create(array $data)
19
+ {
20
+ $email = Mage::app()->getRequest()->getParam('email');
21
+ $status = Mage::app()->getRequest()->getParam('status');
22
 
23
+ if ($email == '' || $status == '') {
24
+ return false;
25
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ if ($email != '' && $status != '') {
28
+ try {
29
+ $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
30
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
31
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
32
+ ->save();
33
+ Mage::helper('newsletter')->sendConfirmationSuccessEmail();
34
+ return 'Thank you for your subscription.';
35
+ } else {
36
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
37
+ ->save();
38
+ Mage::helper('newsletter')->sendUnsubscriptionEmail();
39
+ return 'You have been unsubscribed';
40
+ }
41
+ } catch (Exception $e) {
42
+ Mage::helper('tracking')->debug($e->getMessage());
43
+ }
44
+ }
45
+ }
46
 
47
+ /**
48
+ * Get the newsletter subscription
49
+ *
50
+ * @return array
51
+ */
52
+ public function _retrieveCollection()
53
+ {
54
+ $email = Mage::app()->getRequest()->getParam('email');
55
+ $status = Mage::app()->getRequest()->getParam('status');
56
 
57
+ if ($email == '' || $status == '') {
58
+ return false;
59
+ }
60
 
61
+ if ($email != '' && $status != '') {
62
+ try {
63
+ $customerData = Mage::getModel('customer/customer')
64
+ ->setWebsiteId(1)
65
+ ->loadByEmail($email);
66
 
67
+ $newsletterCustomer = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
68
+ if ($newsletterCustomer->getId()) {
69
+ $newsletterCustomer->setCustomerId($newsletterCustomer->getId());
70
+ $newsletterCustomer->setStatus($status);
71
+ $newsletterCustomer->save();
72
+ }
73
 
74
+ $subscriberData = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
75
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
76
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
77
+ ->save();
78
+ Mage::getModel('newsletter/subscriber')->sendConfirmationSuccessEmail();
79
+ return 'Thank you for your subscription.';
80
+ } else {
81
+ $subscriberTable = $subscriberData->setSubscriberStatus($status)
82
+ ->save();
83
+ Mage::getModel('newsletter/subscriber')->sendUnsubscriptionEmail();
84
+ return 'You have been unsubscribed';
85
+ }
86
+ } catch (Exception $e) {
87
+ Mage::helper('tracking')->debug($e->getMessage());
88
+ }
89
+ }
90
+ }
91
  }
app/code/community/Targetbay/Tracking/Model/Api2/Wishlist.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Api2_Wishlist extends Mage_Api2_Model_Resource
8
  {
9
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Api2_Wishlist extends Mage_Api2_Model_Resource
10
  {
11
  }
app/code/community/Targetbay/Tracking/Model/Api2/Wishlist/Rest/Admin/V1.php CHANGED
@@ -1,30 +1,34 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Wishlist_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Wishlist {
8
-
9
- /**
10
- * Retrieve wishlist items
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $customerId = '';
16
- $wishlistData = array();
17
- $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
18
- foreach($wishlistCollection as $id => $wishlist) {
19
- $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
20
- $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
21
- if ($wishlistItemCollection->getSize() > 0) {
22
- $wishlistData[$id]['wishlist_id'] = $wishlistInfo['wishlist_id'];
23
- $wishlistData[$id]['customer_id'] = $wishlistInfo['customer_id'];
24
- $wishlistData[$id]['updated_at'] = $wishlistInfo['updated_at'];
25
- $wishlistData[$id]['item_details'] = Mage::helper ( 'tracking' )->getWishlistItemsInfo ( $wishlistInfo);
26
- }
27
- }
28
- return $wishlistData;
29
- }
 
 
 
30
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Wishlist_Rest_Admin_V1 extends Targetbay_Tracking_Model_Api2_Wishlist
10
+ {
11
+
12
+ /**
13
+ * Retrieve wishlist items
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $customerId = '';
20
+ $wishlistData = array();
21
+ $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
22
+ foreach ($wishlistCollection as $id => $wishlist) {
23
+ $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
24
+ $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
25
+ if ($wishlistItemCollection->getSize() > 0) {
26
+ $wishlistData[$id]['wishlist_id'] = $wishlistInfo['wishlist_id'];
27
+ $wishlistData[$id]['customer_id'] = $wishlistInfo['customer_id'];
28
+ $wishlistData[$id]['updated_at'] = $wishlistInfo['updated_at'];
29
+ $wishlistData[$id]['item_details'] = Mage::helper('tracking')->getWishlistItemsInfo($wishlistInfo);
30
+ }
31
+ }
32
+ return $wishlistData;
33
+ }
34
  }
app/code/community/Targetbay/Tracking/Model/Api2/Wishlist/Rest/Guest/V1.php CHANGED
@@ -1,30 +1,34 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
7
- class Targetbay_Tracking_Model_Api2_Wishlist_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Wishlist {
8
-
9
- /**
10
- * Retrieve wishlist items
11
- *
12
- * @return array
13
- */
14
- protected function _retrieveCollection() {
15
- $customerId = '';
16
- $wishlistData = array();
17
- $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
18
- foreach($wishlistCollection as $id => $wishlist) {
19
- $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
20
- $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
21
- if ($wishlistItemCollection->getSize() > 0) {
22
- $wishlistData[$id]['wishlist_id'] = $wishlistInfo['wishlist_id'];
23
- $wishlistData[$id]['customer_id'] = $wishlistInfo['customer_id'];
24
- $wishlistData[$id]['updated_at'] = $wishlistInfo['updated_at'];
25
- $wishlistData[$id]['item_details'] = Mage::helper ( 'tracking' )->getWishlistItemsInfo ( $wishlistInfo);
26
- }
27
- }
28
- return $wishlistData;
29
- }
 
 
 
30
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
+ class Targetbay_Tracking_Model_Api2_Wishlist_Rest_Guest_V1 extends Targetbay_Tracking_Model_Api2_Wishlist
10
+ {
11
+
12
+ /**
13
+ * Retrieve wishlist items
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _retrieveCollection()
18
+ {
19
+ $customerId = '';
20
+ $wishlistData = array();
21
+ $wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
22
+ foreach ($wishlistCollection as $id => $wishlist) {
23
+ $wishlistInfo = Mage::getModel('wishlist/wishlist')->loadByCustomer($wishlist->getCustomerId());
24
+ $wishlistItemCollection = $wishlistInfo->setStoreId(1)->getItemCollection();
25
+ if ($wishlistItemCollection->getSize() > 0) {
26
+ $wishlistData[$id]['wishlist_id'] = $wishlistInfo['wishlist_id'];
27
+ $wishlistData[$id]['customer_id'] = $wishlistInfo['customer_id'];
28
+ $wishlistData[$id]['updated_at'] = $wishlistInfo['updated_at'];
29
+ $wishlistData[$id]['item_details'] = Mage::helper('tracking')->getWishlistItemsInfo($wishlistInfo);
30
+ }
31
+ }
32
+ return $wishlistData;
33
+ }
34
  }
app/code/community/Targetbay/Tracking/Model/Customer.php CHANGED
@@ -1,18 +1,20 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Customer extends Mage_Customer_Model_Customer
8
  {
9
  /**#@+
10
  * Configuration pathes for email templates and identities
11
  */
12
  const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template';
13
- const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template';
14
- const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template';
15
- /**#@-*/
16
 
17
  /**
18
  * Send email with new account related information
@@ -23,15 +25,16 @@ class Targetbay_Tracking_Model_Customer extends Mage_Customer_Model_Customer
23
  * @throws Mage_Core_Exception
24
  * @return Mage_Customer_Model_Customer
25
  */
26
- public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
27
  {
28
- $emailStatus = Mage::helper('tracking')->getEmailStatus();
29
- if($emailStatus == 1)
30
- return false;
 
31
 
32
  $types = array(
33
- 'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
34
- 'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
35
  'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
36
  );
37
  if (!isset($types[$type])) {
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Customer extends Mage_Customer_Model_Customer
10
  {
11
  /**#@+
12
  * Configuration pathes for email templates and identities
13
  */
14
  const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template';
15
+ const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template';
16
+ const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template';
17
+ /**#@-*/
18
 
19
  /**
20
  * Send email with new account related information
25
  * @throws Mage_Core_Exception
26
  * @return Mage_Customer_Model_Customer
27
  */
28
+ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0', $password = null)
29
  {
30
+ $emailStatus = Mage::helper('tracking')->getEmailStatus();
31
+ if ($emailStatus == 1) {
32
+ return false;
33
+ }
34
 
35
  $types = array(
36
+ 'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
37
+ 'confirmed' => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
38
  'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
39
  );
40
  if (!isset($types[$type])) {
app/code/community/Targetbay/Tracking/Model/Observer.php CHANGED
@@ -1,34 +1,37 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Observer
8
  {
9
  private $apiToken;
10
  private $indexName;
11
- private $targetbayHost;
12
  private $helper;
13
-
14
  /**
15
  * Get the credentials from store configurations
16
  */
17
  public function __construct()
18
  {
19
- //$expireAfter = 10;
20
  $expireAfter = 1380;
21
 
22
- $this->helper = Mage::helper('tracking');
23
- $this->apiToken = '?api_token=' . $this->helper->getApiToken();
24
- $this->indexName = $this->helper->getApiIndex();
25
- $this->targetbayHost = $this->helper->getHostname();
26
-
 
27
  $sess = Mage::getSingleton('core/session')->getTrackingSessionId();
28
  if (!$this->helper->cookie->get('trackingsession')) {
29
- $visitor_data = Mage::getSingleton('core/session')->getVisitorData();
30
- $trackingsession = $visitor_data['visitor_id'] . strtotime(date('Y-m-d H:i:s'));
31
- Mage::getSingleton('core/session')->setTrackingSessionId($trackingsession);
32
  }
33
 
34
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
@@ -36,68 +39,68 @@ class Targetbay_Tracking_Model_Observer
36
  Mage::getModel('core/cookie')->set('afterlogin_session_id', Mage::getSingleton('core/session')->getCustomerSessionId(), null, null, null, null, false);
37
  }
38
 
39
- if(isset($_SESSION['last_session'])) {
40
-
41
  $secondsInactive = time() - $_SESSION['last_session'];
42
  $expireAfterSeconds = $expireAfter * 60;
43
- if($secondsInactive > $expireAfterSeconds){
44
- Mage::getSingleton('core/session')->unsProductReview();
45
  Mage::getSingleton('core/session')->unsProductReviewResponse();
46
- Mage::getSingleton('core/session')->unsSiteReview();
47
  Mage::getSingleton('core/session')->unsSiteReviewResponse();
48
- Mage::getSingleton('core/session')->unsQaReview();
49
  Mage::getSingleton('core/session')->unsQaReviewResponse();
 
50
  }
51
  }
52
  }
53
-
54
  /**
55
  * Set the cookie values for user differentiate.
56
  */
57
  public function setCookieValues()
58
  {
59
  // For anonymous user
60
- $customerName = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
61
  $customerEmail = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
62
  if (!$this->helper->cookie->get('trackingid')) {
63
  $customerId = Mage::getSingleton('core/session')->getTrackingSessionId();
64
  }
65
-
66
  // for logged user
67
  if (Mage::app()->isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
68
- $customer = Mage::getSingleton('customer/session')->getCustomer();
69
- $customerName = $customer->getName();
70
- $customerId = $customer->getId();
71
  $customerEmail = $customer->getEmail();
72
  }
73
-
74
  // ToDo: Do we need this?
75
- $trackingId = empty($customerId) ? '' : $this->helper->cookie->set('trackingid', $customerId, null, null, null, null, false);
76
-
77
  $this->helper->cookie->set('trackingemail', $customerEmail, null, null, null, null, false);
78
  $this->helper->cookie->set('trackingname', $customerName, null, null, null, null, false);
79
-
80
  $quoteId = Mage::getSingleton('checkout/session')->getQuoteId() ? Mage::getSingleton('checkout/session')->getQuoteId() : '';
81
  $this->helper->cookie->set('trackingorderid', $quoteId, null, null, null, null, false);
82
-
83
  if (!$this->helper->cookie->get('trackingsession')) {
84
  $this->helper->cookie->set('trackingsession', Mage::getSingleton('core/session')->getTrackingSessionId(), null, null, null, null, false);
85
  }
86
  }
87
-
88
  /**
89
  * Visiting page info
90
  *
91
- * @param Varien_Event_Observer $observer
92
  *
93
  * @return void
94
  */
95
  public function pushPageVisitData(Varien_Event_Observer $observer)
96
- {
97
  $request = Mage::app()->getRequest();
98
-
99
- $currenturi = sprintf("%s/%s/%s", $request->getModuleName(), $request->getControllerName(), $request->getActionName());
100
-
101
  $triggers = array(
102
  'checkout/onepage/savePayment',
103
  'checkout/onepage/saveOrder',
@@ -106,69 +109,81 @@ class Targetbay_Tracking_Model_Observer
106
  'onestepcheckout/index/save_shipping',
107
  'onestepcheckout/index/is_valid_email'
108
  );
109
-
110
- if (in_array($currenturi, $triggers))
111
  return false;
112
-
 
113
  $this->setCookieValues();
114
-
115
  // Page referrer Tracking
116
  $this->pushReferralData();
117
-
118
  if ($this->helper->eventAlreadyTracked($observer->getEvent()->getControllerAction()->getFullActionName())) {
119
  return false;
120
  }
121
-
122
  // Set Token Values
123
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
124
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
125
  }
126
-
127
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
128
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
129
  }
130
  }
131
-
132
  /**
133
  * Visiting page info
134
  *
135
- * @param Varien_Event_Observer $observer
136
  *
137
  * @return void
138
  */
139
  public function cmsPageVisit(Varien_Event_Observer $observer)
140
- {
141
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::PAGE_VISIT)) {
142
  return false;
143
  }
144
-
 
 
 
 
145
  // Set Token Values
146
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
147
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
148
  }
149
-
150
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
151
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
152
  }
153
-
154
  $request = Mage::app()->getRequest();
155
  $trackingType = $this->helper->getTrackingType();
156
- $identifier = Mage::getSingleton('cms/page')->getIdentifier();
157
- $moduleName = $request->getModuleName();
158
-
 
159
  // Page Visit Tracking
160
  $data = $this->helper->visitInfo();
161
- if ($trackingType == 1 && ($request->getControllerName() == 'product' || $request->getControllerName() == 'category' || $moduleName == 'cms'))
 
 
 
 
 
162
  return false;
163
-
 
164
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::PAGE_VISIT);
165
  return;
166
  }
167
-
168
  /**
169
  * Add to cart
170
  *
171
- * @param Varien_Event_Observer $observer
172
  *
173
  * @return void
174
  */
@@ -179,59 +194,71 @@ class Targetbay_Tracking_Model_Observer
179
  }
180
  Mage::getSingleton('checkout/session')->setTitle('Shopping cart');
181
 
182
- //$item = $observer->getEvent()->getQuoteItem();
183
  //if ($item->getParentItem())
184
- //$item = $item->getParentItem();
185
 
186
  $productInfo = $observer->getProduct();
187
 
188
  $productEventInfo = $observer->getEvent()->getProduct();
189
  $quote = Mage::getModel('checkout/cart')->getQuote();
190
- $item = $quote->getItemByProduct( $productEventInfo );
191
-
192
- if($productInfo->getData('type_id') == 'grouped') {
193
- $productIds = Mage::app()->getRequest()->getParam('super_group');
194
- $dataItem = array(); $productData= array();
195
- foreach($productIds as $id => $qty) {
196
- if($qty < 1)
197
- continue;
198
- $product = Mage::getModel('catalog/product')->load($id);
199
- $productData['type'] = $product->getTypeId();
200
- $productData['product_id'] = $id;
201
- $productData['product_sku'] = $product->getSku();
202
- $productData['product_name'] = addslashes($product->getName());
203
- $productData['price'] = $product->getPrice()*$qty;
204
- $productData['special_price'] = $product->getSpecialPrice();
205
- $productData['productimg'] = $this->helper->getImageUrl($product, 'image');
206
-
207
- $productData['category'] = $this->helper->getProductCategory($product);
208
- $productData['category_name'] = $this->helper->getProductCategoryName($product);
209
- $productData['quantity'] = $qty;
210
- $productData['page_url'] = Mage::getUrl($product->getUrlPath());
211
- $productData['attributes'] = '';
212
- $dataItem[] = $productData;
213
- }
214
- $data = $this->helper->getCartInfo();
215
- $data['product_type'] = $productInfo->getData('type_id');
216
- $data['cart_item'] = $dataItem;
217
- } else{
218
- $data = array_merge($this->helper->getCartInfo(), $this->helper->getItemInfo($item, Targetbay_Tracking_Helper_Data::ADDTOCART));
219
- $data['product_type'] = $item->getProductType();
220
- $data['price'] = $item->getProduct()->getFinalPrice();
221
- if ($customOptions = $this->helper->getCustomOptionsInfo($item, null)) {
222
- $data['attributes'] = $customOptions;
223
- }
 
 
 
 
 
 
 
 
 
 
 
 
224
  }
225
 
226
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::ADDTOCART);
227
-
228
  return;
229
  }
230
-
231
  /**
232
  * Capture the Update cart event
233
  *
234
- * @param Varien_Event_Observer $observer
235
  *
236
  * @return void
237
  */
@@ -240,10 +267,10 @@ class Targetbay_Tracking_Model_Observer
240
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::UPDATECART)) {
241
  return false;
242
  }
243
- $items = $observer->getEvent()->getCart()->getQuote()->getAllVisibleItems();
244
  $requestInfo = $observer->getEvent()->getInfo();
245
- $data = $this->helper->getCartInfo();
246
-
247
  foreach ($items as $item) {
248
  $newQty = $requestInfo[$item->getId()]['qty'];
249
  $oldQty = $item->getQty();
@@ -251,31 +278,31 @@ class Targetbay_Tracking_Model_Observer
251
  continue;
252
  }
253
  $itemData = $this->helper->getItemInfo($item);
254
-
255
  unset($itemData['quantity']);
256
- $newitemData = $itemData;
257
  $newitemData['old_quantity'] = $oldQty;
258
  $newitemData['new_quantity'] = $newQty;
259
- $data['cart_items'][] = $newitemData;
260
  }
261
-
262
  if (isset($data['cart_items'])) {
263
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::UPDATECART);
264
  }
265
-
266
  return;
267
  }
268
-
269
  /**
270
  * Push the empty cart actions data
271
  *
272
- * @param Varien_Event_Observer $observer
273
  *
274
  * @return void|boolean
275
  */
276
  public function pushEmptyCartData(Varien_Event_Observer $observer)
277
  {
278
- $updateAction = (string)Mage::app()->getRequest()->getParam('update_cart_action');
279
  if ($updateAction != 'empty_cart') {
280
  return false;
281
  }
@@ -283,24 +310,24 @@ class Targetbay_Tracking_Model_Observer
283
  foreach ($items as $item) {
284
  $this->removeCartItem($item);
285
  }
286
-
287
  return;
288
  }
289
-
290
  /**
291
  * Push the remove cart item data
292
  *
293
- * @param Varien_Event_Observer $observer
294
  */
295
  public function pushRemoveCartItemData(Varien_Event_Observer $observer)
296
  {
297
  $this->removeCartItem($observer->getEvent()->getQuoteItem());
298
  }
299
-
300
  /**
301
  * Remove the cart item
302
  *
303
- * @param unknown $item
304
  *
305
  * @return void|boolean
306
  */
@@ -311,14 +338,14 @@ class Targetbay_Tracking_Model_Observer
311
  }
312
  $data = array_merge($this->helper->getCartInfo(), $this->helper->getItemInfo($item));
313
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::REMOVECART);
314
-
315
  return;
316
  }
317
-
318
  /**
319
  * Observe the checkout page
320
  *
321
- * @param Varien_Event_Observer $observer
322
  *
323
  * @return void|boolean
324
  */
@@ -327,31 +354,31 @@ class Targetbay_Tracking_Model_Observer
327
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::CHECKOUT)) {
328
  return false;
329
  }
330
-
331
  // Set Token Values
332
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
333
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
334
  }
335
-
336
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
337
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
338
  }
339
-
340
  $quote = Mage::getSingleton('checkout/session')->getQuote();
341
-
342
- $data = $this->helper->getCartInfo();
343
- $data['cart_items'] = $this->helper->getOrderItemsInfo($quote);
344
- $data['total_qty'] = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();
345
  $data['total_amount'] = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
346
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CHECKOUT);
347
-
348
  return;
349
  }
350
-
351
  /**
352
  * Push billing info when user enter the billing in checkout
353
  *
354
- * @param Varien_Event_Observer $observer
355
  *
356
  * @return void|boolean
357
  */
@@ -362,20 +389,20 @@ class Targetbay_Tracking_Model_Observer
362
  return false;
363
  }
364
  Mage::getSingleton('checkout/session')->setTitle('Checkout Billing');
365
- $quote = Mage::getSingleton('checkout/session')->getQuote();
366
  $billingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::BILLING);
367
  $this->pushPages($billingInfo, Targetbay_Tracking_Helper_Data::BILLING);
368
  } catch (Exception $e) {
369
  $this->helper->debug("ERROR: " . $e->getMessage());
370
  }
371
-
372
  return;
373
  }
374
-
375
  /**
376
  * Push shipping info when user enter the shipping in checkout
377
  *
378
- * @param Varien_Event_Observer $observer
379
  *
380
  * @return void|boolean
381
  */
@@ -386,20 +413,20 @@ class Targetbay_Tracking_Model_Observer
386
  return false;
387
  }
388
  Mage::getSingleton('checkout/session')->setTitle('Checkout Shipping');
389
- $quote = Mage::getSingleton('checkout/session')->getQuote();
390
  $shippingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::SHIPPING);
391
  $this->pushPages($shippingInfo, Targetbay_Tracking_Helper_Data::SHIPPING);
392
  } catch (Exception $e) {
393
  $this->helper->debug("ERROR: " . $e->getMessage());
394
  }
395
-
396
  return;
397
  }
398
-
399
  /**
400
  * Order data
401
  *
402
- * @param Varien_Event_Observer $observer
403
  * @return Targetbay_Tracking_Model_Observer
404
  *
405
  * @return void|boolean
@@ -412,17 +439,18 @@ class Targetbay_Tracking_Model_Observer
412
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ORDER_ITEMS)) {
413
  return false;
414
  }
415
- $order = $observer->getEvent()->getOrder();
416
  $params = Mage::app()->getFrontController()->getRequest()->getParams();
417
 
418
- if ($this->pushShipmentData($order, $params))
419
- return false; // order shipment process so no need to make order submit api.
420
-
421
- // Captute the customer registration.
 
422
  if ($customer = $this->helper->isRegisterCheckout($order)) {
423
  $this->pushRegisterData($customer);
424
  }
425
-
426
  // Order Data Push to the Tag Manager
427
  $orderInfo = $this->helper->getInfo($order);
428
  $this->pushPages($orderInfo, Targetbay_Tracking_Helper_Data::ORDER_ITEMS);
@@ -431,14 +459,14 @@ class Targetbay_Tracking_Model_Observer
431
  } catch (Exception $e) {
432
  $this->helper->debug("ERROR: " . $e->getMessage());
433
  }
434
-
435
  return;
436
  }
437
-
438
  /**
439
  * Order status change data
440
  *
441
- * @param Varien_Event_Observer $observer
442
  * @return Targetbay_Tracking_Model_Observer
443
  *
444
  * @return void|boolean
@@ -449,87 +477,88 @@ class Targetbay_Tracking_Model_Observer
449
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ORDER_STATUS)) {
450
  return false;
451
  }
452
- $order = $observer->getEvent()->getOrder();
453
 
454
- $data = $this->helper->getSessionInfo($order);
455
- $data['first_name'] = $order->getCustomerFirstname();
456
- $data['last_name'] = $order->getCustomerLastname();
457
- $guestUsername = $order->getCustomerFirstname().' '.$order->getCustomerLastname();
458
  $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
459
- $data['user_name'] = $order->getCustomerIsGuest() ? $gName : $data['first_name'] . ' ' . $data['last_name'];
460
- $data['user_mail'] = $order->getCustomerEmail();
461
- $data['order_id'] = $order->getId();
462
  $data['status'] = $order->getStatus();
463
- if($data['status'] === null) {
464
- return false;
465
  }
466
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::ORDER_STATUS);
467
  } catch (Exception $e) {
468
  $this->helper->debug("ERROR: " . $e->getMessage());
469
  }
470
-
471
  return;
472
  }
473
-
474
  /**
475
  * Abandoned cart merge for logged in user
476
  *
477
- * @param Varien_Event_Observer $observer
478
  *
479
  * @return void
480
  */
481
  public function quoteMergeData(Varien_Event_Observer $observer)
482
  {
483
- $abandonedMail = Mage::getSingleton('core/session')->getAbandonedMail();
484
  $cart = Mage::getModel('checkout/cart');
485
- if($abandonedMail) {
486
  try {
487
  $this->helper->debug('MergeObs');
488
  $cart->truncate();
489
- } catch(\Exception $e) {
490
- $this->helper->debug('Error:'.$e->getMessage());
491
  }
492
  }
493
  return;
494
  }
495
-
496
  /**
497
  * Push the shipment data
498
  *
499
- * @param unknown $order
500
  * @param unknown $params
501
  * @return boolean
502
  */
503
- public function pushShipmentData($order, $params) {
 
504
  try {
505
- if ($this->helper->isFullFillmentProcess($params)) {
506
- $data = $this->helper->getFullFillmentData($order, $params);
507
- $this->pushPages($data, Targetbay_Tracking_Helper_Data::ORDER_SHIPMENT);
508
- return true;
509
- }
510
  } catch (Exception $e) {
511
  $this->helper->debug("ERROR: " . $e->getMessage());
512
  }
513
-
514
- return false;
515
  }
516
-
517
  /**
518
  * Push the order shipment data
519
  *
520
- * @param Varien_Event_Observer $observer
521
  * @return Targetbay_Tracking_Model_Observer
522
  * @return boolean
523
  */
524
  public function pushOrderShipmentData(Varien_Event_Observer $observer)
525
  {
526
  try {
527
- if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ORDER_SHIPMENT)) {
528
- return false;
529
- }
530
 
531
- $shipment = $observer->getEvent()->getShipment();
532
- $order = $shipment->getOrder();
533
  $params[Targetbay_Tracking_Helper_Data::ORDER_SHIPMENT] = true;
534
  if ($this->helper->isFullFillmentProcess($params)) {
535
  $data = $this->helper->getFullFillmentData($order, $params);
@@ -538,37 +567,37 @@ class Targetbay_Tracking_Model_Observer
538
  } catch (Exception $e) {
539
  $this->helper->debug("ERROR: " . $e->getMessage());
540
  }
541
- return;
542
  }
543
-
544
  /**
545
  * Push billing and shipping info when user enter into onestepcheckout
546
  *
547
- * @param Varien_Event_Observer $observer
548
  *
549
  * @return void|boolean
550
  */
551
  public function pushCheckoutAddressData(Varien_Event_Observer $observer)
552
- {
553
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ONESTEPCHECKOUT_ADDRESS)) {
554
  return false;
555
  }
556
  Mage::getSingleton('checkout/session')->setTitle('OneStepCheckout');
557
-
558
- $quote = Mage::getSingleton('checkout/session')->getQuote();
559
  $billingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::BILLING);
560
  $this->pushPages($billingInfo, Targetbay_Tracking_Helper_Data::BILLING);
561
-
562
  $shippingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::SHIPPING);
563
  $this->pushPages($shippingInfo, Targetbay_Tracking_Helper_Data::SHIPPING);
564
-
565
  return;
566
  }
567
-
568
  /**
569
  * Push the data when customer loggedin
570
  *
571
- * @param Varien_Event_Observer $observer
572
  *
573
  * @return void|boolean
574
  */
@@ -582,14 +611,14 @@ class Targetbay_Tracking_Model_Observer
582
  }
583
  $data = $this->helper->getCustomerData($observer->getCustomer(), Targetbay_Tracking_Helper_Data::LOGIN);
584
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::LOGIN);
585
-
586
  return;
587
  }
588
-
589
  /**
590
  * Push the data when customer logout
591
  *
592
- * @param Varien_Event_Observer $observer
593
  *
594
  * @return void|boolean
595
  */
@@ -603,24 +632,24 @@ class Targetbay_Tracking_Model_Observer
603
 
604
  // Remove all Cookies
605
  $this->helper->removeCookies();
606
-
607
  return;
608
  }
609
-
610
  /**
611
  * Registration observer
612
  *
613
- * @param Varien_Event_Observer $observer
614
  */
615
  public function customerRegisterPushData(Varien_Event_Observer $observer)
616
  {
617
  $this->pushRegisterData($observer->getCustomer());
618
  }
619
-
620
  /**
621
  * Push the registration data
622
  *
623
- * @param unknown $customer
624
  *
625
  * @return void|boolean
626
  */
@@ -631,41 +660,42 @@ class Targetbay_Tracking_Model_Observer
631
  }
632
  $data = $this->helper->getCustomerData($customer, Targetbay_Tracking_Helper_Data::CREATE_ACCOUNT);
633
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CREATE_ACCOUNT);
634
-
635
  return;
636
  }
637
-
638
  /**
639
  * Push the newslettter subscription data
640
  *
641
- * @param Varien_Event_Observer $observer
642
  *
643
  * @return void|boolean
644
  */
645
  public function pushSubscriptionData(Varien_Event_Observer $observer)
646
- {
647
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::SUBSCRIBE_CUSTOMER)) {
648
  return false;
649
  }
650
 
651
- $webstieId = Mage::app()->getStore()->getWebsiteId();
652
- $customerModel = Mage::getModel('customer/customer');
653
-
654
  if (Mage::app()->getRequest()->getParam('email')) {
655
- $email = Mage::app()->getRequest()->getParam('email');
656
- $customerData = $customerModel->setWebsiteId($webstieId)->loadByEmail($email);
657
- $customerId = $customerData->getEntityId();
 
658
  } else {
659
- $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
660
- $customerData = $customerModel->load($customerId);
661
- $email = '';
662
- }
663
-
664
  $data = $this->helper->visitInfo();
665
-
666
  if (empty($email)) {
667
  $subscriberFactory = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
668
-
669
  if ($subscriberFactory->getSubscriberStatus() == Targetbay_Tracking_Helper_Data::STATUS_UNSUBSCRIBED) {
670
  $status = 'Unsubscribed';
671
  } elseif ($subscriberFactory->getSubscriberStatus() == Targetbay_Tracking_Helper_Data::STATUS_SUBSCRIBED) {
@@ -680,33 +710,33 @@ class Targetbay_Tracking_Model_Observer
680
  } else {
681
  $status = '';
682
  }
683
-
684
- $status = !empty($email) ? 'Subscribed' : $status;
685
- $data['user_mail'] = Mage::getSingleton('customer/session')->isLoggedIn() ? Mage::getSingleton('customer/session')->getCustomer()->getEmail() : $email;
686
  $data['subscription_status'] = $status;
687
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::SUBSCRIBE_CUSTOMER);
688
-
689
  return;
690
  }
691
-
692
  /**
693
  * Admin Account Activation observer
694
  *
695
- * @param Varien_Event_Observer $observer
696
  */
697
  public function customerAdminConfirmData(Varien_Event_Observer $observer)
698
- {
699
  $customer_info = $observer->getCustomer()->getData();
700
- $data = array_merge($this->helper->visitInfo(), $customer_info);
701
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::ADMIN_ACTIVATE_ACCOUNT);
702
-
703
  return;
704
  }
705
-
706
  /**
707
  * Add and update product
708
  *
709
- * @param Varien_Event_Observer $observer
710
  *
711
  * @return void
712
  */
@@ -716,7 +746,7 @@ class Targetbay_Tracking_Model_Observer
716
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ADD_PRODUCT)) {
717
  return false;
718
  }
719
- $param = Mage::app()->getRequest()->getParams();
720
  $product = $observer->getEvent()->getProduct();
721
  if ($product->getId()) {
722
  $type = Targetbay_Tracking_Helper_Data::ADD_PRODUCT;
@@ -732,14 +762,14 @@ class Targetbay_Tracking_Model_Observer
732
  } catch (Exception $e) {
733
  $this->helper->debug("ERROR: " . $e->getMessage());
734
  }
735
-
736
  return;
737
  }
738
-
739
  /**
740
  * Delete product
741
  *
742
- * @param Varien_Event_Observer $observer
743
  *
744
  * @return void
745
  */
@@ -752,31 +782,31 @@ class Targetbay_Tracking_Model_Observer
752
  $params = Mage::app()->getRequest()->getParams();
753
 
754
  if ($params) {
755
- $data['entity_id'] = Mage::app()->getRequest()->getParam('id');
756
- $data['user_name'] = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
757
- $data['user_id'] = strtotime(date('Y-m-d H:i:s'));
758
  $data['session_id'] = strtotime(date('Y-m-d H:i:s'));
759
  if ($this->helper->cookie->get('trackingsession')) {
760
- $data['user_id'] = $this->helper->cookie->get('trackingsession');
761
  $data['session_id'] = $this->helper->cookie->get('trackingsession');
762
  }
763
- $data['date'] = $this->helper->date->date('Y-m-d');
764
  $data['timestamp'] = strtotime($this->helper->date->date('Y-m-d'));
765
- $data['time'] = $this->helper->date->date('H:i');
766
  $data['user_mail'] = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
767
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::DELETE_PRODUCT);
768
  }
769
  } catch (Exception $e) {
770
  $this->helper->debug("ERROR: " . $e->getMessage());
771
  }
772
-
773
  return;
774
  }
775
-
776
  /**
777
  * Category view page
778
  *
779
- * @param Varien_Event_Observer $observer
780
  *
781
  * @return void
782
  */
@@ -785,24 +815,24 @@ class Targetbay_Tracking_Model_Observer
785
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::CATEGORY_VIEW)) {
786
  return false;
787
  }
788
- $category = Mage::registry('current_category');
789
- $data = $this->helper->visitInfo();
790
- $data['category_id'] = $category->getId();
791
- $data['category_url'] = $category->getUrl();
792
  $data['category_name'] = $category->getName();
793
-
794
  $trackingType = $this->helper->getTrackingType();
795
  if ($trackingType != 1):
796
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CATEGORY_VIEW);
797
  endif;
798
-
799
  return;
800
  }
801
-
802
  /**
803
  * Product view page
804
  *
805
- * @param Varien_Event_Observer $observer
806
  *
807
  * @return void
808
  */
@@ -813,36 +843,36 @@ class Targetbay_Tracking_Model_Observer
813
  }
814
 
815
  // Get the base visit info
816
- $data = $this->helper->visitInfo();
817
- $product = Mage::registry('product');
818
  $categoryIds = $product->getCategoryIds();
819
  if (count($categoryIds)) {
820
- $firstCategoryId = $categoryIds[0];
821
- $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
822
  $data['category'] = $_category->getName();
823
  }
824
- $data['product_id'] = $product->getId();
825
  $data['product_name'] = $product->getName();
826
- $data['price'] = $product->getPrice();
827
- $data['productimg'] = $product->getImageUrl();
828
- $data['stock'] = Targetbay_Tracking_Helper_Data::OUT_OF_STOCK;
829
- $stock = $product->getStockItem();
830
  if ($stock->getIsInStock()) {
831
  $data['stock'] = Targetbay_Tracking_Helper_Data::IN_STOCK;
832
  }
833
-
834
  $trackingType = $this->helper->getTrackingType();
835
  if ($trackingType != 1):
836
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::PRODUCT_VIEW);
837
  endif;
838
-
839
  return;
840
  }
841
-
842
  /**
843
  * Push the searhced query string
844
  *
845
- * @param Varien_Event_Observer $observer
846
  *
847
  * @return void
848
  */
@@ -855,24 +885,24 @@ class Targetbay_Tracking_Model_Observer
855
  if (empty($keyword)) {
856
  return false;
857
  }
858
-
859
- $data = $this->helper->visitInfo();
860
  $data['keyword'] = $keyword;
861
 
862
  $trackingType = $this->helper->getTrackingType();
863
  if ($trackingType != 1):
864
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CATALOG_SEARCH);
865
  endif;
866
-
867
  return;
868
  }
869
-
870
  /**
871
- * Add the Wishlist
872
  *
873
- * @param Varien_Event_Observer $observer
874
  *
875
- * @return void
876
  */
877
  public function pushAddWishlistData($observer)
878
  {
@@ -880,134 +910,137 @@ class Targetbay_Tracking_Model_Observer
880
  return false;
881
  }
882
  $wishlistItems = $observer->getEvent()->getItems();
883
- $item_info = array();
884
 
885
  foreach ($wishlistItems as $item) {
886
- if ($item->getParentItem())
887
  $item = $item->getParentItem();
888
-
 
889
  $item_info = $this->helper->getWishlistProductInfo($item->getData('product_id'));
890
 
891
- $data = array_merge($this->helper->visitInfo(), $item_info);
892
- $data['item_id'] = $item->getWishlistItemId();
893
  if ($customOptions = $this->helper->getCustomOptionsInfo($item, null)) {
894
  $data['attributes'] = $customOptions;
895
  }
896
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::WISHLIST);
897
  }
898
-
899
  return;
900
-
901
  }
902
-
903
  /**
904
  * Update the Wishlist items
905
  *
906
- * @param Varien_Event_Observer $observer
907
  */
908
  public function pushUpdateWishlistData(Varien_Event_Observer $observer)
909
  {
910
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::UPDATE_WISHLIST)) {
911
  return false;
912
  }
913
-
914
- $controller = $observer->getEvent()->getControllerAction();
915
- $request = $controller->getRequest();
916
- $wishlistId = Mage::app()->getRequest()->getParam('wishlist_id');
917
  $wishlistDesc = Mage::app()->getRequest()->getParam('description');
918
- $wishlistQty = Mage::app()->getRequest()->getParam('qty');
919
-
920
- $data = $this->helper->visitInfo();
921
- $items = array();
922
- $data['wishlist_id'] = $wishlistId;
923
 
924
  foreach ($wishlistDesc as $id => $item) {
925
  $wishlistItem = Mage::getModel('wishlist/item')->load($id);
926
- $items[$id]['item_id'] = $id;
927
  $items[$id]['product_id'] = $wishlistItem->getProductId();
928
  $items[$id]['store_id'] = $wishlistItem->getStoreId();
929
  $items[$id]['description'] = $item;
930
- $items[$id]['qty'] = $wishlistQty[$id];
931
  }
932
 
933
- $data['wishlist_items'] = $items;
934
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::UPDATE_WISHLIST);
935
-
936
  return;
937
  }
938
-
939
  /**
940
  * Remove the Wishlist items
941
  *
942
- * @param Varien_Event_Observer $observer
943
  */
944
  public function removeWhislistItem(Varien_Event_Observer $observer)
945
- {
946
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::REMOVE_WISHLIST)) {
947
  return false;
948
  }
949
-
950
  $controller = $observer->getEvent()->getControllerAction();
951
- $request = $controller->getRequest();
952
-
 
 
 
953
  $user = Mage::getSingleton('admin/session');
954
-
955
- $id = (int)Mage::app()->getRequest()->getParam('item');
956
  $item = Mage::getModel('wishlist/item')->load($id);
957
-
958
  if (!$item->getId()) {
959
  return false;
960
  }
961
-
962
  $wishlist = Mage::getModel('wishlist/wishlist')->load($item->getWishlistId());
963
-
964
  if (!$wishlist) {
965
  return false;
966
  } else {
967
- $data = $this->helper->visitInfo();
968
- $data['item_id'] = $id;
969
  $data['product_id'] = $item->getProductId();
970
  $data['store_id'] = $item->getStoreId();
971
  $data['wishlist_id'] = $item->getWishlistId();
972
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::REMOVE_WISHLIST);
973
  }
974
-
975
  return;
976
  }
977
-
978
  /**
979
  * Visiting page info
980
  *
981
- * @param Varien_Event_Observer $observer
982
  *
983
  * @return void
984
  */
985
  public function pushCartData(Varien_Event_Observer $observer)
986
- {
987
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::CART_INDEX)) {
988
  return false;
989
  }
990
-
991
  // Set Token Values
992
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
993
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
994
  }
995
-
996
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
997
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
998
  }
999
-
1000
  // Page Visit Tracking
1001
  $data = $this->helper->visitInfo();
1002
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CART_INDEX);
1003
 
1004
  return;
1005
  }
1006
-
1007
  /**
1008
  * Push customer address data
1009
  *
1010
- * @param Varien_Event_Observer $observer
1011
  *
1012
  * @return void
1013
  */
@@ -1017,15 +1050,15 @@ class Targetbay_Tracking_Model_Observer
1017
  return false;
1018
  }
1019
  $addressId = Mage::app()->getRequest()->getParam('id');
1020
- $data = $this->helper->getCustomerAddressData($addressId);
1021
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CUSTOMER_ADDRESS);
1022
  return;
1023
  }
1024
-
1025
  /**
1026
  * Push customer account data
1027
  *
1028
- * @param Varien_Event_Observer $observer
1029
  *
1030
  * @return void
1031
  */
@@ -1040,11 +1073,11 @@ class Targetbay_Tracking_Model_Observer
1040
  $data['firstname'] = Mage::getSingleton('customer/session')->getCustomer()->getFirstname();
1041
  $data['lastname'] = Mage::getSingleton('customer/session')->getCustomer()->getLastname();
1042
  $data['email'] = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
1043
- $data['account_updated'] = Mage::getModel('core/date')->date('Y-m-d');
1044
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CUSTOMER_ACCOUNT);
1045
  return;
1046
  }
1047
-
1048
  /**
1049
  * Push the referrer data.
1050
  *
@@ -1058,40 +1091,40 @@ class Targetbay_Tracking_Model_Observer
1058
  try {
1059
  $request = Mage::app()->getRequest();
1060
  $trackingType = $this->helper->getTrackingType();
1061
- $identifier = Mage::getSingleton('cms/page')->getIdentifier();
1062
- $moduleName = $request->getModuleName();
 
1063
 
1064
- if ($trackingType == 1 && ($request->getControllerName() == 'product'
1065
- || $request->getControllerName() == 'category'
1066
- || $moduleName == 'cms')
1067
- ){
1068
  return false;
1069
  }
1070
 
1071
  if ($referrerData = $this->helper->getRefererData()) {
1072
  $this->pushPages($referrerData, Targetbay_Tracking_Helper_Data::PAGE_REFERRAL);
1073
  }
1074
- } catch(Exception $e) {
1075
- $this->debug('Error message '.$e->getMessage());
1076
  return;
1077
  }
1078
  }
1079
-
1080
  /**
1081
  * API Calls
1082
  *
1083
- * @param unknown $data
1084
- * @param unknown $type
1085
  */
1086
  public function pushPages($data, $type)
1087
  {
1088
- $endPointUrl = $this->targetbayHost . $type . $this->apiToken;
1089
  $data['index_name'] = $this->indexName;
1090
  try {
1091
- $res = $this->helper->postPageInfo($endPointUrl, json_encode($data));
1092
- }
1093
- catch (Exception $e) {
1094
- $this->helper->debug($type ."ERROR:" . $e->getMessage());
1095
  }
1096
  }
1097
- }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Observer
10
  {
11
  private $apiToken;
12
  private $indexName;
13
+ private $targetBayHost;
14
  private $helper;
15
+
16
  /**
17
  * Get the credentials from store configurations
18
  */
19
  public function __construct()
20
  {
21
+ //$expireAfter = 1;
22
  $expireAfter = 1380;
23
 
24
+ $this->helper = Mage::helper('tracking');
25
+ $this->apiToken = '?api_token=' . $this->helper->getApiToken();
26
+ $this->indexName = $this->helper->getApiIndex();
27
+ $this->targetBayHost = $this->helper->getHostname();
28
+
29
+ // ToDo: Fix this unused variable.
30
  $sess = Mage::getSingleton('core/session')->getTrackingSessionId();
31
  if (!$this->helper->cookie->get('trackingsession')) {
32
+ $visitor_data = Mage::getSingleton('core/session')->getVisitorData();
33
+ $trackingSession = $visitor_data['visitor_id'] . strtotime(date('Y-m-d H:i:s'));
34
+ Mage::getSingleton('core/session')->setTrackingSessionId($trackingSession);
35
  }
36
 
37
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
39
  Mage::getModel('core/cookie')->set('afterlogin_session_id', Mage::getSingleton('core/session')->getCustomerSessionId(), null, null, null, null, false);
40
  }
41
 
42
+ if (isset($_SESSION['last_session'])) {
 
43
  $secondsInactive = time() - $_SESSION['last_session'];
44
  $expireAfterSeconds = $expireAfter * 60;
45
+ if ($secondsInactive > $expireAfterSeconds) {
46
+ Mage::getSingleton('core/session')->unsProductReviewCount();
47
  Mage::getSingleton('core/session')->unsProductReviewResponse();
48
+ Mage::getSingleton('core/session')->unsSiteReviewCount();
49
  Mage::getSingleton('core/session')->unsSiteReviewResponse();
50
+ Mage::getSingleton('core/session')->unsQaReviewCount();
51
  Mage::getSingleton('core/session')->unsQaReviewResponse();
52
+ Mage::getSingleton('core/session')->unsProductReviewId();
53
  }
54
  }
55
  }
56
+
57
  /**
58
  * Set the cookie values for user differentiate.
59
  */
60
  public function setCookieValues()
61
  {
62
  // For anonymous user
63
+ $customerName = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
64
  $customerEmail = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
65
  if (!$this->helper->cookie->get('trackingid')) {
66
  $customerId = Mage::getSingleton('core/session')->getTrackingSessionId();
67
  }
68
+
69
  // for logged user
70
  if (Mage::app()->isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
71
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
72
+ $customerName = $customer->getName();
73
+ $customerId = $customer->getId();
74
  $customerEmail = $customer->getEmail();
75
  }
76
+
77
  // ToDo: Do we need this?
78
+ $trackingId = !empty($customerId) ? $this->helper->cookie->set('trackingid', $customerId, null, null, null, null, false) : '';
79
+
80
  $this->helper->cookie->set('trackingemail', $customerEmail, null, null, null, null, false);
81
  $this->helper->cookie->set('trackingname', $customerName, null, null, null, null, false);
82
+
83
  $quoteId = Mage::getSingleton('checkout/session')->getQuoteId() ? Mage::getSingleton('checkout/session')->getQuoteId() : '';
84
  $this->helper->cookie->set('trackingorderid', $quoteId, null, null, null, null, false);
85
+
86
  if (!$this->helper->cookie->get('trackingsession')) {
87
  $this->helper->cookie->set('trackingsession', Mage::getSingleton('core/session')->getTrackingSessionId(), null, null, null, null, false);
88
  }
89
  }
90
+
91
  /**
92
  * Visiting page info
93
  *
94
+ * @param Varien_Event_Observer $observer
95
  *
96
  * @return void
97
  */
98
  public function pushPageVisitData(Varien_Event_Observer $observer)
99
+ {
100
  $request = Mage::app()->getRequest();
101
+
102
+ $currentUri = sprintf("%s/%s/%s", $request->getModuleName(), $request->getControllerName(), $request->getActionName());
103
+
104
  $triggers = array(
105
  'checkout/onepage/savePayment',
106
  'checkout/onepage/saveOrder',
109
  'onestepcheckout/index/save_shipping',
110
  'onestepcheckout/index/is_valid_email'
111
  );
112
+
113
+ if (in_array($currentUri, $triggers, true)) {
114
  return false;
115
+ }
116
+
117
  $this->setCookieValues();
118
+
119
  // Page referrer Tracking
120
  $this->pushReferralData();
121
+
122
  if ($this->helper->eventAlreadyTracked($observer->getEvent()->getControllerAction()->getFullActionName())) {
123
  return false;
124
  }
125
+
126
  // Set Token Values
127
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
128
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
129
  }
130
+
131
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
132
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
133
  }
134
  }
135
+
136
  /**
137
  * Visiting page info
138
  *
139
+ * @param Varien_Event_Observer $observer
140
  *
141
  * @return void
142
  */
143
  public function cmsPageVisit(Varien_Event_Observer $observer)
144
+ {
145
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::PAGE_VISIT)) {
146
  return false;
147
  }
148
+
149
+ if ($this->helper->eventAlreadyTracked($observer->getEvent()->getControllerAction()->getFullActionName())) {
150
+ return false;
151
+ }
152
+
153
  // Set Token Values
154
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
155
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
156
  }
157
+
158
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
159
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
160
  }
161
+
162
  $request = Mage::app()->getRequest();
163
  $trackingType = $this->helper->getTrackingType();
164
+ // ToDo: Do we need this?
165
+ $identifier = Mage::getSingleton('cms/page')->getIdentifier();
166
+ $moduleName = $request->getModuleName();
167
+
168
  // Page Visit Tracking
169
  $data = $this->helper->visitInfo();
170
+ if ($trackingType == 1 && (
171
+ $request->getControllerName() === 'product' ||
172
+ $request->getControllerName() === 'category' ||
173
+ $moduleName === 'cms'
174
+ )
175
+ ) {
176
  return false;
177
+ }
178
+
179
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::PAGE_VISIT);
180
  return;
181
  }
182
+
183
  /**
184
  * Add to cart
185
  *
186
+ * @param Varien_Event_Observer $observer
187
  *
188
  * @return void
189
  */
194
  }
195
  Mage::getSingleton('checkout/session')->setTitle('Shopping cart');
196
 
197
+ //$item = $observer->getEvent()->getQuoteItem();
198
  //if ($item->getParentItem())
199
+ //$item = $item->getParentItem();
200
 
201
  $productInfo = $observer->getProduct();
202
 
203
  $productEventInfo = $observer->getEvent()->getProduct();
204
  $quote = Mage::getModel('checkout/cart')->getQuote();
205
+ $item = $quote->getItemByProduct($productEventInfo);
206
+
207
+ $itemCollection = $quote->getItemsCollection();
208
+
209
+ if ($productInfo->getData('type_id') === 'grouped') {
210
+ $productIds = Mage::app()->getRequest()->getParam('super_group');
211
+ $dataItem = array();
212
+ $productData = array();
213
+ foreach ($productIds as $id => $qty) {
214
+ if ($qty < 1) {
215
+ continue;
216
+ }
217
+ $product = Mage::getModel('catalog/product')->load($id);
218
+ $productData['type'] = $product->getTypeId();
219
+ $productData['product_id'] = $id;
220
+ $productData['product_sku'] = $product->getSku();
221
+ $productData['product_name'] = addslashes($product->getName());
222
+ $productData['price'] = $product->getFinalPrice() * $qty;
223
+ $productData['special_price'] = $product->getSpecialPrice();
224
+ $productData['productimg'] = $this->helper->getImageUrl($product, 'image');
225
+ $productData['category'] = $this->helper->getProductCategory($product);
226
+ $productData['category_name'] = $this->helper->getProductCategoryName($product);
227
+ $productData['quantity'] = $qty;
228
+ $productData['page_url'] = Mage::getUrl($product->getUrlPath());
229
+ $productData['attributes'] = '';
230
+ $dataItem[] = $productData;
231
+ }
232
+
233
+ /*foreach($itemCollection as $_item) {
234
+ $itemPrice = $_item->getCalculationPrice();
235
+ $productData['price'] = $itemPrice * $qty;
236
+ }*/
237
+
238
+ $data = $this->helper->getCartInfo();
239
+ $data['product_type'] = $productInfo->getData('type_id');
240
+ $data['cart_item'] = $dataItem;
241
+ } else {
242
+ $data = array_merge($this->helper->getCartInfo(), $this->helper->getItemInfo($item, Targetbay_Tracking_Helper_Data::ADDTOCART));
243
+ $data['product_type'] = $item->getProductType();
244
+ $data['price'] = $item->getProduct()->getFinalPrice();
245
+ /*foreach($itemCollection as $_item) {
246
+ $data['price'] = $_item->getCalculationPrice();
247
+ }*/
248
+ if ($customOptions = $this->helper->getCustomOptionsInfo($item, null)) {
249
+ $data['attributes'] = $customOptions;
250
+ }
251
  }
252
 
253
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::ADDTOCART);
254
+
255
  return;
256
  }
257
+
258
  /**
259
  * Capture the Update cart event
260
  *
261
+ * @param Varien_Event_Observer $observer
262
  *
263
  * @return void
264
  */
267
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::UPDATECART)) {
268
  return false;
269
  }
270
+ $items = $observer->getEvent()->getCart()->getQuote()->getAllVisibleItems();
271
  $requestInfo = $observer->getEvent()->getInfo();
272
+ $data = $this->helper->getCartInfo();
273
+
274
  foreach ($items as $item) {
275
  $newQty = $requestInfo[$item->getId()]['qty'];
276
  $oldQty = $item->getQty();
278
  continue;
279
  }
280
  $itemData = $this->helper->getItemInfo($item);
281
+
282
  unset($itemData['quantity']);
283
+ $newitemData = $itemData;
284
  $newitemData['old_quantity'] = $oldQty;
285
  $newitemData['new_quantity'] = $newQty;
286
+ $data['cart_items'][] = $newitemData;
287
  }
288
+
289
  if (isset($data['cart_items'])) {
290
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::UPDATECART);
291
  }
292
+
293
  return;
294
  }
295
+
296
  /**
297
  * Push the empty cart actions data
298
  *
299
+ * @param Varien_Event_Observer $observer
300
  *
301
  * @return void|boolean
302
  */
303
  public function pushEmptyCartData(Varien_Event_Observer $observer)
304
  {
305
+ $updateAction = (string) Mage::app()->getRequest()->getParam('update_cart_action');
306
  if ($updateAction != 'empty_cart') {
307
  return false;
308
  }
310
  foreach ($items as $item) {
311
  $this->removeCartItem($item);
312
  }
313
+
314
  return;
315
  }
316
+
317
  /**
318
  * Push the remove cart item data
319
  *
320
+ * @param Varien_Event_Observer $observer
321
  */
322
  public function pushRemoveCartItemData(Varien_Event_Observer $observer)
323
  {
324
  $this->removeCartItem($observer->getEvent()->getQuoteItem());
325
  }
326
+
327
  /**
328
  * Remove the cart item
329
  *
330
+ * @param unknown $item
331
  *
332
  * @return void|boolean
333
  */
338
  }
339
  $data = array_merge($this->helper->getCartInfo(), $this->helper->getItemInfo($item));
340
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::REMOVECART);
341
+
342
  return;
343
  }
344
+
345
  /**
346
  * Observe the checkout page
347
  *
348
+ * @param Varien_Event_Observer $observer
349
  *
350
  * @return void|boolean
351
  */
354
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::CHECKOUT)) {
355
  return false;
356
  }
357
+
358
  // Set Token Values
359
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
360
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
361
  }
362
+
363
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
364
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
365
  }
366
+
367
  $quote = Mage::getSingleton('checkout/session')->getQuote();
368
+
369
+ $data = $this->helper->getCartInfo();
370
+ $data['cart_items'] = $this->helper->getOrderItemsInfo($quote);
371
+ $data['total_qty'] = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();
372
  $data['total_amount'] = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
373
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CHECKOUT);
374
+
375
  return;
376
  }
377
+
378
  /**
379
  * Push billing info when user enter the billing in checkout
380
  *
381
+ * @param Varien_Event_Observer $observer
382
  *
383
  * @return void|boolean
384
  */
389
  return false;
390
  }
391
  Mage::getSingleton('checkout/session')->setTitle('Checkout Billing');
392
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
393
  $billingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::BILLING);
394
  $this->pushPages($billingInfo, Targetbay_Tracking_Helper_Data::BILLING);
395
  } catch (Exception $e) {
396
  $this->helper->debug("ERROR: " . $e->getMessage());
397
  }
398
+
399
  return;
400
  }
401
+
402
  /**
403
  * Push shipping info when user enter the shipping in checkout
404
  *
405
+ * @param Varien_Event_Observer $observer
406
  *
407
  * @return void|boolean
408
  */
413
  return false;
414
  }
415
  Mage::getSingleton('checkout/session')->setTitle('Checkout Shipping');
416
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
417
  $shippingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::SHIPPING);
418
  $this->pushPages($shippingInfo, Targetbay_Tracking_Helper_Data::SHIPPING);
419
  } catch (Exception $e) {
420
  $this->helper->debug("ERROR: " . $e->getMessage());
421
  }
422
+
423
  return;
424
  }
425
+
426
  /**
427
  * Order data
428
  *
429
+ * @param Varien_Event_Observer $observer
430
  * @return Targetbay_Tracking_Model_Observer
431
  *
432
  * @return void|boolean
439
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ORDER_ITEMS)) {
440
  return false;
441
  }
442
+ $order = $observer->getEvent()->getOrder();
443
  $params = Mage::app()->getFrontController()->getRequest()->getParams();
444
 
445
+ if ($this->pushShipmentData($order, $params)) {
446
+ return false;
447
+ } // order shipment process so no need to make order submit api.
448
+
449
+ // Capture the customer registration.
450
  if ($customer = $this->helper->isRegisterCheckout($order)) {
451
  $this->pushRegisterData($customer);
452
  }
453
+
454
  // Order Data Push to the Tag Manager
455
  $orderInfo = $this->helper->getInfo($order);
456
  $this->pushPages($orderInfo, Targetbay_Tracking_Helper_Data::ORDER_ITEMS);
459
  } catch (Exception $e) {
460
  $this->helper->debug("ERROR: " . $e->getMessage());
461
  }
462
+
463
  return;
464
  }
465
+
466
  /**
467
  * Order status change data
468
  *
469
+ * @param Varien_Event_Observer $observer
470
  * @return Targetbay_Tracking_Model_Observer
471
  *
472
  * @return void|boolean
477
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ORDER_STATUS)) {
478
  return false;
479
  }
480
+ $order = $observer->getEvent()->getOrder();
481
 
482
+ $data = $this->helper->getSessionInfo($order);
483
+ $data['first_name'] = $order->getCustomerFirstname();
484
+ $data['last_name'] = $order->getCustomerLastname();
485
+ $guestUsername = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname();
486
  $gName = !empty($guestUsername) ? $guestUsername : self::ANONYMOUS_USER;
487
+ $data['user_name'] = $order->getCustomerIsGuest() ? $gName : $data['first_name'] . ' ' . $data['last_name'];
488
+ $data['user_mail'] = $order->getCustomerEmail();
489
+ $data['order_id'] = $order->getId();
490
  $data['status'] = $order->getStatus();
491
+ if ($data['status'] === null) {
492
+ return false;
493
  }
494
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::ORDER_STATUS);
495
  } catch (Exception $e) {
496
  $this->helper->debug("ERROR: " . $e->getMessage());
497
  }
498
+
499
  return;
500
  }
501
+
502
  /**
503
  * Abandoned cart merge for logged in user
504
  *
505
+ * @param Varien_Event_Observer $observer
506
  *
507
  * @return void
508
  */
509
  public function quoteMergeData(Varien_Event_Observer $observer)
510
  {
511
+ $abandonedMail = Mage::getSingleton('core/session')->getAbandonedMail();
512
  $cart = Mage::getModel('checkout/cart');
513
+ if ($abandonedMail) {
514
  try {
515
  $this->helper->debug('MergeObs');
516
  $cart->truncate();
517
+ } catch (\Exception $e) {
518
+ $this->helper->debug('Error:' . $e->getMessage());
519
  }
520
  }
521
  return;
522
  }
523
+
524
  /**
525
  * Push the shipment data
526
  *
527
+ * @param unknown $order
528
  * @param unknown $params
529
  * @return boolean
530
  */
531
+ public function pushShipmentData($order, $params)
532
+ {
533
  try {
534
+ if ($this->helper->isFullFillmentProcess($params)) {
535
+ $data = $this->helper->getFullFillmentData($order, $params);
536
+ $this->pushPages($data, Targetbay_Tracking_Helper_Data::ORDER_SHIPMENT);
537
+ return true;
538
+ }
539
  } catch (Exception $e) {
540
  $this->helper->debug("ERROR: " . $e->getMessage());
541
  }
542
+
543
+ return false;
544
  }
545
+
546
  /**
547
  * Push the order shipment data
548
  *
549
+ * @param Varien_Event_Observer $observer
550
  * @return Targetbay_Tracking_Model_Observer
551
  * @return boolean
552
  */
553
  public function pushOrderShipmentData(Varien_Event_Observer $observer)
554
  {
555
  try {
556
+ if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ORDER_SHIPMENT)) {
557
+ return false;
558
+ }
559
 
560
+ $shipment = $observer->getEvent()->getShipment();
561
+ $order = $shipment->getOrder();
562
  $params[Targetbay_Tracking_Helper_Data::ORDER_SHIPMENT] = true;
563
  if ($this->helper->isFullFillmentProcess($params)) {
564
  $data = $this->helper->getFullFillmentData($order, $params);
567
  } catch (Exception $e) {
568
  $this->helper->debug("ERROR: " . $e->getMessage());
569
  }
570
+ return;
571
  }
572
+
573
  /**
574
  * Push billing and shipping info when user enter into onestepcheckout
575
  *
576
+ * @param Varien_Event_Observer $observer
577
  *
578
  * @return void|boolean
579
  */
580
  public function pushCheckoutAddressData(Varien_Event_Observer $observer)
581
+ {
582
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ONESTEPCHECKOUT_ADDRESS)) {
583
  return false;
584
  }
585
  Mage::getSingleton('checkout/session')->setTitle('OneStepCheckout');
586
+
587
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
588
  $billingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::BILLING);
589
  $this->pushPages($billingInfo, Targetbay_Tracking_Helper_Data::BILLING);
590
+
591
  $shippingInfo = $this->helper->getAddressData($quote, Targetbay_Tracking_Helper_Data::SHIPPING);
592
  $this->pushPages($shippingInfo, Targetbay_Tracking_Helper_Data::SHIPPING);
593
+
594
  return;
595
  }
596
+
597
  /**
598
  * Push the data when customer loggedin
599
  *
600
+ * @param Varien_Event_Observer $observer
601
  *
602
  * @return void|boolean
603
  */
611
  }
612
  $data = $this->helper->getCustomerData($observer->getCustomer(), Targetbay_Tracking_Helper_Data::LOGIN);
613
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::LOGIN);
614
+
615
  return;
616
  }
617
+
618
  /**
619
  * Push the data when customer logout
620
  *
621
+ * @param Varien_Event_Observer $observer
622
  *
623
  * @return void|boolean
624
  */
632
 
633
  // Remove all Cookies
634
  $this->helper->removeCookies();
635
+
636
  return;
637
  }
638
+
639
  /**
640
  * Registration observer
641
  *
642
+ * @param Varien_Event_Observer $observer
643
  */
644
  public function customerRegisterPushData(Varien_Event_Observer $observer)
645
  {
646
  $this->pushRegisterData($observer->getCustomer());
647
  }
648
+
649
  /**
650
  * Push the registration data
651
  *
652
+ * @param unknown $customer
653
  *
654
  * @return void|boolean
655
  */
660
  }
661
  $data = $this->helper->getCustomerData($customer, Targetbay_Tracking_Helper_Data::CREATE_ACCOUNT);
662
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CREATE_ACCOUNT);
663
+
664
  return;
665
  }
666
+
667
  /**
668
  * Push the newslettter subscription data
669
  *
670
+ * @param Varien_Event_Observer $observer
671
  *
672
  * @return void|boolean
673
  */
674
  public function pushSubscriptionData(Varien_Event_Observer $observer)
675
+ {
676
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::SUBSCRIBE_CUSTOMER)) {
677
  return false;
678
  }
679
 
680
+ $webstieId = Mage::app()->getStore()->getWebsiteId();
681
+ $customerModel = Mage::getModel('customer/customer');
682
+
683
  if (Mage::app()->getRequest()->getParam('email')) {
684
+ $email = Mage::app()->getRequest()->getParam('email');
685
+ $customerData = $customerModel->setWebsiteId($webstieId)->loadByEmail($email);
686
+ // ToDo: Do we need this?
687
+ $customerId = $customerData->getEntityId();
688
  } else {
689
+ $customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
690
+ $customerData = $customerModel->load($customerId);
691
+ $email = '';
692
+ }
693
+
694
  $data = $this->helper->visitInfo();
695
+
696
  if (empty($email)) {
697
  $subscriberFactory = Mage::getModel('newsletter/subscriber')->loadByCustomer($customerData);
698
+
699
  if ($subscriberFactory->getSubscriberStatus() == Targetbay_Tracking_Helper_Data::STATUS_UNSUBSCRIBED) {
700
  $status = 'Unsubscribed';
701
  } elseif ($subscriberFactory->getSubscriberStatus() == Targetbay_Tracking_Helper_Data::STATUS_SUBSCRIBED) {
710
  } else {
711
  $status = '';
712
  }
713
+
714
+ $status = !empty($email) ? 'Subscribed' : $status;
715
+ $data['user_mail'] = Mage::getSingleton('customer/session')->isLoggedIn() ? Mage::getSingleton('customer/session')->getCustomer()->getEmail() : $email;
716
  $data['subscription_status'] = $status;
717
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::SUBSCRIBE_CUSTOMER);
718
+
719
  return;
720
  }
721
+
722
  /**
723
  * Admin Account Activation observer
724
  *
725
+ * @param Varien_Event_Observer $observer
726
  */
727
  public function customerAdminConfirmData(Varien_Event_Observer $observer)
728
+ {
729
  $customer_info = $observer->getCustomer()->getData();
730
+ $data = array_merge($this->helper->visitInfo(), $customer_info);
731
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::ADMIN_ACTIVATE_ACCOUNT);
732
+
733
  return;
734
  }
735
+
736
  /**
737
  * Add and update product
738
  *
739
+ * @param Varien_Event_Observer $observer
740
  *
741
  * @return void
742
  */
746
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::ADD_PRODUCT)) {
747
  return false;
748
  }
749
+ $param = Mage::app()->getRequest()->getParams();
750
  $product = $observer->getEvent()->getProduct();
751
  if ($product->getId()) {
752
  $type = Targetbay_Tracking_Helper_Data::ADD_PRODUCT;
762
  } catch (Exception $e) {
763
  $this->helper->debug("ERROR: " . $e->getMessage());
764
  }
765
+
766
  return;
767
  }
768
+
769
  /**
770
  * Delete product
771
  *
772
+ * @param Varien_Event_Observer $observer
773
  *
774
  * @return void
775
  */
782
  $params = Mage::app()->getRequest()->getParams();
783
 
784
  if ($params) {
785
+ $data['entity_id'] = Mage::app()->getRequest()->getParam('id');
786
+ $data['user_name'] = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
787
+ $data['user_id'] = strtotime(date('Y-m-d H:i:s'));
788
  $data['session_id'] = strtotime(date('Y-m-d H:i:s'));
789
  if ($this->helper->cookie->get('trackingsession')) {
790
+ $data['user_id'] = $this->helper->cookie->get('trackingsession');
791
  $data['session_id'] = $this->helper->cookie->get('trackingsession');
792
  }
793
+ $data['date'] = $this->helper->date->date('Y-m-d');
794
  $data['timestamp'] = strtotime($this->helper->date->date('Y-m-d'));
795
+ $data['time'] = $this->helper->date->date('H:i');
796
  $data['user_mail'] = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
797
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::DELETE_PRODUCT);
798
  }
799
  } catch (Exception $e) {
800
  $this->helper->debug("ERROR: " . $e->getMessage());
801
  }
802
+
803
  return;
804
  }
805
+
806
  /**
807
  * Category view page
808
  *
809
+ * @param Varien_Event_Observer $observer
810
  *
811
  * @return void
812
  */
815
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::CATEGORY_VIEW)) {
816
  return false;
817
  }
818
+ $category = Mage::registry('current_category');
819
+ $data = $this->helper->visitInfo();
820
+ $data['category_id'] = $category->getId();
821
+ $data['category_url'] = $category->getUrl();
822
  $data['category_name'] = $category->getName();
823
+
824
  $trackingType = $this->helper->getTrackingType();
825
  if ($trackingType != 1):
826
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CATEGORY_VIEW);
827
  endif;
828
+
829
  return;
830
  }
831
+
832
  /**
833
  * Product view page
834
  *
835
+ * @param Varien_Event_Observer $observer
836
  *
837
  * @return void
838
  */
843
  }
844
 
845
  // Get the base visit info
846
+ $data = $this->helper->visitInfo();
847
+ $product = Mage::registry('product');
848
  $categoryIds = $product->getCategoryIds();
849
  if (count($categoryIds)) {
850
+ $firstCategoryId = $categoryIds[0];
851
+ $_category = Mage::getModel('catalog/category')->load($firstCategoryId);
852
  $data['category'] = $_category->getName();
853
  }
854
+ $data['product_id'] = $product->getId();
855
  $data['product_name'] = $product->getName();
856
+ $data['price'] = $product->getPrice();
857
+ $data['productimg'] = $product->getImageUrl();
858
+ $data['stock'] = Targetbay_Tracking_Helper_Data::OUT_OF_STOCK;
859
+ $stock = $product->getStockItem();
860
  if ($stock->getIsInStock()) {
861
  $data['stock'] = Targetbay_Tracking_Helper_Data::IN_STOCK;
862
  }
863
+
864
  $trackingType = $this->helper->getTrackingType();
865
  if ($trackingType != 1):
866
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::PRODUCT_VIEW);
867
  endif;
868
+
869
  return;
870
  }
871
+
872
  /**
873
  * Push the searhced query string
874
  *
875
+ * @param Varien_Event_Observer $observer
876
  *
877
  * @return void
878
  */
885
  if (empty($keyword)) {
886
  return false;
887
  }
888
+
889
+ $data = $this->helper->visitInfo();
890
  $data['keyword'] = $keyword;
891
 
892
  $trackingType = $this->helper->getTrackingType();
893
  if ($trackingType != 1):
894
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CATALOG_SEARCH);
895
  endif;
896
+
897
  return;
898
  }
899
+
900
  /**
901
+ * Add the Wishlist
902
  *
903
+ * @param Varien_Event_Observer $observer
904
  *
905
+ * @return void
906
  */
907
  public function pushAddWishlistData($observer)
908
  {
910
  return false;
911
  }
912
  $wishlistItems = $observer->getEvent()->getItems();
913
+ //$item_info = [];
914
 
915
  foreach ($wishlistItems as $item) {
916
+ if ($item->getParentItem()) {
917
  $item = $item->getParentItem();
918
+ }
919
+
920
  $item_info = $this->helper->getWishlistProductInfo($item->getData('product_id'));
921
 
922
+ $data = array_merge($this->helper->visitInfo(), $item_info);
923
+ $data['item_id'] = $item->getWishlistItemId();
924
  if ($customOptions = $this->helper->getCustomOptionsInfo($item, null)) {
925
  $data['attributes'] = $customOptions;
926
  }
927
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::WISHLIST);
928
  }
929
+
930
  return;
 
931
  }
932
+
933
  /**
934
  * Update the Wishlist items
935
  *
936
+ * @param Varien_Event_Observer $observer
937
  */
938
  public function pushUpdateWishlistData(Varien_Event_Observer $observer)
939
  {
940
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::UPDATE_WISHLIST)) {
941
  return false;
942
  }
943
+
944
+ $controller = $observer->getEvent()->getControllerAction();
945
+ $request = $controller->getRequest();
946
+ $wishlistId = Mage::app()->getRequest()->getParam('wishlist_id');
947
  $wishlistDesc = Mage::app()->getRequest()->getParam('description');
948
+ $wishlistQty = Mage::app()->getRequest()->getParam('qty');
949
+
950
+ $data = $this->helper->visitInfo();
951
+ $items = array();
952
+ $data['wishlist_id'] = $wishlistId;
953
 
954
  foreach ($wishlistDesc as $id => $item) {
955
  $wishlistItem = Mage::getModel('wishlist/item')->load($id);
956
+ $items[$id]['item_id'] = $id;
957
  $items[$id]['product_id'] = $wishlistItem->getProductId();
958
  $items[$id]['store_id'] = $wishlistItem->getStoreId();
959
  $items[$id]['description'] = $item;
960
+ $items[$id]['qty'] = $wishlistQty[$id];
961
  }
962
 
963
+ $data['wishlist_items'] = $items;
964
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::UPDATE_WISHLIST);
965
+
966
  return;
967
  }
968
+
969
  /**
970
  * Remove the Wishlist items
971
  *
972
+ * @param Varien_Event_Observer $observer
973
  */
974
  public function removeWhislistItem(Varien_Event_Observer $observer)
975
+ {
976
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::REMOVE_WISHLIST)) {
977
  return false;
978
  }
979
+
980
  $controller = $observer->getEvent()->getControllerAction();
981
+
982
+ // ToDo: Do we need this?
983
+ $request = $controller->getRequest();
984
+
985
+ // ToDo: Do we need this?
986
  $user = Mage::getSingleton('admin/session');
987
+
988
+ $id = (int) Mage::app()->getRequest()->getParam('item');
989
  $item = Mage::getModel('wishlist/item')->load($id);
990
+
991
  if (!$item->getId()) {
992
  return false;
993
  }
994
+
995
  $wishlist = Mage::getModel('wishlist/wishlist')->load($item->getWishlistId());
996
+
997
  if (!$wishlist) {
998
  return false;
999
  } else {
1000
+ $data = $this->helper->visitInfo();
1001
+ $data['item_id'] = $id;
1002
  $data['product_id'] = $item->getProductId();
1003
  $data['store_id'] = $item->getStoreId();
1004
  $data['wishlist_id'] = $item->getWishlistId();
1005
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::REMOVE_WISHLIST);
1006
  }
1007
+
1008
  return;
1009
  }
1010
+
1011
  /**
1012
  * Visiting page info
1013
  *
1014
+ * @param Varien_Event_Observer $observer
1015
  *
1016
  * @return void
1017
  */
1018
  public function pushCartData(Varien_Event_Observer $observer)
1019
+ {
1020
  if (!$this->helper->canTrackPages(Targetbay_Tracking_Helper_Data::CART_INDEX)) {
1021
  return false;
1022
  }
1023
+
1024
  // Set Token Values
1025
  if (isset($_GET['utm_source']) && !$this->helper->cookie->get('utm_source')) {
1026
  $this->helper->cookie->set('utm_source', $_GET['utm_source'], null, null, null, null, false);
1027
  }
1028
+
1029
  if (isset($_GET['token']) && !$this->helper->cookie->get('utm_token')) {
1030
  $this->helper->cookie->set('utm_token', $_GET['token'], null, null, null, null, false);
1031
  }
1032
+
1033
  // Page Visit Tracking
1034
  $data = $this->helper->visitInfo();
1035
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CART_INDEX);
1036
 
1037
  return;
1038
  }
1039
+
1040
  /**
1041
  * Push customer address data
1042
  *
1043
+ * @param Varien_Event_Observer $observer
1044
  *
1045
  * @return void
1046
  */
1050
  return false;
1051
  }
1052
  $addressId = Mage::app()->getRequest()->getParam('id');
1053
+ $data = $this->helper->getCustomerAddressData($addressId);
1054
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CUSTOMER_ADDRESS);
1055
  return;
1056
  }
1057
+
1058
  /**
1059
  * Push customer account data
1060
  *
1061
+ * @param Varien_Event_Observer $observer
1062
  *
1063
  * @return void
1064
  */
1073
  $data['firstname'] = Mage::getSingleton('customer/session')->getCustomer()->getFirstname();
1074
  $data['lastname'] = Mage::getSingleton('customer/session')->getCustomer()->getLastname();
1075
  $data['email'] = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
1076
+ $data['account_updated'] = Mage::getModel('core/date')->date('Y-m-d');
1077
  $this->pushPages($data, Targetbay_Tracking_Helper_Data::CUSTOMER_ACCOUNT);
1078
  return;
1079
  }
1080
+
1081
  /**
1082
  * Push the referrer data.
1083
  *
1091
  try {
1092
  $request = Mage::app()->getRequest();
1093
  $trackingType = $this->helper->getTrackingType();
1094
+ // ToDo: Do we need this?
1095
+ $identifier = Mage::getSingleton('cms/page')->getIdentifier();
1096
+ $moduleName = $request->getModuleName();
1097
 
1098
+ if ($trackingType == 1 && ($request->getControllerName() == 'product'
1099
+ || $request->getControllerName() == 'category'
1100
+ || $moduleName == 'cms')
1101
+ ) {
1102
  return false;
1103
  }
1104
 
1105
  if ($referrerData = $this->helper->getRefererData()) {
1106
  $this->pushPages($referrerData, Targetbay_Tracking_Helper_Data::PAGE_REFERRAL);
1107
  }
1108
+ } catch (Exception $e) {
1109
+ $this->debug('Error message ' . $e->getMessage());
1110
  return;
1111
  }
1112
  }
1113
+
1114
  /**
1115
  * API Calls
1116
  *
1117
+ * @param unknown $data
1118
+ * @param unknown $type
1119
  */
1120
  public function pushPages($data, $type)
1121
  {
1122
+ $endPointUrl = $this->targetBayHost . $type . $this->apiToken;
1123
  $data['index_name'] = $this->indexName;
1124
  try {
1125
+ $this->helper->postPageInfo($endPointUrl, json_encode($data));
1126
+ } catch (Exception $e) {
1127
+ $this->helper->debug($type . "ERROR:" . $e->getMessage());
 
1128
  }
1129
  }
1130
+ }
app/code/community/Targetbay/Tracking/Model/Subscriber.php CHANGED
@@ -1,18 +1,19 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
8
  {
9
- const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'newsletter/subscription/confirm_email_template';
10
- const XML_PATH_CONFIRM_EMAIL_IDENTITY = 'newsletter/subscription/confirm_email_identity';
11
- const XML_PATH_SUCCESS_EMAIL_TEMPLATE = 'newsletter/subscription/success_email_template';
12
- const XML_PATH_SUCCESS_EMAIL_IDENTITY = 'newsletter/subscription/success_email_identity';
13
- const XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE = 'newsletter/subscription/un_email_template';
14
- const XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY = 'newsletter/subscription/un_email_identity';
15
-
16
 
17
  /**
18
  * Sends out confirmation success email
@@ -21,17 +22,18 @@ class Targetbay_Tracking_Model_Subscriber extends Mage_Newsletter_Model_Subscrib
21
  */
22
  public function sendConfirmationSuccessEmail()
23
  {
24
- $emailStatus = Mage::helper('tracking')->getEmailStatus();
 
 
 
 
25
 
26
- if($emailStatus == 1)
27
- return false;
28
-
29
  if ($this->getImportMode()) {
30
  return $this;
31
  }
32
 
33
- if(!Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE)
34
- || !Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY)
35
  ) {
36
  return $this;
37
  }
@@ -47,7 +49,7 @@ class Targetbay_Tracking_Model_Subscriber extends Mage_Newsletter_Model_Subscrib
47
  Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
48
  $this->getEmail(),
49
  $this->getName(),
50
- array('subscriber'=>$this)
51
  );
52
 
53
  $translate->setTranslateInline(true);
@@ -62,16 +64,17 @@ class Targetbay_Tracking_Model_Subscriber extends Mage_Newsletter_Model_Subscrib
62
  */
63
  public function sendUnsubscriptionEmail()
64
  {
65
- $emailStatus = Mage::helper('tracking')->getEmailStatus();
66
 
67
- if($emailStatus == 1)
68
- return false;
 
69
 
70
  if ($this->getImportMode()) {
71
  return $this;
72
  }
73
- if(!Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE)
74
- || !Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY)
75
  ) {
76
  return $this;
77
  }
@@ -87,7 +90,7 @@ class Targetbay_Tracking_Model_Subscriber extends Mage_Newsletter_Model_Subscrib
87
  Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY),
88
  $this->getEmail(),
89
  $this->getName(),
90
- array('subscriber'=>$this)
91
  );
92
 
93
  $translate->setTranslateInline(true);
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
10
  {
11
+ const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'newsletter/subscription/confirm_email_template';
12
+ const XML_PATH_CONFIRM_EMAIL_IDENTITY = 'newsletter/subscription/confirm_email_identity';
13
+ const XML_PATH_SUCCESS_EMAIL_TEMPLATE = 'newsletter/subscription/success_email_template';
14
+ const XML_PATH_SUCCESS_EMAIL_IDENTITY = 'newsletter/subscription/success_email_identity';
15
+ const XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE = 'newsletter/subscription/un_email_template';
16
+ const XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY = 'newsletter/subscription/un_email_identity';
 
17
 
18
  /**
19
  * Sends out confirmation success email
22
  */
23
  public function sendConfirmationSuccessEmail()
24
  {
25
+ $emailStatus = Mage::helper('tracking')->getEmailStatus();
26
+
27
+ if ($emailStatus == 1) {
28
+ return false;
29
+ }
30
 
 
 
 
31
  if ($this->getImportMode()) {
32
  return $this;
33
  }
34
 
35
+ if (!Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE)
36
+ || !Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY)
37
  ) {
38
  return $this;
39
  }
49
  Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
50
  $this->getEmail(),
51
  $this->getName(),
52
+ array('subscriber' => $this)
53
  );
54
 
55
  $translate->setTranslateInline(true);
64
  */
65
  public function sendUnsubscriptionEmail()
66
  {
67
+ $emailStatus = Mage::helper('tracking')->getEmailStatus();
68
 
69
+ if ($emailStatus == 1) {
70
+ return false;
71
+ }
72
 
73
  if ($this->getImportMode()) {
74
  return $this;
75
  }
76
+ if (!Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE)
77
+ || !Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY)
78
  ) {
79
  return $this;
80
  }
90
  Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY),
91
  $this->getEmail(),
92
  $this->getName(),
93
+ array('subscriber' => $this)
94
  );
95
 
96
  $translate->setTranslateInline(true);
app/code/community/Targetbay/Tracking/Model/System/Config/Source/Page.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_System_Config_Source_Page
8
  {
9
  /**
@@ -90,10 +92,10 @@ class Targetbay_Tracking_Model_System_Config_Source_Page
90
  'value' => Targetbay_Tracking_Helper_Data::PAGE_REFERRAL,
91
  'label' => Mage::helper('adminhtml')->__('Referrer page')
92
  ),
93
- array (
94
- 'value' => Targetbay_Tracking_Helper_Data::WISHLIST,
95
- 'label' => Mage::helper ( 'adminhtml' )->__ ( 'Wishlist page' )
96
- )
97
  );
98
  }
99
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_System_Config_Source_Page
10
  {
11
  /**
92
  'value' => Targetbay_Tracking_Helper_Data::PAGE_REFERRAL,
93
  'label' => Mage::helper('adminhtml')->__('Referrer page')
94
  ),
95
+ array(
96
+ 'value' => Targetbay_Tracking_Helper_Data::WISHLIST,
97
+ 'label' => Mage::helper('adminhtml')->__('Wishlist page')
98
+ )
99
  );
100
  }
101
  }
app/code/community/Targetbay/Tracking/Model/System/Config/Source/Snippetstatus.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * @author Targetbay
5
+ * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
+ * @package Targetbay_Tracking
7
+ */
8
+
9
+ class Targetbay_Tracking_Model_System_Config_Source_Snippetstatus
10
+ {
11
+ /**
12
+ * Page Options configurations
13
+ *
14
+ * @return array
15
+ */
16
+ public function toOptionArray()
17
+ {
18
+ return array(
19
+ array(
20
+ 'value' => '',
21
+ 'label' => Mage::helper('adminhtml')->__('Please Select')
22
+ ),
23
+ array(
24
+ 'value' => 0,
25
+ 'label' => Mage::helper('adminhtml')->__('Disable')
26
+ ),
27
+ array(
28
+ 'value' => 1,
29
+ 'label' => Mage::helper('adminhtml')->__('Automatic')
30
+ ),
31
+ array(
32
+ 'value' => 2,
33
+ 'label' => Mage::helper('adminhtml')->__('Manual')
34
+ )
35
+ );
36
+ }
37
+ }
app/code/community/Targetbay/Tracking/Model/System/Config/Source/Status.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_System_Config_Source_Status
8
  {
9
  /**
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_System_Config_Source_Status
10
  {
11
  /**
app/code/community/Targetbay/Tracking/Model/System/Config/Source/Tracking.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_System_Config_Source_Tracking
8
  {
9
  /**
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_System_Config_Source_Tracking
10
  {
11
  /**
app/code/community/Targetbay/Tracking/Model/System/Config/Source/Version.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_System_Config_Source_Version
8
  {
9
  /**
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_System_Config_Source_Version
10
  {
11
  /**
app/code/community/Targetbay/Tracking/Model/System/Config/Source/Yesno.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_Model_System_Config_Source_Yesno
8
  {
9
  /**
@@ -13,9 +15,9 @@ class Targetbay_Tracking_Model_System_Config_Source_Yesno
13
  */
14
  public function toOptionArray()
15
  {
16
- return array(
17
- array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
18
- array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('No')),
19
  );
20
  }
21
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_Model_System_Config_Source_Yesno
10
  {
11
  /**
15
  */
16
  public function toOptionArray()
17
  {
18
+ return array(
19
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Yes')),
20
+ array('value' => 2, 'label' => Mage::helper('adminhtml')->__('No')),
21
  );
22
  }
23
  }
app/code/community/Targetbay/Tracking/controllers/IndexController.php CHANGED
@@ -1,142 +1,93 @@
1
  <?php
 
2
  /*
3
  * @author Targetbay
4
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
5
  * @package Targetbay_Tracking
6
  */
 
7
  class Targetbay_Tracking_IndexController extends Mage_Core_Controller_Front_Action
8
  {
9
  public function reloadAction()
10
  {
11
- if (Mage::getSingleton('customer/session')->isLoggedIn())
12
- return false;
 
13
 
14
  try {
15
- $quoteId = Mage::app()->getRequest()->getParam('quote_id');
16
- $guestUserId = Mage::app()->getRequest()->getParam('guest_user_id');
17
- //$guestUserId = 591861368;
18
- $store_id = Mage::app()->getStore()->getId();
 
 
 
 
 
 
 
19
 
20
- if($guestUserId != '' && !Mage::getSingleton('customer/session')->isLoggedIn()) {
21
- Mage::getModel('core/cookie')->set('targetbay_session_id', $guestUserId, null, null, null, null, false);
22
- }
23
-
24
- $checkout = Mage::getSingleton('checkout/session');
25
- $cust = Mage::getSingleton('customer/session');
26
- $coreSession = Mage::getSingleton('core/session');
27
- $coreSession->setRestoreQuoteId($quoteId);
28
- $coreSession->setAbandonedMail(true);
29
- $chkQuote = Mage::helper('checkout/cart')->getQuote();
30
- $helper = Mage::helper('tracking');
31
 
32
- if(empty($quoteId)) {
33
- $this->_redirectAfterReload();
34
- }
 
 
35
 
36
- if($checkout->getQuoteMerged()) {
37
- $this->_redirectAfterReload();
38
- }
39
 
40
- $quote = Mage::getModel('sales/quote')->load($quoteId);
41
- if($quote && $quote->getId() && $quote->getIsActive() && (($checkout->getQuoteMerged() == null) ||
42
- $checkout->getQuoteMerged() != true)) {
43
- if (!$chkQuote) {
44
- $chkQuote = Mage::getModel('sales/quote');
45
- }
46
 
47
- $chkQuote->merge($quote)
48
- ->collectTotals()
49
- ->save();
50
- $checkout->setQuoteId($chkQuote->getId());
51
- $checkout->setQuoteMerged(true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
- } catch (Exception $e) {
54
- $helper->debug("ERROR: " . $e->getMessage());
55
- }
56
 
57
  return $this->_redirectAfterReload();
58
  }
59
 
60
  private function _redirectAfterReload()
61
- {
62
  $url = 'checkout/cart/';
63
- $utmSource = Mage::app()->getRequest()->getParam('utm_source');
64
- $utmToken = Mage::app()->getRequest()->getParam('token');
65
 
66
  return $this->_redirect(
67
  $url,
68
- array('_secure' => Mage::app()->getStore()->isCurrentlySecure(), 'utm_source' => $utmSource, 'token' => $utmToken)
69
- );
70
- }
71
-
72
- public function tokenAction() {
73
-
74
- $params = array(
75
- 'siteUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/oauth',
76
- 'requestTokenUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/oauth/initiate',
77
- 'accessTokenUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/oauth/token',
78
- 'authorizeUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/admin/oauth_authorize',//This URL is used only if we authenticate as Admin user type
79
- 'consumerKey' => 'fe2975957a5699225d7cbad7873e6d7a',//Consumer key registered in server administration
80
- 'consumerSecret' => '0b59f92cfd9bcfa982aa95d3dc0513c5',//Consumer secret registered in server administration
81
- 'callbackUrl' => 'http://localhost/magento_19/index.php/tracking/index/callback',//Url of callback action below
82
- );
83
-
84
- // Initiate oAuth consumer with above parameters
85
- $consumer = new Zend_Oauth_Consumer($params);
86
-
87
- // Get request token
88
- $requestToken = $consumer->getRequestToken();
89
- Mage::helper('tracking')->debug('requestToken====');
90
- Mage::helper('tracking')->debug(print_r($requestToken, true));
91
- // Get session
92
- $session = Mage::getSingleton('core/session');
93
- // Save serialized request token object in session for later use
94
- $session->setRequestToken(serialize($requestToken));
95
- // Redirect to authorize URL
96
- $consumer->redirect();
97
-
98
- return;
99
- }
100
-
101
- public function callbackAction() {
102
-
103
- $params = array(
104
- 'siteUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/oauth',
105
- 'requestTokenUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/oauth/initiate',
106
- 'accessTokenUrl' => 'http://dev-goodstate.enterpriseapplicationdevelopers.com/oauth/token',
107
- 'consumerKey' => 'fe2975957a5699225d7cbad7873e6d7a',
108
- 'consumerSecret' => '0b59f92cfd9bcfa982aa95d3dc0513c5'
109
  );
110
-
111
- // Get session
112
- $session = Mage::getSingleton('core/session');
113
- // Read and unserialize request token from session
114
- $requestToken = unserialize($session->getRequestToken());
115
- // Initiate oAuth consumer
116
- $consumer = new Zend_Oauth_Consumer($params);
117
- Mage::log('Get Array:' . print_r($_GET, true) );
118
- // Using oAuth parameters and request Token we got, get access token
119
- $acessToken = $consumer->getAccessToken($_GET, $requestToken);
120
- Mage::helper('tracking')->debug('acessToken====');
121
- Mage::helper('tracking')->debug(print_r($acessToken, true));
122
- // Get HTTP client from access token object
123
- $restClient = $acessToken->getHttpClient($params);
124
- Mage::helper('tracking')->debug('restClient====');
125
- Mage::helper('tracking')->debug(print_r($restClient, true));
126
- // Set REST resource URL
127
- //$restClient->setUri('http://dev.getbitoutdoor.com/api/rest/targetbay/totalproductcounts');
128
- //$restClient->setUri('http://developer:heymagento@getbit-live.enterpriseapplicationdevelopers.com/api/rest/targetbay/totalproductcounts');
129
- $restClient->setUri('http://developer:heymagento@dev-goodstate.enterpriseapplicationdevelopers.com/api/rest/targetbay/totalcategorycounts');
130
- // In Magento it is neccesary to set json or xml headers in order to work
131
- $restClient->setHeaders('Accept', 'application/json');
132
- // Get method
133
- $restClient->setMethod(Zend_Http_Client::GET);
134
- //Make REST request
135
- $response = $restClient->request();
136
- // Here we can see that response body contains json list of products
137
- echo '<pre>';
138
- Zend_Debug::dump($response);
139
-
140
- return;
141
  }
142
  }
1
  <?php
2
+
3
  /*
4
  * @author Targetbay
5
  * @copyright 2016 Sathishkumar Mariappan <sathishkumar.m@innoppl.com>
6
  * @package Targetbay_Tracking
7
  */
8
+
9
  class Targetbay_Tracking_IndexController extends Mage_Core_Controller_Front_Action
10
  {
11
  public function reloadAction()
12
  {
13
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
14
+ return false;
15
+ }
16
 
17
  try {
18
+ $quoteId = Mage::app()->getRequest()->getParam('quote_id');
19
+ $guestUserId = Mage::app()->getRequest()->getParam('guest_user_id');
20
+
21
+ // ToDo: Do we need?
22
+ $store_id = Mage::app()->getStore()->getId();
23
+
24
+ if ($guestUserId != '' && !Mage::getSingleton('customer/session')->isLoggedIn()) {
25
+ Mage::getModel('core/cookie')->set('targetbay_session_id', $guestUserId, null, null, null, null, false);
26
+ }
27
+
28
+ $checkout = Mage::getSingleton('checkout/session');
29
 
30
+ // ToDo: Do we need?
31
+ $cust = Mage::getSingleton('customer/session');
 
 
 
 
 
 
 
 
 
32
 
33
+ $coreSession = Mage::getSingleton('core/session');
34
+ $coreSession->setRestoreQuoteId($quoteId);
35
+ $coreSession->setAbandonedMail(true);
36
+ $cart = Mage::getModel('checkout/cart');
37
+ $helper = Mage::helper('tracking');
38
 
39
+ if (empty($quoteId)) {
40
+ $this->_redirectAfterReload();
41
+ }
42
 
43
+ if ($checkout->getQuoteMerged()) {
44
+ $this->_redirectAfterReload();
45
+ }
 
 
 
46
 
47
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
48
+ if ($quote && $quote->getId() && $quote->getIsActive() && (($checkout->getQuoteMerged() == null) ||
49
+ $checkout->getQuoteMerged() != true)
50
+ ) {
51
+ $quoteItems = $quote->getAllVisibleItems();
52
+ $i=0;
53
+ foreach ($quoteItems as $key => $item) {
54
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
55
+ if ($item->getProductType() == 'configurable') {
56
+ $customOptions = $item->getProduct()->getTypeInstance(true)
57
+ ->getOrderOptions($item->getProduct());
58
+ $superAttributeInfo = $customOptions['info_buyRequest'];
59
+ $params = array('qty' => $quoteItems[$i]['qty'],
60
+ 'super_attribute' => $superAttributeInfo['super_attribute']);
61
+ $cart->addProduct($product, $params);
62
+ } else {
63
+ $params = array('qty' => $quoteItems[$i]['qty']);
64
+ $cart->addProduct($product, $params);
65
+ }
66
+ $i++;
67
+ }
68
+ $cart->save();
69
+ $checkout->setQuoteMerged(true);
70
  }
71
+ } catch (Exception $e) {
72
+ $helper->debug("ERROR: " . $e->getMessage());
73
+ }
74
 
75
  return $this->_redirectAfterReload();
76
  }
77
 
78
  private function _redirectAfterReload()
79
+ {
80
  $url = 'checkout/cart/';
81
+ $utmSource = Mage::app()->getRequest()->getParam('utm_source');
82
+ $utmToken = Mage::app()->getRequest()->getParam('token');
83
 
84
  return $this->_redirect(
85
  $url,
86
+ array(
87
+ '_secure' => Mage::app()->getStore()->isCurrentlySecure(),
88
+ 'utm_source' => $utmSource,
89
+ 'token' => $utmToken
90
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
  }
app/code/community/Targetbay/Tracking/etc/api2.xml CHANGED
@@ -21,6 +21,9 @@
21
  <title>Totalcounts</title>
22
  <sort_order>10</sort_order>
23
  <privileges>
 
 
 
24
  <guest>
25
  <retrieve>1</retrieve>
26
  </guest>
@@ -39,6 +42,9 @@
39
  <title>Total Product Counts</title>
40
  <sort_order>20</sort_order>
41
  <privileges>
 
 
 
42
  <guest>
43
  <retrieve>1</retrieve>
44
  </guest>
@@ -58,6 +64,9 @@
58
  <title>Targetbay Export Products</title>
59
  <sort_order>30</sort_order>
60
  <privileges>
 
 
 
61
  <guest>
62
  <retrieve>1</retrieve>
63
  </guest>
@@ -70,6 +79,7 @@
70
  <attribute_set_id>Attribute Set</attribute_set_id>
71
  <stock_data>Inventory Data</stock_data>
72
  <image_url>Default Image</image_url>
 
73
  <is_saleable>Salability Status</is_saleable>
74
  <total_reviews_count>Total Reviews Count</total_reviews_count>
75
  <url>Product URL</url>
@@ -121,6 +131,9 @@
121
  <title>Total Order Counts</title>
122
  <sort_order>40</sort_order>
123
  <privileges>
 
 
 
124
  <guest>
125
  <retrieve>1</retrieve>
126
  </guest>
@@ -139,6 +152,9 @@
139
  <title>Targetbay Export Orders</title>
140
  <sort_order>40</sort_order>
141
  <privileges>
 
 
 
142
  <guest>
143
  <retrieve>1</retrieve>
144
  </guest>
@@ -149,6 +165,8 @@
149
  <entity_id>Order ID (internal)</entity_id>
150
  <increment_id>Order ID</increment_id>
151
  <created_at>Order Date</created_at>
 
 
152
  <status>Order Status</status>
153
  <website_id>Website Id</website_id>
154
  <store_id>Store Id</store_id>
@@ -215,6 +233,9 @@
215
  <title>Total Category Counts</title>
216
  <sort_order>50</sort_order>
217
  <privileges>
 
 
 
218
  <guest>
219
  <retrieve>1</retrieve>
220
  </guest>
@@ -233,6 +254,9 @@
233
  <title>Targetbay Export Categories</title>
234
  <sort_order>60</sort_order>
235
  <privileges>
 
 
 
236
  <guest>
237
  <retrieve>1</retrieve>
238
  </guest>
@@ -263,6 +287,9 @@
263
  <title>Total Customer Counts</title>
264
  <sort_order>70</sort_order>
265
  <privileges>
 
 
 
266
  <guest>
267
  <retrieve>1</retrieve>
268
  </guest>
@@ -281,6 +308,9 @@
281
  <title>Targetbay Export Customer</title>
282
  <sort_order>75</sort_order>
283
  <privileges>
 
 
 
284
  <guest>
285
  <retrieve>1</retrieve>
286
  </guest>
@@ -313,6 +343,9 @@
313
  <title>Total CartItem Counts</title>
314
  <sort_order>80</sort_order>
315
  <privileges>
 
 
 
316
  <guest>
317
  <retrieve>1</retrieve>
318
  </guest>
@@ -331,6 +364,9 @@
331
  <title>Targetbay Export Cart Items</title>
332
  <sort_order>90</sort_order>
333
  <privileges>
 
 
 
334
  <guest>
335
  <retrieve>1</retrieve>
336
  </guest>
@@ -357,6 +393,9 @@
357
  <title>Total Wishlist Counts</title>
358
  <sort_order>110</sort_order>
359
  <privileges>
 
 
 
360
  <guest>
361
  <retrieve>1</retrieve>
362
  </guest>
@@ -375,6 +414,9 @@
375
  <title>Targetbay Export Wishlist Items</title>
376
  <sort_order>120</sort_order>
377
  <privileges>
 
 
 
378
  <guest>
379
  <retrieve>1</retrieve>
380
  </guest>
@@ -401,6 +443,9 @@
401
  <title>Total Review Counts</title>
402
  <sort_order>130</sort_order>
403
  <privileges>
 
 
 
404
  <guest>
405
  <retrieve>1</retrieve>
406
  </guest>
@@ -419,6 +464,9 @@
419
  <title>Targetbay Export Review</title>
420
  <sort_order>140</sort_order>
421
  <privileges>
 
 
 
422
  <guest>
423
  <retrieve>1</retrieve>
424
  </guest>
@@ -446,6 +494,10 @@
446
  <title>Create Newsletter Subscription</title>
447
  <sort_order>150</sort_order>
448
  <privileges>
 
 
 
 
449
  <guest>
450
  <create>1</create>
451
  <retrieve>1</retrieve>
@@ -471,6 +523,10 @@
471
  <title>Update Subscription</title>
472
  <sort_order>155</sort_order>
473
  <privileges>
 
 
 
 
474
  <guest>
475
  <create>1</create>
476
  <retrieve>1</retrieve>
@@ -496,6 +552,9 @@
496
  <title>Total Shipment Counts</title>
497
  <sort_order>160</sort_order>
498
  <privileges>
 
 
 
499
  <guest>
500
  <retrieve>1</retrieve>
501
  </guest>
@@ -514,6 +573,9 @@
514
  <title>Targetbay Export Shipment</title>
515
  <sort_order>165</sort_order>
516
  <privileges>
 
 
 
517
  <guest>
518
  <retrieve>1</retrieve>
519
  </guest>
@@ -550,6 +612,9 @@
550
  <title>Targetbay Export Stores</title>
551
  <sort_order>170</sort_order>
552
  <privileges>
 
 
 
553
  <guest>
554
  <retrieve>1</retrieve>
555
  </guest>
@@ -574,6 +639,9 @@
574
  <title>Total Subscriber Counts</title>
575
  <sort_order>175</sort_order>
576
  <privileges>
 
 
 
577
  <guest>
578
  <retrieve>1</retrieve>
579
  </guest>
@@ -592,6 +660,9 @@
592
  <title>Subscriber</title>
593
  <sort_order>180</sort_order>
594
  <privileges>
 
 
 
595
  <guest>
596
  <retrieve>1</retrieve>
597
  </guest>
@@ -611,6 +682,33 @@
611
  </routes>
612
  <versions>1</versions>
613
  </tracking_subscriber>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
614
  </resources>
615
  </api2>
616
  </config>
21
  <title>Totalcounts</title>
22
  <sort_order>10</sort_order>
23
  <privileges>
24
+ <admin>
25
+ <retrieve>1</retrieve>
26
+ </admin>
27
  <guest>
28
  <retrieve>1</retrieve>
29
  </guest>
42
  <title>Total Product Counts</title>
43
  <sort_order>20</sort_order>
44
  <privileges>
45
+ <admin>
46
+ <retrieve>1</retrieve>
47
+ </admin>
48
  <guest>
49
  <retrieve>1</retrieve>
50
  </guest>
64
  <title>Targetbay Export Products</title>
65
  <sort_order>30</sort_order>
66
  <privileges>
67
+ <admin>
68
+ <retrieve>1</retrieve>
69
+ </admin>
70
  <guest>
71
  <retrieve>1</retrieve>
72
  </guest>
79
  <attribute_set_id>Attribute Set</attribute_set_id>
80
  <stock_data>Inventory Data</stock_data>
81
  <image_url>Default Image</image_url>
82
+ <stock_count>Stock Count</stock_count>
83
  <is_saleable>Salability Status</is_saleable>
84
  <total_reviews_count>Total Reviews Count</total_reviews_count>
85
  <url>Product URL</url>
131
  <title>Total Order Counts</title>
132
  <sort_order>40</sort_order>
133
  <privileges>
134
+ <admin>
135
+ <retrieve>1</retrieve>
136
+ </admin>
137
  <guest>
138
  <retrieve>1</retrieve>
139
  </guest>
152
  <title>Targetbay Export Orders</title>
153
  <sort_order>40</sort_order>
154
  <privileges>
155
+ <admin>
156
+ <retrieve>1</retrieve>
157
+ </admin>
158
  <guest>
159
  <retrieve>1</retrieve>
160
  </guest>
165
  <entity_id>Order ID (internal)</entity_id>
166
  <increment_id>Order ID</increment_id>
167
  <created_at>Order Date</created_at>
168
+ <shipped_at>Shipment Date</shipped_at>
169
+ <timezone>Time Zone</timezone>
170
  <status>Order Status</status>
171
  <website_id>Website Id</website_id>
172
  <store_id>Store Id</store_id>
233
  <title>Total Category Counts</title>
234
  <sort_order>50</sort_order>
235
  <privileges>
236
+ <admin>
237
+ <retrieve>1</retrieve>
238
+ </admin>
239
  <guest>
240
  <retrieve>1</retrieve>
241
  </guest>
254
  <title>Targetbay Export Categories</title>
255
  <sort_order>60</sort_order>
256
  <privileges>
257
+ <admin>
258
+ <retrieve>1</retrieve>
259
+ </admin>
260
  <guest>
261
  <retrieve>1</retrieve>
262
  </guest>
287
  <title>Total Customer Counts</title>
288
  <sort_order>70</sort_order>
289
  <privileges>
290
+ <admin>
291
+ <retrieve>1</retrieve>
292
+ </admin>
293
  <guest>
294
  <retrieve>1</retrieve>
295
  </guest>
308
  <title>Targetbay Export Customer</title>
309
  <sort_order>75</sort_order>
310
  <privileges>
311
+ <admin>
312
+ <retrieve>1</retrieve>
313
+ </admin>
314
  <guest>
315
  <retrieve>1</retrieve>
316
  </guest>
343
  <title>Total CartItem Counts</title>
344
  <sort_order>80</sort_order>
345
  <privileges>
346
+ <admin>
347
+ <retrieve>1</retrieve>
348
+ </admin>
349
  <guest>
350
  <retrieve>1</retrieve>
351
  </guest>
364
  <title>Targetbay Export Cart Items</title>
365
  <sort_order>90</sort_order>
366
  <privileges>
367
+ <admin>
368
+ <retrieve>1</retrieve>
369
+ </admin>
370
  <guest>
371
  <retrieve>1</retrieve>
372
  </guest>
393
  <title>Total Wishlist Counts</title>
394
  <sort_order>110</sort_order>
395
  <privileges>
396
+ <admin>
397
+ <retrieve>1</retrieve>
398
+ </admin>
399
  <guest>
400
  <retrieve>1</retrieve>
401
  </guest>
414
  <title>Targetbay Export Wishlist Items</title>
415
  <sort_order>120</sort_order>
416
  <privileges>
417
+ <admin>
418
+ <retrieve>1</retrieve>
419
+ </admin>
420
  <guest>
421
  <retrieve>1</retrieve>
422
  </guest>
443
  <title>Total Review Counts</title>
444
  <sort_order>130</sort_order>
445
  <privileges>
446
+ <admin>
447
+ <retrieve>1</retrieve>
448
+ </admin>
449
  <guest>
450
  <retrieve>1</retrieve>
451
  </guest>
464
  <title>Targetbay Export Review</title>
465
  <sort_order>140</sort_order>
466
  <privileges>
467
+ <admin>
468
+ <retrieve>1</retrieve>
469
+ </admin>
470
  <guest>
471
  <retrieve>1</retrieve>
472
  </guest>
494
  <title>Create Newsletter Subscription</title>
495
  <sort_order>150</sort_order>
496
  <privileges>
497
+ <admin>
498
+ <retrieve>1</retrieve>
499
+ <create>1</create>
500
+ </admin>
501
  <guest>
502
  <create>1</create>
503
  <retrieve>1</retrieve>
523
  <title>Update Subscription</title>
524
  <sort_order>155</sort_order>
525
  <privileges>
526
+ <admin>
527
+ <retrieve>1</retrieve>
528
+ <create>1</create>
529
+ </admin>
530
  <guest>
531
  <create>1</create>
532
  <retrieve>1</retrieve>
552
  <title>Total Shipment Counts</title>
553
  <sort_order>160</sort_order>
554
  <privileges>
555
+ <admin>
556
+ <retrieve>1</retrieve>
557
+ </admin>
558
  <guest>
559
  <retrieve>1</retrieve>
560
  </guest>
573
  <title>Targetbay Export Shipment</title>
574
  <sort_order>165</sort_order>
575
  <privileges>
576
+ <admin>
577
+ <retrieve>1</retrieve>
578
+ </admin>
579
  <guest>
580
  <retrieve>1</retrieve>
581
  </guest>
612
  <title>Targetbay Export Stores</title>
613
  <sort_order>170</sort_order>
614
  <privileges>
615
+ <admin>
616
+ <retrieve>1</retrieve>
617
+ </admin>
618
  <guest>
619
  <retrieve>1</retrieve>
620
  </guest>
639
  <title>Total Subscriber Counts</title>
640
  <sort_order>175</sort_order>
641
  <privileges>
642
+ <admin>
643
+ <retrieve>1</retrieve>
644
+ </admin>
645
  <guest>
646
  <retrieve>1</retrieve>
647
  </guest>
660
  <title>Subscriber</title>
661
  <sort_order>180</sort_order>
662
  <privileges>
663
+ <admin>
664
+ <retrieve>1</retrieve>
665
+ </admin>
666
  <guest>
667
  <retrieve>1</retrieve>
668
  </guest>
682
  </routes>
683
  <versions>1</versions>
684
  </tracking_subscriber>
685
+ <tracking_tbreviewcount translate="title" module="targetbay_tracking">
686
+ <group>tracking</group>
687
+ <model>tracking/api2_tbreviewcount</model>
688
+ <title>TB Review count</title>
689
+ <sort_order>190</sort_order>
690
+ <privileges>
691
+ <admin>
692
+ <retrieve>1</retrieve>
693
+ </admin>
694
+ <guest>
695
+ <retrieve>1</retrieve>
696
+ </guest>
697
+ </privileges>
698
+ <attributes>
699
+ <product_id>Product Id</product_id>
700
+ <store_id>Store ID</store_id>
701
+ <review_count>Review Count</review_count>
702
+ <page_identifier>Page Identifier</page_identifier>
703
+ </attributes>
704
+ <routes>
705
+ <route_collection>
706
+ <route>/targetbay/tbreviewcount</route>
707
+ <action_type>collection</action_type>
708
+ </route_collection>
709
+ </routes>
710
+ <versions>1</versions>
711
+ </tracking_tbreviewcount>
712
  </resources>
713
  </api2>
714
  </config>
app/code/community/Targetbay/Tracking/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <Targetbay_Tracking>
12
- <version>5.1.2</version>
13
  </Targetbay_Tracking>
14
  </modules>
15
  <frontend>
9
  <config>
10
  <modules>
11
  <Targetbay_Tracking>
12
+ <version>5.1.3</version>
13
  </Targetbay_Tracking>
14
  </modules>
15
  <frontend>
app/code/community/Targetbay/Tracking/etc/system.xml CHANGED
@@ -42,6 +42,7 @@
42
  <show_in_website>1</show_in_website>
43
  <show_in_store>1</show_in_store>
44
  </enabled>
 
45
  <hostname translate="label">
46
  <label>Hostname</label>
47
  <comment>Enter hostname to track (ie: example.com).</comment>
@@ -112,6 +113,17 @@
112
  <show_in_store>1</show_in_store>
113
  </tracking_script>
114
 
 
 
 
 
 
 
 
 
 
 
 
115
  <reviews_per_page translate="label">
116
  <label>Reviews per page</label>
117
  <frontend_type>text</frontend_type>
42
  <show_in_website>1</show_in_website>
43
  <show_in_store>1</show_in_store>
44
  </enabled>
45
+
46
  <hostname translate="label">
47
  <label>Hostname</label>
48
  <comment>Enter hostname to track (ie: example.com).</comment>
113
  <show_in_store>1</show_in_store>
114
  </tracking_script>
115
 
116
+ <richsnippets_type translate="label">
117
+ <label>Select Richsnippets Type</label>
118
+ <frontend_type>select</frontend_type>
119
+ <source_model>tracking/system_config_source_snippetstatus</source_model>
120
+ <sort_order>162</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ <comment>Microdata alread exists in website choose manual or choose automatic</comment>
125
+ </richsnippets_type>
126
+
127
  <reviews_per_page translate="label">
128
  <label>Reviews per page</label>
129
  <frontend_type>text</frontend_type>
app/design/frontend/base/default/layout/tracking.xml CHANGED
@@ -12,12 +12,22 @@
12
  <block type="tracking/tracking" name="innpltracking" as="innpltracking" />
13
  </reference>
14
  </default>
 
 
 
 
 
15
  <catalog_product_view>
16
  <reference name="content">
17
  <remove name="product.reviews"/>
18
- <block type="tracking/product_review" name="innpl-product-review" as="innpl-product-review"
19
- after="product.info" />
 
 
 
 
20
  </reference>
 
21
  <reference name="product.info.tabs">
22
  <action method="unsetChild">
23
  <child>review</child>
12
  <block type="tracking/tracking" name="innpltracking" as="innpltracking" />
13
  </reference>
14
  </default>
15
+ <cms_index_index>
16
+ <reference name="content">
17
+ <block type="tracking/recommended" name="tbrecommended" as="tbrecommended" after="-" />
18
+ </reference>
19
+ </cms_index_index>
20
  <catalog_product_view>
21
  <reference name="content">
22
  <remove name="product.reviews"/>
23
+ <block type="tracking/product_review" name="innpl-product-review" as="innpl-product-review" after="product.info" />
24
+ <block type="tracking/product_richsnippets" name="tracking-product-richsnippets" as="tracking-richsnippets" after="product.info" />
25
+ </reference>
26
+
27
+ <reference name="product.info.addtocart">
28
+ <block type="tracking/product_inventary" name="tracking-product-inventary" as="tracking-inventary" after="-" />
29
  </reference>
30
+
31
  <reference name="product.info.tabs">
32
  <action method="unsetChild">
33
  <child>review</child>
app/design/frontend/base/default/template/tracking/product/inventary.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo $this->getBackOrderStatus(); ?>
app/design/frontend/base/default/template/tracking/product/review.phtml CHANGED
@@ -1,55 +1,10 @@
1
  <div id="targetbay_reviews"></div>
2
- <?php $product = Mage::registry('current_product'); ?>
3
- <?php $_helper = $this->helper('catalog/output'); ?>
4
- <?php $richSnippets = Mage::helper('tracking')->getRichSnippets(); ?>
5
-
6
- <?php $productSku = $_helper->productAttribute($product, $product->getSku(), 'sku'); ?>
7
- <?php $productName = $_helper->productAttribute($product, $product->getName(), 'name'); ?>
8
- <?php if(!empty($richSnippets) && $richSnippets['average_score'] > 0): ?>
9
- <div id="<?php echo $productSku; ?>" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
10
- <span itemprop="bestRating" content="5"></span>
11
- <span itemprop="worstRating" content="1"></span>
12
- <span itemprop="ratingValue" content="<?php echo $richSnippets['average_score']; ?>"></span>
13
- <span itemprop="reviewCount" content="<?php echo $richSnippets['reviews_count']; ?>"></span>
14
- <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">
15
- <span itemprop="name" content="<?php echo $productName; ?>"></span>
16
- </div>
17
- </div>
18
- <?php if($richSnippets['reviews_count'] > 0): ?>
19
- <?php foreach($richSnippets['reviews'] as $key => $aggregateReviewDetails): ?>
20
- <?php $reviewId = $aggregateReviewDetails->_id; ?>
21
- <?php $reviewTitle = $aggregateReviewDetails->_source->review_title; ?>
22
- <?php $review = $aggregateReviewDetails->_source->review; ?>
23
- <?php $timestamp = $aggregateReviewDetails->_source->timestamp; ?>
24
- <?php $reviewRating = $aggregateReviewDetails->_source->review_rating; ?>
25
- <?php $userName = $aggregateReviewDetails->_source->user_name; ?>
26
- <div itemprop="review" id="<?php echo 'tb-review-'.$key; ?>" itemscope itemtype="http://schema.org/Review" data-reviewid="<?php echo $reviewId; ?>">
27
- <span itemprop="name" content="<?php echo $reviewTitle; ?>"></span>
28
- <span itemprop="description" content="<?php echo $review; ?>"></span>
29
- <span itemprop="datePublished" content="<?php echo date('m/d/Y', $timestamp); ?>"></span>
30
- <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">
31
- <span itemprop="name" content="<?php echo $productName; ?>"></span>
32
- </div>
33
- <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
34
- <span itemprop="ratingValue" content="<?php echo $reviewRating; ?>"></span>
35
- <span itemprop="worstRating" content="1"></span>
36
- <span itemprop="bestRating" content="5"></span>
37
- </div>
38
- <div itemprop="author" itemscope itemtype="http://schema.org/Thing">
39
- <span itemprop="name" content="<?php echo $userName; ?>"></span>
40
- </div>
41
- </div>
42
- <?php endforeach; ?>
43
- <?php endif; ?>
44
- <?php else: ?>
45
- <div id="<?php echo $productSku; ?>"></div>
46
- <?php endif; ?>
47
 
48
  <?php $questionSnippets = Mage::helper('tracking')->getQuestionSnippets(); ?>
49
-
50
- <?php if(!empty($questionSnippets) && $questionSnippets['qa_count'] > 0): ?>
51
  <?php $authorName = $questionSnippets['qa_author']; ?>
52
- <?php foreach($questionSnippets['qa_details'] as $key => $qasDetails): ?>
53
  <?php $productName = $qasDetails->_source->product_name; ?>
54
  <?php $questionName = $qasDetails->_source->questions; ?>
55
  <?php $qasCreatedDate = $qasDetails->_source->timestamp; ?>
@@ -57,28 +12,28 @@
57
  <?php $answerArray = $qasDetails->_source->question_answers; ?>
58
  <?php $qasId = $qasDetails->_id; ?>
59
  <?php $i = 1; ?>
60
- <div id="<?php echo 'tb-qas-'.$key; ?>" itemscope itemtype="http://schema.org/Question">
61
 
62
- <span itemprop="name" content="<?php echo $productName; ?>"></span>
63
- <span itemprop="text" content="<?php echo $questionName; ?>"></span>
64
  <span itemprop="dateCreated" content="<?php echo date('m/d/Y', $qasCreatedDate); ?>"></span>
65
  <span itemprop="author" itemscope itemtype="http://schema.org/Person">
66
  <span itemprop="name" content="<?php echo $qasUsername; ?>"></span>
67
  </span>
68
- <?php if(count($answerArray) > 0): ?>
69
  <span itemprop="answerCount" content="<?php echo count($answerArray); ?>"></span>
70
- <span itemprop="acceptedAnswer" itemscope itemtype="http://schema.org/Answer" id="<?php echo $qasId.'-0'; ?>">
71
  <span itemprop="upvoteCount" content="<?php echo $answerArray[0]->upvotes; ?>"></span>
72
- <span itemprop="text" content="<?php echo $answerArray[0]->answers; ?>"></span>
73
  <span itemprop="dateCreated" content="<?php echo date('m/d/Y', $answerArray[0]->answer_timestamp); ?>"></span>
74
  <span itemprop="author" itemscope itemtype="http://schema.org/Person">
75
  <span itemprop="name" content="<?php echo $authorName; ?>"></span>
76
  </span>
77
  </span>
78
- <?php foreach($answerArray as $key => $answers): ?>
79
- <span itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer" id="<?php echo $qasId.'-'.$i; ?>">
80
  <span itemprop="upvoteCount" content="<?php echo $answers->upvotes; ?>"></span>
81
- <span itemprop="text" content="<?php echo $answers->answers; ?>"></span>
82
  <span itemprop="dateCreated" content="<?php echo date('m/d/Y', $answers->answer_timestamp); ?>"></span>
83
  <span itemprop="author" itemscope itemtype="http://schema.org/Person">
84
  <span itemprop="name" content="<?php echo $authorName; ?>"></span>
@@ -88,4 +43,4 @@
88
  <?php endif; ?>
89
  </div>
90
  <?php endforeach; ?>
91
- <?php endif; ?>
1
  <div id="targetbay_reviews"></div>
2
+ <div id="tb_recommended_products"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  <?php $questionSnippets = Mage::helper('tracking')->getQuestionSnippets(); ?>
5
+ <?php if (!empty($questionSnippets) && $questionSnippets['qa_count'] > 0): ?>
 
6
  <?php $authorName = $questionSnippets['qa_author']; ?>
7
+ <?php foreach ($questionSnippets['qa_details'] as $key => $qasDetails): ?>
8
  <?php $productName = $qasDetails->_source->product_name; ?>
9
  <?php $questionName = $qasDetails->_source->questions; ?>
10
  <?php $qasCreatedDate = $qasDetails->_source->timestamp; ?>
12
  <?php $answerArray = $qasDetails->_source->question_answers; ?>
13
  <?php $qasId = $qasDetails->_id; ?>
14
  <?php $i = 1; ?>
15
+ <div id="<?php echo $this->escapeHtml($questionName) . '-' . $key; ?>" itemscope itemtype="http://schema.org/Question">
16
 
17
+ <span itemprop="name" content="<?php echo $this->escapeHtml($productName); ?>"></span>
18
+ <span itemprop="text" content="<?php echo $this->escapeHtml($questionName); ?>"></span>
19
  <span itemprop="dateCreated" content="<?php echo date('m/d/Y', $qasCreatedDate); ?>"></span>
20
  <span itemprop="author" itemscope itemtype="http://schema.org/Person">
21
  <span itemprop="name" content="<?php echo $qasUsername; ?>"></span>
22
  </span>
23
+ <?php if (count($answerArray) > 0): ?>
24
  <span itemprop="answerCount" content="<?php echo count($answerArray); ?>"></span>
25
+ <span itemprop="acceptedAnswer" itemscope itemtype="http://schema.org/Answer" id="<?php echo $qasId . '-0'; ?>">
26
  <span itemprop="upvoteCount" content="<?php echo $answerArray[0]->upvotes; ?>"></span>
27
+ <span itemprop="text" content="<?php echo $this->escapeHtml($answerArray[0]->answers); ?>"></span>
28
  <span itemprop="dateCreated" content="<?php echo date('m/d/Y', $answerArray[0]->answer_timestamp); ?>"></span>
29
  <span itemprop="author" itemscope itemtype="http://schema.org/Person">
30
  <span itemprop="name" content="<?php echo $authorName; ?>"></span>
31
  </span>
32
  </span>
33
+ <?php foreach ($answerArray as $key => $answers): ?>
34
+ <span itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer" id="<?php echo $qasId . '-' . $i; ?>">
35
  <span itemprop="upvoteCount" content="<?php echo $answers->upvotes; ?>"></span>
36
+ <span itemprop="text" content="<?php echo $this->escapeHtml($answers->answers); ?>"></span>
37
  <span itemprop="dateCreated" content="<?php echo date('m/d/Y', $answers->answer_timestamp); ?>"></span>
38
  <span itemprop="author" itemscope itemtype="http://schema.org/Person">
39
  <span itemprop="name" content="<?php echo $authorName; ?>"></span>
43
  <?php endif; ?>
44
  </div>
45
  <?php endforeach; ?>
46
+ <?php endif;?>
app/design/frontend/base/default/template/tracking/product/richsnippets.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $richSnippetsType = Mage::helper('tracking')->getRichsnippetType(); ?>
2
+ <?php $richSnippets = Mage::helper('tracking')->getRichSnippets(); ?>
3
+
4
+ <?php if ($richSnippetsType == 1) { ?>
5
+ <div itemscope itemtype="http://schema.org/Product">
6
+ <span itemprop="name" content="<?php echo $this->getEscapedProductName(); ?>"></span>
7
+ <?php } ?>
8
+ <?php if (!empty($richSnippets) && $richSnippets['average_score'] > 0): ?>
9
+ <span itemprop="aggregateRating" itemscope itemtype= "http://schema.org/AggregateRating">
10
+ <span itemprop="bestRating" content="5"></span>
11
+ <span itemprop="worstRating" content="1"></span>
12
+ <span itemprop="ratingValue" content="<?php echo $richSnippets['average_score']; ?>"></span>
13
+ <span itemprop="reviewCount" content="<?php echo $richSnippets['reviews_count']; ?>"></span>
14
+ <span itemprop="ratingCount" content="<?php echo $richSnippets['reviews_count']; ?>"></span>
15
+ </span>
16
+
17
+ <?php if ($richSnippets['reviews_count'] > 0): ?>
18
+ <?php foreach ($richSnippets['reviews'] as $key => $aggregateReviewDetails): ?>
19
+ <?php $reviewId = $aggregateReviewDetails->_id; ?>
20
+ <?php $reviewTitle = $aggregateReviewDetails->_source->review_title; ?>
21
+ <?php $review = $aggregateReviewDetails->_source->review; ?>
22
+ <?php $timestamp = $aggregateReviewDetails->_source->timestamp; ?>
23
+ <?php $reviewRating = $aggregateReviewDetails->_source->review_rating; ?>
24
+ <?php $userName = $aggregateReviewDetails->_source->user_name; ?>
25
+ <div itemprop="review" id="<?php echo $this->escapeHtml($reviewTitle) . '-' . $key; ?>" itemscope itemtype="http://schema.org/Review" data-reviewid="<?php echo $reviewId; ?>">
26
+ <span itemprop="name" content="<?php echo $this->escapeHtml($reviewTitle); ?>"></span>
27
+ <span itemprop="description" content="<?php echo $this->escapeHtml($review); ?>"></span>
28
+ <span itemprop="datePublished" content="<?php echo date('m/d/Y', $timestamp); ?>"></span>
29
+ <div itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">
30
+ <span itemprop="name" content="<?php echo $this->getEscapedProductName(); ?>"></span>
31
+ </div>
32
+ <?php if ($reviewRating > 0): ?>
33
+ <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
34
+ <span itemprop="ratingValue" content="<?php echo $reviewRating; ?>"></span>
35
+ <span itemprop="worstRating" content="1"></span>
36
+ <span itemprop="bestRating" content="5"></span>
37
+ </div>
38
+ <?php endif; ?>
39
+ <div itemprop="author" itemscope itemtype="http://schema.org/Thing">
40
+ <span itemprop="name" content="<?php echo $userName; ?>"></span>
41
+ </div>
42
+ </div>
43
+ <?php endforeach; ?>
44
+ <?php endif; ?>
45
+ <?php endif; ?>
46
+ <?php if ($richSnippetsType == 1) { ?>
47
+ </div>
48
+ <?php } ?>
app/design/frontend/base/default/template/tracking/recommended.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ $routeName = Mage::app()->getRequest()->getRouteName();
3
+ $identifier = Mage::getSingleton('cms/page')->getIdentifier();
4
+
5
+ if ($routeName == 'cms' && $identifier == 'home') {
6
+ echo '<div id="tb_most_reviewed"></div>';
7
+ }
app/design/frontend/base/default/template/tracking/session/tracking.phtml CHANGED
@@ -1,4 +1,2 @@
1
  <?php
2
  //echo Mage::helper ( 'tracking' )->getSessionTrackingJs ();
3
-
4
- ?>
1
  <?php
2
  //echo Mage::helper ( 'tracking' )->getSessionTrackingJs ();
 
 
app/design/frontend/base/default/template/tracking/tracking.phtml CHANGED
@@ -1,9 +1,11 @@
1
  <?php
2
  $pageVisitData = ''; $pageVisitUrl = ''; $trackingTypeVal = '';
3
- $pname = ''; $pid = ''; $purl = ''; $pimage = '';
 
4
  $controllerData = array('index','category','product');
5
  $controllername = Mage::app()->getRequest()->getControllerName();
6
  $modulename = Mage::app()->getRequest()->getModuleName();
 
7
  $trackingHelper = Mage::helper('tracking');
8
  $userSession = Mage::getSingleton('customer/session');
9
 
@@ -17,26 +19,26 @@ $vistorName = Targetbay_Tracking_Helper_Data::ANONYMOUS_USER;
17
  $moduleVersion = $trackingHelper->getProductVersion();
18
  $trackingType = $trackingHelper->getTrackingType();
19
 
20
- if($trackingType == 1) :
21
- $pageVisitUrl = $trackingHelper->getApiUrl();
22
- $pageVisitData = $trackingHelper->getPageInfo();
23
- $trackingTypeVal = $trackingType;
24
  endif;
25
 
26
- if($modulename == 'catalog' && $controllername == 'product') {
27
- $product = Mage::registry('current_product');
28
- $pname = addslashes($product->getName());
29
- $pid = $product->getId();
30
- $pimage = $trackingHelper->getImageUrl($product, 'image');
31
- $purl = Mage::getUrl().$product->getUrlPath();
32
  }
33
  $trackingScript = $trackingHelper->getTrackingScript();
34
 
35
- if($trackingScript) {
36
- $trackingCode = $trackingScript;
37
  } else {
38
- $trackingCode = 'tbTrack: true,
39
- tbMessage: false,
40
  tbReview: {
41
  tbSiteReview: true,
42
  tbProductReview: true,
@@ -49,6 +51,13 @@ if($trackingScript) {
49
  <div id="targetbay_message"></div>
50
  <div id="targetbay_site_reviews"></div>
51
 
 
 
 
 
 
 
 
52
  <script type="text/javascript">
53
  tbConfig = {
54
  apiStatus: '<?php echo $apiStatus; ?>',
@@ -60,14 +69,16 @@ tbConfig = {
60
  moduleVersion:'<?php echo $moduleVersion; ?>',
61
  productName: '<?php echo $pname; ?>',
62
  productId: '<?php echo $pid; ?>',
63
- productImageUrl: '<?php echo $pimage; ?>',
64
  productUrl: '<?php echo $purl; ?>',
65
- userId: '<?php echo $userSession->isLoggedIn()?$userSession->getId():$vistorId?>',
66
- userMail: '<?php echo $userSession->isLoggedIn()?$userSession->getCustomer()->getEmail():''?>',
67
- userName: '<?php echo $userSession->isLoggedIn()?$userSession->getCustomer()->getName():$vistorName?>',
 
68
  userAvatar: '',
69
  pageUrl: '<?php echo $pageVisitUrl;?>',
70
  pageData: '<?php echo json_encode($pageVisitData);?>',
 
71
  <?php echo $trackingCode; ?>
72
 
73
  };
@@ -86,15 +97,16 @@ tbConfig = {
86
  ], tbConfig);
87
  </script>
88
  <?php $siteReviewSnippets = $trackingHelper->getSiteReviewSnippets();?>
89
- <?php if(!empty($siteReviewSnippets) && $siteReviewSnippets['average_score'] > 0): ?>
90
  <div itemscope itemtype="http://schema.org/Organization">
91
  <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
92
  <span itemprop="bestRating" content="5"></span>
93
  <span itemprop="ratingValue" content="<?php echo $siteReviewSnippets['average_score']; ?>"></span>
94
  <span itemprop="reviewCount" content="<?php echo $siteReviewSnippets['reviews_count']; ?>"></span>
 
95
  </div>
96
- <?php if($siteReviewSnippets['reviews_count'] > 0): ?>
97
- <?php foreach($siteReviewSnippets['reviews'] as $key => $aggregateReviewDetails): ?>
98
  <?php $reviewId = $aggregateReviewDetails->_id; ?>
99
  <?php $reviewTitle = $aggregateReviewDetails->_source->title; ?>
100
  <?php $review = $aggregateReviewDetails->_source->message; ?>
@@ -102,9 +114,9 @@ tbConfig = {
102
  <?php $reviewRating = $aggregateReviewDetails->_source->review_rating; ?>
103
  <?php $userName = $aggregateReviewDetails->_source->user_name; ?>
104
 
105
- <div itemprop="review" id="<?php echo 'tb-site-review-'.$key; ?>" itemscope itemtype="http://schema.org/Review" data-reviewid="<?php echo $reviewId; ?>">
106
- <span itemprop="name" content="<?php echo $reviewTitle; ?>"></span>
107
- <span itemprop="description" content="<?php echo $review; ?>"></span>
108
  <span itemprop="datePublished" content="<?php echo date('m/d/Y', $timestamp); ?>"></span>
109
  <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
110
  <span itemprop="ratingValue" content="<?php echo $reviewRating; ?>"></span>
1
  <?php
2
  $pageVisitData = ''; $pageVisitUrl = ''; $trackingTypeVal = '';
3
+ $pname = ''; $pid = ''; $purl = ''; $lastOrderId = ''; $pimage= '';
4
+ $defaultImage = Mage::getModel('catalog/product')->getSmallImageUrl(200, 200);
5
  $controllerData = array('index','category','product');
6
  $controllername = Mage::app()->getRequest()->getControllerName();
7
  $modulename = Mage::app()->getRequest()->getModuleName();
8
+ $actionName = Mage::app()->getRequest()->getActionName();
9
  $trackingHelper = Mage::helper('tracking');
10
  $userSession = Mage::getSingleton('customer/session');
11
 
19
  $moduleVersion = $trackingHelper->getProductVersion();
20
  $trackingType = $trackingHelper->getTrackingType();
21
 
22
+ if ($trackingType == 1) :
23
+ $pageVisitUrl = $trackingHelper->getApiUrl();
24
+ $pageVisitData = $trackingHelper->getPageInfo();
25
+ $trackingTypeVal = $trackingType;
26
  endif;
27
 
28
+ if ($modulename == 'catalog' && $controllername == 'product') {
29
+ $product = Mage::registry('current_product');
30
+ $pname = addslashes($product->getName());
31
+ $pid = addslashes($product->getId());
32
+ $pimage = $trackingHelper->getImageUrl($product, 'image');
33
+ $purl = Mage::getUrl() . $product->getUrlPath();
34
  }
35
  $trackingScript = $trackingHelper->getTrackingScript();
36
 
37
+ if ($trackingScript) {
38
+ $trackingCode = $trackingScript;
39
  } else {
40
+ $trackingCode = 'tbTrack: true,
41
+ tbMessage: true,
42
  tbReview: {
43
  tbSiteReview: true,
44
  tbProductReview: true,
51
  <div id="targetbay_message"></div>
52
  <div id="targetbay_site_reviews"></div>
53
 
54
+ <?php
55
+ if ($modulename == 'checkout' && $actionName == 'success') {
56
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
57
+ echo '<div id="targetbay_order_reviews"></div>';
58
+ }
59
+ ?>
60
+
61
  <script type="text/javascript">
62
  tbConfig = {
63
  apiStatus: '<?php echo $apiStatus; ?>',
69
  moduleVersion:'<?php echo $moduleVersion; ?>',
70
  productName: '<?php echo $pname; ?>',
71
  productId: '<?php echo $pid; ?>',
72
+ productImageUrl: '<?php echo ($pimage) ? $pimage : $defaultImage; ?>',
73
  productUrl: '<?php echo $purl; ?>',
74
+ productStockStatus: <?php echo $this->getStockAvaliability(); ?>,
75
+ userId: '<?php echo $userSession->isLoggedIn() ? $userSession->getId() : $vistorId?>',
76
+ userMail: '<?php echo $userSession->isLoggedIn() ? $userSession->getCustomer()->getEmail() : ''?>',
77
+ userName: '<?php echo $userSession->isLoggedIn() ? $userSession->getCustomer()->getName() : $vistorName?>',
78
  userAvatar: '',
79
  pageUrl: '<?php echo $pageVisitUrl;?>',
80
  pageData: '<?php echo json_encode($pageVisitData);?>',
81
+ orderId: '<?php echo $lastOrderId; ?>',
82
  <?php echo $trackingCode; ?>
83
 
84
  };
97
  ], tbConfig);
98
  </script>
99
  <?php $siteReviewSnippets = $trackingHelper->getSiteReviewSnippets();?>
100
+ <?php if (!empty($siteReviewSnippets) && $siteReviewSnippets['average_score'] > 0): ?>
101
  <div itemscope itemtype="http://schema.org/Organization">
102
  <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
103
  <span itemprop="bestRating" content="5"></span>
104
  <span itemprop="ratingValue" content="<?php echo $siteReviewSnippets['average_score']; ?>"></span>
105
  <span itemprop="reviewCount" content="<?php echo $siteReviewSnippets['reviews_count']; ?>"></span>
106
+ <span itemprop="ratingCount" content="<?php echo $siteReviewSnippets['reviews_count']; ?>"></span>
107
  </div>
108
+ <?php if ($siteReviewSnippets['reviews_count'] > 0): ?>
109
+ <?php foreach ($siteReviewSnippets['reviews'] as $key => $aggregateReviewDetails): ?>
110
  <?php $reviewId = $aggregateReviewDetails->_id; ?>
111
  <?php $reviewTitle = $aggregateReviewDetails->_source->title; ?>
112
  <?php $review = $aggregateReviewDetails->_source->message; ?>
114
  <?php $reviewRating = $aggregateReviewDetails->_source->review_rating; ?>
115
  <?php $userName = $aggregateReviewDetails->_source->user_name; ?>
116
 
117
+ <div itemprop="review" id="<?php echo $this->escapeHtml($reviewTitle) . '-' . $key; ?>" itemscope itemtype="http://schema.org/Review" data-reviewid="<?php echo $reviewId; ?>">
118
+ <span itemprop="name" content="<?php echo $this->escapeHtml($reviewTitle); ?>"></span>
119
+ <span itemprop="description" content="<?php echo $this->escapeHtml($review); ?>"></span>
120
  <span itemprop="datePublished" content="<?php echo date('m/d/Y', $timestamp); ?>"></span>
121
  <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
122
  <span itemprop="ratingValue" content="<?php echo $reviewRating; ?>"></span>
app/etc/modules/Targetbay_Tracking.xml CHANGED
@@ -11,7 +11,7 @@
11
  <Targetbay_Tracking>
12
  <active>true</active>
13
  <codePool>community</codePool>
14
- <version>1.1.7</version>
15
  </Targetbay_Tracking>
16
  </modules>
17
  </config>
11
  <Targetbay_Tracking>
12
  <active>true</active>
13
  <codePool>community</codePool>
14
+ <version>5.1.3</version>
15
  </Targetbay_Tracking>
16
  </modules>
17
  </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Targetbay_Tracking</name>
4
- <version>5.1.2</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Targetbay&amp;amp;apos;s Personalization platform continuously profiles in real-time, opening up the scope for behavioral targeting.</summary>
10
  <description>Making every interaction count and engaging customers with relevant messages will improve the chances of conversion exponentially. You can profile and segment users based on various parameters and actions, the data from which will form the basis for your customer engagement objectives.You can create triggers based on customer engagement objectives to deliver personalized messages. Your newsletter campaigns can also be personalized to deliver better customer engagement results. And all of this can be achieved with the help of our ecommerce-based email personalization platform.</description>
11
  <notes>Making every interaction count and engaging customers with relevant messages will improve the chances of conversion exponentially. You can profile and segment users based on various parameters and actions, the data from which will form the basis for your customer engagement objectives.You can create triggers based on customer engagement objectives to deliver personalized messages. Your newsletter campaigns can also be personalized to deliver better customer engagement results. And all of this can be achieved with the help of our ecommerce-based email personalization platform.</notes>
12
- <authors><author><name>Targetbay</name><user>Targetbay</user><email>Targetbay@gmail.com</email></author></authors>
13
- <date>2017-03-06</date>
14
- <time>07:48:50</time>
15
- <contents><target name="magecommunity"><dir name="Targetbay"><dir name="Tracking"><dir name="Block"><dir name="Product"><file name="Product.php" hash="25ef7a360f9c92d75dfc657f1cecefe6"/><file name="Review.php" hash="5c37ac0e6533069f34486c95983ae512"/></dir><dir name="Session"><file name="Tracking.php" hash="bead621eadabe0428a99f12ff4f4f60a"/></dir><file name="Tracking.php" hash="d78910db0d380d8f9c88dd55e4a174ed"/></dir><dir name="Helper"><file name="Data.php" hash="3d5eb594d3b372b4450ba4069968d5ea"/></dir><dir name="Model"><dir name="Api2"><dir name="Cartitem"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="e249ac528ec557cc6736387ff85e26ec"/></dir><dir name="Guest"><file name="V1.php" hash="54ed95bbdad05f906f423aac4cb208b9"/></dir></dir></dir><file name="Cartitem.php" hash="f0de9fec4777d78a8d621b92295650ae"/><dir name="Category"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="74764d41a1d32bfb0ad4825d40e8cf46"/></dir><dir name="Guest"><file name="V1.php" hash="2dfc77fcf40841a6fbcb4e92b18c5cbe"/></dir></dir></dir><file name="Category.php" hash="37c664ba07ff52d64787ba635492b862"/><dir name="Createsubscription"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="7d1b2e26e7a5a37459f31dd5b0cb6741"/></dir><dir name="Guest"><file name="V1.php" hash="6c94923e0e86c75b90268e70f91ddb38"/></dir></dir></dir><file name="Createsubscription.php" hash="45dc64e2c1c37293f13a9eab8edd94d0"/><dir name="Customer"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="296c8a85e3c4ba7a0cacf6a0c80c5d06"/></dir><dir name="Guest"><file name="V1.php" hash="1ca174a22acfe731c0e70777c098b4f3"/></dir></dir></dir><file name="Customer.php" hash="6e4adecce83bf453e977a837ed77b0a4"/><dir name="Orders"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="f5b3a992b2e9486558ff8ddd7fd597dc"/></dir><dir name="Guest"><file name="V1.php" hash="a60f6181469b7e5dec6080956674e7e5"/></dir></dir></dir><dir name="Product"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="2d86752c37e3a30660dcff77b2dedaaf"/><file name="V1.php~" hash="cb0e0f6f152441bfbd489588a5299b20"/></dir><dir name="Guest"><file name="V1.php" hash="ef4524e81bc4afbd147a59aae41ef0c8"/></dir></dir></dir><dir name="Review"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="765499958011f928e16a3f14336bd078"/></dir><dir name="Guest"><file name="V1.php" hash="6d9f13ee0c3a904fdb3f289ca09fecc0"/></dir></dir></dir><file name="Review.php" hash="2d6fb0e0141fc73f61e2a586e2fa895d"/><dir name="Shipment"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="eab736400f2275a32603e0b3f1d4351c"/></dir><dir name="Guest"><file name="V1.php" hash="8607da53bca20022f1781ee159b2fc3c"/></dir></dir></dir><file name="Shipment.php" hash="17756fb5e6411bbb27fd0806ce156d74"/><dir name="Stores"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="27e7e2b3fd927e91456b9e529b226522"/></dir><dir name="Guest"><file name="V1.php" hash="8dd09e20ffaef75837bfc00ccbc1c282"/></dir></dir></dir><file name="Stores.php" hash="f5eb4d00382b03c2418f83eb8b7d0ad3"/><dir name="Subscriber"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="65f5f38d5521687b6a106e29a502b7c9"/></dir><dir name="Guest"><file name="V1.php" hash="1fb1e146c1398d2858f5a088a1d59d16"/></dir></dir></dir><file name="Subscriber.php" hash="43f2f4f9c8b01b07f3130cf7488342d1"/><dir name="Totalcartiteminfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="65dffb80d635d17d5599a9ee1a61a35e"/></dir><dir name="Guest"><file name="V1.php" hash="c4ce67530cc5ddd7e306a1f95250a00c"/></dir></dir></dir><file name="Totalcartiteminfo.php" hash="b0b10b2a6d42ddecd0e4d97834090be7"/><dir name="Totalcategoryinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="be76b164dbb7cc439a1bbd8a9aa82a53"/></dir><dir name="Guest"><file name="V1.php" hash="d6ea3c89fa7e7396614d983c026c7907"/></dir></dir></dir><file name="Totalcategoryinfo.php" hash="06b6428e59e402ad92f8404e42ce5b35"/><dir name="Totalcustomerinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="def08bb44fc493c15b0a98c5717f68a8"/></dir><dir name="Guest"><file name="V1.php" hash="e0efa78eff478bf0204da6b2f5c95659"/></dir></dir></dir><file name="Totalcustomerinfo.php" hash="fdf343e2d69375826c94e5ce3988cc01"/><dir name="Totalinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="0bf6291950d09e4feea261b3e75ab5a4"/></dir><dir name="Guest"><file name="V1.php" hash="d853313e63bd6708c5669dd42cb51e1b"/></dir></dir></dir><file name="Totalinfo.php" hash="c5a797bd61744e897cefe6287fce5d7d"/><dir name="Totalorderinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ce01e5d386310382fbc9b06531194b45"/></dir><dir name="Guest"><file name="V1.php" hash="b24afbd009b16df4106af72c475d0ca0"/></dir></dir></dir><file name="Totalorderinfo.php" hash="69d3cb8c8d07d53b43561050ba182580"/><dir name="Totalproductinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="655db4b937dcb52d6c0b0e4ad48cf8fd"/></dir><dir name="Guest"><file name="V1.php" hash="c59844f2844c2a129aede9f8c5cf0364"/></dir></dir></dir><file name="Totalproductinfo.php" hash="5724d79872c49cc2950c93489dbd3b6b"/><dir name="Totalreviewinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="7d753cc08978ac86022bbb5754095064"/></dir><dir name="Guest"><file name="V1.php" hash="192f46027f72e1a668a30ab7d44cadf5"/></dir></dir></dir><file name="Totalreviewinfo.php" hash="fa652146fdf0c6939cd6ef36ca5ca696"/><dir name="Totalshipmentinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="041b6b543d49b78710f71791511955d6"/></dir><dir name="Guest"><file name="V1.php" hash="5ec014ecc06ea8a72c8188acb1340308"/></dir></dir></dir><file name="Totalshipmentinfo.php" hash="d1db98b2163db7453c6a32804482c074"/><dir name="Totalsubscriberinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="908a9d13f2a65b0bae45e9b35e00d232"/></dir><dir name="Guest"><file name="V1.php" hash="230ad7202d191bd9e93c1b9fd41f12bd"/></dir></dir></dir><file name="Totalsubscriberinfo.php" hash="6932199b92398c7a08026fc045b34182"/><dir name="Totalwishlistinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="f938b29721d1b20cdd0d4ea7a6a6aac8"/></dir><dir name="Guest"><file name="V1.php" hash="5f44c6b021e6910458ff6140358540a1"/></dir></dir></dir><file name="Totalwishlistinfo.php" hash="9d24d05506d74208a72322f91fc03c7a"/><dir name="Updatesubscription"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="f1014aaec990673e76dec42e66d52a33"/></dir><dir name="Guest"><file name="V1.php" hash="76639c8508b730322b8d5d29bbfe7ff8"/></dir></dir></dir><file name="Updatesubscription.php" hash="1dc100c9b09c83fed1f2b343107f7a2b"/><dir name="Wishlist"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="666cf3408575628734771774afeeb915"/></dir><dir name="Guest"><file name="V1.php" hash="44671ff4a131b0fc35751440b0c03790"/></dir></dir></dir><file name="Wishlist.php" hash="41015ddf11163ec6efc21ca02d48b3eb"/></dir><file name="Customer.php" hash="4d8a9b5726458a01b0cf4eedee27f84f"/><file name="Observer.php" hash="6eef5b6dab779fd9bdbac8b9e0989d66"/><file name="Subscriber.php" hash="7c9a69c0340d85fb78149b2d1e5a3f6f"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Page.php" hash="9f110c8010f7274aee995030dbcf37e4"/><file name="Status.php" hash="17aed527b9c4b30f2d4350cf64b3a50a"/><file name="Tracking.php" hash="be2a32ac4523ee58de1b82c228796731"/><file name="Version.php" hash="27118fa886e6c21aa259d399d211b82d"/><file name="Yesno.php" hash="b99b00ea683b4c7be69c2b17b3cacae8"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="cd241666f46f8a40d664afca4ec58a04"/></dir><dir name="etc"><file name="api2.xml" hash="4068013dac12bc72c5aa58554070816c"/><file name="config.xml" hash="e465837c2e9e1e2ae5ba41bbd4314f86"/><file name="system.xml" hash="7cdf4973563deb45cfea65683603ea7c"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tracking.xml" hash="a74b3eaf6139b0efb020da91f26d9fae"/></dir><dir name="template"><dir name="tracking"><dir name="product"><file name="review.phtml" hash="70c8d76b676f2ca2942d0b384c14762c"/></dir><dir name="session"><file name="tracking.phtml" hash="5e946c9e929f6b324de083e014ede6a3"/></dir><file name="tracking.phtml" hash="e0c9aeefab4d19557ac598b41d0480ff"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Targetbay_Tracking.xml" hash="a66e9417278e5e9efd1a530a324c79ef"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>7.0.13</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Targetbay_Tracking</name>
4
+ <version>5.1.3</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Targetbay Personalization platform continuously profiles in real-time, opening up the scope for behavioral targeting.</summary>
10
  <description>Making every interaction count and engaging customers with relevant messages will improve the chances of conversion exponentially. You can profile and segment users based on various parameters and actions, the data from which will form the basis for your customer engagement objectives.You can create triggers based on customer engagement objectives to deliver personalized messages. Your newsletter campaigns can also be personalized to deliver better customer engagement results. And all of this can be achieved with the help of our ecommerce-based email personalization platform.</description>
11
  <notes>Making every interaction count and engaging customers with relevant messages will improve the chances of conversion exponentially. You can profile and segment users based on various parameters and actions, the data from which will form the basis for your customer engagement objectives.You can create triggers based on customer engagement objectives to deliver personalized messages. Your newsletter campaigns can also be personalized to deliver better customer engagement results. And all of this can be achieved with the help of our ecommerce-based email personalization platform.</notes>
12
+ <authors><author><name>Targetbay</name><user>Targetbay</user><email>targetbay@gmail.com</email></author></authors>
13
+ <date>2017-05-09</date>
14
+ <time>11:11:24</time>
15
+ <contents><target name="magecommunity"><dir name="Targetbay"><dir name="Tracking"><dir name="Block"><dir name="Product"><file name="Inventary.php" hash="5cc317cc35d4c95bb9c111a17e3a28f4"/><file name="Product.php" hash="481746e96ba38594fa9547853610d42c"/><file name="Review.php" hash="1fb7e8b3835484de18153f38c088ef25"/><file name="Richsnippets.php" hash="c2a0caf56cd3732ff0bf296965607e5a"/></dir><file name="Recommended.php" hash="367d2edf2575a9b3bbdb6800cfc18992"/><dir name="Session"><file name="Tracking.php" hash="b4ed5c9ebe756b8f7bc94e8fd0c589b4"/></dir><file name="Tracking.php" hash="28cb1e2fdc91fb6fec90b7cb91b9856e"/></dir><dir name="Helper"><file name="Data.php" hash="1197b09b2d37943c0f2a7f36533cac67"/></dir><dir name="Model"><dir name="Api2"><dir name="Cartitem"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="b794e6dbd5dc09a5efc7d48ce5562167"/></dir><dir name="Guest"><file name="V1.php" hash="049f464fd594d6d9a243ce25910eca08"/></dir></dir></dir><file name="Cartitem.php" hash="8b96aeff8957c54d6817ea753326c25c"/><dir name="Category"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="c91c0d1706b393f4456aa44e1dc9ac1c"/></dir><dir name="Guest"><file name="V1.php" hash="93f4cfe184c098a67c5f9977c94c5bc4"/></dir></dir></dir><file name="Category.php" hash="d785f96499aa0561cb4e45a87818f9cd"/><dir name="Createsubscription"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="0d799239964ce3f23bcd2baffd094a8a"/></dir><dir name="Guest"><file name="V1.php" hash="83adb08117b5f36250c0708d99034ff1"/></dir></dir></dir><file name="Createsubscription.php" hash="e4fd9002138e782e87a7e951fdb1fb2d"/><dir name="Customer"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="fdb84eca7450a0e12c19b0aec0c48c45"/></dir><dir name="Guest"><file name="V1.php" hash="7bab3aa5a64db3c2c3965087d98f30ed"/></dir></dir></dir><file name="Customer.php" hash="e22d5756a9b05e0e52150ebff9942fb6"/><dir name="Orders"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="77a27f3c7238c0d9c0330ade41c54e5e"/></dir><dir name="Guest"><file name="V1.php" hash="79357a091a78dcd915518db81f90f3a7"/></dir></dir></dir><dir name="Product"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ddbaedb26af61b1947ea629644df2338"/></dir><dir name="Guest"><file name="V1.php" hash="cabdab3aa88e488992c1ff8471a6fea3"/></dir></dir></dir><dir name="Review"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="f2a557b53a495a266f816e6fd49f2f69"/></dir><dir name="Guest"><file name="V1.php" hash="213ad1469adf0f5d0c7c590fc45511ae"/></dir></dir></dir><file name="Review.php" hash="ebc718ab27d08dac146f24832eaed1a4"/><dir name="Shipment"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ff143ace5ccb97c0db4b0fb75f9c4733"/></dir><dir name="Guest"><file name="V1.php" hash="12876a3a0031d129b80da6249fc4c100"/></dir></dir></dir><file name="Shipment.php" hash="e910b20c15a26b0cb94ee04c4e9679ad"/><dir name="Stores"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="a982f5bbbb23717ebe7864263c32aed4"/></dir><dir name="Guest"><file name="V1.php" hash="d579e949e4eec05b82daa8d78b35caa4"/></dir></dir></dir><file name="Stores.php" hash="378ff5ef3d2f1d9593e425352969b9b7"/><dir name="Subscriber"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="85b6595f7a5df7cb3a72fe84844c3389"/></dir><dir name="Guest"><file name="V1.php" hash="d56cf88f01860f6fc2da41cc43283da9"/></dir></dir></dir><file name="Subscriber.php" hash="e6a58a75e882472c6caad413849f1ad8"/><dir name="Tbreviewcount"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="c50bb36b6847f82d27f491aaacae79b9"/></dir><dir name="Guest"><file name="V1.php" hash="dd55e026fea6dd6b0e42dd924ec89ebc"/></dir></dir></dir><file name="Tbreviewcount.php" hash="5e72bcee5c4dbb563f6def131b294c48"/><dir name="Totalcartiteminfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="2234b324626d72398928c2bf7bcf1ca2"/></dir><dir name="Guest"><file name="V1.php" hash="12ccee219f154277fa7d2adf11aea22b"/></dir></dir></dir><file name="Totalcartiteminfo.php" hash="c9c13a17641948956b4f1aa356597b82"/><dir name="Totalcategoryinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="eda1c51672b11c1e3b0b1a796a94ef10"/></dir><dir name="Guest"><file name="V1.php" hash="8451e57ddb3a8b40abaf21845772cc5d"/></dir></dir></dir><file name="Totalcategoryinfo.php" hash="9708949c0d2bdc21f8a586815c074184"/><dir name="Totalcustomerinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="f0aa899feb69ca6311d4851d93195a03"/></dir><dir name="Guest"><file name="V1.php" hash="b64229ee062618f4bc97c6cf3dbd973a"/></dir></dir></dir><file name="Totalcustomerinfo.php" hash="2fb56184e5f62bef355cad9724d8c6fd"/><dir name="Totalinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="6d6145ba19b163926a048f7f135af198"/></dir><dir name="Guest"><file name="V1.php" hash="792fbd840c878d6621e626e8b54e73e1"/></dir></dir></dir><file name="Totalinfo.php" hash="584475358d4f72fe1c445cf2dc4d3553"/><dir name="Totalorderinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="98da13da4c62ef81018371575f3df05d"/></dir><dir name="Guest"><file name="V1.php" hash="e16ac0e2104c080db3dfebb56f0899f2"/></dir></dir></dir><file name="Totalorderinfo.php" hash="3797fb6da6be29e6fa41e0dc07be9015"/><dir name="Totalproductinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="93e815ed48412f52cec3ad63afc02483"/></dir><dir name="Guest"><file name="V1.php" hash="553476518e1ac99a5ed826944cd43537"/></dir></dir></dir><file name="Totalproductinfo.php" hash="1d3b4aae14d7c6a1abbea1ad45628f1d"/><dir name="Totalreviewinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="b6cd39d44a6413e3ded9a61d656ce7c1"/></dir><dir name="Guest"><file name="V1.php" hash="e8ab5612f4c2131b412b951fc27aa31e"/></dir></dir></dir><file name="Totalreviewinfo.php" hash="1b7900b90bac2f0d884df9e809016f73"/><dir name="Totalshipmentinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="dae0017be8896c022ea218b627f7a8da"/></dir><dir name="Guest"><file name="V1.php" hash="a8be685ccd4182daecd3ceacd4eeb6d4"/></dir></dir></dir><file name="Totalshipmentinfo.php" hash="c4ea9390b2fc29b0a831bbfff6015909"/><dir name="Totalsubscriberinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="690a339187e58be7f37dc7a337653230"/></dir><dir name="Guest"><file name="V1.php" hash="9eb5d9dea3423bfe627c1d2f734e843c"/></dir></dir></dir><file name="Totalsubscriberinfo.php" hash="4ffe3b0986cd7c9e4b02d087dd36adaf"/><dir name="Totalwishlistinfo"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="7bf60c2759df9e3e2c397e2be53c8b9f"/></dir><dir name="Guest"><file name="V1.php" hash="5ec85d262e18ffc56adc96def6e1c5bc"/></dir></dir></dir><file name="Totalwishlistinfo.php" hash="92f3117093628f476091857a7f13b003"/><dir name="Updatesubscription"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="374066b9b1d1bd70e1cc2d7241d4d99f"/></dir><dir name="Guest"><file name="V1.php" hash="21d660933836ad9d84059e5845d7a81c"/></dir></dir></dir><file name="Updatesubscription.php" hash="41359746372b5bebad6e9a092bc9d71f"/><dir name="Wishlist"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ca3961fc15bbfdd41e130ddbf9b82658"/></dir><dir name="Guest"><file name="V1.php" hash="884d3374fdf4e729f89ab76c852e20d4"/></dir></dir></dir><file name="Wishlist.php" hash="e7b77b6a9a4867f8b05863a5a20c86c2"/></dir><file name="Customer.php" hash="0f4adbf8ba12826cb97ebc3ba0b5fdd6"/><file name="Observer.php" hash="69f1005c9f3629ff0bc2d28e5d338c3c"/><file name="Subscriber.php" hash="76ad32bcf2b37901601a70bbd7a31d9d"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Page.php" hash="d67360cf422ac56f06d92dddecb801b4"/><file name="Snippetstatus.php" hash="60d2fb3b903477d5de941f4b1d0f2d77"/><file name="Status.php" hash="a94fc57d2540b136a606e062aa7db71c"/><file name="Tracking.php" hash="e2a8cef15daf13a86db3d6ae361f1c87"/><file name="Version.php" hash="b1a66dba48c0a6e6beae381bec7b6542"/><file name="Yesno.php" hash="9057c48b876b3881a0fcfda37a4b2efd"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="b0736493bb9a394f90ad2901f85bc233"/></dir><dir name="etc"><file name="api2.xml" hash="24ca026a21758354a6a4e10d45cbaa1d"/><file name="config.xml" hash="7482f6ce644089316607c824ca775a24"/><file name="system.xml" hash="39831a58662bc0af1a3bb342e45703ac"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tracking.xml" hash="1a283fb57409de8a93f8cafec473da5e"/></dir><dir name="template"><dir name="tracking"><dir name="product"><file name="inventary.phtml" hash="5c3ffeba1da050dd5b58a9b2141a4db3"/><file name="review.phtml" hash="c776bb6353ffaba2a39dd8aca99858ec"/><file name="richsnippets.phtml" hash="c4016c24d9bcc06c659ca93f6d1f131f"/></dir><file name="recommended.phtml" hash="1c82bdc108a926b74e52dfcb98192a77"/><dir name="session"><file name="tracking.phtml" hash="b5df9a8f56de51379205f7eb59f20437"/></dir><file name="tracking.phtml" hash="d5dfbb4106592e6592ca79fe01b4cc50"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Targetbay_Tracking.xml" hash="7ed0274e2781dc391f5abc29d0e06ea0"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>7.0.17</max></php></required></dependencies>
18
  </package>