Version Notes
SALESmanago Marketing Automation integration.
Download this release
Release Info
Developer | Benhauer Sp. z o.o. Sp. K. |
Extension | SALESmanago |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.3.1
- CHANGELOG.md +0 -64
- app/code/community/SalesManago/Tracking/Block/Layer.php +2 -14
- app/code/community/SalesManago/Tracking/Helper/Data.php +331 -42
- app/code/community/SalesManago/Tracking/Model/Customersync.php +8 -8
- app/code/community/SalesManago/Tracking/Model/Observer.php +163 -237
- app/code/community/SalesManago/Tracking/Model/Resource/Customersync.php +6 -6
- app/code/community/SalesManago/Tracking/Model/Resource/Customersync/Collection.php +7 -7
- app/code/community/SalesManago/Tracking/Model/Resource/Setup.php +4 -4
- app/code/community/SalesManago/Tracking/controllers/CustomerController.php +241 -241
- app/code/community/SalesManago/Tracking/controllers/Newsletter/SubscriberController.php +0 -0
- app/code/community/SalesManago/Tracking/etc/config.xml +22 -42
- app/code/community/SalesManago/Tracking/etc/system.xml +13 -31
- app/code/community/SalesManago/Tracking/sql/tracking_setup/mysql4-install-0.0.4.php +0 -0
- app/design/frontend/base/default/layout/salesmanago.xml +0 -0
- app/design/frontend/base/default/template/salesmanago/tracking/tracking.phtml +22 -21
- app/design/frontend/default/default/layout/salesmanago.xml +0 -10
- app/design/frontend/default/default/template/salesmanago/tracking/tracking.phtml +0 -28
- app/etc/modules/SalesManago_Tracking.xml +0 -0
- app/locale/de_DE/Salesmanago_Tracking.csv +0 -15
- app/locale/es_ES/Salesmanago_Tracking.csv +0 -15
- app/locale/pl_PL/Salesmanago_Tracking.csv +0 -15
- app/locale/ru_RU/Salesmanago_Tracking.csv +0 -15
- package.xml +18 -111
CHANGELOG.md
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
Magento integration v1.5.1 (Released: 21.11.2016)
|
2 |
-
Changes:
|
3 |
-
- New monitoring code
|
4 |
-
|
5 |
-
--------------------------------------------------
|
6 |
-
Magento integration v1.5.0 (Released: 09.11.2016)
|
7 |
-
Added:
|
8 |
-
- Register tags,
|
9 |
-
- Newsletter tags,
|
10 |
-
- Purchase tags,
|
11 |
-
- New method to upsert Vendor platform and version to support account
|
12 |
-
- Translations, MultiLanguage: Polish, English, Spanish, German, Russian
|
13 |
-
- New other event: Wishlist,
|
14 |
-
|
15 |
-
Improvements:
|
16 |
-
- More details in events,
|
17 |
-
|
18 |
-
Fixed:
|
19 |
-
- Installation bug - creating directories instead files,
|
20 |
-
--------------------------------------------------
|
21 |
-
Magento integration v0.1.2.1 (Released: 04.04.2016)
|
22 |
-
-Fixes:
|
23 |
-
OptIn after anonymous client purchase
|
24 |
-
--------------------------------------------------
|
25 |
-
Magento integration v0.1.2 (Released: 16.02.2016)
|
26 |
-
Added:
|
27 |
-
- Register form with address fields - compatibility
|
28 |
-
BugFixes:
|
29 |
-
- Profile and address editing in Magento make changes in SalesManago,
|
30 |
-
- Registering by form with address fields,
|
31 |
-
- Synchronizing contact details in salesmanago,
|
32 |
-
--------------------------------------------------
|
33 |
-
Magento integration v0.1.1 (Released: 29.07.2015)
|
34 |
-
Added:
|
35 |
-
- Profile and address editing in Magento make changes in SalesManago
|
36 |
-
--------------------------------------------------
|
37 |
-
Magento integration v0.1.0 (Released: 24.07.2015)
|
38 |
-
Added:
|
39 |
-
- creating SMclient cookie after login and registering
|
40 |
-
--------------------------------------------------
|
41 |
-
Magento integration v0.0.8 (Released: 05.05.2015)
|
42 |
-
Added:
|
43 |
-
- cart events for unregistered users (with smclient cookie)
|
44 |
-
--------------------------------------------------
|
45 |
-
Magento integration v0.0.7 (Released: 12.03.2015)
|
46 |
-
Added:
|
47 |
-
- enable/disable module
|
48 |
-
- when newsletter requires confirm, contact is sent to sm as optout.
|
49 |
-
--------------------------------------------------
|
50 |
-
Magento integration v0.0.6 (Released: 20.01.2015)
|
51 |
-
Added:
|
52 |
-
- optin callback support
|
53 |
-
- birthday date is sent to SM
|
54 |
-
--------------------------------------------------
|
55 |
-
Magento integration v0.0.5 (Released: 21.11.2014)
|
56 |
-
Added:
|
57 |
-
- support subscription form
|
58 |
-
- admin subscription managment integrated with SM
|
59 |
-
|
60 |
-
Bugfixes:
|
61 |
-
- address, phone etc. not send to SM
|
62 |
-
- cookie not created after guest purchase
|
63 |
-
- tracking code not shown in newest magento
|
64 |
-
- bad price for CART event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/SalesManago/Tracking/Block/Layer.php
CHANGED
@@ -53,23 +53,11 @@ class SalesManago_Tracking_Block_Layer extends Mage_Core_Block_Template
|
|
53 |
}
|
54 |
|
55 |
|
56 |
-
public function
|
57 |
-
$tags = Mage::getStoreConfig('salesmanago_tracking/general/
|
58 |
$tags = explode(',', $tags);
|
59 |
return $tags;
|
60 |
}
|
61 |
-
|
62 |
-
public function getTagsNewsletter(){
|
63 |
-
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tagsNewsletter');
|
64 |
-
$tags = explode(',', $tags);
|
65 |
-
return $tags;
|
66 |
-
}
|
67 |
-
|
68 |
-
public function getTagsPurchase(){
|
69 |
-
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tagsPurchase');
|
70 |
-
$tags = explode(',', $tags);
|
71 |
-
return $tags;
|
72 |
-
}
|
73 |
|
74 |
public function getClientSalesManagoId(){
|
75 |
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
53 |
}
|
54 |
|
55 |
|
56 |
+
public function getTags(){
|
57 |
+
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
58 |
$tags = explode(',', $tags);
|
59 |
return $tags;
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
public function getClientSalesManagoId(){
|
63 |
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
|
app/code/community/SalesManago/Tracking/Helper/Data.php
CHANGED
@@ -32,7 +32,262 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
public function salesmanagoOrderSync($orderDetails){
|
37 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
38 |
if($active == 1) {
|
@@ -40,22 +295,31 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
40 |
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
41 |
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
42 |
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
43 |
-
$registerTags = explode(",", Mage::getStoreConfig('salesmanago_tracking/general/tagsPurchase'));
|
44 |
-
|
45 |
-
$productsIdsList = array();
|
46 |
-
$productsNamesList = array();
|
47 |
|
48 |
$items = $orderDetails->getAllVisibleItems();
|
|
|
49 |
foreach ($items as $item) {
|
50 |
-
array_push($
|
51 |
-
array_push($productsNamesList, $item->getProduct()->getName());
|
52 |
}
|
53 |
|
54 |
$customerEmail = $orderDetails->getCustomerEmail();
|
|
|
|
|
55 |
$grandTotal = $orderDetails->getBaseGrandTotal();
|
56 |
$incrementOrderId = $orderDetails->getIncrementId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($customerEmail)->getData();
|
|
|
|
|
58 |
$orderData = $orderDetails->getData();
|
|
|
|
|
59 |
$customerDetails = $orderDetails->getBillingAddress();
|
60 |
|
61 |
$data = array();
|
@@ -67,8 +331,9 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
67 |
$data['address']['zipCode'] = $customerDetails->getPostcode();
|
68 |
$data['address']['city'] = $customerDetails->getCity();
|
69 |
$data['address']['country'] = $customerDetails->getCountryId();
|
|
|
70 |
$data['customerEmail'] = $customerEmail;
|
71 |
-
|
72 |
|
73 |
if (isset($orderData['customer_dob']) && !empty($orderData['customer_dob'])) {
|
74 |
$dataArray = date_parse($orderData['customer_dob']);
|
@@ -83,9 +348,8 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
83 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customerEmail);
|
84 |
$status = $subscriber->isSubscribed();
|
85 |
if ($status) $data['is_subscribed'] = true;
|
86 |
-
else $data['is_subscribed'] = false;
|
87 |
} else {
|
88 |
-
$data['is_subscribed'] =
|
89 |
}
|
90 |
|
91 |
|
@@ -93,6 +357,7 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
93 |
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
94 |
$data['status'] = 0;
|
95 |
$data['action'] = 1; //rejestracja
|
|
|
96 |
}
|
97 |
|
98 |
|
@@ -114,24 +379,36 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
114 |
'email' => $customerEmail,
|
115 |
'contactEvent' => array(
|
116 |
'date' => $dateTime->format('c'),
|
117 |
-
'products' => implode(',', $
|
118 |
'contactExtEventType' => 'PURCHASE',
|
119 |
'value' => $grandTotal,
|
120 |
-
|
|
|
|
|
|
|
|
|
121 |
'externalId' => $incrementOrderId,
|
122 |
),
|
123 |
);
|
124 |
-
|
125 |
$json = json_encode($data_to_json);
|
126 |
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/addContactExtEvent', $json);
|
127 |
$r = json_decode($result, true);
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
return $r;
|
130 |
}
|
131 |
}
|
132 |
-
|
133 |
/*
|
134 |
-
* Upsert event execute when new user register, sign in and for new owner, which shopping without register
|
135 |
*/
|
136 |
public function salesmanagoContactSync($data){
|
137 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
@@ -139,6 +416,7 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
139 |
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
140 |
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
141 |
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
|
|
142 |
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
143 |
|
144 |
$apiKey = md5(time() . $apiSecret);
|
@@ -153,20 +431,22 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
153 |
'name' => $data['name'],
|
154 |
'fax' => $data['fax'],
|
155 |
'company' => $data['company'],
|
156 |
-
'phone' => $data['
|
157 |
'address' => array(
|
158 |
-
'streetAddress' => $data['
|
159 |
-
'zipCode' => $data['
|
160 |
-
'city' => $data['city'],
|
161 |
-
'country' => $data['country'],
|
162 |
),
|
163 |
),
|
164 |
'owner' => $ownerEmail,
|
165 |
'async' => false,
|
166 |
-
'tags' => $data['tags'],
|
167 |
);
|
168 |
|
169 |
-
|
|
|
|
|
|
|
170 |
$data_to_json['forceOptOut'] = true;
|
171 |
$data_to_json['forceOptIn'] = false;
|
172 |
} else {
|
@@ -178,6 +458,22 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
178 |
$data_to_json['birthday'] = $data['birthday'];
|
179 |
}
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
$json = json_encode($data_to_json);
|
182 |
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
|
183 |
|
@@ -186,47 +482,40 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
186 |
return $r;
|
187 |
}
|
188 |
}
|
189 |
-
|
190 |
public function salesmanagoSubscriberSync(){
|
191 |
-
|
192 |
}
|
193 |
-
|
194 |
public function _setCustomerData($customer){
|
195 |
$data = array();
|
196 |
$subscription_status = 0;
|
197 |
-
foreach ($customer->getAddresses() as $address) {
|
198 |
-
$data = $address->toArray();
|
199 |
-
}
|
200 |
|
201 |
$data['customerEmail'] = $customer['email'];
|
202 |
$data['entity_id'] = $customer['entity_id'];
|
203 |
-
|
204 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']);
|
205 |
$subscription_status = $subscriber->isSubscribed();
|
206 |
-
|
207 |
-
if(isset($customer['firstname']) && isset($customer['lastname'])
|
208 |
-
$data['name'] = $customer['firstname'].' '.$data['middlename'].' '.$customer['lastname'];
|
209 |
-
} else {
|
210 |
$data['name'] = $customer['firstname'].' '.$customer['lastname'];
|
211 |
}
|
212 |
-
|
213 |
if(isset($customer['is_subscribed']) || $subscription_status == 1){
|
214 |
$data['is_subscribed'] = true;
|
215 |
}
|
216 |
-
|
217 |
if(isset($customer['dob'])){
|
218 |
$dataArray = date_parse($customer['dob']);
|
219 |
$month = ($dataArray['month'] < 10) ? "0".$dataArray['month'] : $dataArray['month'];
|
220 |
$day = ($dataArray['day'] < 10) ? "0".$dataArray['day'] : $dataArray['day'];
|
221 |
$year = $dataArray['year'];
|
222 |
-
$data['birthday'] = $year . $month . $day;
|
223 |
}
|
224 |
|
225 |
-
$data['country']=$data['country_id'].' '.$data['region'];
|
226 |
-
|
227 |
return $data;
|
228 |
}
|
229 |
-
|
230 |
public function _doPostRequest($url, $data) {
|
231 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
232 |
if($active == 1) {
|
@@ -263,9 +552,9 @@ class SalesManago_Tracking_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
263 |
}
|
264 |
}
|
265 |
function sm_create_cookie($name, $value, $period){
|
266 |
-
$url = parse_url(Mage::getBaseUrl());
|
267 |
-
setcookie($name, $value, $period, '/', '.'.$this -> sm_get_domain($url['host']));
|
268 |
-
|
269 |
}
|
270 |
function sm_get_domain($domain, $debug = false){
|
271 |
$original = $domain = strtolower($domain);
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
+
/*
|
36 |
+
* BK Changes to Sales Manago Module.
|
37 |
+
* Redeem Coupon via API to SalesManago
|
38 |
+
* @author: Carlos Alonso de Linaje Garcia
|
39 |
+
*/
|
40 |
+
public function salesmanagoRedeemCoupon($customerEmail,$couponCode)
|
41 |
+
{
|
42 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
43 |
+
if ($active == 1)
|
44 |
+
{
|
45 |
+
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
46 |
+
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
47 |
+
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
48 |
+
$apiKey = md5(time() . $apiSecret);
|
49 |
+
$data_to_json = array(
|
50 |
+
'apiKey' => $apiKey,
|
51 |
+
'clientId' => $clientId,
|
52 |
+
'email' => $customerEmail,
|
53 |
+
'coupon' => $couponCode,
|
54 |
+
);
|
55 |
+
$json = json_encode($data_to_json);
|
56 |
+
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/useContactCoupon', $json);
|
57 |
+
$r = json_decode($result, true);
|
58 |
+
|
59 |
+
return $r;
|
60 |
+
}
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
/*
|
64 |
+
* BK Changes to Sales Manago Module.
|
65 |
+
* Calc Total Sales of Customer
|
66 |
+
* @author: Carlos Alonso de Linaje Garcia
|
67 |
+
*/
|
68 |
+
protected function _calcTotal($fromDate = null,$toDate,$customerEmail)
|
69 |
+
{
|
70 |
+
$orders = Mage::getModel('sales/order')->getCollection()
|
71 |
+
->addAttributeToFilter('status', array('neq' => Mage_Sales_Model_Order::STATE_CANCELED))
|
72 |
+
->addAttributeToFilter('customer_email', $customerEmail);
|
73 |
+
if ($fromDate != null)
|
74 |
+
$orders->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate));
|
75 |
+
else
|
76 |
+
$orders->addAttributeToFilter('created_at', array('to'=>$toDate));
|
77 |
+
|
78 |
+
$totalSales = 0;
|
79 |
+
foreach ($orders->getData() as $data)
|
80 |
+
{
|
81 |
+
$totalSales += $data['grand_total'];
|
82 |
+
}
|
83 |
+
return $totalSales;
|
84 |
+
}
|
85 |
+
/*
|
86 |
+
* BK Changes to Sales Manago Module.
|
87 |
+
* Send Sales Totals via API to SalesManago
|
88 |
+
* @author: Carlos Alonso de Linaje Garcia
|
89 |
+
*/
|
90 |
+
public function salesmanagoSalesSync ($orderDetails)
|
91 |
+
{
|
92 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
93 |
+
if($active == 1) {
|
94 |
+
|
95 |
+
$customerEmail = $orderDetails->getCustomerEmail();
|
96 |
+
$month = date("m", Mage::getModel('core/date')->timestamp(time()));
|
97 |
+
$year = date("Y", Mage::getModel('core/date')->timestamp(time()));
|
98 |
+
$toDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
99 |
+
|
100 |
+
//Getting Sales of the month
|
101 |
+
$fromDate = date('Y-m-1 H:i:s', Mage::getModel('core/date')->timestamp(time()));
|
102 |
+
$totalSales_month = $this->_calcTotal($fromDate,$toDate,$customerEmail);
|
103 |
+
$JanuarySales = $this->_calcTotal(date($year.'-1-1'),$toDate,$customerEmail);
|
104 |
+
$total_sales =$this->_calcTotal(null,$toDate,$customerEmail);
|
105 |
+
|
106 |
+
//Getting Sales of the Q, T and Semester.
|
107 |
+
switch ($month) {
|
108 |
+
case 1:
|
109 |
+
case 2:
|
110 |
+
case 3:
|
111 |
+
$data_to_json = array(
|
112 |
+
'Latest_Purchase_date_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
113 |
+
=> $toDate,
|
114 |
+
'Total_Sales_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
115 |
+
=> $total_sales,
|
116 |
+
'Sales_'.$year.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
117 |
+
=> $JanuarySales,
|
118 |
+
'Sales_'.$year.'_M'.$month.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $totalSales_month,
|
119 |
+
'Sales_'.$year.'_1Q_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
120 |
+
'Sales_'.$year.'_1FMP_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
121 |
+
'Sales_'.$year.'_1S_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
122 |
+
);
|
123 |
+
break;
|
124 |
+
case 4:
|
125 |
+
$AprilSales = $this->_calcTotal(date($year.'-4-1'),$toDate,$customerEmail);
|
126 |
+
$data_to_json = array(
|
127 |
+
'Latest_Purchase_date_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
128 |
+
=> $toDate,
|
129 |
+
'Total_Sales_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
130 |
+
=> $total_sales,
|
131 |
+
'Sales_'.$year.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
132 |
+
'Sales_'.$year.'_M'.$month.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $totalSales_month,
|
133 |
+
'Sales_'.$year.'_2Q_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $AprilSales,
|
134 |
+
'Sales_'.$year.'_1FMP_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
135 |
+
'Sales_'.$year.'_1S_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
136 |
+
);
|
137 |
+
break;
|
138 |
+
case 5:
|
139 |
+
case 6:
|
140 |
+
$AprilSales = $this->_calcTotal(date($year.'-4-1'),$toDate,$customerEmail);
|
141 |
+
$MaySales = $this->_calcTotal(date($year.'-5-1'),$toDate,$customerEmail);
|
142 |
+
$data_to_json = array(
|
143 |
+
'Latest_Purchase_date_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
144 |
+
=> $toDate,
|
145 |
+
'Total_Sales_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
146 |
+
=> $total_sales,
|
147 |
+
'Sales_'.$year.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
148 |
+
'Sales_'.$year.'_M'.$month.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $totalSales_month,
|
149 |
+
'Sales_'.$year.'_2Q_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $AprilSales,
|
150 |
+
'Sales_'.$year.'_2FMP_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $MaySales,
|
151 |
+
'Sales_'.$year.'_1S_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
152 |
+
);
|
153 |
+
break;
|
154 |
+
case 7:
|
155 |
+
case 8:
|
156 |
+
$JulySales = $this->_calcTotal(date($year.'-7-1'),$toDate,$customerEmail);
|
157 |
+
$MaySales = $this->_calcTotal(date($year.'-5-1'),$toDate,$customerEmail);
|
158 |
+
$data_to_json = array(
|
159 |
+
'Latest_Purchase_date_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
160 |
+
=> $toDate,
|
161 |
+
'Total_Sales_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
162 |
+
=> $total_sales,
|
163 |
+
'Sales_'.$year.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
164 |
+
'Sales_'.$year.'_M'.$month.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $totalSales_month,
|
165 |
+
'Sales_'.$year.'_3Q_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JulySales,
|
166 |
+
'Sales_'.$year.'_2FMP_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $MaySales,
|
167 |
+
'Sales_'.$year.'_2S_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JulySales,
|
168 |
+
);
|
169 |
+
break;
|
170 |
+
case 9:
|
171 |
+
$JulySales = $this->_calcTotal(date($year.'-7-1'),$toDate,$customerEmail);
|
172 |
+
$SeptSales = $this->_calcTotal(date($year.'-9-1'),$toDate,$customerEmail);
|
173 |
+
$data_to_json = array(
|
174 |
+
'Latest_Purchase_date_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
175 |
+
=> $toDate,
|
176 |
+
'Total_Sales_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
177 |
+
=> $total_sales,
|
178 |
+
'Sales_'.$year.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
179 |
+
'Sales_'.$year.'_M'.$month.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $totalSales_month,
|
180 |
+
'Sales_'.$year.'_3Q_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JulySales,
|
181 |
+
'Sales_'.$year.'_3FMP_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $SeptSales,
|
182 |
+
'Sales_'.$year.'_2S_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JulySales,
|
183 |
+
);
|
184 |
+
break;
|
185 |
+
case 10:
|
186 |
+
case 11:
|
187 |
+
case 12:
|
188 |
+
$JulySales = $this->_calcTotal(date($year.'-7-1'),$toDate,$customerEmail);
|
189 |
+
$SeptSales = $this->_calcTotal(date($year.'-9-1'),$toDate,$customerEmail);
|
190 |
+
$OctSales = $this->_calcTotal(date($year.'-10-1'),$toDate,$customerEmail);
|
191 |
+
$data_to_json = array(
|
192 |
+
'Latest_Purchase_date_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
193 |
+
=> $toDate,
|
194 |
+
'Total_Sales_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST))
|
195 |
+
=> $total_sales,
|
196 |
+
'Sales_'.$year.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JanuarySales,
|
197 |
+
'Sales_'.$year.'_M'.$month.'_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $totalSales_month,
|
198 |
+
'Sales_'.$year.'_4Q_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $OctSales,
|
199 |
+
'Sales_'.$year.'_3FMP_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $SeptSales,
|
200 |
+
'Sales_'.$year.'_2S_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) => $JulySales,
|
201 |
+
);
|
202 |
+
break;
|
203 |
+
} //end Switch Months calculation
|
204 |
+
$r = $this->_SendUpsertPropertiesJson($data_to_json,$customerEmail);
|
205 |
+
|
206 |
+
return $r;
|
207 |
+
|
208 |
+
}
|
209 |
+
}
|
210 |
+
/*
|
211 |
+
* BK Changes to Sales Manago Module.
|
212 |
+
* Send Upsert Api Call
|
213 |
+
* @author: Carlos Alonso de Linaje Garcia
|
214 |
+
*/
|
215 |
+
protected function _SendUpsertPropertiesJson($data,$email)
|
216 |
+
{
|
217 |
+
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
218 |
+
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
219 |
+
$apiKey = md5(time() . $apiSecret);
|
220 |
+
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
221 |
+
$email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
222 |
+
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
223 |
+
|
224 |
+
$data_to_json = array(
|
225 |
+
'apiKey' => $apiKey,
|
226 |
+
'clientId' => $clientId,
|
227 |
+
'requestTime' => time(),
|
228 |
+
'contact' => array(
|
229 |
+
'email' => $email,
|
230 |
+
'state' => 'CUSTOMER',
|
231 |
+
),
|
232 |
+
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
233 |
+
'owner' => $ownerEmail,
|
234 |
+
);
|
235 |
+
$data_to_json['properties'] = $data;
|
236 |
+
$json = json_encode($data_to_json);
|
237 |
+
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
|
238 |
+
$r = json_decode($result, true);
|
239 |
+
|
240 |
+
return $r;
|
241 |
+
}
|
242 |
+
/*
|
243 |
+
* BK Changes to Sales Manago Module.
|
244 |
+
* Send Event Review.
|
245 |
+
* @author: Carlos Alonso de Linaje Garcia
|
246 |
+
*/
|
247 |
+
public function salesmanagoReviewSync($review)
|
248 |
+
{
|
249 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
250 |
+
if($active == 1) {
|
251 |
+
Mage::log('salesmanagoReviewSync');
|
252 |
+
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
253 |
+
$apiKey = md5(time() . $apiSecret);
|
254 |
+
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
255 |
+
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
256 |
+
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
257 |
+
$dateTime = new DateTime('NOW');
|
258 |
+
|
259 |
+
$customerEmail = Mage::getModel('customer/customer')->load($review['customer_id'])->getEmail();
|
260 |
+
|
261 |
+
//Last Minute Change
|
262 |
+
//22 December 2015
|
263 |
+
//Adding Rating to Event
|
264 |
+
|
265 |
+
|
266 |
+
$data_to_json = array(
|
267 |
+
'apiKey' => $apiKey,
|
268 |
+
'clientId' => $clientId,
|
269 |
+
'requestTime' => time(),
|
270 |
+
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
271 |
+
'owner' => $ownerEmail,
|
272 |
+
'email' => $customerEmail,
|
273 |
+
'contactEvent' => array(
|
274 |
+
'date' => $dateTime->format('c'),
|
275 |
+
'contactExtEventType' => 'OTHER',
|
276 |
+
'products' => $review['entity_pk_value'],
|
277 |
+
'detail1' => 'review',
|
278 |
+
'detail2' => $review['title'],
|
279 |
+
'detail3' => $review['detail']
|
280 |
+
),
|
281 |
+
);
|
282 |
+
Mage::log($data_to_json);
|
283 |
+
$json = json_encode($data_to_json);
|
284 |
+
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/addContactExtEvent', $json);
|
285 |
+
$r = json_decode($result, true);
|
286 |
+
|
287 |
+
return $r;
|
288 |
+
|
289 |
+
}
|
290 |
+
}
|
291 |
public function salesmanagoOrderSync($orderDetails){
|
292 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
293 |
if($active == 1) {
|
295 |
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
296 |
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
297 |
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
|
|
|
|
|
|
|
|
298 |
|
299 |
$items = $orderDetails->getAllVisibleItems();
|
300 |
+
$itemsNamesList = array();
|
301 |
foreach ($items as $item) {
|
302 |
+
array_push($itemsNamesList, $item->getProduct()->getId());
|
|
|
303 |
}
|
304 |
|
305 |
$customerEmail = $orderDetails->getCustomerEmail();
|
306 |
+
$customerFirstname = $orderDetails->getCustomerFirstname();
|
307 |
+
$customerLastname = $orderDetails->getCustomerLastname();
|
308 |
$grandTotal = $orderDetails->getBaseGrandTotal();
|
309 |
$incrementOrderId = $orderDetails->getIncrementId();
|
310 |
+
//BK Send Payment Method name, Shipping Method name and Shipping Cost on Event.
|
311 |
+
$payment_name = $orderDetails->getPayment()->getMethodInstance()->getTitle();;
|
312 |
+
$shipping_name = $orderDetails->getShippingDescription();
|
313 |
+
$shippment_cost = $orderDetails->getShippingAmount();
|
314 |
+
//BK Coupon Code.
|
315 |
+
$couponCode = $orderDetails->coupon_code;
|
316 |
+
|
317 |
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($customerEmail)->getData();
|
318 |
+
|
319 |
+
|
320 |
$orderData = $orderDetails->getData();
|
321 |
+
|
322 |
+
|
323 |
$customerDetails = $orderDetails->getBillingAddress();
|
324 |
|
325 |
$data = array();
|
331 |
$data['address']['zipCode'] = $customerDetails->getPostcode();
|
332 |
$data['address']['city'] = $customerDetails->getCity();
|
333 |
$data['address']['country'] = $customerDetails->getCountryId();
|
334 |
+
|
335 |
$data['customerEmail'] = $customerEmail;
|
336 |
+
|
337 |
|
338 |
if (isset($orderData['customer_dob']) && !empty($orderData['customer_dob'])) {
|
339 |
$dataArray = date_parse($orderData['customer_dob']);
|
348 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customerEmail);
|
349 |
$status = $subscriber->isSubscribed();
|
350 |
if ($status) $data['is_subscribed'] = true;
|
|
|
351 |
} else {
|
352 |
+
$data['is_subscribed'] = true; //after purchase
|
353 |
}
|
354 |
|
355 |
|
357 |
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
358 |
$data['status'] = 0;
|
359 |
$data['action'] = 1; //rejestracja
|
360 |
+
//$this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
|
361 |
}
|
362 |
|
363 |
|
379 |
'email' => $customerEmail,
|
380 |
'contactEvent' => array(
|
381 |
'date' => $dateTime->format('c'),
|
382 |
+
'products' => implode(',', $itemsNamesList),
|
383 |
'contactExtEventType' => 'PURCHASE',
|
384 |
'value' => $grandTotal,
|
385 |
+
//BK Sending Values on detail 1,2 & 3
|
386 |
+
'detail1' => $payment_name,
|
387 |
+
'detail2' => $shipping_name,
|
388 |
+
'detail3' => $shippment_cost,
|
389 |
+
'detail4' => $couponCode,
|
390 |
'externalId' => $incrementOrderId,
|
391 |
),
|
392 |
);
|
|
|
393 |
$json = json_encode($data_to_json);
|
394 |
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/addContactExtEvent', $json);
|
395 |
$r = json_decode($result, true);
|
396 |
|
397 |
+
//BK Redeem Coupon
|
398 |
+
if ($couponCode)
|
399 |
+
{
|
400 |
+
Mage::log($couponCode);
|
401 |
+
$j = $this->salesmanagoRedeemCoupon($customerEmail,$couponCode);
|
402 |
+
Mage::log($j);
|
403 |
+
|
404 |
+
}//BK
|
405 |
+
|
406 |
return $r;
|
407 |
}
|
408 |
}
|
409 |
+
|
410 |
/*
|
411 |
+
* Upsert event execute when new user register, sign in and for new owner, which shopping without register
|
412 |
*/
|
413 |
public function salesmanagoContactSync($data){
|
414 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
416 |
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
417 |
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
418 |
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
419 |
+
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
420 |
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
421 |
|
422 |
$apiKey = md5(time() . $apiSecret);
|
431 |
'name' => $data['name'],
|
432 |
'fax' => $data['fax'],
|
433 |
'company' => $data['company'],
|
434 |
+
'phone' => $data['phone'],
|
435 |
'address' => array(
|
436 |
+
'streetAddress' => $data['address']['streetAddress'],
|
437 |
+
'zipCode' => $data['address']['zipCode'],
|
438 |
+
'city' => $data['address']['city'],
|
439 |
+
'country' => $data['address']['country'],
|
440 |
),
|
441 |
),
|
442 |
'owner' => $ownerEmail,
|
443 |
'async' => false,
|
|
|
444 |
);
|
445 |
|
446 |
+
|
447 |
+
|
448 |
+
|
449 |
+
if (!isset($data['is_subscribed'])) {
|
450 |
$data_to_json['forceOptOut'] = true;
|
451 |
$data_to_json['forceOptIn'] = false;
|
452 |
} else {
|
458 |
$data_to_json['birthday'] = $data['birthday'];
|
459 |
}
|
460 |
|
461 |
+
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($data['customerEmail'])->getData();
|
462 |
+
|
463 |
+
//BK Change Add a new tag on customer_login
|
464 |
+
//BK Change Add a new tag on newsletter subscribe
|
465 |
+
$tags=$tags.',last_logged_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST));
|
466 |
+
if ($data['is_subscribed'])
|
467 |
+
$tags = $tags.',Newsletter_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST));
|
468 |
+
|
469 |
+
if (!empty($tags)) {
|
470 |
+
$tags = explode(",", $tags);
|
471 |
+
if (is_array($tags) && count($tags) > 0) {
|
472 |
+
$tags = array_map('trim', $tags);
|
473 |
+
$data_to_json['tags'] = $tags;
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
$json = json_encode($data_to_json);
|
478 |
$result = $this->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
|
479 |
|
482 |
return $r;
|
483 |
}
|
484 |
}
|
485 |
+
|
486 |
public function salesmanagoSubscriberSync(){
|
487 |
+
|
488 |
}
|
489 |
+
|
490 |
public function _setCustomerData($customer){
|
491 |
$data = array();
|
492 |
$subscription_status = 0;
|
|
|
|
|
|
|
493 |
|
494 |
$data['customerEmail'] = $customer['email'];
|
495 |
$data['entity_id'] = $customer['entity_id'];
|
496 |
+
|
497 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']);
|
498 |
$subscription_status = $subscriber->isSubscribed();
|
499 |
+
|
500 |
+
if(isset($customer['firstname']) && isset($customer['lastname'])){
|
|
|
|
|
501 |
$data['name'] = $customer['firstname'].' '.$customer['lastname'];
|
502 |
}
|
503 |
+
|
504 |
if(isset($customer['is_subscribed']) || $subscription_status == 1){
|
505 |
$data['is_subscribed'] = true;
|
506 |
}
|
507 |
+
|
508 |
if(isset($customer['dob'])){
|
509 |
$dataArray = date_parse($customer['dob']);
|
510 |
$month = ($dataArray['month'] < 10) ? "0".$dataArray['month'] : $dataArray['month'];
|
511 |
$day = ($dataArray['day'] < 10) ? "0".$dataArray['day'] : $dataArray['day'];
|
512 |
$year = $dataArray['year'];
|
513 |
+
$data['birthday'] = $year . $month . $day;
|
514 |
}
|
515 |
|
|
|
|
|
516 |
return $data;
|
517 |
}
|
518 |
+
|
519 |
public function _doPostRequest($url, $data) {
|
520 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
521 |
if($active == 1) {
|
552 |
}
|
553 |
}
|
554 |
function sm_create_cookie($name, $value, $period){
|
555 |
+
$url = parse_url(Mage::getBaseUrl());
|
556 |
+
setcookie($name, $value, $period, '/', '.'.$this -> sm_get_domain($url['host']));
|
557 |
+
|
558 |
}
|
559 |
function sm_get_domain($domain, $debug = false){
|
560 |
$original = $domain = strtolower($domain);
|
app/code/community/SalesManago/Tracking/Model/Customersync.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class SalesManago_Tracking_Model_Customersync extends Mage_Core_Model_Abstract
|
3 |
-
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
parent::_construct();
|
7 |
-
$this->_init('tracking/customersync');
|
8 |
-
}
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class SalesManago_Tracking_Model_Customersync extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('tracking/customersync');
|
8 |
+
}
|
9 |
}
|
app/code/community/SalesManago/Tracking/Model/Observer.php
CHANGED
@@ -1,20 +1,41 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SalesManago_Tracking_Model_Observer
|
4 |
-
|
5 |
-
|
6 |
-
protected function _getHelper()
|
7 |
-
{
|
8 |
return Mage::helper('tracking');
|
9 |
}
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
14 |
-
if
|
15 |
-
$customer = $observer->getCustomer();
|
16 |
|
17 |
-
if (!empty($customer)) {
|
18 |
if (!isset($customer['salesmanago_contact_id']) || empty($customer['salesmanago_contact_id'])) {
|
19 |
$data = $this->_getHelper()->_setCustomerData($customer);
|
20 |
|
@@ -36,23 +57,21 @@ class SalesManago_Tracking_Model_Observer
|
|
36 |
}
|
37 |
}
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
-
public function customer_register_success($observer)
|
48 |
-
{
|
49 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
50 |
-
if
|
51 |
-
$customer = $observer->getCustomer();
|
52 |
|
53 |
-
if (
|
54 |
$data = $this->_getHelper()->_setCustomerData($customer);
|
55 |
-
$data['tags'] = explode(",", Mage::getStoreConfig('salesmanago_tracking/general/tagsRegistration'));
|
56 |
|
57 |
$r = $this->_getHelper()->salesmanagoContactSync($data);
|
58 |
|
@@ -71,25 +90,23 @@ class SalesManago_Tracking_Model_Observer
|
|
71 |
}
|
72 |
}
|
73 |
}
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
}
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
/*
|
84 |
* Dodanie zdarzenia addContactExtEvent na podsumowaniu zam�wienia z typem PURCHASE
|
85 |
*/
|
86 |
-
|
87 |
-
{
|
88 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
89 |
-
if
|
90 |
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
91 |
$orderDetails = Mage::getModel('sales/order')->load($orderId);
|
92 |
-
|
93 |
$r = $this->_getHelper()->salesmanagoOrderSync($orderDetails);
|
94 |
|
95 |
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
@@ -102,30 +119,77 @@ class SalesManago_Tracking_Model_Observer
|
|
102 |
);
|
103 |
$this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
|
104 |
}
|
105 |
-
|
106 |
$eventId = Mage::getSingleton('core/session')->getEventId();
|
107 |
if (isset($eventId) && !empty($eventId)) {
|
108 |
Mage::getSingleton('core/session')->unsEventId();
|
109 |
}
|
110 |
}
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
/*
|
114 |
* Dodanie (oraz na biezaco modyfikowanie) zdarzenia w koszyku addContactExtEvent z typem CART
|
115 |
*/
|
116 |
-
|
117 |
-
{
|
118 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
119 |
-
if
|
120 |
$cartHelper = Mage::getModel('checkout/cart')->getQuote();
|
121 |
-
$
|
122 |
-
$
|
123 |
-
|
124 |
-
$items = $cartHelper->getAllItems();
|
125 |
foreach ($items as $item) {
|
126 |
-
array_push($
|
127 |
-
array_push($productsNamesList, $item->getProduct()->getName());
|
128 |
-
|
129 |
}
|
130 |
|
131 |
|
@@ -137,58 +201,56 @@ class SalesManago_Tracking_Model_Observer
|
|
137 |
$customerEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
138 |
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
139 |
//if (!empty($customerEmail)) {
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
)
|
157 |
-
);
|
158 |
|
159 |
-
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
} else {
|
166 |
-
if ($isLoggedIn) {
|
167 |
-
$data_to_json['email'] = $customerEmail;
|
168 |
} else {
|
169 |
-
if
|
170 |
-
$data_to_json['
|
171 |
-
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
-
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
//}
|
185 |
}
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
{
|
190 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
191 |
-
if
|
192 |
$request = Mage::app()->getRequest();
|
193 |
$moduleName = $request->getModuleName();
|
194 |
$controllerName = $request->getControllerName();
|
@@ -207,7 +269,7 @@ class SalesManago_Tracking_Model_Observer
|
|
207 |
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
208 |
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
209 |
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
210 |
-
$
|
211 |
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
212 |
|
213 |
|
@@ -221,37 +283,34 @@ class SalesManago_Tracking_Model_Observer
|
|
221 |
|
222 |
$apiKey = md5(time() . $apiSecret);
|
223 |
|
|
|
224 |
$data_to_json = array(
|
225 |
'apiKey' => $apiKey,
|
226 |
'clientId' => $clientId,
|
227 |
'requestTime' => time(),
|
228 |
'contact' => array(
|
229 |
'email' => $email,
|
230 |
-
'state' => '
|
231 |
),
|
232 |
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
233 |
'owner' => $ownerEmail,
|
234 |
);
|
|
|
|
|
|
|
|
|
235 |
|
236 |
-
if (!empty($newsletterTags)) {
|
237 |
-
$newsletterTags = explode(",", $newsletterTags);
|
238 |
-
if (is_array($newsletterTags) && count($newsletterTags) > 0) {
|
239 |
-
$newsletterTags = array_map('trim', $newsletterTags);
|
240 |
-
|
241 |
-
}
|
242 |
-
}
|
243 |
|
244 |
if ($data['subscriber_status'] == "1" && ($statusChange == true || ($id && $code) || $isAdmin)) {
|
245 |
$data_to_json['forceOptIn'] = true;
|
246 |
-
$data_to_json['tags'] = $newsletterTags;
|
247 |
} elseif ($data['subscriber_status'] == "3" && ($statusChange == true || ($id && $code) || $isAdmin)) {
|
248 |
$data_to_json['forceOptOut'] = true;
|
249 |
-
$data_to_json['removeTags'] = $newsletterTags;
|
250 |
} elseif ($actionName == 'massDelete') {
|
251 |
$data_to_json['forceOptOut'] = true;
|
252 |
-
$data_to_json['removeTags'] = $newsletterTags;
|
253 |
}
|
254 |
-
|
|
|
|
|
255 |
$json = json_encode($data_to_json);
|
256 |
$result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
|
257 |
|
@@ -272,9 +331,8 @@ class SalesManago_Tracking_Model_Observer
|
|
272 |
return $r;
|
273 |
}
|
274 |
}
|
275 |
-
|
276 |
-
|
277 |
-
public function newsletter_subscriber_delete_after($observer)
|
278 |
{
|
279 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
280 |
if ($active == 1) {
|
@@ -320,137 +378,5 @@ class SalesManago_Tracking_Model_Observer
|
|
320 |
}
|
321 |
}
|
322 |
}
|
323 |
-
|
324 |
-
public function customer_data_edit($observer)
|
325 |
-
{
|
326 |
-
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
327 |
-
if ($active == 1) {
|
328 |
-
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
329 |
-
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
330 |
-
|
331 |
-
if (isset($customer['salesmanago_contact_id']) && !empty($customer['salesmanago_contact_id'])) {
|
332 |
-
|
333 |
-
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
334 |
-
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
335 |
-
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
336 |
-
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
337 |
-
$apiKey = md5(time() . $apiSecret);
|
338 |
-
$contactId = $customer->getSalesmanagoContactId();
|
339 |
-
|
340 |
-
foreach ($customer->getAddresses() as $address) {
|
341 |
-
$data = $address->toArray();
|
342 |
-
}
|
343 |
-
|
344 |
-
$street = $address->getStreet(1) . ' ' . $address->getStreet(2);
|
345 |
-
|
346 |
-
if (isset($data['firstname']) && isset($data['lastname']) && isset($data['middlename'])) {
|
347 |
-
$data['name'] = $data['firstname'] . ' ' . $data['middlename'] . ' ' . $data['lastname'];
|
348 |
-
} else {
|
349 |
-
$data['name'] = $data['firstname'] . ' ' . $data['lastname'];
|
350 |
-
}
|
351 |
-
|
352 |
-
$data_to_json = array(
|
353 |
-
'apiKey' => $apiKey,
|
354 |
-
'clientId' => $clientId,
|
355 |
-
'requestTime' => time(),
|
356 |
-
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
357 |
-
'contactId' => $contactId,
|
358 |
-
'contact' => array(
|
359 |
-
'name' => $data['name'],
|
360 |
-
'fax' => $data['fax'],
|
361 |
-
'company' => $data['company'],
|
362 |
-
'phone' => $data['telephone'],
|
363 |
-
'address' => array(
|
364 |
-
'streetAddress' => $street,
|
365 |
-
'zipCode' => $data['postcode'],
|
366 |
-
'city' => $data['city'],
|
367 |
-
'country' => $data['country_id'],
|
368 |
-
),
|
369 |
-
),
|
370 |
-
'owner' => $ownerEmail,
|
371 |
-
'async' => false,
|
372 |
-
);
|
373 |
-
|
374 |
-
$json = json_encode($data_to_json);
|
375 |
-
$this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/update', $json);
|
376 |
-
}
|
377 |
-
}
|
378 |
-
}
|
379 |
-
}
|
380 |
-
|
381 |
-
public function adminSystemConfigChangedSectionSalesmanago_tracking($observer)
|
382 |
-
{
|
383 |
-
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
384 |
-
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
385 |
-
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
386 |
-
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
387 |
-
$apiKey = md5(time() . $apiSecret);
|
388 |
-
$version = Mage::getVersion();
|
389 |
-
|
390 |
-
$data_to_json = array(
|
391 |
-
'apiKey' => $apiKey,
|
392 |
-
'clientId' => $clientId,
|
393 |
-
'requestTime' => time(),
|
394 |
-
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
395 |
-
'owner' => $ownerEmail,
|
396 |
-
'tags' => ["MAGENTO_1"],
|
397 |
-
'properties' => array("platform"=>"Magento", "version"=>$version),
|
398 |
-
);
|
399 |
-
|
400 |
-
$json = json_encode($data_to_json);
|
401 |
-
$this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsertVendorToSupport', $json);
|
402 |
-
}
|
403 |
-
|
404 |
-
public function wishlist_event($observer)
|
405 |
-
{
|
406 |
-
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
407 |
-
if ($active == 1) {
|
408 |
-
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
409 |
-
if ($isLoggedIn) {
|
410 |
-
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
411 |
-
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
412 |
-
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
413 |
-
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
414 |
-
$apiKey = md5(time() . $apiSecret);
|
415 |
-
$dateTime = new DateTime('NOW');
|
416 |
-
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
417 |
-
$product = $observer->getEvent()->getItems()[0]->getProduct();
|
418 |
-
$productId = $product->getId();
|
419 |
-
$productName = $product->getName();
|
420 |
-
$productValue = round($product->getPrice(), 2);
|
421 |
-
|
422 |
-
|
423 |
-
$data_to_json = array(
|
424 |
-
'apiKey' => $apiKey,
|
425 |
-
'clientId' => $clientId,
|
426 |
-
'requestTime' => time(),
|
427 |
-
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
428 |
-
'owner' => $ownerEmail,
|
429 |
-
'contactEvent' => array(
|
430 |
-
'date' => $dateTime->format('c'),
|
431 |
-
'contactExtEventType' => 'OTHER',
|
432 |
-
'products' => $productId,
|
433 |
-
'value' => $productValue,
|
434 |
-
'detail1' => $productName,
|
435 |
-
'description' => 'WISHLIST',
|
436 |
-
),
|
437 |
-
);
|
438 |
-
|
439 |
-
|
440 |
-
if ($isLoggedIn) {
|
441 |
-
$data_to_json['email'] = $customer->getEmail();
|
442 |
-
$json = json_encode($data_to_json);
|
443 |
-
} else {
|
444 |
-
if (!isset($_COOKIE['smclient']) || empty($_COOKIE['smclient'])){
|
445 |
-
$data_to_json['contactId'] = $_COOKIE['smclient'];
|
446 |
-
$json = json_encode($data_to_json);
|
447 |
-
}
|
448 |
-
}
|
449 |
-
|
450 |
-
if(!empty($json))
|
451 |
-
$this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsertVendorToSupport', $json);
|
452 |
-
}
|
453 |
-
}
|
454 |
-
}
|
455 |
}
|
456 |
|
1 |
<?php
|
2 |
|
3 |
+
class SalesManago_Tracking_Model_Observer {
|
4 |
+
|
5 |
+
protected function _getHelper(){
|
|
|
|
|
6 |
return Mage::helper('tracking');
|
7 |
}
|
8 |
+
|
9 |
+
/*
|
10 |
+
* BK Changes to Sales Manago Module.
|
11 |
+
* Adding Observer to Review event.
|
12 |
+
* Will send Sales Manago API If a customer review is approved.
|
13 |
+
* @author:Carlos Alonso de Linaje.
|
14 |
+
* @date: 28/Oct/2015
|
15 |
+
*/
|
16 |
+
public function review_save_after($observer)
|
17 |
+
{
|
18 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
19 |
+
if($active == 1) {
|
20 |
+
$object = $observer->getEvent()->getObject();
|
21 |
+
$review = $object->getData();
|
22 |
+
//Only send data if is a Customer (not just Guest)
|
23 |
+
//And if the review is approved
|
24 |
+
if ($review['status_id']==1 && array_key_exists('customer_id', $review))
|
25 |
+
{
|
26 |
+
$r =$this->_getHelper()->salesmanagoReviewSync($review);
|
27 |
+
return $r;
|
28 |
+
Mage::log($r);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
public function customer_login($observer) {
|
34 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
35 |
+
if($active == 1) {
|
36 |
+
$customer = $observer->getCustomer()->getData();
|
37 |
|
38 |
+
if (is_array($customer) && !empty($customer)) {
|
39 |
if (!isset($customer['salesmanago_contact_id']) || empty($customer['salesmanago_contact_id'])) {
|
40 |
$data = $this->_getHelper()->_setCustomerData($customer);
|
41 |
|
57 |
}
|
58 |
}
|
59 |
}
|
60 |
+
if(!isset($_COOKIE['smclient']) || empty($_COOKIE['smclient'])){
|
61 |
+
$period = time() + 36500 * 86400;
|
62 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
63 |
+
$contactId = $customerData->getSalesmanagoContactId();
|
64 |
+
$this->_getHelper()->sm_create_cookie('smclient', $contactId, $period);
|
65 |
}
|
66 |
}
|
67 |
+
|
68 |
+
public function customer_register_success($observer) {
|
|
|
69 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
70 |
+
if($active == 1) {
|
71 |
+
$customer = $observer->getCustomer()->getData();
|
72 |
|
73 |
+
if (is_array($customer) && !empty($customer)) {
|
74 |
$data = $this->_getHelper()->_setCustomerData($customer);
|
|
|
75 |
|
76 |
$r = $this->_getHelper()->salesmanagoContactSync($data);
|
77 |
|
90 |
}
|
91 |
}
|
92 |
}
|
93 |
+
if(!isset($_COOKIE['smclient']) || empty($_COOKIE['smclient'])){
|
94 |
+
$period = time() + 36500 * 86400;
|
95 |
+
$customerData = Mage::getSingleton('customer/session')->getCustomer();
|
96 |
+
$contactId = $customerData->getSalesmanagoContactId();
|
97 |
+
$this->_getHelper()->sm_create_cookie('smclient', $contactId, $period);
|
98 |
}
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
/*
|
103 |
* Dodanie zdarzenia addContactExtEvent na podsumowaniu zam�wienia z typem PURCHASE
|
104 |
*/
|
105 |
+
public function checkout_onepage_controller_success_action($observer){
|
|
|
106 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
107 |
+
if($active == 1) {
|
108 |
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
109 |
$orderDetails = Mage::getModel('sales/order')->load($orderId);
|
|
|
110 |
$r = $this->_getHelper()->salesmanagoOrderSync($orderDetails);
|
111 |
|
112 |
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
119 |
);
|
120 |
$this->_getHelper()->setSalesmanagoCustomerSyncStatus($data);
|
121 |
}
|
122 |
+
$this->_getHelper()->salesmanagoSalesSync($orderDetails);
|
123 |
$eventId = Mage::getSingleton('core/session')->getEventId();
|
124 |
if (isset($eventId) && !empty($eventId)) {
|
125 |
Mage::getSingleton('core/session')->unsEventId();
|
126 |
}
|
127 |
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/*
|
131 |
+
* BK Changes to Sales Manago Module.
|
132 |
+
* Adding Observer to Whislist event.
|
133 |
+
* Will Save WishList products on customer's Custom Details
|
134 |
+
* @author:Carlos Alonso de Linaje.
|
135 |
+
* @date: 17/Oct/2015
|
136 |
+
*/
|
137 |
+
public function wishlist_item_collection_products_after_load($observer)
|
138 |
+
{
|
139 |
+
Mage::log('whislist');
|
140 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
141 |
+
if($active == 1)
|
142 |
+
{
|
143 |
+
$_itemCollection = Mage::helper('wishlist')->getWishlistItemCollection();
|
144 |
+
foreach ($_itemCollection as $_item)
|
145 |
+
{
|
146 |
+
$_products .= $_item->getProduct()->getId().',';
|
147 |
+
}
|
148 |
+
|
149 |
+
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
150 |
+
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
151 |
+
$apiKey = md5(time() . $apiSecret);
|
152 |
+
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
153 |
+
$email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
154 |
+
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
155 |
+
|
156 |
+
$data_to_json = array(
|
157 |
+
'apiKey' => $apiKey,
|
158 |
+
'clientId' => $clientId,
|
159 |
+
'requestTime' => time(),
|
160 |
+
'contact' => array(
|
161 |
+
'email' => $email,
|
162 |
+
'state' => 'CUSTOMER',
|
163 |
+
),
|
164 |
+
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
165 |
+
'owner' => $ownerEmail,
|
166 |
+
);
|
167 |
+
//BK Change Add a new tag on newsletter subscribe
|
168 |
+
$data_to_json['properties'] = array(
|
169 |
+
'WhislistDate_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) =>
|
170 |
+
Mage::getModel('core/date')->date('Y-m-d H:i:s'),
|
171 |
+
'WhislistProducts_'.str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)) =>
|
172 |
+
$_products
|
173 |
+
);
|
174 |
+
|
175 |
+
$json = json_encode($data_to_json);
|
176 |
+
$result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
|
177 |
+
$r = json_decode($result, true);
|
178 |
+
return $r;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
/*
|
183 |
* Dodanie (oraz na biezaco modyfikowanie) zdarzenia w koszyku addContactExtEvent z typem CART
|
184 |
*/
|
185 |
+
public function checkout_cart_save_after($observer){
|
|
|
186 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
187 |
+
if($active == 1) {
|
188 |
$cartHelper = Mage::getModel('checkout/cart')->getQuote();
|
189 |
+
$items = $cartHelper->getAllVisibleItems();
|
190 |
+
$itemsNamesList = array();
|
|
|
|
|
191 |
foreach ($items as $item) {
|
192 |
+
array_push($itemsNamesList, $item->getProduct()->getId());
|
|
|
|
|
193 |
}
|
194 |
|
195 |
|
201 |
$customerEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
202 |
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
203 |
//if (!empty($customerEmail)) {
|
204 |
+
$apiKey = md5(time() . $apiSecret);
|
205 |
+
$dateTime = new DateTime('NOW');
|
|
|
206 |
|
207 |
+
$data_to_json = array(
|
208 |
+
'apiKey' => $apiKey,
|
209 |
+
'clientId' => $clientId,
|
210 |
+
'requestTime' => time(),
|
211 |
+
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
212 |
+
'owner' => $ownerEmail,
|
213 |
+
'contactEvent' => array(
|
214 |
+
'date' => $dateTime->format('c'),
|
215 |
+
'contactExtEventType' => 'CART',
|
216 |
+
'products' => implode(',', $itemsNamesList),
|
217 |
+
'value' => $cartHelper->getGrandTotal(),
|
218 |
+
),
|
219 |
+
);
|
|
|
220 |
|
221 |
+
$eventId = Mage::getSingleton('core/session')->getEventId();
|
222 |
|
223 |
+
if (isset($eventId) && !empty($eventId)) {
|
224 |
+
$data_to_json['contactEvent']['eventId'] = $eventId;
|
225 |
+
$json = json_encode($data_to_json);
|
226 |
+
$result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/updateContactExtEvent', $json);
|
|
|
|
|
|
|
227 |
} else {
|
228 |
+
if($isLoggedIn){
|
229 |
+
$data_to_json['email'] = $customerEmail;
|
230 |
+
}
|
231 |
+
else {
|
232 |
+
if(!empty($_COOKIE['smclient']))
|
233 |
+
$data_to_json['contactId'] = $_COOKIE['smclient'];
|
234 |
+
}
|
235 |
|
236 |
+
Mage::log(serialize($data_to_json), null, 'mylogfile.log');
|
237 |
|
238 |
+
$json = json_encode($data_to_json);
|
239 |
+
$result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/addContactExtEvent', $json);
|
240 |
+
}
|
241 |
|
242 |
+
$r = json_decode($result, true);
|
243 |
|
244 |
+
if (!isset($eventId) && isset($r['eventId'])) {
|
245 |
+
Mage::getSingleton('core/session')->setEventId($r['eventId']);
|
246 |
+
}
|
247 |
//}
|
248 |
}
|
249 |
+
}
|
250 |
+
|
251 |
+
public function newsletter_subscriber_save_before($observer){
|
|
|
252 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
253 |
+
if($active == 1) {
|
254 |
$request = Mage::app()->getRequest();
|
255 |
$moduleName = $request->getModuleName();
|
256 |
$controllerName = $request->getControllerName();
|
269 |
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
270 |
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
271 |
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
272 |
+
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
273 |
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
274 |
|
275 |
|
283 |
|
284 |
$apiKey = md5(time() . $apiSecret);
|
285 |
|
286 |
+
//BK Change to PROSPECT
|
287 |
$data_to_json = array(
|
288 |
'apiKey' => $apiKey,
|
289 |
'clientId' => $clientId,
|
290 |
'requestTime' => time(),
|
291 |
'contact' => array(
|
292 |
'email' => $email,
|
293 |
+
'state' => 'PROSPECT',
|
294 |
),
|
295 |
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
296 |
'owner' => $ownerEmail,
|
297 |
);
|
298 |
+
//BK Change Add a new tag on newsletter subscribe
|
299 |
+
$data_to_json['tags'] = array('Newsletter_'.
|
300 |
+
str_replace('.','_',parse_url(Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB), PHP_URL_HOST)));
|
301 |
+
//Mage::log($data_to_json);
|
302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
if ($data['subscriber_status'] == "1" && ($statusChange == true || ($id && $code) || $isAdmin)) {
|
305 |
$data_to_json['forceOptIn'] = true;
|
|
|
306 |
} elseif ($data['subscriber_status'] == "3" && ($statusChange == true || ($id && $code) || $isAdmin)) {
|
307 |
$data_to_json['forceOptOut'] = true;
|
|
|
308 |
} elseif ($actionName == 'massDelete') {
|
309 |
$data_to_json['forceOptOut'] = true;
|
|
|
310 |
}
|
311 |
+
|
312 |
+
|
313 |
+
|
314 |
$json = json_encode($data_to_json);
|
315 |
$result = $this->_getHelper()->_doPostRequest('https://' . $endPoint . '/api/contact/upsert', $json);
|
316 |
|
331 |
return $r;
|
332 |
}
|
333 |
}
|
334 |
+
}
|
335 |
+
public function newsletter_subscriber_delete_after($observer)
|
|
|
336 |
{
|
337 |
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
338 |
if ($active == 1) {
|
378 |
}
|
379 |
}
|
380 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
}
|
382 |
|
app/code/community/SalesManago/Tracking/Model/Resource/Customersync.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
class SalesManago_Tracking_Model_Resource_Customersync extends Mage_Core_Model_Resource_Db_Abstract {
|
3 |
-
|
4 |
-
protected function _construct() {
|
5 |
-
$this->_init('tracking/customersync', 'customer_sync_id');
|
6 |
-
}
|
7 |
}
|
1 |
+
<?php
|
2 |
+
class SalesManago_Tracking_Model_Resource_Customersync extends Mage_Core_Model_Resource_Db_Abstract {
|
3 |
+
|
4 |
+
protected function _construct() {
|
5 |
+
$this->_init('tracking/customersync', 'customer_sync_id');
|
6 |
+
}
|
7 |
}
|
app/code/community/SalesManago/Tracking/Model/Resource/Customersync/Collection.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
class SalesManago_Tracking_Model_Resource_Customersync_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
-
{
|
4 |
-
public function _construct()
|
5 |
-
{
|
6 |
-
$this->_init('tracking/customersync');
|
7 |
-
}
|
8 |
}
|
1 |
+
<?php
|
2 |
+
class SalesManago_Tracking_Model_Resource_Customersync_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('tracking/customersync');
|
7 |
+
}
|
8 |
}
|
app/code/community/SalesManago/Tracking/Model/Resource/Setup.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class SalesManago_Tracking_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
4 |
-
{
|
5 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SalesManago_Tracking_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
|
4 |
+
{
|
5 |
}
|
app/code/community/SalesManago/Tracking/controllers/CustomerController.php
CHANGED
@@ -1,242 +1,242 @@
|
|
1 |
-
<?php
|
2 |
-
class SalesManago_Tracking_CustomerController extends Mage_Core_Controller_Front_Action{
|
3 |
-
|
4 |
-
protected function _getHelper(){
|
5 |
-
return Mage::helper('tracking');
|
6 |
-
}
|
7 |
-
|
8 |
-
public function exportAction(){
|
9 |
-
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
10 |
-
if($active == 1) {
|
11 |
-
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
12 |
-
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
13 |
-
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
14 |
-
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
15 |
-
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
16 |
-
|
17 |
-
$key = $this->getRequest()->getParam('key');
|
18 |
-
|
19 |
-
if (isset($key) && isset($apiSecret) && $key == sha1($apiSecret)) {
|
20 |
-
|
21 |
-
$apiKey = md5(time() . $apiSecret);
|
22 |
-
|
23 |
-
$data_to_json = array(
|
24 |
-
'apiKey' => $apiKey,
|
25 |
-
'clientId' => $clientId,
|
26 |
-
'requestTime' => time(),
|
27 |
-
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
28 |
-
|
29 |
-
'upsertDetails' => array(),
|
30 |
-
'owner' => $ownerEmail,
|
31 |
-
);
|
32 |
-
|
33 |
-
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
|
34 |
-
|
35 |
-
$i = 0;
|
36 |
-
foreach ($collection as $item) {
|
37 |
-
if (!isset($item['salesmanago_contact_id']) || empty($item['salesmanago_contact_id']) || $item['salesmanago_contact_id'] == 0) {
|
38 |
-
$status = Mage::getModel('newsletter/subscriber')->loadByEmail($item['email'])->isSubscribed();
|
39 |
-
|
40 |
-
if ($status) {
|
41 |
-
$data_to_json['upsertDetails'][$i]['forceOptIn'] = true;
|
42 |
-
} else {
|
43 |
-
$data_to_json['upsertDetails'][$i]['forceOptOut'] = true;
|
44 |
-
}
|
45 |
-
$data_to_json['upsertDetails'][$i]['contact']['email'] = $item['email'];
|
46 |
-
$data_to_json['upsertDetails'][$i]['contact']['name'] = $item['firstname'] . ' ' . $item['lastname'];
|
47 |
-
|
48 |
-
$i++;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
$json = json_encode($data_to_json);
|
53 |
-
$result = $this->_do_post_request('https://' . $endPoint . '/api/contact/batchupsert', $json);
|
54 |
-
|
55 |
-
$r = json_decode($result, true);
|
56 |
-
|
57 |
-
$return = array();
|
58 |
-
if (isset($r['success']) && $r['success'] == true && isset($r['contactIds']) && is_array($r['contactIds'])) {
|
59 |
-
foreach ($r['contactIds'] as $key => $value) {
|
60 |
-
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($key);
|
61 |
-
try {
|
62 |
-
$return[$key]['msg'] = 'Successfully added';
|
63 |
-
$customer->setData('salesmanago_contact_id', $value)->save();
|
64 |
-
} catch (Exception $e) {
|
65 |
-
$return[$key]['msg'] = 'Upsert error';
|
66 |
-
Mage::log($e->getMessage());
|
67 |
-
}
|
68 |
-
}
|
69 |
-
} else {
|
70 |
-
$return['msg'] = 'BatchUpsert error';
|
71 |
-
}
|
72 |
-
return $return;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
public function syncAction(){
|
78 |
-
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
79 |
-
if($active == 1) {
|
80 |
-
$key = $this->getRequest()->getParam('key');
|
81 |
-
$action = $this->getRequest()->getParam('action');
|
82 |
-
|
83 |
-
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
84 |
-
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
85 |
-
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
86 |
-
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
87 |
-
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
88 |
-
|
89 |
-
if (isset($key) && isset($apiSecret) && $key == sha1($apiSecret)) {
|
90 |
-
$model = Mage::getModel('tracking/customersync');
|
91 |
-
$collection = $model->getCollection()->addFieldToFilter('status', 0);
|
92 |
-
$dateTime = new DateTime('NOW');
|
93 |
-
|
94 |
-
foreach ($collection as $item) {
|
95 |
-
if (!isset($action) || !ctype_digit($action)) {
|
96 |
-
$action = $item->getAction();
|
97 |
-
}
|
98 |
-
$counter = $item->getCounter();
|
99 |
-
|
100 |
-
if ($counter < 5) {
|
101 |
-
switch ($action) {
|
102 |
-
case 1: //register
|
103 |
-
$customer = Mage::getModel('customer/customer')->load($item->getCustomerId())->getData();
|
104 |
-
$data = $this->_getHelper()->_setCustomerData($customer);
|
105 |
-
|
106 |
-
$r = $this->_getHelper()->salesmanagoContactSync($data);
|
107 |
-
|
108 |
-
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
109 |
-
try {
|
110 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
111 |
-
} catch (Exception $e) {
|
112 |
-
Mage::log($e->getMessage());
|
113 |
-
}
|
114 |
-
} elseif (isset($r['success']) && $r['success'] == true) {
|
115 |
-
try {
|
116 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
117 |
-
} catch (Exception $e) {
|
118 |
-
Mage::log($e->getMessage());
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
break;
|
123 |
-
case 2: //login
|
124 |
-
$customer = Mage::getModel('customer/customer')->load($item->getCustomerId())->getData();
|
125 |
-
|
126 |
-
if (!isset($customer['salesmanago_contact_id']) || empty($customer['salesmanago_contact_id'])) {
|
127 |
-
$data = $this->_getHelper()->_setCustomerData($customer);
|
128 |
-
|
129 |
-
$r = $this->_getHelper()->salesmanagoContactSync($data);
|
130 |
-
|
131 |
-
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
132 |
-
try {
|
133 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
134 |
-
} catch (Exception $e) {
|
135 |
-
Mage::log($e->getMessage());
|
136 |
-
}
|
137 |
-
} elseif (isset($r['success']) && $r['success'] == true) {
|
138 |
-
try {
|
139 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
140 |
-
} catch (Exception $e) {
|
141 |
-
Mage::log($e->getMessage());
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}
|
145 |
-
break;
|
146 |
-
case 3: //order purchase
|
147 |
-
$orderId = $item->getOrderId();
|
148 |
-
$orderDetails = Mage::getModel('sales/order')->load($orderId);
|
149 |
-
|
150 |
-
$r = $this->_getHelper()->salesmanagoOrderSync($orderDetails);
|
151 |
-
|
152 |
-
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
153 |
-
try {
|
154 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
155 |
-
} catch (Exception $e) {
|
156 |
-
Mage::log($e->getMessage());
|
157 |
-
}
|
158 |
-
} elseif (isset($r['success']) && $r['success'] == true) {
|
159 |
-
try {
|
160 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
161 |
-
} catch (Exception $e) {
|
162 |
-
Mage::log($e->getMessage());
|
163 |
-
}
|
164 |
-
}
|
165 |
-
break;
|
166 |
-
case 4: //newsletter subscribe / unsubscribe
|
167 |
-
$status = Mage::getModel('newsletter/subscriber')->loadByEmail($item->getEmail())->isSubscribed();
|
168 |
-
|
169 |
-
$apiKey = md5(time() . $apiSecret);
|
170 |
-
|
171 |
-
$data_to_json = array(
|
172 |
-
'apiKey' => $apiKey,
|
173 |
-
'clientId' => $clientId,
|
174 |
-
'requestTime' => time(),
|
175 |
-
'email' => $item->getEmail(),
|
176 |
-
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
177 |
-
'owner' => $ownerEmail,
|
178 |
-
);
|
179 |
-
|
180 |
-
if ($status) {
|
181 |
-
$data_to_json['forceOptIn'] = true;
|
182 |
-
} else {
|
183 |
-
$data_to_json['forceOptOut'] = true;
|
184 |
-
}
|
185 |
-
|
186 |
-
$json = json_encode($data_to_json);
|
187 |
-
$result = $this->_do_post_request('https://' . $endPoint . '/api/contact/update', $json);
|
188 |
-
|
189 |
-
$r = json_decode($result, true);
|
190 |
-
|
191 |
-
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
192 |
-
try {
|
193 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
194 |
-
} catch (Exception $e) {
|
195 |
-
Mage::log($e->getMessage());
|
196 |
-
}
|
197 |
-
} elseif (isset($r['success']) && $r['success'] == true) {
|
198 |
-
try {
|
199 |
-
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
200 |
-
} catch (Exception $e) {
|
201 |
-
Mage::log($e->getMessage());
|
202 |
-
}
|
203 |
-
}
|
204 |
-
break;
|
205 |
-
default:
|
206 |
-
break;
|
207 |
-
}
|
208 |
-
}
|
209 |
-
}
|
210 |
-
}
|
211 |
-
}
|
212 |
-
}
|
213 |
-
|
214 |
-
private function _do_post_request($url, $data) {
|
215 |
-
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
216 |
-
if($active == 1) {
|
217 |
-
$connection_timeout = Mage::getStoreConfig('salesmanago_tracking/general/connection_timeout');
|
218 |
-
|
219 |
-
$ch = curl_init($url);
|
220 |
-
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
221 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
222 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
223 |
-
if (isset($connection_timeout) && !empty($connection_timeout)) {
|
224 |
-
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $connection_timeout);
|
225 |
-
}
|
226 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
|
227 |
-
|
228 |
-
$result = curl_exec($ch);
|
229 |
-
|
230 |
-
if (curl_errno($ch) > 0) {
|
231 |
-
if (curl_errno($ch) == 28) {
|
232 |
-
Mage::log("TIMEOUT ERROR NO: " . curl_errno($ch));
|
233 |
-
} else {
|
234 |
-
Mage::log("ERROR NO: " . curl_errno($ch));
|
235 |
-
}
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
|
239 |
-
return $result;
|
240 |
-
}
|
241 |
-
}
|
242 |
}
|
1 |
+
<?php
|
2 |
+
class SalesManago_Tracking_CustomerController extends Mage_Core_Controller_Front_Action{
|
3 |
+
|
4 |
+
protected function _getHelper(){
|
5 |
+
return Mage::helper('tracking');
|
6 |
+
}
|
7 |
+
|
8 |
+
public function exportAction(){
|
9 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
10 |
+
if($active == 1) {
|
11 |
+
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
12 |
+
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
13 |
+
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
14 |
+
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
15 |
+
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
16 |
+
|
17 |
+
$key = $this->getRequest()->getParam('key');
|
18 |
+
|
19 |
+
if (isset($key) && isset($apiSecret) && $key == sha1($apiSecret)) {
|
20 |
+
|
21 |
+
$apiKey = md5(time() . $apiSecret);
|
22 |
+
|
23 |
+
$data_to_json = array(
|
24 |
+
'apiKey' => $apiKey,
|
25 |
+
'clientId' => $clientId,
|
26 |
+
'requestTime' => time(),
|
27 |
+
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
28 |
+
|
29 |
+
'upsertDetails' => array(),
|
30 |
+
'owner' => $ownerEmail,
|
31 |
+
);
|
32 |
+
|
33 |
+
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
|
34 |
+
|
35 |
+
$i = 0;
|
36 |
+
foreach ($collection as $item) {
|
37 |
+
if (!isset($item['salesmanago_contact_id']) || empty($item['salesmanago_contact_id']) || $item['salesmanago_contact_id'] == 0) {
|
38 |
+
$status = Mage::getModel('newsletter/subscriber')->loadByEmail($item['email'])->isSubscribed();
|
39 |
+
|
40 |
+
if ($status) {
|
41 |
+
$data_to_json['upsertDetails'][$i]['forceOptIn'] = true;
|
42 |
+
} else {
|
43 |
+
$data_to_json['upsertDetails'][$i]['forceOptOut'] = true;
|
44 |
+
}
|
45 |
+
$data_to_json['upsertDetails'][$i]['contact']['email'] = $item['email'];
|
46 |
+
$data_to_json['upsertDetails'][$i]['contact']['name'] = $item['firstname'] . ' ' . $item['lastname'];
|
47 |
+
|
48 |
+
$i++;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
$json = json_encode($data_to_json);
|
53 |
+
$result = $this->_do_post_request('https://' . $endPoint . '/api/contact/batchupsert', $json);
|
54 |
+
|
55 |
+
$r = json_decode($result, true);
|
56 |
+
|
57 |
+
$return = array();
|
58 |
+
if (isset($r['success']) && $r['success'] == true && isset($r['contactIds']) && is_array($r['contactIds'])) {
|
59 |
+
foreach ($r['contactIds'] as $key => $value) {
|
60 |
+
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($key);
|
61 |
+
try {
|
62 |
+
$return[$key]['msg'] = 'Successfully added';
|
63 |
+
$customer->setData('salesmanago_contact_id', $value)->save();
|
64 |
+
} catch (Exception $e) {
|
65 |
+
$return[$key]['msg'] = 'Upsert error';
|
66 |
+
Mage::log($e->getMessage());
|
67 |
+
}
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
$return['msg'] = 'BatchUpsert error';
|
71 |
+
}
|
72 |
+
return $return;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
public function syncAction(){
|
78 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
79 |
+
if($active == 1) {
|
80 |
+
$key = $this->getRequest()->getParam('key');
|
81 |
+
$action = $this->getRequest()->getParam('action');
|
82 |
+
|
83 |
+
$clientId = Mage::getStoreConfig('salesmanago_tracking/general/client_id');
|
84 |
+
$apiSecret = Mage::getStoreConfig('salesmanago_tracking/general/api_secret');
|
85 |
+
$ownerEmail = Mage::getStoreConfig('salesmanago_tracking/general/email');
|
86 |
+
$tags = Mage::getStoreConfig('salesmanago_tracking/general/tags');
|
87 |
+
$endPoint = Mage::getStoreConfig('salesmanago_tracking/general/endpoint');
|
88 |
+
|
89 |
+
if (isset($key) && isset($apiSecret) && $key == sha1($apiSecret)) {
|
90 |
+
$model = Mage::getModel('tracking/customersync');
|
91 |
+
$collection = $model->getCollection()->addFieldToFilter('status', 0);
|
92 |
+
$dateTime = new DateTime('NOW');
|
93 |
+
|
94 |
+
foreach ($collection as $item) {
|
95 |
+
if (!isset($action) || !ctype_digit($action)) {
|
96 |
+
$action = $item->getAction();
|
97 |
+
}
|
98 |
+
$counter = $item->getCounter();
|
99 |
+
|
100 |
+
if ($counter < 5) {
|
101 |
+
switch ($action) {
|
102 |
+
case 1: //register
|
103 |
+
$customer = Mage::getModel('customer/customer')->load($item->getCustomerId())->getData();
|
104 |
+
$data = $this->_getHelper()->_setCustomerData($customer);
|
105 |
+
|
106 |
+
$r = $this->_getHelper()->salesmanagoContactSync($data);
|
107 |
+
|
108 |
+
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
109 |
+
try {
|
110 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
111 |
+
} catch (Exception $e) {
|
112 |
+
Mage::log($e->getMessage());
|
113 |
+
}
|
114 |
+
} elseif (isset($r['success']) && $r['success'] == true) {
|
115 |
+
try {
|
116 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
117 |
+
} catch (Exception $e) {
|
118 |
+
Mage::log($e->getMessage());
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
break;
|
123 |
+
case 2: //login
|
124 |
+
$customer = Mage::getModel('customer/customer')->load($item->getCustomerId())->getData();
|
125 |
+
|
126 |
+
if (!isset($customer['salesmanago_contact_id']) || empty($customer['salesmanago_contact_id'])) {
|
127 |
+
$data = $this->_getHelper()->_setCustomerData($customer);
|
128 |
+
|
129 |
+
$r = $this->_getHelper()->salesmanagoContactSync($data);
|
130 |
+
|
131 |
+
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
132 |
+
try {
|
133 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
134 |
+
} catch (Exception $e) {
|
135 |
+
Mage::log($e->getMessage());
|
136 |
+
}
|
137 |
+
} elseif (isset($r['success']) && $r['success'] == true) {
|
138 |
+
try {
|
139 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
140 |
+
} catch (Exception $e) {
|
141 |
+
Mage::log($e->getMessage());
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
break;
|
146 |
+
case 3: //order purchase
|
147 |
+
$orderId = $item->getOrderId();
|
148 |
+
$orderDetails = Mage::getModel('sales/order')->load($orderId);
|
149 |
+
|
150 |
+
$r = $this->_getHelper()->salesmanagoOrderSync($orderDetails);
|
151 |
+
|
152 |
+
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
153 |
+
try {
|
154 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
155 |
+
} catch (Exception $e) {
|
156 |
+
Mage::log($e->getMessage());
|
157 |
+
}
|
158 |
+
} elseif (isset($r['success']) && $r['success'] == true) {
|
159 |
+
try {
|
160 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
161 |
+
} catch (Exception $e) {
|
162 |
+
Mage::log($e->getMessage());
|
163 |
+
}
|
164 |
+
}
|
165 |
+
break;
|
166 |
+
case 4: //newsletter subscribe / unsubscribe
|
167 |
+
$status = Mage::getModel('newsletter/subscriber')->loadByEmail($item->getEmail())->isSubscribed();
|
168 |
+
|
169 |
+
$apiKey = md5(time() . $apiSecret);
|
170 |
+
|
171 |
+
$data_to_json = array(
|
172 |
+
'apiKey' => $apiKey,
|
173 |
+
'clientId' => $clientId,
|
174 |
+
'requestTime' => time(),
|
175 |
+
'email' => $item->getEmail(),
|
176 |
+
'sha' => sha1($apiKey . $clientId . $apiSecret),
|
177 |
+
'owner' => $ownerEmail,
|
178 |
+
);
|
179 |
+
|
180 |
+
if ($status) {
|
181 |
+
$data_to_json['forceOptIn'] = true;
|
182 |
+
} else {
|
183 |
+
$data_to_json['forceOptOut'] = true;
|
184 |
+
}
|
185 |
+
|
186 |
+
$json = json_encode($data_to_json);
|
187 |
+
$result = $this->_do_post_request('https://' . $endPoint . '/api/contact/update', $json);
|
188 |
+
|
189 |
+
$r = json_decode($result, true);
|
190 |
+
|
191 |
+
if ($r == false || (isset($r['success']) && $r['success'] == false)) {
|
192 |
+
try {
|
193 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setId($item->getCustomerSyncId())->save();
|
194 |
+
} catch (Exception $e) {
|
195 |
+
Mage::log($e->getMessage());
|
196 |
+
}
|
197 |
+
} elseif (isset($r['success']) && $r['success'] == true) {
|
198 |
+
try {
|
199 |
+
$model->load($item->getCustomerSyncId())->setCounter($counter + 1)->setUpdateTime($dateTime->format('c'))->setStatus(1)->setId($item->getCustomerSyncId())->save();
|
200 |
+
} catch (Exception $e) {
|
201 |
+
Mage::log($e->getMessage());
|
202 |
+
}
|
203 |
+
}
|
204 |
+
break;
|
205 |
+
default:
|
206 |
+
break;
|
207 |
+
}
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
private function _do_post_request($url, $data) {
|
215 |
+
$active = Mage::getStoreConfig('salesmanago_tracking/general/active');
|
216 |
+
if($active == 1) {
|
217 |
+
$connection_timeout = Mage::getStoreConfig('salesmanago_tracking/general/connection_timeout');
|
218 |
+
|
219 |
+
$ch = curl_init($url);
|
220 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
221 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
222 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
223 |
+
if (isset($connection_timeout) && !empty($connection_timeout)) {
|
224 |
+
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $connection_timeout);
|
225 |
+
}
|
226 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
|
227 |
+
|
228 |
+
$result = curl_exec($ch);
|
229 |
+
|
230 |
+
if (curl_errno($ch) > 0) {
|
231 |
+
if (curl_errno($ch) == 28) {
|
232 |
+
Mage::log("TIMEOUT ERROR NO: " . curl_errno($ch));
|
233 |
+
} else {
|
234 |
+
Mage::log("ERROR NO: " . curl_errno($ch));
|
235 |
+
}
|
236 |
+
return false;
|
237 |
+
}
|
238 |
+
|
239 |
+
return $result;
|
240 |
+
}
|
241 |
+
}
|
242 |
}
|
app/code/community/SalesManago/Tracking/controllers/Newsletter/SubscriberController.php
CHANGED
File without changes
|
app/code/community/SalesManago/Tracking/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SalesManago_Tracking>
|
5 |
-
<version>
|
6 |
</SalesManago_Tracking>
|
7 |
</modules>
|
8 |
|
@@ -81,35 +81,24 @@
|
|
81 |
</salesmanago_tracking_observer>
|
82 |
</observers>
|
83 |
</checkout_cart_save_after>
|
84 |
-
|
85 |
-
<customer_address_save_commit_after>
|
86 |
-
<observers>
|
87 |
-
<salesmanago_tracking_observer>
|
88 |
-
<type>singleton</type>
|
89 |
-
<class>SalesManago_Tracking_Model_Observer</class>
|
90 |
-
<method>customer_data_edit</method>
|
91 |
-
</salesmanago_tracking_observer>
|
92 |
-
</observers>
|
93 |
-
</customer_address_save_commit_after>
|
94 |
-
<admin_system_config_changed_section_salesmanago_tracking>
|
95 |
<observers>
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
</
|
103 |
-
|
104 |
-
<wishlist_product_add_after>
|
105 |
<observers>
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
</
|
113 |
</events>
|
114 |
|
115 |
<helpers>
|
@@ -120,7 +109,7 @@
|
|
120 |
|
121 |
<blocks>
|
122 |
<tracking>
|
123 |
-
<class>SalesManago_Tracking_Block</class>
|
124 |
</tracking>
|
125 |
</blocks>
|
126 |
|
@@ -175,20 +164,11 @@
|
|
175 |
</routers>
|
176 |
</frontend>
|
177 |
<adminhtml>
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
<files>
|
182 |
-
<default>Salesmanago_Tracking.csv</default>
|
183 |
-
</files>
|
184 |
-
</SalesManago_Tracking>
|
185 |
-
</modules>
|
186 |
-
</translate>
|
187 |
-
<acl>
|
188 |
-
<resources>
|
189 |
-
<all>
|
190 |
<title>Allow Everything</title>
|
191 |
-
|
192 |
<admin>
|
193 |
<children>
|
194 |
<system>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SalesManago_Tracking>
|
5 |
+
<version>0.0.8</version>
|
6 |
</SalesManago_Tracking>
|
7 |
</modules>
|
8 |
|
81 |
</salesmanago_tracking_observer>
|
82 |
</observers>
|
83 |
</checkout_cart_save_after>
|
84 |
+
<wishlist_item_collection_products_after_load>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
<observers>
|
86 |
+
<salesmanago_tracking_observer>
|
87 |
+
<type>singleton</type>
|
88 |
+
<class>SalesManago_Tracking_Model_Observer</class>
|
89 |
+
<method>wishlist_item_collection_products_after_load</method>
|
90 |
+
</salesmanago_tracking_observer>
|
91 |
+
</observers>
|
92 |
+
</wishlist_item_collection_products_after_load>
|
93 |
+
<review_save_after>
|
|
|
94 |
<observers>
|
95 |
+
<salesmanago_tracking_observer>
|
96 |
+
<type>singleton</type>
|
97 |
+
<class>SalesManago_Tracking_Model_Observer</class>
|
98 |
+
<method>review_save_after</method>
|
99 |
+
</salesmanago_tracking_observer>
|
100 |
+
</observers>
|
101 |
+
</review_save_after>
|
102 |
</events>
|
103 |
|
104 |
<helpers>
|
109 |
|
110 |
<blocks>
|
111 |
<tracking>
|
112 |
+
<class>SalesManago_Tracking_Block</class>
|
113 |
</tracking>
|
114 |
</blocks>
|
115 |
|
164 |
</routers>
|
165 |
</frontend>
|
166 |
<adminhtml>
|
167 |
+
<acl>
|
168 |
+
<resources>
|
169 |
+
<all>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
<title>Allow Everything</title>
|
171 |
+
</all>
|
172 |
<admin>
|
173 |
<children>
|
174 |
<system>
|
app/code/community/SalesManago/Tracking/etc/system.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
</tabs>
|
9 |
<sections>
|
10 |
<salesmanago_tracking translate="label" module="tracking">
|
11 |
-
<label>
|
12 |
<tab>salesmanago</tab>
|
13 |
<frontend_type>text</frontend_type>
|
14 |
<sort_order>10</sort_order>
|
@@ -17,7 +17,7 @@
|
|
17 |
<show_in_store>1</show_in_store>
|
18 |
<groups>
|
19 |
<general translate="label" module="tracking">
|
20 |
-
<label>
|
21 |
<sort_order>800</sort_order>
|
22 |
<show_in_default>1</show_in_default>
|
23 |
<show_in_website>1</show_in_website>
|
@@ -33,7 +33,7 @@
|
|
33 |
<show_in_store>1</show_in_store>
|
34 |
</client_id>
|
35 |
<api_secret translate="label">
|
36 |
-
<label>
|
37 |
<frontend_type>text</frontend_type>
|
38 |
<sort_order>20</sort_order>
|
39 |
<show_in_default>1</show_in_default>
|
@@ -41,7 +41,7 @@
|
|
41 |
<show_in_store>1</show_in_store>
|
42 |
</api_secret>
|
43 |
<email translate="label">
|
44 |
-
<label>
|
45 |
<frontend_type>text</frontend_type>
|
46 |
<sort_order>30</sort_order>
|
47 |
<show_in_default>1</show_in_default>
|
@@ -49,44 +49,26 @@
|
|
49 |
<show_in_store>1</show_in_store>
|
50 |
</email>
|
51 |
<endpoint translate="label">
|
52 |
-
<label>End point
|
53 |
<frontend_type>text</frontend_type>
|
54 |
<sort_order>40</sort_order>
|
55 |
<show_in_default>1</show_in_default>
|
56 |
<show_in_website>1</show_in_website>
|
57 |
<show_in_store>1</show_in_store>
|
58 |
</endpoint>
|
59 |
-
<
|
60 |
-
<label>
|
61 |
<frontend_type>text</frontend_type>
|
62 |
<sort_order>50</sort_order>
|
63 |
<show_in_default>1</show_in_default>
|
64 |
<show_in_website>1</show_in_website>
|
65 |
<show_in_store>1</show_in_store>
|
66 |
-
<comment>
|
67 |
-
</
|
68 |
-
<tagsRegistration translate="label">
|
69 |
-
<label>Sign up tag</label>
|
70 |
-
<frontend_type>text</frontend_type>
|
71 |
-
<sort_order>51</sort_order>
|
72 |
-
<show_in_default>1</show_in_default>
|
73 |
-
<show_in_website>1</show_in_website>
|
74 |
-
<show_in_store>1</show_in_store>
|
75 |
-
<comment>If you want to use more tags, separate them with a comma</comment>
|
76 |
-
</tagsRegistration>
|
77 |
-
<tagsPurchase translate="label">
|
78 |
-
<label>Purchase tag</label>
|
79 |
-
<frontend_type>text</frontend_type>
|
80 |
-
<sort_order>60</sort_order>
|
81 |
-
<show_in_default>1</show_in_default>
|
82 |
-
<show_in_website>1</show_in_website>
|
83 |
-
<show_in_store>1</show_in_store>
|
84 |
-
<comment>If you want to use more tags, separate them with a comma</comment>
|
85 |
-
</tagsPurchase>
|
86 |
<additional_js translate="label">
|
87 |
-
<label>
|
88 |
<frontend_type>text</frontend_type>
|
89 |
-
<sort_order>
|
90 |
<show_in_default>1</show_in_default>
|
91 |
<show_in_website>1</show_in_website>
|
92 |
<show_in_store>1</show_in_store>
|
@@ -94,11 +76,11 @@
|
|
94 |
<connection_timeout translate="label">
|
95 |
<label>Connection Timeout</label>
|
96 |
<frontend_type>text</frontend_type>
|
97 |
-
<sort_order>
|
98 |
<show_in_default>1</show_in_default>
|
99 |
<show_in_website>1</show_in_website>
|
100 |
<show_in_store>1</show_in_store>
|
101 |
-
<comment>
|
102 |
</connection_timeout>
|
103 |
<active translate="label">
|
104 |
<label>Enabled</label>
|
8 |
</tabs>
|
9 |
<sections>
|
10 |
<salesmanago_tracking translate="label" module="tracking">
|
11 |
+
<label>General</label>
|
12 |
<tab>salesmanago</tab>
|
13 |
<frontend_type>text</frontend_type>
|
14 |
<sort_order>10</sort_order>
|
17 |
<show_in_store>1</show_in_store>
|
18 |
<groups>
|
19 |
<general translate="label" module="tracking">
|
20 |
+
<label>General</label>
|
21 |
<sort_order>800</sort_order>
|
22 |
<show_in_default>1</show_in_default>
|
23 |
<show_in_website>1</show_in_website>
|
33 |
<show_in_store>1</show_in_store>
|
34 |
</client_id>
|
35 |
<api_secret translate="label">
|
36 |
+
<label>Api secret</label>
|
37 |
<frontend_type>text</frontend_type>
|
38 |
<sort_order>20</sort_order>
|
39 |
<show_in_default>1</show_in_default>
|
41 |
<show_in_store>1</show_in_store>
|
42 |
</api_secret>
|
43 |
<email translate="label">
|
44 |
+
<label>E-mail</label>
|
45 |
<frontend_type>text</frontend_type>
|
46 |
<sort_order>30</sort_order>
|
47 |
<show_in_default>1</show_in_default>
|
49 |
<show_in_store>1</show_in_store>
|
50 |
</email>
|
51 |
<endpoint translate="label">
|
52 |
+
<label>End point</label>
|
53 |
<frontend_type>text</frontend_type>
|
54 |
<sort_order>40</sort_order>
|
55 |
<show_in_default>1</show_in_default>
|
56 |
<show_in_website>1</show_in_website>
|
57 |
<show_in_store>1</show_in_store>
|
58 |
</endpoint>
|
59 |
+
<tags translate="label">
|
60 |
+
<label>Tags</label>
|
61 |
<frontend_type>text</frontend_type>
|
62 |
<sort_order>50</sort_order>
|
63 |
<show_in_default>1</show_in_default>
|
64 |
<show_in_website>1</show_in_website>
|
65 |
<show_in_store>1</show_in_store>
|
66 |
+
<comment>Next tags paste followed by coma</comment>
|
67 |
+
</tags>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
<additional_js translate="label">
|
69 |
+
<label>Additional JS extract</label>
|
70 |
<frontend_type>text</frontend_type>
|
71 |
+
<sort_order>60</sort_order>
|
72 |
<show_in_default>1</show_in_default>
|
73 |
<show_in_website>1</show_in_website>
|
74 |
<show_in_store>1</show_in_store>
|
76 |
<connection_timeout translate="label">
|
77 |
<label>Connection Timeout</label>
|
78 |
<frontend_type>text</frontend_type>
|
79 |
+
<sort_order>70</sort_order>
|
80 |
<show_in_default>1</show_in_default>
|
81 |
<show_in_website>1</show_in_website>
|
82 |
<show_in_store>1</show_in_store>
|
83 |
+
<comment>The maximum waiting period for script performance in miliseconds (optional)</comment>
|
84 |
</connection_timeout>
|
85 |
<active translate="label">
|
86 |
<label>Enabled</label>
|
app/code/community/SalesManago/Tracking/sql/tracking_setup/mysql4-install-0.0.4.php
CHANGED
File without changes
|
app/design/frontend/base/default/layout/salesmanago.xml
CHANGED
File without changes
|
app/design/frontend/base/default/template/salesmanago/tracking/tracking.phtml
CHANGED
@@ -4,25 +4,26 @@
|
|
4 |
$client_salesmanago_id = $this->getClientSalesManagoId();
|
5 |
$additional_js = $this->getAdditionalJs();
|
6 |
$active = $this -> isActive();
|
7 |
-
|
8 |
-
if($active == 1 && !empty($client_id) && !empty($endpoint)){
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
?>
|
4 |
$client_salesmanago_id = $this->getClientSalesManagoId();
|
5 |
$additional_js = $this->getAdditionalJs();
|
6 |
$active = $this -> isActive();
|
7 |
+
|
8 |
+
if($active == 1 && !empty($client_id) && !empty($endpoint)){
|
9 |
+
$trackingScript = "<script type='text/javascript'>\n";
|
10 |
+
$trackingScript .= "\tvar _smid = '".$client_id."';\n";
|
11 |
+
if(isset($additional_js) && !empty($additional_js)){
|
12 |
+
$trackingScript .= "\t".$additional_js."\n";
|
13 |
+
}
|
14 |
+
if($client_salesmanago_id){
|
15 |
+
$trackingScript .= "\tvar _smclientid = '".$client_salesmanago_id."';\n";
|
16 |
+
}
|
17 |
+
$trackingScript .= "\t(function () {\n";
|
18 |
+
$trackingScript .= "\t\tvar sm = document.createElement('script');\n";
|
19 |
+
$trackingScript .= "\t\tsm.type = 'text/javascript';\n";
|
20 |
+
$trackingScript .= "\t\tsm.async = true;\n";
|
21 |
+
$trackingScript .= "\t\tsm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '".$endpoint."/static/sm.js';\n";
|
22 |
+
$trackingScript .= "\t\tvar s = document.getElementsByTagName('script')[0];\n";
|
23 |
+
$trackingScript .= "\t\ts.parentNode.insertBefore(sm, s);\n";
|
24 |
+
$trackingScript .= "\t})();\n";
|
25 |
+
$trackingScript .= "</script>\n";
|
26 |
+
|
27 |
+
echo $trackingScript;
|
28 |
+
}
|
29 |
?>
|
app/design/frontend/default/default/layout/salesmanago.xml
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<default>
|
4 |
-
<reference name="head">
|
5 |
-
<block type="tracking/layer" name="salesmanago_tracking">
|
6 |
-
<action method="setTemplate"><template>salesmanago/tracking/tracking.phtml</template></action>
|
7 |
-
</block>
|
8 |
-
</reference>
|
9 |
-
</default>
|
10 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/template/salesmanago/tracking/tracking.phtml
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$client_id = $this->getClientId();
|
3 |
-
$endpoint = $this->getEndPoint();
|
4 |
-
$client_salesmanago_id = $this->getClientSalesManagoId();
|
5 |
-
$additional_js = $this->getAdditionalJs();
|
6 |
-
$active = $this -> isActive();
|
7 |
-
|
8 |
-
if($active == 1 && !empty($client_id) && !empty($endpoint)){
|
9 |
-
$trackingScript = "<script type='text/javascript'>\n";
|
10 |
-
$trackingScript .= "\tvar _smid = '".$client_id."';\n";
|
11 |
-
if(isset($additional_js) && !empty($additional_js)){
|
12 |
-
$trackingScript .= "\t".$additional_js."\n";
|
13 |
-
}
|
14 |
-
if($client_salesmanago_id){
|
15 |
-
$trackingScript .= "\tvar _smclientid = '".$client_salesmanago_id."';\n";
|
16 |
-
}
|
17 |
-
$trackingScript .= "\t(function(w, r, a, sm, s ) {\n";
|
18 |
-
$trackingScript .= "\t\tw['SalesmanagoObject'] = r;\n";
|
19 |
-
$trackingScript .= "\t\tw[r] = w[r] || function () {( w[r].q = w[r].q || [] ).push(arguments)};\n";
|
20 |
-
$trackingScript .= "\t\tsm = document.createElement('script'); sm.type = 'text/javascript'; sm.async = true; sm.src = a;\n";
|
21 |
-
$trackingScript .= "\t\ts = document.getElementsByTagName('script')[0];\n";
|
22 |
-
$trackingScript .= "\t\ts.parentNode.insertBefore(sm, s);\n";
|
23 |
-
$trackingScript .= "\t\t})(window, 'sm', ('https:' == document.location.protocol ? 'https://' : 'http://') + '".$endpoint."/static/sm.js');\n";
|
24 |
-
$trackingScript .= "</script>\n";
|
25 |
-
|
26 |
-
echo $trackingScript;
|
27 |
-
}
|
28 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/SalesManago_Tracking.xml
CHANGED
File without changes
|
app/locale/de_DE/Salesmanago_Tracking.csv
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
"Connector settings","Verbindungseinstellungen"
|
2 |
-
"SalesManago_Tracking::Enabled","Freigeschaltet"
|
3 |
-
"Yes","Ja"
|
4 |
-
"No","Nein"
|
5 |
-
"Client ID","Kundennummer"
|
6 |
-
"API secret code","API Geheimnis"
|
7 |
-
"Main owner E-mail","Main owner E-mail"
|
8 |
-
"End point address","Endpunkt adresse"
|
9 |
-
"Newsletter subscription tags","Newsletter abonnement tag"
|
10 |
-
"Sign up tag","Anmelde tag"
|
11 |
-
"Purchase tag","Kauf tag"
|
12 |
-
"Custom JS code","Angepaster JS code"
|
13 |
-
"Connection Timeout","Verbindungsfehler"
|
14 |
-
"If you want to use more tags, separate them with a comma","Wenn Sie mehr Label (tag) nutzen möchten, trennen Sie diese durch Kommas"
|
15 |
-
"Limit the maximum execution time in ms (optional)","Limieteren Sie die maximale Ausfürungszeit ms (fakultativ)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/locale/es_ES/Salesmanago_Tracking.csv
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
"Connector settings","Ajustes o configuración del conector"
|
2 |
-
"SalesManago_Tracking::Enabled","Habilitado"
|
3 |
-
"Yes","Sí"
|
4 |
-
"No","No"
|
5 |
-
"Client ID","ID del Cliente"
|
6 |
-
"API secret code","API secret code"
|
7 |
-
"Main owner E-mail","Main owner E-mail"
|
8 |
-
"End point address","End point address"
|
9 |
-
"Newsletter subscription tags","Etiqueta de suscripción a newsletter"
|
10 |
-
"Sign up tag","Etiqueta de suscripción"
|
11 |
-
"Purchase tag","Etiqueta de compra"
|
12 |
-
"Custom JS code","Código JS personalizado"
|
13 |
-
"Connection Timeout","El tiempo de conexión expiro"
|
14 |
-
"If you want to use more tags, separate them with a comma","Si necesitas usar mas etiquetas, Separarlas con comas"
|
15 |
-
"Limit the maximum execution time in ms (optional)","Limitar el tiempo máximo de ejecución en ms (opcional)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/locale/pl_PL/Salesmanago_Tracking.csv
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
"Connector settings","Ustawienia Wtyczki"
|
2 |
-
"SalesManago_Tracking::Enabled","Włączona"
|
3 |
-
"Yes","Tak"
|
4 |
-
"No","Nie"
|
5 |
-
"Client ID","ID klienta"
|
6 |
-
"API secret code","Kod Api secret"
|
7 |
-
"Main owner E-mail","E-mail właściciela"
|
8 |
-
"End point address","Endpoint"
|
9 |
-
"Newsletter subscription tags","Tagi newsletter"
|
10 |
-
"Sign up tag","Tagi rejestracji"
|
11 |
-
"Purchase tag","Tagi zakupu"
|
12 |
-
"Custom JS code","Dodatkowy fragment JS"
|
13 |
-
"Connection Timeout","Czas wykonywania skryptu"
|
14 |
-
"If you want to use more tags, separate them with a comma","Kolejne tagi wpisuj po przecinku"
|
15 |
-
"Limit the maximum execution time in ms (optional)","Maksymalny czas oczekiwania na wykonanie skryptu w milisekundach (opcjonalnie)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/locale/ru_RU/Salesmanago_Tracking.csv
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
"Connector settings","Настройка связки"
|
2 |
-
"SalesManago_Tracking::Enabled","Включен"
|
3 |
-
"Yes","да"
|
4 |
-
"No","Нет"
|
5 |
-
"Client ID","ИН клиента"
|
6 |
-
"API secret code","API secret code"
|
7 |
-
"Main owner E-mail","Емейл"
|
8 |
-
"End point address","End point address"
|
9 |
-
"Newsletter subscription tags","Тег подписки на рассылку"
|
10 |
-
"Sign up tag","Тег регестрации"
|
11 |
-
"Purchase tag","Тег покупки"
|
12 |
-
"Custom JS code","Пользовательский JS-код"
|
13 |
-
"Connection Timeout","Время ожидания подключения"
|
14 |
-
"If you want to use more tags, separate them with a comma","Если Вы хотите использовать несколько тегов, разделяйте их запятой"
|
15 |
-
"Limit the maximum execution time in ms (optional)","Лимит максимального времени выполнения в ms (дополнительно) "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,111 +1,18 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<package>
|
3 |
-
<name>SALESmanago</name>
|
4 |
-
<version>1.
|
5 |
-
<stability>stable</stability>
|
6 |
-
<license>ASL</license>
|
7 |
-
<channel>community</channel>
|
8 |
-
<extends/>
|
9 |
-
<summary>SALESmanago Marketing Automation integration.</summary>
|
10 |
-
<description>SALESmanago Marketing Automation integration.</description>
|
11 |
-
<notes>SALESmanago Marketing Automation integration.</notes>
|
12 |
-
<authors><author><name>Benhauer Sp. z o.o. Sp. K.</name><user>SalesManago</user><email>info@salesmanago.pl</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents>
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
<dir name="Block">
|
20 |
-
<file name="Layer.php" hash="5564c2dfb2cd62ea3d2f9cba11722718"/>
|
21 |
-
</dir>
|
22 |
-
<dir name="Helper">
|
23 |
-
<file name="Data.php" hash="11f51fb7782d47b1d0245ac43fb5962c"/>
|
24 |
-
</dir>
|
25 |
-
<dir name="Model">
|
26 |
-
<file name="Customersync.php" hash="c2535f600d93d711fc67324bf786b576"/>
|
27 |
-
<file name="Observer.php" hash="9a75d0f9550f24d4ddcb795b31276d27"/>
|
28 |
-
<dir name="Resource">
|
29 |
-
<dir name="Customersync">
|
30 |
-
<file name="Collection.php" hash="660921ec631893a685e0cacd4b9d07ef"/>
|
31 |
-
</dir>
|
32 |
-
<file name="Customersync.php" hash="3f6789e8568fb496e65d23cd6b8c3794"/>
|
33 |
-
<file name="Setup.php" hash="f196f0e7972b723dfaeecaea7ea0a0ee"/>
|
34 |
-
</dir>
|
35 |
-
</dir>
|
36 |
-
<dir name="controllers">
|
37 |
-
<file name="CustomerController.php" hash="c0154d7e55d551e1e0c1e8bed796e32e"/>
|
38 |
-
<dir name="Newsletter">
|
39 |
-
<file name="SubscriberController.php" hash="e683bda792cd39c11c40ad77d3b1a18e"/>
|
40 |
-
</dir>
|
41 |
-
</dir>
|
42 |
-
<dir name="etc">
|
43 |
-
<file name="config.xml" hash="d12c4b7723ad2ff49ffca0b2ccdb3460"/>
|
44 |
-
<file name="system.xml" hash="b0db5f4d20cd98eef017b1da798e59cd"/>
|
45 |
-
</dir><dir name="sql">
|
46 |
-
<dir name="tracking_setup">
|
47 |
-
<file name="mysql4-install-0.0.4.php" hash="efbe2ef2e234e72f8cfb61b02cd79fd8"/>
|
48 |
-
</dir>
|
49 |
-
</dir>
|
50 |
-
</dir>
|
51 |
-
</dir>
|
52 |
-
</target>
|
53 |
-
<target name="mageetc">
|
54 |
-
<dir name="modules">
|
55 |
-
<file name="SalesManago_Tracking.xml" hash="14e6da8fc1550fd46dc56ceea822d648"/>
|
56 |
-
</dir>
|
57 |
-
</target>
|
58 |
-
<target name="magedesign">
|
59 |
-
<dir name="frontend">
|
60 |
-
<dir name="default">
|
61 |
-
<dir name="default">
|
62 |
-
<dir name="layout">
|
63 |
-
<file name="salesmanago.xml" hash="c8d48e529e20472913b844723b0513a6"/>
|
64 |
-
</dir>
|
65 |
-
<dir name="template">
|
66 |
-
<dir name="salesmanago">
|
67 |
-
<dir name="tracking">
|
68 |
-
<file name="tracking.phtml" hash="f39205215f98504187fbfd9e90d477fb"/>
|
69 |
-
</dir>
|
70 |
-
</dir>
|
71 |
-
</dir>
|
72 |
-
</dir>
|
73 |
-
</dir>
|
74 |
-
</dir>
|
75 |
-
</target>
|
76 |
-
<target name="magedesign">
|
77 |
-
<dir name="frontend">
|
78 |
-
<dir name="base">
|
79 |
-
<dir name="default">
|
80 |
-
<dir name="layout">
|
81 |
-
<file name="salesmanago.xml" hash="c8d48e529e20472913b844723b0513a6"/>
|
82 |
-
</dir>
|
83 |
-
<dir name="template">
|
84 |
-
<dir name="salesmanago">
|
85 |
-
<dir name="tracking">
|
86 |
-
<file name="tracking.phtml" hash="f39205215f98504187fbfd9e90d477fb"/>
|
87 |
-
</dir>
|
88 |
-
</dir>
|
89 |
-
</dir>
|
90 |
-
</dir>
|
91 |
-
</dir>
|
92 |
-
</dir>
|
93 |
-
</target>
|
94 |
-
<target name="magelocale">
|
95 |
-
<dir name="de_DE">
|
96 |
-
<file name="Salesmanago_Tracking.csv"/>
|
97 |
-
</dir>
|
98 |
-
<dir name="es_ES">
|
99 |
-
<file name="Salesmanago_Tracking.csv"/>
|
100 |
-
</dir>
|
101 |
-
<dir name="pl_PL">
|
102 |
-
<file name="Salesmanago_Tracking.csv"/>
|
103 |
-
</dir>
|
104 |
-
<dir name="ru_RU">
|
105 |
-
<file name="Salesmanago_Tracking.csv"/>
|
106 |
-
</dir>
|
107 |
-
</target>
|
108 |
-
</contents>
|
109 |
-
<compatible/>
|
110 |
-
<dependencies><required><php><min>5.2.0</min><max>7.2.0</max></php></required></dependencies>
|
111 |
-
</package>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>SALESmanago</name>
|
4 |
+
<version>1.3.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>ASL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>SALESmanago Marketing Automation integration.</summary>
|
10 |
+
<description>SALESmanago Marketing Automation integration.</description>
|
11 |
+
<notes>SALESmanago Marketing Automation integration.</notes>
|
12 |
+
<authors><author><name>Benhauer Sp. z o.o. Sp. K.</name><user>SalesManago</user><email>info@salesmanago.pl</email></author><author><name>Carlos Alonso</name><user>delinaje</user><email>carlos@alonsodelinaje.com</email></author></authors>
|
13 |
+
<date>2016-10-19</date>
|
14 |
+
<time>13:48:37</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="SalesManago"><dir name="Tracking"><dir name="Block"><file name="Layer.php" hash="112b431cd5af7e4bec6722b898a3afe3"/></dir><dir name="Helper"><file name="Data.php" hash="06350d6fd9788f9992de2ca7ed6d41ad"/></dir><dir name="Model"><file name="Customersync.php" hash="c2535f600d93d711fc67324bf786b576"/><file name="Observer.php" hash="9f486ab44ff4a2136934265996943705"/><dir name="Resource"><dir name="Customersync"><file name="Collection.php" hash="660921ec631893a685e0cacd4b9d07ef"/></dir><file name="Customersync.php" hash="3f6789e8568fb496e65d23cd6b8c3794"/><file name="Setup.php" hash="f196f0e7972b723dfaeecaea7ea0a0ee"/></dir></dir><dir name="controllers"><file name="CustomerController.php" hash="8f45dfe0ab7e33ce6801f58ca8576c52"/><dir name="Newsletter"><file name="SubscriberController.php" hash="790674d2e1a9aab3d0f795688d107cd5"/></dir></dir><dir name="etc"><file name="config.xml" hash="2c5d1fd9d6a8047f2edc8a32296af923"/><file name="system.xml" hash="b4344b259212dd8f83e7ee8163db63f3"/></dir><dir name="sql"><dir name="tracking_setup"><file name="mysql4-install-0.0.4.php" hash="efbe2ef2e234e72f8cfb61b02cd79fd8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="salesmanago.xml" hash="c8d48e529e20472913b844723b0513a6"/></dir><dir name="template"><dir name="salesmanago"><dir name="tracking"><file name="tracking.phtml" hash="7341fb419c9c86e6d0ec1eba6265d979"/></dir></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="salesmanago"><dir name="tracking"><file name="tracking.phtml" hash=""/></dir></dir></dir><dir name="layout"><file name="salesmanago.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SalesManago_Tracking.xml" hash="14e6da8fc1550fd46dc56ceea822d648"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|