Betaout - Version 2.2.1

Version Notes

Increase plugin support for betaout version v2.

Download this release

Release Info

Developer jitendra
Extension Betaout
Version 2.2.1
Comparing to
See all releases


Code changes from version 2.1.1 to 2.2.1

app/code/community/Betaout/Amplify/Model/Amplify.php CHANGED
@@ -70,12 +70,12 @@ class Amplify {
70
  /**
71
  * amplify host
72
  */
73
- public $host = 'betaout.in';
74
 
75
  /**
76
  * amplify version
77
  */
78
- private $version = 'v1';
79
 
80
  /*
81
  * param to be send on amplify
@@ -105,16 +105,7 @@ class Amplify {
105
  * Whether we are in debug mode. This is set by the constructor
106
  */
107
  private $debug = true;
108
-
109
- /**
110
- * If the spider text is found in the current user agent, then return true
111
- */
112
-
113
- /**
114
- * gettting device info
115
- */
116
- private $botDetect = false;
117
-
118
  /**
119
  * gettting device info
120
  */
@@ -125,274 +116,14 @@ class Amplify {
125
  */
126
  protected $functionUrlMap = array(
127
  'identify' => 'user/identify/',
128
- 'event' => 'user/event/',
129
- 'update' => 'user/update/',
130
- 'add' => 'user/add/',
131
- 'verify' => 'client/verify/',
132
- 'userProfile' => 'user/profile/',
133
- 'fetchwidget' => 'client/fetchwidget/',
134
- 'product_add' => 'product/add/',
135
- 'product_edit' => 'product/edit/',
136
- 'product_delete' => 'product/remove/',
137
- 'customer_action' => 'user/customer_activity/',
138
- 'order_update' => 'product/updateorder/',
139
- 'send_old_order' => 'user/send_old_order/'
140
- );
141
-
142
- /**
143
- * spider array used to call is not human
144
- */
145
- protected $spiders = array("seek", "accoona", "acoon", "adressendeutschland", "ah-ha.com", "ahoy", "altavista", "ananzi", "anthill", "appie", "arachnophilia", "arale", "araneo", "aranha", "architext", "aretha", "arks", "asterias", "atlocal", "atn", "atomz", "augurfind", "backrub", "bannana_bot", "baypup", "bdfetch", "big brother", "biglotron", "bjaaland", "blackwidow", "blaiz", "blog", "blo.", "bloodhound", "boitho", "booch", "bradley", "butterfly", "calif", "cassandra", "ccubee", "cfetch", "charlotte", "churl", "cienciaficcion", "cmc", "collective", "comagent", "combine", "computingsite", "csci", "curl", "cusco", "daumoa", "deepindex", "delorie", "depspid", "deweb", "die blinde kuh", "digger", "ditto", "dmoz", "docomo", "download express", "dtaagent", "dwcp", "ebiness", "ebingbong", "e-collector", "ejupiter", "emacs-w3 search engine", "esther", "evliya celebi", "ezresult", "falcon", "felix ide", "ferret", "fetchrover", "fido", "findlinks", "fireball", "fish search", "fouineur", "funnelweb", "gazz", "gcreep", "genieknows", "getterroboplus", "geturl", "glx", "goforit", "golem", "grabber", "grapnel", "gralon", "griffon", "gromit", "grub", "gulliver", "hamahakki", "harvest", "havindex", "helix", "heritrix", "hku www octopus", "homerweb", "htdig", "html index", "html_analyzer",
146
- "htmlgobble",
147
- "hubater",
148
- "hyper-decontextualizer",
149
- "ia_archiver",
150
- "ibm_planetwide",
151
- "ichiro",
152
- "iconsurf",
153
- "iltrovatore",
154
- "image.kapsi.net",
155
- "imagelock",
156
- "incywincy",
157
- "indexer",
158
- "infobee",
159
- "informant",
160
- "ingrid",
161
- "inktomisearch.com",
162
- "inspector web",
163
- "intelliagent",
164
- "internet shinchakubin",
165
- "ip3000",
166
- "iron33",
167
- "israeli-search",
168
- "ivia",
169
- "jack",
170
- "jakarta",
171
- "javabee",
172
- "jetbot",
173
- "jumpstation",
174
- "katipo",
175
- "kdd-explorer",
176
- "kilroy",
177
- "knowledge",
178
- "kototoi",
179
- "kretrieve",
180
- "labelgrabber",
181
- "lachesis",
182
- "larbin",
183
- "legs",
184
- "libwww",
185
- "linkalarm",
186
- "link validator",
187
- "linkscan",
188
- "lockon",
189
- "lwp",
190
- "lycos",
191
- "magpie",
192
- "mantraagent",
193
- "mapoftheinternet",
194
- "marvin/",
195
- "mattie",
196
- "mediafox",
197
- "mediapartners",
198
- "mercator",
199
- "merzscope",
200
- "microsoft url control",
201
- "minirank",
202
- "miva",
203
- "mj12",
204
- "mnogosearch",
205
- "moget",
206
- "monster",
207
- "moose",
208
- "motor",
209
- "multitext",
210
- "muncher",
211
- "muscatferret",
212
- "mwd.search",
213
- "myweb",
214
- "najdi",
215
- "nameprotect",
216
- "nationaldirectory",
217
- "nazilla",
218
- "ncsa beta",
219
- "nec-meshexplorer",
220
- "nederland.zoek",
221
- "netcarta webmap engine",
222
- "netmechanic",
223
- "netresearchserver",
224
- "netscoop",
225
- "newscan-online",
226
- "nhse",
227
- "nokia6682/",
228
- "nomad",
229
- "noyona",
230
- "nutch",
231
- "nzexplorer",
232
- "objectssearch",
233
- "occam",
234
- "omni",
235
- "open text",
236
- "openfind",
237
- "openintelligencedata",
238
- "orb search",
239
- "osis-project",
240
- "pack rat",
241
- "pageboy",
242
- "pagebull",
243
- "page_verifier",
244
- "panscient",
245
- "parasite",
246
- "partnersite",
247
- "patric",
248
- "pear.",
249
- "pegasus",
250
- "peregrinator",
251
- "pgp key agent",
252
- "phantom",
253
- "phpdig",
254
- "picosearch",
255
- "piltdownman",
256
- "pimptrain",
257
- "pinpoint",
258
- "pioneer",
259
- "piranha",
260
- "plumtreewebaccessor",
261
- "pogodak",
262
- "poirot",
263
- "pompos",
264
- "poppelsdorf",
265
- "poppi",
266
- "popular iconoclast",
267
- "psycheclone",
268
- "publisher",
269
- "python",
270
- "rambler",
271
- "raven search",
272
- "roach",
273
- "road runner",
274
- "roadhouse",
275
- "robbie",
276
- "robofox",
277
- "robozilla",
278
- "rules",
279
- "salty",
280
- "sbider",
281
- "scooter",
282
- "scoutjet",
283
- "scrubby",
284
- "search.",
285
- "searchprocess",
286
- "semanticdiscovery",
287
- "senrigan",
288
- "sg-scout",
289
- "shai'hulud",
290
- "shark",
291
- "shopwiki",
292
- "sidewinder",
293
- "sift",
294
- "silk",
295
- "simmany",
296
- "site searcher",
297
- "site valet",
298
- "sitetech-rover",
299
- "skymob.com",
300
- "sleek",
301
- "smartwit",
302
- "sna-",
303
- "snappy",
304
- "snooper",
305
- "sohu",
306
- "speedfind",
307
- "sphere",
308
- "sphider",
309
- "spinner",
310
- "spyder",
311
- "steeler/",
312
- "suke",
313
- "suntek",
314
- "supersnooper",
315
- "surfnomore",
316
- "sven",
317
- "sygol",
318
- "szukacz",
319
- "tach black widow",
320
- "tarantula",
321
- "templeton",
322
- "/teoma",
323
- "t-h-u-n-d-e-r-s-t-o-n-e",
324
- "theophrastus",
325
- "titan",
326
- "titin",
327
- "tkwww",
328
- "toutatis",
329
- "t-rex",
330
- "tutorgig",
331
- "twiceler",
332
- "twisted",
333
- "ucsd",
334
- "udmsearch",
335
- "url check",
336
- "updated",
337
- "vagabondo",
338
- "valkyrie",
339
- "verticrawl",
340
- "victoria",
341
- "vision-search",
342
- "volcano",
343
- "voyager/",
344
- "voyager-hc",
345
- "w3c_validator",
346
- "w3m2",
347
- "w3mir",
348
- "walker",
349
- "wallpaper",
350
- "wanderer",
351
- "wauuu",
352
- "wavefire",
353
- "web core",
354
- "web hopper",
355
- "web wombat",
356
- "webbandit",
357
- "webcatcher",
358
- "webcopy",
359
- "webfoot",
360
- "weblayers",
361
- "weblinker",
362
- "weblog monitor",
363
- "webmirror",
364
- "webmonkey",
365
- "webquest",
366
- "webreaper",
367
- "websitepulse",
368
- "websnarf",
369
- "webstolperer",
370
- "webvac",
371
- "webwalk",
372
- "webwatch",
373
- "webwombat",
374
- "webzinger",
375
- "wget",
376
- "whizbang",
377
- "whowhere",
378
- "wild ferret",
379
- "worldlight",
380
- "wwwc",
381
- "wwwster",
382
- "xenu",
383
- "xget",
384
- "xift",
385
- "xirq",
386
- "yandex",
387
- "yanga",
388
- "yeti",
389
- "yodao",
390
- "zao/",
391
- "zippp",
392
- "zyborg",
393
- "...."
394
  );
395
-
396
  /**
397
  * The constructor
398
  *
@@ -402,14 +133,12 @@ class Amplify {
402
  * @param string $debug Optional debug flag
403
  * @return void
404
  * */
405
- public function __construct($apiKey, $apiSecret, $projectId, $debug = true) {
406
  $this->basicSetUp();
407
  $this->setApiKey($apiKey);
408
- $this->setApiSecret($apiSecret);
409
  $this->setProjectId($projectId);
410
  $this->setPublicationUrl();
411
  $this->setTimeStamp(time());
412
- // $this->setOtt();
413
  $this->debug = $debug;
414
  }
415
 
@@ -431,12 +160,11 @@ class Amplify {
431
  CURLOPT_CONNECTTIMEOUT_MS => 3000,
432
  CURLOPT_RETURNTRANSFER => true,
433
  CURLOPT_TIMEOUT_MS => 3000,
434
- CURLOPT_USERAGENT => 'amplify-php-1.0',
435
  );
436
 
437
  public function setApiKey($apiKey) {
438
  $this->apiKey = $apiKey;
439
- // return $this;
440
  }
441
 
442
  public function getApiKey() {
@@ -445,7 +173,6 @@ class Amplify {
445
 
446
  public function setProjectId($projectId) {
447
  $this->projectId = $projectId;
448
- // return $this;
449
  }
450
 
451
  public function getProjectId() {
@@ -453,22 +180,13 @@ class Amplify {
453
  }
454
 
455
  public function setPublicationUrl() {
456
- $this->publicationUrl = "http://" . $this->getProjectId() . "." . $this->host . "/" . $this->version . "/";
457
  }
458
 
459
  public function getPublicationUrl() {
460
  return $this->publicationUrl;
461
  }
462
 
463
- public function setHash($hash) {
464
- $this->hash = $hash;
465
- return $this;
466
- }
467
-
468
- public function getHash() {
469
- return $this->hash;
470
- }
471
-
472
  public function setParams($params) {
473
  $this->params = $params;
474
  // return $this;
@@ -478,15 +196,6 @@ class Amplify {
478
  return $this->params;
479
  }
480
 
481
- public function setApiSecret($apiSecret) {
482
- $this->apiSecret = $apiSecret;
483
- // return $this;
484
- }
485
-
486
- public function getApiSecret() {
487
- return $this->apiSecret;
488
- }
489
-
490
  public function getRequestUrl() {
491
  return $this->requestUrl;
492
  }
@@ -522,24 +231,28 @@ class Amplify {
522
  $this->showError[] = "paramter should be associative array!";
523
  $this->setOtt();
524
  if (isset($this->ott)) {
525
- $params['token'] = $this->getOtt();
 
 
526
  }
527
- if((isset($params['email'])&& empty($params['email'])) ||!isset($params['email']))
528
  {
529
- $email=base64_decode(Mage::getModel('core/cookie')->get('_ampEm'));
530
- if($email!=""){
531
- $params['email']= base64_decode(Mage::getModel('core/cookie')->get('_ampEm'));
532
- $params['token']="";
533
- }
534
  }
 
535
  try {
536
- if (!isset($params['apiKey']))
537
- $params['apiKey'] = $this->getApiKey();
 
 
 
 
538
  if (!isset($params['timestamp']))
539
  $params['timestamp'] = $this->getTimeStamp();
540
-
541
  $paramUrl = json_encode($params);
542
- $this->setParams($paramUrl);
543
  } catch (Exception $ex) {
544
  $this->showError[] = $ex->getCode() . ":" . $ex->getMessage();
545
  }
@@ -547,105 +260,60 @@ class Amplify {
547
 
548
  function http_call($functionName, $argumentsArray) {
549
 
550
- $this->_bot_detected();
551
- if (!$this->botDetect) {
552
  $apiKey = $this->getApiKey();
553
- $apiSecret = $this->getApiSecret();
554
  if (empty($apiKey))
555
  $this->showError[] = "Invalid Api call, Api key must be provided!";
556
- if (empty($apiSecret))
557
- $this->showError[] = "Invalid Api call, Api Secret must be provided!";
558
  if (!isset($this->functionUrlMap[$functionName]))
559
  $this->showError[] = "Invalid Function call!";
560
  try {
561
  $this->deviceDetector();
562
  $requestUrl = $this->getPublicationUrl() . $this->functionUrlMap[$functionName]; //there should be error handling to make sure function name exist
 
563
  if (isset($argumentsArray) && is_array($argumentsArray) && count($argumentsArray) > 0) {
564
- $argumentsArray['systemInfo'] = $_SERVER['HTTP_USER_AGENT'];
 
565
  $this->makeParams($argumentsArray);
566
  } else
567
  $this->makeParams();
568
  $paramdata=$this->getParams();
569
- //$requestUrl.="?" . $this->getParams();
570
- //$this->setRequestUrl($requestUrl,$paramdata);
571
- //$this->signString();
572
-
573
  return $this->makeRequest($requestUrl,$paramdata);
574
  } catch (Exception $ex) {
575
  $this->showError[] = $ex->getCode() . ":" . $ex->getMessage();
576
  }
577
- } else {
578
- return false;
579
- }
580
- }
581
-
582
- protected function signString() {
583
- switch ($this->signatureMethod) {
584
- case 'HMAC-SHA1':
585
- $key = $this->encode_rfc3986($this->apiSecret);
586
- $params = $this->getParams();
587
- $hash = urlencode(base64_encode(hash_hmac('sha1', $params, $key, true)));
588
- $this->setHash($hash);
589
- break;
590
- default :
591
- $this->showError[] = "Signature method is not valid";
592
- break;
593
- }
594
- }
595
-
596
- protected function encode_rfc3986($string) {
597
- return str_replace('+', ' ', str_replace('%7E', '~', rawurlencode(($string))));
598
- // return str_replace(str_replace('%7E', '~', rawurlencode(($string))));
599
  }
600
 
601
  protected function makeRequest($requestUrl,$data="", $ch = null) {
 
602
  if (!$ch) {
603
  $ch = curl_init();
604
  }
605
  $options = self::$CURL_OPTS;
606
  $options[CURLOPT_URL] = $requestUrl;
607
 
608
- $options[CURLOPT_POSTFIELDS]=array("params"=>$data);
609
- // print_r($requestUrl);
610
-
611
-
612
  if ($this->debug) {
613
- // echo $requestUrl;
614
  $options[CURLOPT_VERBOSE] = true;
615
  }
616
- // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
617
- // for 2 seconds if the server does not support this header.
618
- if (isset($options[CURLOPT_HTTPHEADER])) {
619
- $existing_headers = $options[CURLOPT_HTTPHEADER];
620
- $existing_headers[] = 'Expect:';
621
- $options[CURLOPT_HTTPHEADER] = $existing_headers;
622
- } else {
623
- $options[CURLOPT_HTTPHEADER] = array('Expect:');
624
- }
625
-
626
-
627
  curl_setopt_array($ch, $options);
628
  $result = curl_exec($ch);
629
-
630
  if ($result === false) {
631
  $this->showError[] = 'Curl error: ' . curl_error($ch);
632
  }
633
- // print_r($result);
634
  curl_close($ch);
635
  $retrun = json_decode($result, true);
636
  if ($retrun['responseCode'] == '500')
637
  $this->showError[] = $retrun;
638
  return $retrun;
639
- }
640
-
641
- /*
642
- * check api key and api secret are valid
643
- * amplify->verify();
644
- */
645
-
646
- public function verify() {
647
- $argumentsArray = array('apiSecret' => $this->apiSecret, 'clientType' => 'magento');
648
- return $this->http_call('verify', $argumentsArray);
649
  }
650
 
651
  /*
@@ -654,29 +322,20 @@ class Amplify {
654
  * Replace with name and email of current user
655
  */
656
 
657
- public function identify($email = '', $name = '', $url = '', $referer = '',$token='') {
658
-
659
- $cemail="";
660
- if(Mage::getModel('core/cookie')->get('_ampUITN')!=""){
661
- $token=Mage::getModel('core/cookie')->get('_ampUITN');
662
- }
663
- if(Mage::getModel('core/cookie')->get('_ampEm')!=""){
664
- $cemail= base64_decode(Mage::getModel('core/cookie')->get('_ampEm'));
665
  }
666
- if($email==''){
667
- $email=$cemail;
668
- }
669
 
670
- $argumentsArray = array('email' => $email, 'name' => $name, 'url' => $url, 'referer' => $referer,'token'=>$token);
671
- $response = $this->http_call('identify', $argumentsArray);
672
- if($email!=''){
673
- setcookie('_ampEm',base64_encode($email),time()+604800,'/');
674
- setcookie('_ampUITN','',time()+604800,'/');
675
- }
676
-
677
-
678
-
679
- return $response;
680
  }
681
 
682
  /*
@@ -684,40 +343,30 @@ class Amplify {
684
  * $amplify->event('sandeep@socialaxishq.com',array('addtocart'=>array('product'=>'Samsung Note2','category'=>'Mobile','price'=>'456.78')));
685
  */
686
 
687
- public function event($email, $eventArray) {
688
- // $tmp1=array_values($eventArray);
689
- // $tmp1=$tmp1[0];
690
- // $res=$this->customer_action($tmp1);
691
- $eventTemp = array_keys($eventArray);
692
- $eventTemp = $eventTemp[0];
693
- $eventTemp = array($eventTemp => false);
694
- $argumentsArray = array('email' => $email, 'event' => $eventTemp);
695
- return $this->http_call('event', $argumentsArray);
696
  }
697
 
698
  // $sku, $productTitle, $productPictureUrl, $price,$currency ,$specialPrice, $status, $stockAvailability, $pageUrl
699
  public function product_add($productDetails) {
700
- // $argumentsArray = array('email' => $email, 'event' => $eventArray);
701
- // $argumentsArray=$productDetails;
702
- return $this->http_call('product_add', $productDetails);
703
- }
704
-
705
- public function product_delete($sku) {
706
- $argumentsArray = array('sku' => $sku);
707
- return $this->http_call('product_delete', $argumentsArray);
708
  }
709
 
710
  // $sku, $action, $size = false, $color = false, $amount = false
711
  public function customer_action($actionDescription) {
712
  $argumentsArray = $actionDescription;
713
  $argumentsArray['url'] = $this->getCurrentUrl();
714
- $argumentsArray['ref'] = isset($_COOKIE['_ampREF']) ? $_COOKIE['_ampREF'] : "";
715
 
716
- return $this->http_call('customer_action', $argumentsArray);
717
  }
718
 
719
- public function update_order($orderId, $status) {
720
- return $this->http_call('order_update', array("orderId" => $orderId, "status" => $status));
721
  }
722
 
723
  /*
@@ -725,59 +374,12 @@ class Amplify {
725
  * $amplify->update('sandeep@socialaxishq.com',array('country'=>'India','city'=>'Noida'));
726
  */
727
 
728
- public function update($email, $propetyArray) {
729
- $argumentsArray = array('email' => $email, 'properties' => $propetyArray);
730
-
731
- return $this->http_call('update', $argumentsArray);
732
- }
733
-
734
- /*
735
- * add new user properties
736
- * $amplify->add('sandeep@socialaxishq.com',array('total_comments'=>'5','total_shares'=>'4'));
737
- */
738
-
739
- public function add($email, $propetyArray, $text = 0) {
740
- $argumentsArray = array('email' => $email, 'properties' => $propetyArray);
741
- if ($text)
742
- $argumentsArray = array('email' => $email, 'properties' => $propetyArray, 'property_force_data_type' => 'text'); // if string
743
-
744
- return $this->http_call('add', $argumentsArray);
745
  }
746
 
747
- /*
748
- * get userprofile
749
- * $amplify->userProfile();
750
- */
751
-
752
- public function userProfile() {
753
- $argumentsArray = array('ott' => $this->getOtt());
754
- return $this->http_call('userProfile', $argumentsArray);
755
- }
756
-
757
- /*
758
- * get widget
759
- * amplify->add('));
760
- */
761
-
762
- public function fetchwidget($widgetId) {
763
- $argumentsArray = array('widgetId' => $widgetId);
764
- return $this->http_call('fetchwidget', $argumentsArray);
765
- }
766
-
767
- private function _bot_detected() {
768
-
769
- // if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
770
- // $this->botDetect = true;
771
- // } else {
772
- //
773
- // foreach ($this->spiders as $spider) {
774
- ////If the spider text is found in the current user agent, then return true
775
- // if (stripos($_SERVER['HTTP_USER_AGENT'], $spider) !== false)
776
- // $this->botDetect = true;
777
- // }
778
- ////If it gets this far then no bot was found!
779
- // }
780
- }
781
 
782
  protected function deviceDetector() {
783
  if (stripos($_SERVER['HTTP_USER_AGENT'], "Android") && stripos($_SERVER['HTTP_USER_AGENT'], "mobile")) {
@@ -798,7 +400,6 @@ class Amplify {
798
  }
799
 
800
  public function describe() {
801
- // if ($this->debug)
802
  return $this->showError;
803
  }
804
 
@@ -818,7 +419,7 @@ class Amplify {
818
  $argumentsArray = $actionDescription;
819
  return $this->http_call('send_old_order', $argumentsArray);
820
  }
821
- public function getToken() {
822
  $visitorData = Mage::getSingleton('core/session')->getVisitorData();
823
  return $visitorData['visitor_id'];
824
  }
70
  /**
71
  * amplify host
72
  */
73
+ public $host = 'api.betaout.com';
74
 
75
  /**
76
  * amplify version
77
  */
78
+ private $version = 'v2';
79
 
80
  /*
81
  * param to be send on amplify
105
  * Whether we are in debug mode. This is set by the constructor
106
  */
107
  private $debug = true;
108
+
 
 
 
 
 
 
 
 
 
109
  /**
110
  * gettting device info
111
  */
116
  */
117
  protected $functionUrlMap = array(
118
  'identify' => 'user/identify/',
119
+ 'user_events' => 'user/events',
120
+ 'user_properties' => 'user/properties',
121
+ 'ecommerce_products' => 'ecommerce/products',
122
+ 'ecommerce_categories'=>'ecommerce/categories',
123
+ 'ecommerce_activities' => 'ecommerce/activities',
124
+ 'ecommerce_orders ' => 'ecommerce/orders',
125
+ 'campaign_transactional' => 'campaign/transactional'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  );
 
127
  /**
128
  * The constructor
129
  *
133
  * @param string $debug Optional debug flag
134
  * @return void
135
  * */
136
+ public function __construct($apiKey, $projectId, $debug = true) {
137
  $this->basicSetUp();
138
  $this->setApiKey($apiKey);
 
139
  $this->setProjectId($projectId);
140
  $this->setPublicationUrl();
141
  $this->setTimeStamp(time());
 
142
  $this->debug = $debug;
143
  }
144
 
160
  CURLOPT_CONNECTTIMEOUT_MS => 3000,
161
  CURLOPT_RETURNTRANSFER => true,
162
  CURLOPT_TIMEOUT_MS => 3000,
163
+ CURLOPT_USERAGENT => 'amplify-php-2.0',
164
  );
165
 
166
  public function setApiKey($apiKey) {
167
  $this->apiKey = $apiKey;
 
168
  }
169
 
170
  public function getApiKey() {
173
 
174
  public function setProjectId($projectId) {
175
  $this->projectId = $projectId;
 
176
  }
177
 
178
  public function getProjectId() {
180
  }
181
 
182
  public function setPublicationUrl() {
183
+ $this->publicationUrl = "http://".$this->host . "/" . $this->version . "/";
184
  }
185
 
186
  public function getPublicationUrl() {
187
  return $this->publicationUrl;
188
  }
189
 
 
 
 
 
 
 
 
 
 
190
  public function setParams($params) {
191
  $this->params = $params;
192
  // return $this;
196
  return $this->params;
197
  }
198
 
 
 
 
 
 
 
 
 
 
199
  public function getRequestUrl() {
200
  return $this->requestUrl;
201
  }
231
  $this->showError[] = "paramter should be associative array!";
232
  $this->setOtt();
233
  if (isset($this->ott)) {
234
+ if($this->getOtt()){
235
+ $params['identifiers']['token']=$this->getOtt();
236
+ }
237
  }
238
+ if((isset($params['identifiers'])&& count($params['identifiers'])==0) ||!isset($params['identifiers']))
239
  {
240
+ $params['identifiers']=json_decode(base64_decode(Mage::getModel('core/cookie')->get('_ampUSER')),true);
241
+
 
 
 
242
  }
243
+ $params['identifiers']= array_filter($params['identifiers']);
244
  try {
245
+ if (!isset($params['apikey']))
246
+ $params['apikey'] = $this->getApiKey();
247
+
248
+ if (!isset($params['project_id']))
249
+ $params['project_id'] = $this->getProjectId();
250
+
251
  if (!isset($params['timestamp']))
252
  $params['timestamp'] = $this->getTimeStamp();
253
+
254
  $paramUrl = json_encode($params);
255
+ $this->setParams($paramUrl);
256
  } catch (Exception $ex) {
257
  $this->showError[] = $ex->getCode() . ":" . $ex->getMessage();
258
  }
260
 
261
  function http_call($functionName, $argumentsArray) {
262
 
 
 
263
  $apiKey = $this->getApiKey();
264
+ $projectId = $this->getProjectId();
265
  if (empty($apiKey))
266
  $this->showError[] = "Invalid Api call, Api key must be provided!";
267
+ if (empty($projectId))
268
+ $this->showError[] = "Invalid Api call, Project Id must be provided!";
269
  if (!isset($this->functionUrlMap[$functionName]))
270
  $this->showError[] = "Invalid Function call!";
271
  try {
272
  $this->deviceDetector();
273
  $requestUrl = $this->getPublicationUrl() . $this->functionUrlMap[$functionName]; //there should be error handling to make sure function name exist
274
+
275
  if (isset($argumentsArray) && is_array($argumentsArray) && count($argumentsArray) > 0) {
276
+ $argumentsArray['useragent'] = $_SERVER['HTTP_USER_AGENT'];
277
+ $argumentsArray['ip'] = $_SERVER['REMOTE_ADDR'];
278
  $this->makeParams($argumentsArray);
279
  } else
280
  $this->makeParams();
281
  $paramdata=$this->getParams();
282
+
 
 
 
283
  return $this->makeRequest($requestUrl,$paramdata);
284
  } catch (Exception $ex) {
285
  $this->showError[] = $ex->getCode() . ":" . $ex->getMessage();
286
  }
287
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  }
289
 
290
  protected function makeRequest($requestUrl,$data="", $ch = null) {
291
+ try{
292
  if (!$ch) {
293
  $ch = curl_init();
294
  }
295
  $options = self::$CURL_OPTS;
296
  $options[CURLOPT_URL] = $requestUrl;
297
 
298
+ $options[CURLOPT_POSTFIELDS]=$data;
 
 
 
299
  if ($this->debug) {
 
300
  $options[CURLOPT_VERBOSE] = true;
301
  }
302
+ $options[CURLOPT_HTTPHEADER] =array('Content-Type: application/json');
303
+ //mail("rohit@getamplify.com", "magento event", $data);
 
 
 
 
 
 
 
 
 
304
  curl_setopt_array($ch, $options);
305
  $result = curl_exec($ch);
 
306
  if ($result === false) {
307
  $this->showError[] = 'Curl error: ' . curl_error($ch);
308
  }
 
309
  curl_close($ch);
310
  $retrun = json_decode($result, true);
311
  if ($retrun['responseCode'] == '500')
312
  $this->showError[] = $retrun;
313
  return $retrun;
314
+ } catch (Exception $ex) {
315
+
316
+ }
 
 
 
 
 
 
 
317
  }
318
 
319
  /*
322
  * Replace with name and email of current user
323
  */
324
 
325
+ public function identify($data = array()) {
326
+ $cdata=array();
327
+ if(Mage::getModel('core/cookie')->get('_ampUSER')!=""){
328
+ $cdata= json_decode(base64_decode(Mage::getModel('core/cookie')->get('_ampUSER')),true);
 
 
 
 
329
  }
330
+ $identifiers['identifiers']= array_merge($cdata,$data);
 
 
331
 
332
+ $response = $this->http_call('identify', $identifiers);
333
+ if(isset($identifiers['identifiers'])){
334
+ $jdata= json_encode($identifiers['identifiers']);
335
+ setcookie('_ampUSER',base64_encode($jdata),time()+604800,'/');
336
+
337
+ }
338
+ return $response;
 
 
 
339
  }
340
 
341
  /*
343
  * $amplify->event('sandeep@socialaxishq.com',array('addtocart'=>array('product'=>'Samsung Note2','category'=>'Mobile','price'=>'456.78')));
344
  */
345
 
346
+ public function event($identifier, $eventName) {
347
+ if($eventName!=""){
348
+ $eventArray=array("name"=>$eventName,"timestamp"=>time());
349
+ $argumentsArray = array('identifiers' => $identifier, 'events' => array($eventArray));
350
+ return $this->http_call('user_events', $argumentsArray);
351
+ }
 
 
 
352
  }
353
 
354
  // $sku, $productTitle, $productPictureUrl, $price,$currency ,$specialPrice, $status, $stockAvailability, $pageUrl
355
  public function product_add($productDetails) {
356
+ return $this->http_call('ecommerce_products', $productDetails);
 
 
 
 
 
 
 
357
  }
358
 
359
  // $sku, $action, $size = false, $color = false, $amount = false
360
  public function customer_action($actionDescription) {
361
  $argumentsArray = $actionDescription;
362
  $argumentsArray['url'] = $this->getCurrentUrl();
363
+ $argumentsArray['referrer'] = isset($_COOKIE['_ampREF']) ? $_COOKIE['_ampREF'] : "";
364
 
365
+ return $this->http_call('ecommerce_activities', $argumentsArray);
366
  }
367
 
368
+ public function update_order($data) {
369
+ return $this->http_call('ecommerce_orders',$data);
370
  }
371
 
372
  /*
374
  * $amplify->update('sandeep@socialaxishq.com',array('country'=>'India','city'=>'Noida'));
375
  */
376
 
377
+ public function userProperties($identifier, $propetyArray) {
378
+ $argumentsArray = array('identifiers' => $identifier, 'properties' => $propetyArray);
379
+ return $this->http_call('user_properties', $argumentsArray);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  }
381
 
382
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
  protected function deviceDetector() {
385
  if (stripos($_SERVER['HTTP_USER_AGENT'], "Android") && stripos($_SERVER['HTTP_USER_AGENT'], "mobile")) {
400
  }
401
 
402
  public function describe() {
 
403
  return $this->showError;
404
  }
405
 
419
  $argumentsArray = $actionDescription;
420
  return $this->http_call('send_old_order', $argumentsArray);
421
  }
422
+ public function getToken() {
423
  $visitorData = Mage::getSingleton('core/session')->getVisitorData();
424
  return $visitorData['visitor_id'];
425
  }
app/code/community/Betaout/Amplify/Model/Key.php CHANGED
@@ -39,8 +39,8 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
39
  $this->key = Mage::getStoreConfig(self::XML_PATH_KEY);
40
  $this->secret = Mage::getStoreConfig(self::XML_PATH_SECRET);
41
  $this->projectId = Mage::getStoreConfig(self::XML_PATH_PROJECTID);
42
- $this->verified = 1; // Mage::getStoreConfig('betaout_amplify_options/settings/amplify_verified');
43
- $this->amplify = new Amplify($this->key, $this->secret, $this->projectId);
44
  $this->verified = 1;
45
  $this->_process_date = Mage::getStoreConfig('betaout_amplify_options/settings/_process_date');
46
  } catch (Exception $ex) {
@@ -53,38 +53,8 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
53
  return $visitorData['visitor_id'];
54
  }
55
 
56
- public function getAmplifyCheckOrderStatus($observer) {
57
-
58
- }
59
-
60
  public function getAmplifyConfigChangeObserver($evnt) {
61
- // if (($this->key && $this->secret && $this->projectId)) {
62
- // $this->key = Mage::getStoreConfig(self::XML_PATH_KEY);
63
- // $this->secret = Mage::getStoreConfig(self::XML_PATH_SECRET);
64
- // $this->projectId = Mage::getStoreConfig(self::XML_PATH_PROJECTID);
65
- // $this->amplify = new Betaout_Amplify_Model_Amplify($this->key, $this->secret, $this->projectId);
66
- // Mage::getModel('core/config')->saveConfig('betaout_amplify_options/settings/amplify_verified', TRUE);
67
- // Mage::getStoreConfig('betaout_amplify_options/settings/beta_start_date');
68
- // if (!Mage::getStoreConfig('betaout_amplify_options/settings/beta_start_date')) {
69
- //
70
- // try {
71
- //
72
- // $this->setUser();
73
- // $website = Mage::getBaseUrl();
74
- // $this->informBetaout("$this->projectId is used by a magento client $website");
75
- // } catch (Exception $exc) {
76
- //
77
- // }
78
- //
79
- // Mage::getModel('core/config')->saveConfig('betaout_amplify_options/settings/beta_start_date', gmdate('Y-m-d H:i:s'));
80
- // Mage::getModel('core/config')->saveConfig('betaout_amplify_options/order/cron_setting', '*/5 * * * *');
81
- // Mage::getModel('core/config')->saveConfig('betaout_amplify_options/settings/_process_date', gmdate('Y-m-d H:i:s', strtotime("+1 hour")));
82
- // }else{
83
- //
84
- // //Mage::getStoreConfig('betaout_amplify_options/settings/_process_date');
85
- // }
86
- // }
87
- //
88
  }
89
 
90
  public function getAmplifyEventRemoveFromCart(Varien_Event_Observer $observer) {
@@ -93,40 +63,32 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
93
  if ($this->verified && is_object($observer)) {
94
 
95
  $product = $observer->getEvent()->getQuote_item();
96
-
97
  $actionData = array();
98
- $actionData[0]['productId'] = $product->getProductId();
99
- $actionData[0]['productTitle'] = $product->getName();
100
  $actionData[0]['sku'] = $product->getSku();
101
  $actionData[0]['price'] = $product->getPrice();
102
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
103
- $actionData[0]['specialPrice'] = $product->getFinalPrice();
104
- $actionData[0]['status'] = $product->getStatus();
105
- $actionData[0]['productPictureUrl'] = $product->getImageUrl();
106
- $actionData[0]['pageUrl'] = $product->getProductUrl();
107
- $actionData[0]['weight'] = $product->getWeight();
108
- $actionData[0]['size'] = false;
109
- $actionData[0]['color'] = false;
110
- $actionData[0]['qty'] = (int) $product->getQty();
111
- $actionData[0]['category'] = "";
112
- $actionData[0]['discount'] = abs($product->getPrice() - $product->getFinalPrice());
113
  $subprice = (int) $product->getQty() * $product->getPrice();
114
  $subprice=Mage::helper('core')->currency($subprice , false, false);
115
  $cart = Mage::getSingleton('checkout/cart');
116
  $cart_id=$cart->getQuote()->getId();
117
  $subTotalPrice = $cart->getQuote()->getGrandTotal();
118
- $orderInfo["subtotalPrice"] = $subTotalPrice - $subprice;
119
- $orderInfo['shoppingCartNo'] =$cart_id;
120
- $orderInfo['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
121
- $actionDescription = array(
122
- 'action' => 'removed_from_cart',
123
- 'email' => $this->getCustomerIdentity(),
124
- 'or' => $orderInfo,
125
- 'pd' => $actionData
126
- );
127
 
 
 
 
128
 
129
- //mail("rohit@getamplify.com","removedfrom cart",json_encode($actionDescription));
 
 
 
 
 
130
  $res = $this->amplify->customer_action($actionDescription);
131
  }
132
  } catch (Exception $ex) {
@@ -153,7 +115,7 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
153
  if ($pid == 1) {
154
  $pid = 0;
155
  }
156
- $cateHolder[$id] = array("n" => $name, "p" => $pid);
157
  }
158
 
159
  $productName = $product->getName();
@@ -164,41 +126,34 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
164
  $cart_id=$cart->getQuote()->getId();
165
  setcookie('_ampCart',$cart_id,time()+604800,'/');
166
 
167
- // $this->event('add_to_cart', array('product_name' => false));
168
- $stock_data = $product->getIs_in_stock();
169
- // $product = Mage::getModel('catalog/product')->load($productId);
170
  $actionData = array();
171
 
172
- $actionData[0]['productId'] = $product->getId();
173
- $actionData[0]['productTitle'] = $product->getName();
174
  $actionData[0]['sku'] = $product->getSku();
175
- $actionData[0]['price'] = $product->getPrice();
176
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
177
- $actionData[0]['specialPrice'] = $product->getPrice();
178
- $actionData[0]['status'] = $product->getStatus();
179
- $actionData[0]['productPictureUrl'] = $product->getImageUrl();
180
- $actionData[0]['pageUrl'] = $product->getProductUrl();
181
- $actionData[0]['weight'] = $product->getWeight();
182
- $actionData[0]['size'] = $product->getResource()->getAttribute('shirt_size') ? $product->getAttributeText('shirt_size') : false;
183
- $actionData[0]['color'] = $product->getResource()->getAttribute('color') ? $product->getAttributeText('color') : false;
184
- $actionData[0]['brandName'] = $product->getResource()->getAttribute('brand') ? $product->getAttributeText('brand') : false;
185
- $actionData[0]['qty'] = (int) $product->getQty();
186
- $actionData[0]['category'] = $cateHolder;
187
- $actionData[0]['discount'] = abs($product->getPrice() - $product->getFinalPrice());
188
  $subTotalPrice = $cart->getQuote()->getGrandTotal();
189
- $orderInfo["subtotalPrice"] = $subTotalPrice;
190
- $orderInfo["shoppingCartNo"] = $cart_id;
191
- $orderInfo['abandonedCheckoutUrl'] = Mage::getUrl('checkout/cart');
192
- $orderInfo['currency'] =Mage::app()->getStore()->getCurrentCurrencyCode();
 
 
193
  $actionDescription = array(
194
- 'or' => $orderInfo,
195
- 'email' => $this->getCustomerIdentity(),
196
- 'action' => 'add_to_cart',
197
- 'pd' => $actionData
198
  );
 
199
  //mail("rohit@getamplify.com","add to cart",json_encode($actionDescription));
200
- // print_r($actionDescription);
201
- $res = $this->amplify->customer_action($actionDescription);
202
 
203
  }
204
  } catch (Exception $ex) {
@@ -206,6 +161,62 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
206
  }
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  public function getAmplifyEventReview($evnt) {
210
  try {
211
  if ($this->verified) {
@@ -226,31 +237,26 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
226
  if ($pid == 1) {
227
  $pid = 0;
228
  }
229
- $cateHolder[$id] = array("n" => $name, "p" => $pid);
230
  }
231
 
232
  $actionData = array();
233
- $actionData[0]['productId'] = $product->getId();
234
- $actionData[0]['productTitle'] = $product->getName();
235
  $actionData[0]['sku'] = $product->getSku();
236
  $actionData[0]['price'] = $product->getPrice();
237
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
238
- $actionData[0]['specialPrice'] = $product->getFinalPrice();
239
- $actionData[0]['status'] = $product->getStatus();
240
- $actionData[0]['productPictureUrl'] = $product->getImageUrl();
241
- $actionData[0]['pageUrl'] = $product->getProductUrl();
242
- $actionData[0]['weight'] = $product->getWeight();
243
- $actionData[0]['stockAvailability'] = $stock_data ? $stock_data : 2;
244
- $actionData[0]['size'] = false;
245
- $actionData[0]['color'] = false;
246
- $actionData[0]['qty'] = false;
247
- $actionData[0]['category'] = $cateHolder;
248
- $actionData[0]['discount'] = abs($product->getPrice() - $product->getFinalPrice());
249
- $actionDescription = array(
250
- 'action' => 'reviewed',
251
- 'email' => $this->getCustomerIdentity(),
252
  'products' => $actionData
253
  );
 
254
  $res = $this->amplify->customer_action($actionDescription);
255
  }
256
  } catch (Exception $ex) {
@@ -266,7 +272,7 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
266
  try {
267
  if ($this->verified) {
268
 
269
- $this->event('customer_logout', array('action' => 'logout'));
270
  }
271
  } catch (Exception $ex) {
272
 
@@ -276,25 +282,13 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
276
  public function getAmplifyEventCustomerLogin($evnt) {
277
  try {
278
  if ($this->verified) {
279
-
280
  $c = Mage::getSingleton('customer/session')->getCustomer();
281
  $customer = Mage::getModel('customer/customer')->load($c->getId());
282
  $email = $customer->getEmail();
283
  $custName = $customer->getFirstname();
284
  $custName = $custName . " " . $customer->getLastname();
285
- try {
286
- $this->amplify->identify($email, $custName);
287
- } catch (Exception $ex) {
288
-
289
- }
290
- $this->amplify->event($email, array("customer_login" => 1));
291
-
292
-
293
- $person = array();
294
- $person['webId'] = $customer->getWebsiteId();
295
- $person['storeId'] = $customer->getStoreId();
296
- $person['groupId]'] = $customer->getGroupId();
297
- $res = $this->amplify->add($email, $person, 1);
298
  $person = array();
299
  $customerAddressId = $c->getDefaultShipping();
300
  if ($customerAddressId) {
@@ -306,17 +300,31 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
306
  if (is_object($customer)) {
307
  $person['firstname'] = $customer->getFirstname();
308
  $person['lastname'] = $customer->getLastname();
309
-
310
  $person['postcode'] = $customer->getPostcode();
311
- $person['telephone'] = $customer->getTelephone();
312
  $person['fax'] = $customer->getfax();
313
- $person['customerId'] = $customer->getCustomerId();
314
  $person['company'] = $customer->getCompany();
315
- // $person['region'] = $customer->getRegion();
316
  $person['street'] = $customer->getStreetFull();
 
 
 
 
 
 
 
 
317
  $person = array_filter($person);
318
- $res = $this->amplify->update($email, $person);
 
 
 
 
 
 
 
 
319
  }
 
 
320
  }
321
  } catch (Exception $ex) {
322
 
@@ -328,14 +336,17 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
328
  if ($this->verified) {
329
 
330
  $subscriber = $evnt->getEvent()->getSubscriber();
331
- $this->amplify->identify($subscriber->subscriber_email);
 
 
 
 
 
332
 
333
  if ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
334
-
335
- $this->event('subscribed_to_newsletter', array('action' => 'subscribed_to_newsletter'));
336
  } elseif ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED) {
337
-
338
- $this->event('unsubscribed_from_newsletter', array('action' => 'unsubscribed_from_newsletter'));
339
  }
340
  }
341
  } catch (Exception $ex) {
@@ -345,7 +356,7 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
345
 
346
  public function getCustomerIdentity($true = 1) {
347
  try {
348
-
349
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
350
 
351
  $c = Mage::getSingleton('customer/session')->getCustomer();
@@ -353,11 +364,13 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
353
  $email = $customer->getEmail();
354
  $custName = $customer->getFirstname();
355
  $custName = $custName . " " . $customer->getLastname();
 
 
356
  } else {
357
- $email = base64_decode(Mage::getModel('core/cookie')->get('_ampEm'));
358
  }
359
  if ($true)
360
- return $email;
361
  } catch (Exception $ex) {
362
 
363
  }
@@ -383,6 +396,7 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
383
 
384
  $person = array();
385
  $person['email'] = $customer->getEmail();
 
386
  $person['first_name'] = $customer->getFirstname();
387
  $person['last_name'] = $customer->getLastname();
388
  $person['created'] = $customer->getCreatedAt();
@@ -406,9 +420,11 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
406
  $customer = $evnt->getCustomer();
407
  $person = array();
408
  $person = $this->getCustomereventInfo($customer);
409
- $this->amplify->identify($person['email'], $person['first_name']);
410
- $this->amplify->event($person['email'], array("create_account" => 1));
411
- // $this->eventPerson($person);
 
 
412
  }
413
  } catch (Exception $ex) {
414
 
@@ -427,13 +443,9 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
427
  $coupon_code = $oRule->getCoupon_code();
428
 
429
  if (isset($coupon_code) && !empty($coupon_code)) {
430
- $this->event('coupon_success', array('code' => $coupon_code));
431
- $this->amplify->add($this->getCustomerIdentity(), array("coupon_used" => 'couponCode_' . $coupon_code));
432
  } else {
433
-
434
- $this->event('coupon_unsuccess', array('code' => $coupon_code));
435
- // $this->amplify->add($this->getCustomerIdentity(), array("coupon_used" => 'couponCode_' . $coupon_code));
436
- }
437
  return $this;
438
  }
439
  } catch (Exception $ex) {
@@ -441,15 +453,10 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
441
  }
442
  }
443
 
444
- public function event($event, $properties = array()) {
445
  try {
446
  if ($this->verified) {
447
-
448
- $params = array(
449
- $event => false
450
- );
451
- if ($this->verified)
452
- $this->amplify->event($this->getCustomerIdentity(1), $params);
453
  }
454
  } catch (Exception $ex) {
455
 
@@ -472,61 +479,36 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
472
  $eventname = $event->getName();
473
  $product = $event->getProduct();
474
 
475
- $productName = $product->getName();
476
- $sku = $product->getSku();
477
- $qty = $product->getPrice();
478
  $catCollection = $product->getCategoryCollection();
479
  $categs = $catCollection->exportToArray();
480
  $cateHolder = array();
481
 
482
- foreach ($categs as $cat) {
483
  $cateName = Mage::getModel('catalog/category')->load($cat['entity_id']);
484
  $name = $cateName->getName();
485
  $id = $cateName->getEntityId();
486
  $pid = $cateName->getParent_id();
487
- $cateHolder[$id] = array("n" => $name, "p" => $pid);
488
- }
489
- $wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
490
- $wishListItemCollection = $wishList->getItemCollection();
491
- if (count($wishListItemCollection)) {
492
- $arrProductIds = array();
493
-
494
- foreach ($wishListItemCollection as $item) {
495
- /* @var $product Mage_Catalog_Model_Product */
496
- $product = $item->getProduct();
497
- $arrProductIds[] = $product->getId();
498
  }
 
499
  }
500
- $whlistDeatails = array(
501
- 'product_name' => $productName,
502
- 'sku' => $sku,
503
- );
504
- $eventArr = array(
505
- $eventname => $whlistDeatails
506
- );
507
- // $this->amplify->event($this->getCustomerIdentity(), $eventArr);
508
- $stock_data = $product->getIs_in_stock();
509
  $actionData = array();
510
  $actionData[0]['productId'] = $product->getId();
511
  $actionData[0]['productTitle'] = $product->getName();
512
  $actionData[0]['sku'] = $product->getSku();
513
  $actionData[0]['price'] = $product->getPrice();
514
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
515
- $actionData[0]['specialPrice'] = $product->getFinalPrice();
516
- $actionData[0]['status'] = $product->getStatus();
517
- $actionData[0]['productPictureUrl'] = $product->getImageUrl();
518
- $actionData[0]['pageUrl'] = $product->getProductUrl();
519
-
520
- $actionData[0]['weight'] = $product->getWeight();
521
- $actionData[0]['stockAvailability'] = $stock_data ? $stock_data : 2;
522
- $actionData[0]['size'] = false;
523
- $actionData[0]['color'] = false;
524
- $actionData[0]['qty'] = false;
525
- $actionData[0]['category'] = $cateHolder;
526
- $actionData[0]['discount'] = abs($product->getPrice() - $product->getFinalPrice());
527
  $actionDescription = array(
528
- 'action' => 'wishlist',
529
- 'email' => $this->getCustomerIdentity(),
530
  'products' => $actionData
531
  );
532
  $res = $this->amplify->customer_action($actionDescription);
@@ -543,54 +525,64 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
543
  public function getAmplifyOrderSuccessPageView(Varien_Event_Observer $evnt) {
544
  try {
545
  if ($this->verified) {
546
-
547
- $orderdata = $evnt->getData('order_ids');
548
- $order_idn = $orderdata[0];
549
-
550
- $order = Mage::getModel("sales/order")->load($order_idn);
 
 
551
  $order_id = $order->getIncrementId();
552
  $person = array();
 
553
  $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
554
  if ($customerAddressId) {
555
  $customer = $order->getShippingAddress();
556
 
557
  if (is_object($customer)) {
 
 
 
558
  $person['firstname'] = $customer->getFirstname();
559
  $person['lastname'] = $customer->getLastname();
560
- $person['email'] = $customer->getEmail();
561
  $person['postcode'] = $customer->getPostcode();
562
- $person['telephone'] = $customer->getTelephone();
563
  $person['fax'] = $customer->getfax();
564
- $person['customerId'] = $customer->getCustomerId();
565
  $person['company'] = $customer->getCompany();
566
  $person['street'] = $customer->getStreetFull();
567
  }
 
 
 
 
568
  $person = array_filter($person);
569
- $this->amplify->identify($person['email'], $person['firstname']);
570
- $res = $this->amplify->update($email, $person);
 
571
  } else {
572
  $customer = $order->getShippingAddress();
573
  if (is_object($customer)) {
 
 
 
574
  $person['firstname'] = $customer->getFirstname();
575
  $person['lastname'] = $customer->getLastname();
576
- $person['email'] = $customer->getEmail();
577
  $person['postcode'] = $customer->getPostcode();
578
- $person['telephone'] = $customer->getTelephone();
579
  $person['fax'] = $customer->getfax();
580
- $person['customerId'] = $customer->getCustomerId();
581
  $person['company'] = $customer->getCompany();
582
  $person['street'] = $customer->getStreetFull();
583
- $this->amplify->identify($person['email'], $person['firstname']);
 
 
 
 
 
 
584
  }
585
  }
586
 
587
  $items = $order->getAllVisibleItems();
588
  $itemcount = count($items);
589
- $name = array();
590
- $unitPrice = array();
591
- $sku = array();
592
- $ids = array();
593
- $qty = array();
594
  $i = 0;
595
  $actionData = array();
596
 
@@ -609,64 +601,58 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
609
  if ($pid == 1) {
610
  $pid = 0;
611
  }
612
- $cateHolder[$id] = array("n" => $name, "p" => $pid);
613
  }
614
 
615
- $actionData[$i]['productId'] = $product->getId();
616
- $actionData[$i]['productTitle'] = $product->getName();
617
  $actionData[$i]['sku'] = $product->getSku();
618
  $actionData[$i]['price'] = $product->getPrice();
619
  $actionData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
620
- $actionData[$i]['specialPrice'] = $product->getFinalPrice();
621
- $actionData[$i]['status'] = $product->getStatus();
622
- $actionData[$i]['productPictureUrl'] = $product->getImageUrl();
623
- $actionData[$i]['pageUrl'] = $product->getProductUrl();
624
- $actionData[$i]['weight'] = $product->getWeight();
625
- $actionData[$i]['stockAvailability'] = $stock_data ? $stock_data : 2;
626
- $actionData[$i]['size'] = $product->getResource()->getAttribute('size') ? $product->getAttributeText('size') : false;
627
- $actionData[$i]['color'] = $product->getResource()->getAttribute('color') ? $product->getAttributeText('color') : false;
628
- $actionData[$i]['brandName'] = $product->getResource()->getAttribute('manufacturer') ? $product->getAttributeText('manufacturer') : false;
629
- $actionData[$i]['qty'] = (int) $item->getQtyOrdered();
630
- $actionData[$i]['category'] = $cateHolder;
631
- $actionData[$i]['orderId'] = $order_id;
632
- $actionData[$i]['totalProductPrice'] = $item->getRowTotal() - $item->getDiscountAmount();
633
- $actionData[$i]['discountPrice'] = $item->getDiscountAmount();
634
  $i++;
635
  }
636
 
637
- //$cart = Mage::getSingleton('checkout/cart');
638
  $cart_id=Mage::getModel('core/cookie')->get('_ampCart');
 
 
639
  $TotalPrice = $order->getGrandTotal();
640
  $totalShippingPrice = $order->getShippingAmount();
641
  $TotalPrice = $TotalPrice;
642
  $subTotalPrice = $order->getSubtotal();
643
- $orderInfo["subtotalPrice"] = $subTotalPrice - abs($order->getDiscountAmount());
644
- $orderInfo["totalPrice"] = $TotalPrice;
645
- $orderInfo["totalShippingPrice"] = $totalShippingPrice;
646
- $orderInfo['orderId'] = $order->getIncrementId();
647
- $orderInfo['promocode'] = $order->getCouponCode();
648
- $orderInfo['totalDiscount'] = abs($order->getDiscountAmount());
649
- $orderInfo['DiscountPer'] = abs($order->getDiscountPercent());
650
- $orderInfo['DiscountDesc'] = $order->getDiscountDescription();
651
  $orderInfo['currency'] = $order->getOrderCurrencyCode();
652
- $orderInfo['financialStatus'] = 'paid';
653
- $orderInfo['shoppingCartNo'] =$cart_id;
654
- $orderInfo['abandonedCheckoutUrl'] = Mage::getUrl('checkout/cart');
655
- $orderInfo['totalTaxes'] = $order->getShippingTaxAmount();
656
- $orderInfo['paymentType'] = $order->getPayment()->getMethodInstance()->getCode();
657
-
658
- $cemail = $person['email'];
659
-
 
660
  $actionDescription = array(
661
- 'action' => 'purchased',
662
- 'email' => $cemail,
663
- 'or' => $orderInfo,
664
- 'pd' => $actionData
665
  );
666
- // mail("rohit@getamplify.com","purchased",json_encode($actionDescription));
667
- //print_r($actionDescription);
668
  $res = $this->amplify->customer_action($actionDescription);
669
-
 
670
  }
671
  } catch (Exception $ex) {
672
  $this->event('error_one');
@@ -674,161 +660,68 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
674
  }
675
 
676
  public function getAmplifyOrderSaveSuccess(Varien_Event_Observer $evnt) {
677
- // echo "order save 3d m3 bf3 ";
678
-
679
- // try {
680
- // if ($this->verified) {
681
- // $order_id = $evnt->getEvent()->getOrder()->getId() ;
682
- // $order_no = $evnt->getEvent()->getOrder()->getIncrementId() ;
683
- // $order = Mage::getModel("sales/order")->load($order_id);
684
- // $person=array();
685
- // $paymentmethod=$order->getPayment()->getMethodInstance()->getCode();
686
- // $orderstatus=$order->getStatusLabel();
687
- // if(($paymentmethod=="payucheckout_shared" && $orderstatus!="Pending") || $paymentmethod=="cashondelivery"){
688
- // $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
689
- // if ($customerAddressId) {
690
- // $customer = $order->getShippingAddress();
691
- //
692
- // if (is_object($customer)) {
693
- // $person['firstname'] = $customer->getFirstname();
694
- // $person['lastname'] = $customer->getLastname();
695
- // $person['email']=$customer->getEmail();
696
- // $person['postcode'] = $customer->getPostcode();
697
- // $person['telephone'] = $customer->getTelephone();
698
- // $person['fax'] = $customer->getfax();
699
- // $person['customerId'] = $customer->getCustomerId();
700
- // $person['company'] = $customer->getCompany();
701
- // $person['street'] = $customer->getStreetFull();
702
- // }
703
- // $person = array_filter($person);
704
- // $this->amplify->identify($person['email'], $person['firstname']);
705
- // $res = $this->amplify->update($email, $person);
706
- // } else {
707
- // $customer = $order->getShippingAddress();
708
- // if (is_object($customer)) {
709
- // $person['firstname'] = $customer->getFirstname();
710
- // $person['lastname'] = $customer->getLastname();
711
- // $person['email']=$customer->getEmail();
712
- // $person['postcode'] = $customer->getPostcode();
713
- // $person['telephone'] = $customer->getTelephone();
714
- // $person['fax'] = $customer->getfax();
715
- // $person['customerId'] = $customer->getCustomerId();
716
- // $person['company'] = $customer->getCompany();
717
- // $person['street'] = $customer->getStreetFull();
718
- // $this->amplify->identify($person['email'], $person['firstname']);
719
- // }
720
- // }
721
- // $items = $order->getAllVisibleItems();
722
- // $itemcount = count($items);
723
- // $name = array();
724
- // $unitPrice = array();
725
- // $sku = array();
726
- // $ids = array();
727
- // $qty = array();
728
- // $i = 0;
729
- // $actionData = array();
730
- //
731
- // foreach ($items as $itemId => $item) {
732
- // $product = $item;
733
- //
734
- // $product = Mage::getModel('catalog/product')->load($product->getProductId());
735
- // $categoryIds = $product->getCategoryIds();
736
- // $cateHolder = array();
737
- //
738
- // foreach ($categoryIds as $cat) {
739
- // $cateName = Mage::getModel('catalog/category')->load($cat['entity_id']);
740
- // $name=$cateName->getName();
741
- // $id=$cateName->getEntityId();
742
- // $pid=$cateName->getParent_id();
743
- // if($pid==1){
744
- // $pid=0;
745
- // }
746
- // $cateHolder[$id] = array("n"=>$name,"p"=>$pid);
747
- // }
748
- //
749
- // $actionData[$i]['productId'] = $product->getId();
750
- // $actionData[$i]['productTitle'] = $product->getName();
751
- // $actionData[$i]['sku'] = $product->getSku();
752
- // $actionData[$i]['price'] = $product->getPrice();
753
- // $actionData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
754
- // $actionData[$i]['specialPrice'] = $product->getFinalPrice();
755
- // $actionData[$i]['status'] = $product->getStatus();
756
- // $actionData[$i]['productPictureUrl'] = $product->getImageUrl();
757
- // $actionData[$i]['pageUrl'] = $product->getProductUrl();
758
- // $actionData[$i]['weight'] = $product->getWeight();
759
- // $actionData[$i]['stockAvailability'] = $stock_data ? $stock_data : 2;
760
- // $actionData[$i]['size'] = $product->getResource()->getAttribute('size') ? $product->getAttributeText('size') : false;
761
- // $actionData[$i]['color'] = $product->getResource()->getAttribute('color') ? $product->getAttributeText('color') : false;
762
- // $actionData[$i]['brandName'] = $product->getResource()->getAttribute('manufacturer') ? $product->getAttributeText('manufacturer') : false;
763
- // $actionData[$i]['qty'] = (int) $item->getQtyOrdered();
764
- // $actionData[$i]['category'] = $cateHolder;
765
- // $actionData[$i]['orderId'] = $order_no;
766
- // $actionData[$i]['totalProductPrice']=$item->getRowTotal()-$item->getDiscountAmount();
767
- // $actionData[$i]['discountPrice'] = $item->getDiscountAmount();
768
- // $i++;
769
- // }
770
- //
771
- // $cart = Mage::getSingleton('checkout/cart');
772
- // $TotalPrice = $order->getGrandTotal();
773
- // $totalShippingPrice = $order->getShippingAmount();
774
- // $TotalPrice = $TotalPrice;
775
- // $subTotalPrice = $order->getSubtotal();
776
- // $orderInfo["subtotalPrice"] = $subTotalPrice-abs($order->getDiscountAmount());
777
- // $orderInfo["totalPrice"] = $TotalPrice;
778
- // $orderInfo["totalShippingPrice"] = $totalShippingPrice;
779
- // $orderInfo['orderId'] = $order_no;
780
- // $orderInfo['promocode'] = $order->getCouponCode();
781
- // $orderInfo['totalDiscount'] = abs($order->getDiscountAmount());
782
- // $orderInfo['DiscountPer'] = abs($order->getDiscountPercent());
783
- // $orderInfo['DiscountDesc'] = $order->getDiscountDescription();
784
- // $orderInfo['currency'] = $order->getOrderCurrencyCode();
785
- // $orderInfo['financialStatus'] = $order->getStatusLabel();
786
- // $orderInfo['abandonedCheckoutUrl'] = Mage::getUrl('checkout/cart');
787
- // $orderInfo['totalTaxes'] = $order->getShippingTaxAmount();
788
- // $orderInfo['paymentType']=$order->getPayment()->getMethodInstance()->getCode();
789
- //
790
- //
791
- // $cemail=$person['email'];
792
- //
793
- // $actionDescription = array(
794
- // 'action' => 'purchased',
795
- // 'email' =>$cemail,
796
- // 'or' => $orderInfo,
797
- // 'pd' => $actionData
798
- // );
799
- //
800
- // $res = $this->amplify->customer_action($actionDescription);
801
- //
802
- // }
803
- //
804
- // }
805
- //
806
- // } catch (Exception $ex) {
807
- // $this->event('error_two');
808
- // }
809
  }
810
 
811
  public function getAmplify_checkout_allow_guest($evnt) {
812
  try {
813
  if ($this->verified) {
814
-
815
  $getquote = $evnt->getQuote();
816
  $data = array_filter($getquote->getData());
 
817
  Mage::getModel('core/cookie')->set('amplify_email', $data['customer_email']);
818
  $person = array();
819
  $person['webId'] = Mage::app()->getWebsite()->getId();
820
  $person['storeId'] = Mage::app()->getStore()->getId();
 
 
821
  $person = array_filter($person);
822
- $this->amplify->identify($data['customer_email'], $data['customer_firstname']);
823
- $res = $this->amplify->add($data['customer_email'], $person, 1);
 
 
 
 
 
824
  }
825
  } catch (Exception $ex) {
826
 
827
  }
828
  }
829
 
830
- public function getAmplifyCatalog_product_save_after($evnt) {
831
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
  }
833
 
834
  public function getAmplifyCatalog_product_delete_after_done($evnt) {
@@ -852,7 +745,7 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
852
  if ($pid == 1) {
853
  $pid = 0;
854
  }
855
- $cateHolder[$id] = array("n" => $name, "p" => $pid);
856
  }
857
 
858
 
@@ -860,123 +753,38 @@ class Betaout_Amplify_Model_Key extends Mage_Core_Model_Abstract {
860
  $action = $event->getControllerAction();
861
  $stock_data = $product->getIs_in_stock();
862
  $actionData = array();
863
- $actionData[0]['productId'] = $product->getId();
864
- $actionData[0]['productTitle'] = $product->getName();
865
  $actionData[0]['sku'] = $product->getSku();
866
  $actionData[0]['price'] = $product->getPrice();
867
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
868
- $actionData[0]['specialPrice'] = $product->getFinalPrice();
869
- $actionData[0]['status'] = $product->getStatus();
870
- $actionData[0]['productPictureUrl'] = $product->getImageUrl();
871
- $actionData[0]['pageUrl'] = $product->getProductUrl();
872
- $actionData[0]['weight'] = $product->getWeight();
873
- $actionData[0]['stockAvailability'] = $stock_data ? $stock_data : 2;
874
- $actionData[0]['size'] = false;
875
- $actionData[0]['color'] = false;
876
- $actionData[0]['qty'] = 1;
877
- $actionData[0]['category'] = $cateHolder;
878
- $actionData[0]['discount'] = abs($product->getPrice() - $product->getFinalPrice());
879
  $actionDescription = array(
880
- 'action' => 'viewed',
881
- "email" => $this->getCustomerIdentity(),
882
- 'pd' => $actionData
883
  );
884
-
885
  $res = $this->amplify->customer_action($actionDescription);
886
  }
887
  } catch (Exception $ex) {
888
 
889
  }
890
  }
891
-
892
- public function wishlistShare(Mage_Framework_Event_Observer $evnt) {
893
-
894
- }
895
-
896
- public function getAmplifySendfriendProduct(Varien_Event_Observer $evnt) {
897
-
898
- }
899
-
900
- public function catalogProductCompareAddProduct(Varien_Event_Observer $evnt) {
901
-
902
- }
903
-
904
  public function getAmplifyCustomerAdressSaveAfter($evnt) {
905
 
906
  }
907
 
908
- public function getAmplifySales_order_save_commit_after($observer) {
909
-
910
- }
911
-
912
  /**
913
  * @param Varien_Event_Observer $observer
914
  * @author Dharam <dharmendra@socialcrawler.in>
915
  *
916
  */
917
- public function getAmplify_cartUpdate(Varien_Event_Observer $observer) {
918
- try {
919
- if ($this->verified) {
920
- $i = 0;
921
- $subdiff = 0;
922
- $actionData = array();
923
- foreach ($observer->getCart()->getQuote()->getAllVisibleItems() as $product) {
924
-
925
- if ($product->hasDataChanges()) {
926
- $productId = $product->getProductId();
927
- $catCollection = $product->getCategoryCollection();
928
-
929
- $categs = array(); //$catCollection->exportToArray();
930
- $cateHolder = array();
931
-
932
- $productName = $product->getName();
933
- $sku = $productName . "_" . $product->getSku();
934
- $qty = $product->getPrice();
935
- $stock_data = $product->getIs_in_stock();
936
-
937
- $actionData[$i]['productId'] = $product->getProductId();
938
- $actionData[$i]['productTitle'] = $product->getName();
939
- $actionData[$i]['sku'] = $product->getSku();
940
- $actionData[$i]['price'] = $product->getPrice();
941
- $actionData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
942
- $actionData[$i]['specialPrice'] = $product->getPrice();
943
- $actionData[$i]['status'] = $product->getStatus();
944
- $actionData[$i]['productPictureUrl'] = $product->getImageUrl();
945
- $actionData[$i]['pageUrl'] = $product->getProductUrl();
946
- $actionData[$i]['weight'] = $product->getWeight();
947
- $oldQty = (int) $product->getOrigData('qty');
948
- $newQty = (int) $product->getQty();
949
- $qtyDiff = 0;
950
- $subdiff = $subdiff + ($newQty - $oldQty) * $product->getPrice();
951
- $actionData[$i]['qty'] = (int) $product->getQty();
952
- $actionData[$i]['category'] = $cateHolder;
953
- $i++;
954
- }
955
- }
956
- $subdiff=Mage::helper('core')->currency($subdiff , false, false);
957
-
958
- $cart = Mage::getSingleton('checkout/cart');
959
- $cart_id=$cart->getQuote()->getId();
960
- $subTotalPrice = $cart->getQuote()->getGrandTotal();
961
- $orderInfo["subtotalPrice"] = $subTotalPrice + $subdiff;
962
- $orderInfo['abandonedCheckoutUrl'] = Mage::getUrl('checkout/cart');
963
- $orderInfo['shoppingCartNo'] =$cart_id;
964
- $orderInfo['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
965
- $actionDescription = array(
966
- 'or' => $orderInfo,
967
- 'email' => $this->getCustomerIdentity(),
968
- 'action' => 'update_cart',
969
- 'pd' => $actionData
970
- );
971
- // print_r($actionDescription);
972
-
973
- // mail("rohit@getamplify.com","update cart",json_encode($actionDescription));
974
- $res = $this->amplify->customer_action($actionDescription);
975
- }
976
- } catch (Exception $ex) {
977
-
978
- }
979
- }
980
 
981
  public function getAmplifyCancelOrderItem($observer) {
982
 
39
  $this->key = Mage::getStoreConfig(self::XML_PATH_KEY);
40
  $this->secret = Mage::getStoreConfig(self::XML_PATH_SECRET);
41
  $this->projectId = Mage::getStoreConfig(self::XML_PATH_PROJECTID);
42
+ $this->verified = 1;
43
+ $this->amplify = new Amplify($this->key,$this->projectId);
44
  $this->verified = 1;
45
  $this->_process_date = Mage::getStoreConfig('betaout_amplify_options/settings/_process_date');
46
  } catch (Exception $ex) {
53
  return $visitorData['visitor_id'];
54
  }
55
 
56
+
 
 
 
57
  public function getAmplifyConfigChangeObserver($evnt) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  public function getAmplifyEventRemoveFromCart(Varien_Event_Observer $observer) {
63
  if ($this->verified && is_object($observer)) {
64
 
65
  $product = $observer->getEvent()->getQuote_item();
 
66
  $actionData = array();
67
+ $actionData[0]['id'] = $product->getProductId();
68
+ $actionData[0]['name'] = $product->getName();
69
  $actionData[0]['sku'] = $product->getSku();
70
  $actionData[0]['price'] = $product->getPrice();
71
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
72
+ $actionData[0]['image_url'] = $product->getImageUrl();
73
+ $actionData[0]['product_url'] = $product->getProductUrl();
74
+ $actionData[0]['quantity'] = (int) $product->getQty();
75
+
 
 
 
 
 
 
76
  $subprice = (int) $product->getQty() * $product->getPrice();
77
  $subprice=Mage::helper('core')->currency($subprice , false, false);
78
  $cart = Mage::getSingleton('checkout/cart');
79
  $cart_id=$cart->getQuote()->getId();
80
  $subTotalPrice = $cart->getQuote()->getGrandTotal();
 
 
 
 
 
 
 
 
 
81
 
82
+ $cartInfo["total"] = $subTotalPrice - $subprice;
83
+ $cartInfo["revenue"] = $subTotalPrice - $subprice;
84
+ $cartInfo['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
85
 
86
+ $actionDescription = array(
87
+ 'activity_type' => 'remove_from_cart',
88
+ 'identifiers' => $this->getCustomerIdentity(),
89
+ 'cart_info' => $cartInfo,
90
+ 'products' => $actionData
91
+ );
92
  $res = $this->amplify->customer_action($actionDescription);
93
  }
94
  } catch (Exception $ex) {
115
  if ($pid == 1) {
116
  $pid = 0;
117
  }
118
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
119
  }
120
 
121
  $productName = $product->getName();
126
  $cart_id=$cart->getQuote()->getId();
127
  setcookie('_ampCart',$cart_id,time()+604800,'/');
128
 
 
 
 
129
  $actionData = array();
130
 
131
+ $actionData[0]['id'] = $product->getId();
132
+ $actionData[0]['name'] = $product->getName();
133
  $actionData[0]['sku'] = $product->getSku();
134
+ $actionData[0]['price'] = $product->getFinalPrice();
135
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
136
+ $actionData[0]['image_url'] = $product->getImageUrl();
137
+ $actionData[0]['product_url'] = $product->getProductUrl();
138
+ $actionData[0]['quantity'] = (int) $product->getQty();
139
+ $actionData[0]['categories'] = $cateHolder;
140
+
 
 
 
 
 
 
141
  $subTotalPrice = $cart->getQuote()->getGrandTotal();
142
+
143
+ $cartInfo["total"] =$subTotalPrice;
144
+ $cartInfo["revenue"] = $subTotalPrice;
145
+ $cartInfo['abandon_cart_url'] = Mage::getUrl('checkout/cart');
146
+ $cartInfo['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
147
+
148
  $actionDescription = array(
149
+ 'activity_type' => 'add_to_cart',
150
+ 'identifiers' => $this->getCustomerIdentity(),
151
+ 'cart_info' => $cartInfo,
152
+ 'products' => $actionData
153
  );
154
+
155
  //mail("rohit@getamplify.com","add to cart",json_encode($actionDescription));
156
+ $res = $this->amplify->customer_action($actionDescription);
 
157
 
158
  }
159
  } catch (Exception $ex) {
161
  }
162
  }
163
 
164
+ public function getAmplify_cartUpdate(Varien_Event_Observer $observer) {
165
+ try {
166
+ if ($this->verified) {
167
+ $i = 0;
168
+ $subdiff = 0;
169
+ $actionData = array();
170
+ foreach ($observer->getCart()->getQuote()->getAllVisibleItems() as $product) {
171
+
172
+ if ($product->hasDataChanges()) {
173
+ $productId = $product->getProductId();
174
+
175
+ $actionData[$i]['id'] = $product->getProductId();
176
+ $actionData[$i]['name'] = $product->getName();
177
+ $actionData[$i]['sku'] = $product->getSku();
178
+ $actionData[$i]['price'] = $product->getPrice();
179
+ $actionData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
180
+
181
+ $actionData[$i]['image_url'] = $product->getImageUrl();
182
+ $actionData[$i]['product_url'] = $product->getProductUrl();
183
+
184
+ $oldQty = (int) $product->getOrigData('qty');
185
+ $newQty = (int) $product->getQty();
186
+ $qtyDiff = 0;
187
+ $subdiff = $subdiff + ($newQty - $oldQty) * $product->getPrice();
188
+ $actionData[$i]['quantity'] = (int) $product->getQty();
189
+ $i++;
190
+ }
191
+ }
192
+ $subdiff=Mage::helper('core')->currency($subdiff , false, false);
193
+
194
+ $cart = Mage::getSingleton('checkout/cart');
195
+ $cart_id=$cart->getQuote()->getId();
196
+ $subTotalPrice = $cart->getQuote()->getGrandTotal();
197
+ $totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
198
+
199
+
200
+ $cartInfo["total"] =$subTotalPrice + $subdiff;
201
+ $cartInfo["revenue"] = $subTotalPrice + $subdiff;
202
+ $cartInfo['abandon_cart_url'] = Mage::getUrl('checkout/cart');
203
+ $cartInfo['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
204
+
205
+ $actionDescription = array(
206
+ 'activity_type' => 'update_cart',
207
+ 'identifiers' => $this->getCustomerIdentity(),
208
+ 'cart_info' => $cartInfo,
209
+ 'products' => $actionData
210
+ );
211
+
212
+ mail("rohit@getamplify.com","update cart",json_encode($actionDescription));
213
+ $res = $this->amplify->customer_action($actionDescription);
214
+ }
215
+ } catch (Exception $ex) {
216
+
217
+ }
218
+ }
219
+
220
  public function getAmplifyEventReview($evnt) {
221
  try {
222
  if ($this->verified) {
237
  if ($pid == 1) {
238
  $pid = 0;
239
  }
240
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
241
  }
242
 
243
  $actionData = array();
244
+ $actionData[0]['id'] = $product->getId();
245
+ $actionData[0]['name'] = $product->getName();
246
  $actionData[0]['sku'] = $product->getSku();
247
  $actionData[0]['price'] = $product->getPrice();
248
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
249
+
250
+ $actionData[0]['image_url'] = $product->getImageUrl();
251
+ $actionData[0]['product_url'] = $product->getProductUrl();
252
+ $actionData[0]['categories'] = $cateHolder;
253
+
254
+ $actionDescription = array(
255
+ 'activity_type' => 'review',
256
+ 'identifiers' => $this->getCustomerIdentity(),
 
 
 
 
 
 
257
  'products' => $actionData
258
  );
259
+
260
  $res = $this->amplify->customer_action($actionDescription);
261
  }
262
  } catch (Exception $ex) {
272
  try {
273
  if ($this->verified) {
274
 
275
+ $this->event('customer_logout');
276
  }
277
  } catch (Exception $ex) {
278
 
282
  public function getAmplifyEventCustomerLogin($evnt) {
283
  try {
284
  if ($this->verified) {
285
+ $data=array();
286
  $c = Mage::getSingleton('customer/session')->getCustomer();
287
  $customer = Mage::getModel('customer/customer')->load($c->getId());
288
  $email = $customer->getEmail();
289
  $custName = $customer->getFirstname();
290
  $custName = $custName . " " . $customer->getLastname();
291
+
 
 
 
 
 
 
 
 
 
 
 
 
292
  $person = array();
293
  $customerAddressId = $c->getDefaultShipping();
294
  if ($customerAddressId) {
300
  if (is_object($customer)) {
301
  $person['firstname'] = $customer->getFirstname();
302
  $person['lastname'] = $customer->getLastname();
 
303
  $person['postcode'] = $customer->getPostcode();
 
304
  $person['fax'] = $customer->getfax();
 
305
  $person['company'] = $customer->getCompany();
 
306
  $person['street'] = $customer->getStreetFull();
307
+
308
+ $data['email']=$email;
309
+ $data['phone'] = $customer->getTelephone();
310
+ $data['customer_id'] = $customer->getCustomerId();
311
+ try {
312
+ $this->amplify->identify($data);
313
+ } catch (Exception $ex) {
314
+ }
315
  $person = array_filter($person);
316
+ $properties['update']=$person;
317
+ $res = $this->amplify->userProperties($data, $properties);
318
+ }else{
319
+ try {
320
+ $data['email']=$email;
321
+ $this->amplify->identify($data);
322
+ } catch (Exception $ex) {
323
+
324
+ }
325
  }
326
+
327
+ $this->amplify->event($data, "customer_login");
328
  }
329
  } catch (Exception $ex) {
330
 
336
  if ($this->verified) {
337
 
338
  $subscriber = $evnt->getEvent()->getSubscriber();
339
+ $identity['email']=$subscriber->subscriber_email;
340
+ try{
341
+ $this->amplify->identify($identity);
342
+ }catch(Exception $ex){
343
+
344
+ }
345
 
346
  if ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
347
+ $this->event('subscribed_to_newsletter');
 
348
  } elseif ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED) {
349
+ $this->event('unsubscribed_from_newsletter');
 
350
  }
351
  }
352
  } catch (Exception $ex) {
356
 
357
  public function getCustomerIdentity($true = 1) {
358
  try {
359
+ $data=array();
360
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
361
 
362
  $c = Mage::getSingleton('customer/session')->getCustomer();
364
  $email = $customer->getEmail();
365
  $custName = $customer->getFirstname();
366
  $custName = $custName . " " . $customer->getLastname();
367
+ $data = json_decode(base64_decode(Mage::getModel('core/cookie')->get('_ampUSER')),true);
368
+ $data['email']=$email;
369
  } else {
370
+ $data = json_decode(base64_decode(Mage::getModel('core/cookie')->get('_ampUSER')),true);
371
  }
372
  if ($true)
373
+ return $data;
374
  } catch (Exception $ex) {
375
 
376
  }
396
 
397
  $person = array();
398
  $person['email'] = $customer->getEmail();
399
+ $person['customer_id'] = $customer->getId();
400
  $person['first_name'] = $customer->getFirstname();
401
  $person['last_name'] = $customer->getLastname();
402
  $person['created'] = $customer->getCreatedAt();
420
  $customer = $evnt->getCustomer();
421
  $person = array();
422
  $person = $this->getCustomereventInfo($customer);
423
+ $identifyData['email']=$person['email'];
424
+ $identifyData['customer_id']=$person['customer_id'];
425
+ $this->amplify->identify($identifyData, $person['first_name']);
426
+ $properties['update']=array("first_name"=>$person['first_name'],'last_name'=>$person['first_name']);
427
+ $this->amplify->event($identifyData, $properties);
428
  }
429
  } catch (Exception $ex) {
430
 
443
  $coupon_code = $oRule->getCoupon_code();
444
 
445
  if (isset($coupon_code) && !empty($coupon_code)) {
446
+ $this->event('coupon_success');
 
447
  } else {
448
+ $this->event('coupon_unsuccess'); }
 
 
 
449
  return $this;
450
  }
451
  } catch (Exception $ex) {
453
  }
454
  }
455
 
456
+ public function event($event) {
457
  try {
458
  if ($this->verified) {
459
+ $this->amplify->event($this->getCustomerIdentity(), $event);
 
 
 
 
 
460
  }
461
  } catch (Exception $ex) {
462
 
479
  $eventname = $event->getName();
480
  $product = $event->getProduct();
481
 
 
 
 
482
  $catCollection = $product->getCategoryCollection();
483
  $categs = $catCollection->exportToArray();
484
  $cateHolder = array();
485
 
486
+ foreach ($categs as $cat) {
487
  $cateName = Mage::getModel('catalog/category')->load($cat['entity_id']);
488
  $name = $cateName->getName();
489
  $id = $cateName->getEntityId();
490
  $pid = $cateName->getParent_id();
491
+ if ($pid == 1) {
492
+ $pid = 0;
 
 
 
 
 
 
 
 
 
493
  }
494
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
495
  }
496
+
 
 
 
 
 
 
 
 
497
  $actionData = array();
498
  $actionData[0]['productId'] = $product->getId();
499
  $actionData[0]['productTitle'] = $product->getName();
500
  $actionData[0]['sku'] = $product->getSku();
501
  $actionData[0]['price'] = $product->getPrice();
502
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
503
+
504
+ $actionData[0]['image_url'] = $product->getImageUrl();
505
+ $actionData[0]['product_url'] = $product->getProductUrl();
506
+
507
+ $actionData[0]['categories'] = $cateHolder;
508
+
 
 
 
 
 
 
509
  $actionDescription = array(
510
+ 'activity_type' => 'wishlist',
511
+ 'identifiers' => $this->getCustomerIdentity(),
512
  'products' => $actionData
513
  );
514
  $res = $this->amplify->customer_action($actionDescription);
525
  public function getAmplifyOrderSuccessPageView(Varien_Event_Observer $evnt) {
526
  try {
527
  if ($this->verified) {
528
+ $orderIds = $evnt->getData('order_ids');
529
+ if (empty($orderIds) || !is_array($orderIds)) {
530
+
531
+ $this->event('Order Id Missing');
532
+ }else{
533
+ foreach($orderIds as $_orderId){
534
+ $order = Mage::getModel("sales/order")->load($_orderId);
535
  $order_id = $order->getIncrementId();
536
  $person = array();
537
+ $data=array();
538
  $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
539
  if ($customerAddressId) {
540
  $customer = $order->getShippingAddress();
541
 
542
  if (is_object($customer)) {
543
+ $data['email']=$customer->getEmail();
544
+ $data['phone'] = $customer->getTelephone();
545
+ $data['customer_id'] = $customer->getCustomerId();
546
  $person['firstname'] = $customer->getFirstname();
547
  $person['lastname'] = $customer->getLastname();
 
548
  $person['postcode'] = $customer->getPostcode();
 
549
  $person['fax'] = $customer->getfax();
 
550
  $person['company'] = $customer->getCompany();
551
  $person['street'] = $customer->getStreetFull();
552
  }
553
+ try {
554
+ $this->amplify->identify($data);
555
+ } catch (Exception $ex) {
556
+ }
557
  $person = array_filter($person);
558
+ $properties['update']=$person;
559
+ $res = $this->amplify->userProperties($data, $properties);
560
+
561
  } else {
562
  $customer = $order->getShippingAddress();
563
  if (is_object($customer)) {
564
+ $data['email']=$customer->getEmail();
565
+ $data['phone'] = $customer->getTelephone();
566
+ $data['customer_id'] = $customer->getCustomerId();
567
  $person['firstname'] = $customer->getFirstname();
568
  $person['lastname'] = $customer->getLastname();
 
569
  $person['postcode'] = $customer->getPostcode();
 
570
  $person['fax'] = $customer->getfax();
 
571
  $person['company'] = $customer->getCompany();
572
  $person['street'] = $customer->getStreetFull();
573
+ try {
574
+ $this->amplify->identify($data);
575
+ } catch (Exception $ex) {
576
+ }
577
+ $person = array_filter($person);
578
+ $properties['update']=$person;
579
+ $res = $this->amplify->userProperties($data, $properties);
580
  }
581
  }
582
 
583
  $items = $order->getAllVisibleItems();
584
  $itemcount = count($items);
585
+
 
 
 
 
586
  $i = 0;
587
  $actionData = array();
588
 
601
  if ($pid == 1) {
602
  $pid = 0;
603
  }
604
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
605
  }
606
 
607
+ $actionData[$i]['id'] = $product->getId();
608
+ $actionData[$i]['name'] = $product->getName();
609
  $actionData[$i]['sku'] = $product->getSku();
610
  $actionData[$i]['price'] = $product->getPrice();
611
  $actionData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
612
+ $actionData[$i]['image_url'] = $product->getImageUrl();
613
+ $actionData[$i]['product_url'] = $product->getProductUrl();
614
+ $actionData[$i]['brandname'] = $product->getResource()->getAttribute('manufacturer') ? $product->getAttributeText('manufacturer') : false;
615
+ $actionData[$i]['quantity'] = (int) $item->getQtyOrdered();
616
+ $actionData[$i]['categories'] = $cateHolder;
 
 
 
 
 
 
 
 
 
617
  $i++;
618
  }
619
 
620
+
621
  $cart_id=Mage::getModel('core/cookie')->get('_ampCart');
622
+
623
+
624
  $TotalPrice = $order->getGrandTotal();
625
  $totalShippingPrice = $order->getShippingAmount();
626
  $TotalPrice = $TotalPrice;
627
  $subTotalPrice = $order->getSubtotal();
628
+
629
+ $orderInfo["revenue"] = $subTotalPrice - abs($order->getDiscountAmount());
630
+ $orderInfo["total"] = $TotalPrice;
631
+ $orderInfo["shipping"] = $totalShippingPrice;
632
+ $orderInfo['order_id'] = $order->getIncrementId();
633
+ $orderInfo['coupon']= $order->getCouponCode();
634
+ $orderInfo['discount'] = abs($order->getDiscountAmount());
635
+
636
  $orderInfo['currency'] = $order->getOrderCurrencyCode();
637
+ $orderInfo['status'] = 'completed';
638
+
639
+ $orderInfo['tax'] = $order->getShippingTaxAmount();
640
+ if(!is_object($order->getPayment())){
641
+ $orderInfo['payment_method']="Custom";
642
+ }else{
643
+ $orderInfo['payment_method'] = $order->getPayment()->getMethodInstance()->getCode();
644
+ }
645
+
646
  $actionDescription = array(
647
+ 'activity_type' => 'purchase',
648
+ 'identifiers' => $data,
649
+ 'order_info' => $orderInfo,
650
+ 'products' => $actionData
651
  );
652
+
 
653
  $res = $this->amplify->customer_action($actionDescription);
654
+ }
655
+ }
656
  }
657
  } catch (Exception $ex) {
658
  $this->event('error_one');
660
  }
661
 
662
  public function getAmplifyOrderSaveSuccess(Varien_Event_Observer $evnt) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  }
664
 
665
  public function getAmplify_checkout_allow_guest($evnt) {
666
  try {
667
  if ($this->verified) {
 
668
  $getquote = $evnt->getQuote();
669
  $data = array_filter($getquote->getData());
670
+ if(isset($data['customer_email']) && $data['customer_email']!=""){
671
  Mage::getModel('core/cookie')->set('amplify_email', $data['customer_email']);
672
  $person = array();
673
  $person['webId'] = Mage::app()->getWebsite()->getId();
674
  $person['storeId'] = Mage::app()->getStore()->getId();
675
+ $person['firstName'] = $data['customer_firstname'];
676
+ $person['lastName'] = $data['customer_lastname'];
677
  $person = array_filter($person);
678
+ $identifierData['email']=$data['customer_email'];
679
+ $identifierData['customer_id']="";
680
+ $identifierData['phone']="";
681
+ $this->amplify->identify($identifierData);
682
+ $properties['update']=$person;
683
+ $res = $this->amplify->userProperties($identifierData, $properties);
684
+ }
685
  }
686
  } catch (Exception $ex) {
687
 
688
  }
689
  }
690
 
691
+ public function getAmplifyCatalog_product_save_after($observer) {
692
+ try {
693
+ $product = $observer->getProduct();
694
+ $catCollection = $product->getCategoryCollection();
695
+
696
+ $categs = $catCollection->exportToArray();
697
+ $cateHolder = array();
698
+ foreach ($categs as $cat) {
699
+ $cateName = Mage::getModel('catalog/category')->load($cat['entity_id']);
700
+ $name = $cateName->getName();
701
+ $id = $cateName->getEntityId();
702
+ $pid = $cateName->getParent_id();
703
+ if ($pid == 1) {
704
+ $pid = 0;
705
+ }
706
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
707
+ }
708
+ $actionData = array();
709
+ $actionData[0]['id'] = $product->getId();
710
+ $actionData[0]['name'] = $product->getName();
711
+ $actionData[0]['sku'] = $product->getSku();
712
+ $actionData[0]['price'] = $product->getPrice();
713
+ $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
714
+ $actionData[0]['image_url'] = $product->getImageUrl();
715
+ $actionData[0]['product_url'] = $product->getProductUrl();
716
+ $actionData[0]['categories'] = $cateHolder;
717
+ $actionDescription = array(
718
+ "identifiers" => $this->getCustomerIdentity(),
719
+ 'products' => $actionData
720
+ );
721
+ $this->amplify->product_add($actionDescription);
722
+ } catch (Exception $ex) {
723
+
724
+ }
725
  }
726
 
727
  public function getAmplifyCatalog_product_delete_after_done($evnt) {
745
  if ($pid == 1) {
746
  $pid = 0;
747
  }
748
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
749
  }
750
 
751
 
753
  $action = $event->getControllerAction();
754
  $stock_data = $product->getIs_in_stock();
755
  $actionData = array();
756
+ $actionData[0]['id'] = $product->getId();
757
+ $actionData[0]['name'] = $product->getName();
758
  $actionData[0]['sku'] = $product->getSku();
759
  $actionData[0]['price'] = $product->getPrice();
760
  $actionData[0]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
761
+ $actionData[0]['image_url'] = $product->getImageUrl();
762
+ $actionData[0]['product_url'] = $product->getProductUrl();
763
+ $actionData[0]['categories'] = $cateHolder;
764
+
765
+
766
+ // $actionData[0]['discount'] = abs($product->getPrice() - $product->getFinalPrice());
 
 
 
 
 
767
  $actionDescription = array(
768
+ 'activity_type' => 'view',
769
+ "identifiers" => $this->getCustomerIdentity(),
770
+ 'products' => $actionData
771
  );
 
772
  $res = $this->amplify->customer_action($actionDescription);
773
  }
774
  } catch (Exception $ex) {
775
 
776
  }
777
  }
778
+
 
 
 
 
 
 
 
 
 
 
 
 
779
  public function getAmplifyCustomerAdressSaveAfter($evnt) {
780
 
781
  }
782
 
 
 
 
 
783
  /**
784
  * @param Varien_Event_Observer $observer
785
  * @author Dharam <dharmendra@socialcrawler.in>
786
  *
787
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
788
 
789
  public function getAmplifyCancelOrderItem($observer) {
790
 
app/code/community/Betaout/Amplify/controllers/betaoutorderController.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Betaout_Amplify_BetaoutorderController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function importAction(){
6
+ try{
7
+ $startDate=isset($_GET['startDate'])?$_GET['startDate']:date("Y-m-d 00:00:00");
8
+ $endDate=isset($_GET['endDate'])?$_GET['endDate']:date("Y-m-d 23:00:00");
9
+ $status=isset($_GET['status'])?$_GET['status']:"completed";
10
+ $yesterday=date("Y-m-d 00:00:00", strtotime($startDate));
11
+ $today=date("Y-m-d 23:59:59", strtotime($endDate));
12
+ $orders = Mage::getModel('sales/order')->getCollection()
13
+ ->addFieldToFilter('status', $status)
14
+ ->addAttributeToFilter('created_at', array("from" => $yesterday, "to" => $today, "datetime" => true))
15
+ ->addAttributeToSelect('entity_id');
16
+
17
+ echo $count=$orders->Count();
18
+ if($count){
19
+ foreach ($orders as $order) {
20
+ $orderId = $order->getId();
21
+ $order = Mage::getModel("sales/order")->load($orderId);
22
+ $order_id = $order->getIncrementId();
23
+ $email= $order->getData('customer_email');
24
+ $email= $order->getData('customer_email');
25
+ $data=array();
26
+ $data['email']=$email;
27
+ $customer = $order->getShippingAddress();
28
+ if (is_object($customer)) {
29
+ $data['email']=$customer->getEmail();
30
+ $data['phone'] = $customer->getTelephone();
31
+ $data['customer_id'] = $customer->getCustomerId();
32
+ }
33
+ $data= array_filter($data);
34
+ $items = $order->getAllVisibleItems();
35
+ $itemcount = count($items);
36
+ $i = 0;
37
+ $actionData = array();
38
+
39
+ foreach ($items as $itemId => $item) {
40
+ $product = $item;
41
+ $product = Mage::getModel('catalog/product')->load($product->getProductId());
42
+ $categoryIds = $product->getCategoryIds();
43
+ $cateHolder = array();
44
+
45
+ foreach ($categoryIds as $cat) {
46
+ $cateName = Mage::getModel('catalog/category')->load($cat['entity_id']);
47
+ $name = $cateName->getName();
48
+ $id = $cateName->getEntityId();
49
+ $pid = $cateName->getParent_id();
50
+ if ($pid == 1) {
51
+ $pid = 0;
52
+ }
53
+ $cateHolder[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
54
+ }
55
+
56
+ $actionData[$i]['id'] = $product->getId();
57
+ $actionData[$i]['name'] = $product->getName();
58
+ $actionData[$i]['sku'] = $product->getSku();
59
+ $actionData[$i]['price'] = $product->getPrice();
60
+ $actionData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
61
+
62
+ $actionData[$i]['image_url'] = $product->getImageUrl();
63
+ $actionData[$i]['product_url'] = $product->getProductUrl();
64
+ $actionData[$i]['brandname'] = $product->getResource()->getAttribute('manufacturer') ? $product->getAttributeText('manufacturer') : false;
65
+ $actionData[$i]['quantity'] = (int) $item->getQtyOrdered();
66
+ $actionData[$i]['category'] = $cateHolder;
67
+
68
+ $i++;
69
+ }
70
+
71
+
72
+ $TotalPrice = $order->getGrandTotal();
73
+ $totalShippingPrice = $order->getShippingAmount();
74
+ $TotalPrice = $TotalPrice;
75
+ $subTotalPrice = $order->getSubtotal();
76
+ $orderInfo["revenue"] = $subTotalPrice - abs($order->getDiscountAmount());
77
+ $orderInfo["total"] = $TotalPrice;
78
+ $orderInfo["shipping"] = $totalShippingPrice;
79
+ $orderInfo['order_id'] = $order->getIncrementId();
80
+ $orderInfo['coupon'] = $order->getCouponCode();
81
+ $orderInfo['discount'] = abs($order->getDiscountAmount());
82
+ $orderInfo['currency'] = $order->getOrderCurrencyCode();
83
+ $orderInfo['status'] = 'completed';
84
+ $orderInfo['tax'] = $order->getShippingTaxAmount();
85
+ $orderInfo['payment_method']="Custom";
86
+
87
+ $actionDescription = array(
88
+ 'activity_type' => 'purchase',
89
+ 'identifiers' => $data,
90
+ 'order_info' => $orderInfo,
91
+ 'products' => $actionData,
92
+ 'timestamp'=>Mage::getModel('core/date')->timestamp($order->getData('created_at'))
93
+ );
94
+ echo "Time".$order->getData('created_at');
95
+ //
96
+
97
+ self::sendData($actionDescription,'ecommerce/activities/');
98
+
99
+ }
100
+ }else{
101
+
102
+ }
103
+
104
+ }catch(Exception $e){
105
+ echo json_encode(array("error"=>$e->getMessage()));
106
+ }
107
+
108
+ }
109
+
110
+ public function addProductAction(){
111
+ $limit=isset($_GET['limit'])?$_GET['limit']:"5";
112
+ $cpage=isset($_GET['pageNo'])?$_GET['pageNo']:1;
113
+ $products = Mage::getModel('catalog/product')->getCollection()
114
+ ->addAttributeToSelect('*') // select all attributes
115
+ ->setPageSize($limit) // limit number of results returned
116
+ ->setCurPage($cpage); // set the offset (useful for pagination)
117
+
118
+ $productData=array();
119
+ $i=0;
120
+ // we iterate through the list of products to get attribute values
121
+ foreach ($products as $product) {
122
+ $productData[$i]['name']=$product->getName(); //get name
123
+ $productData[$i]['price']=(float) $product->getPrice(); //get price as cast to float
124
+ $productData[$i]['id']=$product->getId();
125
+ $productData[$i]['sku']= $product->getSku();
126
+ $productData[$i]['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
127
+ $productData[$i]['image_url'] = $product->getImageUrl();
128
+ $productData[$i]['product_url'] = $product->getProductUrl();
129
+ $productData[$i]['brandname'] = $product->getResource()->getAttribute('manufacturer') ? $product->getAttributeText('manufacturer') : false;
130
+ $categories=array();
131
+ $categoryIds = $product->getCategoryIds();
132
+ // getCategoryIds(); returns an array of category IDs associated with the product
133
+ foreach ($categoryIds as $category_id) {
134
+ $cateName = Mage::getModel('catalog/category')->load($category_id['entity_id']);
135
+ $name = $cateName->getName();
136
+ $id = $cateName->getEntityId();
137
+ $pid = $cateName->getParent_id();
138
+ if ($pid == 1) {
139
+ $pid = 0;
140
+ }
141
+ $categories[] = array("cat_id"=>$id,"cat_name" => $name, "parent_cat_id" => $pid);
142
+ }
143
+ $productData[$i]['categories']=$categories;
144
+ $i++;
145
+ }
146
+ $actionDescription = array(
147
+ 'products' => $productData,
148
+ 'timestamp'=> time()
149
+ );
150
+ self::sendData($actionDescription,'ecommerce/products/');
151
+ }
152
+ public function sendData($data,$path){
153
+ $key=Mage::getStoreConfig('betaout_amplify_options/settings/amplify_key');
154
+ $projectId = Mage::getStoreConfig('betaout_amplify_options/settings/amplify_projectId');
155
+ $url="https://api.betaout.com/v2/".$path;
156
+ $data['apikey']=$key;
157
+ $data['project_id']=$projectId;
158
+ $data['useragent'] = $_SERVER['HTTP_USER_AGENT'];
159
+ $jdata = json_encode($data);
160
+ $curl = curl_init($url);
161
+ curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-Type: application/json'));
162
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 3000);
163
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
164
+ curl_setopt($curl, CURLOPT_POST, true);
165
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $jdata);
166
+ $result = curl_exec($curl);
167
+ $response = json_decode($result);
168
+ curl_close($curl);
169
+ }
170
+ }
app/code/community/Betaout/Amplify/etc/config.xml CHANGED
@@ -74,46 +74,22 @@
74
  </yourmodule>
75
  </observers>
76
  </admin_system_config_changed_section_betaout_amplify_options>
77
- <!-- <checkout_onepage_controller_success_action>
78
- <observers>
79
- <checkout_type_onepage_save_order>
80
- <class>Betaout_Amplify_Model_Key</class>
81
- <method>getAmplifyOrderSuccessPageView</method>
82
- </checkout_type_onepage_save_order>
83
- </observers>
84
- </checkout_onepage_controller_success_action>-->
85
-
86
- <!-- <checkout_onepage_controller_success_action>
87
- <observers>
88
- <amplify_order_success>
89
- <class>Betaout_Amplify_Model_Key</class>
90
- <method>getAmplifyOrderSuccessPageView</method>
91
- </amplify_order_success>
92
- </observers>
93
- </checkout_onepage_controller_success_action>-->
94
-
95
- <sales_order_save_commit_after><!--could used sales_order_save_after for backend support, but it fires mulitple times-->
96
  <observers>
97
- <amplify_sales_order_save_commit_after>
98
  <type>singleton</type>
99
  <class>Betaout_Amplify_Model_Key</class>
100
- <method>getAmplifySales_order_save_commit_after</method>
101
- </amplify_sales_order_save_commit_after>
102
  </observers>
103
- </sales_order_save_commit_after>
104
-
105
- <checkout_type_onepage_save_order_after>
106
- <observers>
107
- <betaout_amplify>
108
- <class>Betaout_Amplify_Model_Key</class>
109
- <method>getAmplifyOrderSaveSuccess</method>
110
- </betaout_amplify>
111
- </observers>
112
- </checkout_type_onepage_save_order_after>
113
-
114
  </events>
115
-
116
- </global>
117
  <frontend>
118
  <routers>
119
  <amplify>
@@ -135,11 +111,21 @@
135
  <checkout_onepage_controller_success_action>
136
  <observers>
137
  <amplify_order_success>
 
138
  <class>Betaout_Amplify_Model_Key</class>
139
  <method>getAmplifyOrderSuccessPageView</method>
140
  </amplify_order_success>
141
  </observers>
142
  </checkout_onepage_controller_success_action>
 
 
 
 
 
 
 
 
 
143
  <sales_quote_remove_item>
144
  <observers>
145
  <sales_quote_remove_item>
@@ -257,32 +243,7 @@
257
  </catalogProductView>
258
  </observers>
259
  </catalog_controller_product_view>
260
- <wishlist_share>
261
- <observers>
262
- <wishlist_share>
263
- <class>Betaout_Amplify_Model_Key</class>
264
- <method>wishlistShare</method>
265
- </wishlist_share>
266
- </observers>
267
- </wishlist_share>
268
- <sendfriend_product>
269
- <observers>
270
- <sendfriend_product>
271
- <class>Betaout_Amplify_Model_Key</class>
272
- <method>getAmplifySendfriendProduct</method>
273
- </sendfriend_product>
274
- </observers>
275
- </sendfriend_product>
276
- <catalog_product_compare_add_product>
277
- <observers>
278
- <catalog_product_compare_add_product>
279
- <class>Betaout_Amplify_Model_Key</class>
280
- <method>catalogProductCompareAddProduct</method>
281
- </catalog_product_compare_add_product>
282
- </observers>
283
- </catalog_product_compare_add_product>
284
-
285
- </events>
286
  </frontend>
287
  <admin>
288
  <routers>
74
  </yourmodule>
75
  </observers>
76
  </admin_system_config_changed_section_betaout_amplify_options>
77
+ </events>
78
+
79
+ </global>
80
+ <adminhtml>
81
+ <events>
82
+ <catalog_product_save_before><!-- observe the event -->
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  <observers>
84
+ <amplify>
85
  <type>singleton</type>
86
  <class>Betaout_Amplify_Model_Key</class>
87
+ <method>getAmplifyCatalog_product_save_after</method>
88
+ </amplify>
89
  </observers>
90
+ </catalog_product_save_before>
 
 
 
 
 
 
 
 
 
 
91
  </events>
92
+ </adminhtml>
 
93
  <frontend>
94
  <routers>
95
  <amplify>
111
  <checkout_onepage_controller_success_action>
112
  <observers>
113
  <amplify_order_success>
114
+ <type>singleton</type>
115
  <class>Betaout_Amplify_Model_Key</class>
116
  <method>getAmplifyOrderSuccessPageView</method>
117
  </amplify_order_success>
118
  </observers>
119
  </checkout_onepage_controller_success_action>
120
+ <checkout_multishipping_controller_success_action>
121
+ <observers>
122
+ <points_observer>
123
+ <type>singleton</type>
124
+ <class>Betaout_Amplify_Model_Key</class>
125
+ <method>getAmplifyOrderSuccessPageView</method>
126
+ </points_observer>
127
+ </observers>
128
+ </checkout_multishipping_controller_success_action>
129
  <sales_quote_remove_item>
130
  <observers>
131
  <sales_quote_remove_item>
243
  </catalogProductView>
244
  </observers>
245
  </catalog_controller_product_view>
246
+ </events>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  </frontend>
248
  <admin>
249
  <routers>
app/code/community/Betaout/Amplify/etc/system.xml CHANGED
@@ -57,15 +57,7 @@
57
  <show_in_website>1</show_in_website>
58
  <show_in_store>1</show_in_store>
59
  </amplify_projectId>
60
- <amplify_secret>
61
- <label>Betaout API Secret</label>
62
- <frontend_type>text</frontend_type>
63
- <sort_order>2</sort_order>
64
- <show_in_default>1</show_in_default>
65
- <show_in_website>1</show_in_website>
66
- <show_in_store>1</show_in_store>
67
- </amplify_secret>
68
- <amplify_key>
69
  <label>Betaout API Key</label>
70
  <frontend_type>text</frontend_type>
71
  <sort_order>1</sort_order>
@@ -73,80 +65,9 @@
73
  <show_in_website>1</show_in_website>
74
  <show_in_store>1</show_in_store>
75
  </amplify_key>
76
- <AmplifyConnect_Widget>
77
- <label>BetaoutConnect_Widget</label>
78
- <frontend_type>select</frontend_type>
79
- <source_model>Betaout_Amplify_Model_Amplifyconnectwidget</source_model>
80
- <sort_order>4</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
- </AmplifyConnect_Widget>
85
- <urlTracking>
86
- <label>Url Tracking</label>
87
- <frontend_type>select</frontend_type>
88
- <source_model>Betaout_Amplify_Model_Urltracking</source_model>
89
- <sort_order>5</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>
93
- </urlTracking>
94
- <shareTracking>
95
- <label>Share Tracking</label>
96
- <frontend_type>select</frontend_type>
97
- <source_model>Betaout_Amplify_Model_Sharetracking</source_model>
98
- <sort_order>5</sort_order>
99
- <show_in_default>1</show_in_default>
100
- <show_in_website>1</show_in_website>
101
- <show_in_store>1</show_in_store>
102
- </shareTracking>
103
  </fields>
104
  </settings>
105
- <!-- <conflictchecker>
106
- <label>Conflict Checker</label>
107
- <frontend_type>text</frontend_type>
108
- <sort_order>40</sort_order>
109
- <show_in_default>1</show_in_default>
110
- <show_in_website>1</show_in_website>
111
- <show_in_store>1</show_in_store>
112
- <expanded>1</expanded>
113
- <fields>
114
- <check_conflicts>
115
- <label>Check Conflicts</label>
116
- <comment>Find all module conflicts</comment>
117
- <frontend_type>text</frontend_type>
118
- <frontend_model>Betaout_Amplify_Block_Adminhtml_System_Config_Form_Field_Conflict</frontend_model>
119
- <sort_order>1</sort_order>
120
- <show_in_default>1</show_in_default>
121
- <show_in_website>1</show_in_website>
122
- <show_in_store>1</show_in_store>
123
- </check_conflicts>
124
- </fields>
125
- </conflictchecker>-->
126
- <!-- <order translate="label">
127
- <label>What's about previous data</label>
128
- <frontend_type>text</frontend_type>
129
- <sort_order>2</sort_order>
130
- <show_in_default>1</show_in_default>
131
- <fields>
132
- <status1>
133
- <label>Wanna send</label>
134
- <frontend_type>select</frontend_type>
135
- <source_model>Betaout_Amplify_Model_CronStatus</source_model>
136
- <sort_order>39</sort_order>
137
- <show_in_default>1</show_in_default>
138
- <show_in_website>1</show_in_website>
139
- <show_in_store>1</show_in_store>
140
- </status1>
141
- <cron_setting>
142
- <label>How often do you want too send data?</label>
143
- <frontend_type>text</frontend_type>
144
- <sort_order>40</sort_order>
145
- <comment>Use Crontab Format (Eg. "*/5 * * * *" for every 5 minutes)</comment>
146
- <show_in_default>1</show_in_default>
147
- </cron_setting>
148
- </fields>
149
- </order>-->
150
  </groups>
151
  </betaout_amplify_options>
152
 
57
  <show_in_website>1</show_in_website>
58
  <show_in_store>1</show_in_store>
59
  </amplify_projectId>
60
+ <amplify_key>
 
 
 
 
 
 
 
 
61
  <label>Betaout API Key</label>
62
  <frontend_type>text</frontend_type>
63
  <sort_order>1</sort_order>
65
  <show_in_website>1</show_in_website>
66
  <show_in_store>1</show_in_store>
67
  </amplify_key>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  </fields>
69
  </settings>
70
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  </groups>
72
  </betaout_amplify_options>
73
 
app/design/frontend/base/default/template/betaout_amplify/checkout.phtml CHANGED
@@ -1,42 +0,0 @@
1
- <script>
2
- if (Ajax.Responders) {
3
-
4
- Ajax.Responders.register({
5
- onComplete: function (data) {
6
- if (!data.url.include("progress") && !data.url.include("getAdditional")) {
7
-
8
- if (data.url.include("saveOrder")) {
9
-
10
- _bOut.push(["addEvent", {'checkout_process_completed': {
11
- 'step': 'checkout_process_completed'
12
- }}]);
13
-
14
- } else if (accordion.currentSection) {
15
- temp = (accordion.currentSection).split("-");
16
- evtName = 'checkout_process_' + temp[1];
17
- if (evtName == "checkout_process_billing") {
18
- _bOut.push(["addEvent", {"checkout_process_billing": {
19
- 'step': accordion.currentSection
20
-
21
- }}]);
22
- }
23
- if (evtName == "checkout_process_payment") {
24
- _bOut.push(["addEvent", {"checkout_process_payment": {
25
- 'step': accordion.currentSection
26
- }}]);
27
- }
28
- if (evtName == "checkout_process_review") {
29
- _bOut.push(["addEvent", {"checkout_process_review": {
30
- 'step': accordion.currentSection
31
- }}]);
32
- }
33
-
34
- }
35
- }
36
-
37
- }
38
-
39
- });
40
- }
41
-
42
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/betaout_amplify/head.phtml CHANGED
@@ -1,13 +1,14 @@
1
  <?php
2
  //$startTime = microtime(true);
3
  try {
4
- // $model = Mage::getModel('betaout_amplify/key');
 
5
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
6
 
7
  $c = Mage::getSingleton('customer/session')->getCustomer();
8
  $customer = Mage::getModel('customer/customer')->load($c->getId());
9
-
10
  $identity = $customer->getEmail();
 
11
  }
12
  else {
13
  $identity= Mage::getModel('core/cookie')->get('amplify_email');
@@ -15,29 +16,25 @@ try {
15
 
16
  ?>
17
  <script type="text/javascript">
18
- var Amplify = "";
19
- _bOutCW =<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/AmplifyConnect_Widget"); ?>;
20
- _bOutST = "<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/shareTracking"); ?>";
21
- urlTracking = "<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/urlTracking"); ?>";
22
- _bOutAKEY = '<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/amplify_key"); ?>';
23
- _bOutPID = '<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/amplify_projectId"); ?>';
24
-
25
- var _bOut = _bOut || [];
26
- function _bOutS(u) {
27
- var d = document, f = d.getElementsByTagName("script")[0], _sc = d.createElement("script");
28
- _sc.type = "text/javascript";
29
- _sc.async = true;
30
- _sc.src = u;
31
- f.parentNode.insertBefore(_sc, f);
 
 
32
  }
33
- _bOutS("//d22vyp49cxb9py.cloudfront.net/jal-v1.min.js");
34
-
35
- _bOut.push(["identify", {
36
- "email": "<?php echo $identity; ?>",
37
- "name": ""
38
- }]);
39
-
40
- </script>
41
 
42
  <?php
43
 
1
  <?php
2
  //$startTime = microtime(true);
3
  try {
4
+ $identity="";
5
+ $customer_id="";
6
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
7
 
8
  $c = Mage::getSingleton('customer/session')->getCustomer();
9
  $customer = Mage::getModel('customer/customer')->load($c->getId());
 
10
  $identity = $customer->getEmail();
11
+ $customer_id = $customer->getId();
12
  }
13
  else {
14
  $identity= Mage::getModel('core/cookie')->get('amplify_email');
16
 
17
  ?>
18
  <script type="text/javascript">
19
+ var _bout = _bout || [];
20
+ var _boutAKEY = '<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/amplify_key"); ?>';
21
+ var _boutPID = '<?php echo Mage::getStoreConfig("betaout_amplify_options/settings/amplify_projectId"); ?>';
22
+
23
+
24
+ var d = document, f = d.getElementsByTagName("script")[0], _sc = d.createElement("script");
25
+ _sc.type = "text/javascript";
26
+ _sc.async = true;
27
+ _sc.src = "//d22vyp49cxb9py.cloudfront.net/jal-v2.min.js";
28
+ f.parentNode.insertBefore(_sc, f);
29
+ _bout.push(["identify", {
30
+ "customer_id": "<?php echo $customer_id;?>",
31
+ "email": "<?php echo $identity; ?>",
32
+ "phone": "",
33
+ "gcm_id": "",
34
+ "apn_id": ""
35
  }
36
+ ]);
37
+ </script>
 
 
 
 
 
 
38
 
39
  <?php
40
 
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Betaout</name>
4
- <version>2.1.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Helping Ecommerce Companies drive more sales and customer happiness. </summary>
10
  <description>Helping Ecommerce Companies drive more sales and customer happiness. </description>
11
- <notes>Increase plugin support for magento 1.5 and 1.6 version,Fix some issues in compiler mode and multishop</notes>
12
  <authors><author><name>jitendra</name><user>jitendra</user><email>jitendra@getamplify.com</email></author></authors>
13
- <date>2015-12-14</date>
14
- <time>12:30:08</time>
15
- <contents><target name="magecommunity"><dir name="Betaout"><dir name="Amplify"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="About.php" hash="5d714a88c93aa83a3cdfed81712a1611"/><dir name="Form"><dir name="Field"><file name="Conflict.php" hash="6f91b2528452ee1a96440d3a9da43962"/></dir></dir><file name="Logo.php" hash="40f74b3fab0f1bed08315ae83abb4d42"/></dir></dir><dir name="Widget"><dir name="Button"><file name="Conflict.php" hash="903c3c00124ae86bde48f7ce2ad2f066"/></dir></dir></dir><file name="Conflictprinter.php" hash="ce0256621be50bfe02bf01a80ac11b20"/></dir><dir name="Helper"><file name="Conflictchecker.php" hash="a03e8cff4427d5a7ed28f06530f75838"/><file name="Data.php" hash="ab8d5234d07dd762f516169f3be73fe8"/></dir><dir name="Model"><file name="Amplify.php" hash="78dc75e23cfc5fe4c36f4be604db0eb7"/><file name="Amplifyconnectwidget.php" hash="904cedccd8685cb3f4e801b81802ec6d"/><dir name="Config"><file name="Blocks.php" hash="d32094f94f70ddc75f4ecb4ea90bdc16"/><file name="Checker.php" hash="b2b4fc113e7511f23360dc01ca3dc7e3"/><file name="ConfigAbstract.php" hash="b19f0f25177fbea91c817758886d6373"/><file name="ConfigInterface.php" hash="85c1b11953b73728feb498ae81711c29"/><file name="Datastore.php" hash="f8a8c60c2f4e1801941c334ebe45cc1a"/><file name="Helpers.php" hash="f337bdceb3fb867f7e2aa8ad90b1216e"/><file name="Models.php" hash="500a145c160beb6797f7450d03069637"/><file name="Printer.php" hash="577801efaeb6bc6dd8bd096875fda08b"/><file name="Resources.php" hash="1f14e467d10ba2afbd2354f78c0047e7"/></dir><dir name="Core"><dir name="Config"><file name="Base.php" hash="7bccfac5cac9b19f1073bb97568958f8"/><file name="Element.php" hash="d2ce6a9a5840dbe335514b7455c60688"/></dir><file name="Config.php" hash="4222a35a2c71b3702199efbfddbee701"/></dir><file name="CronStatus.php" hash="298e6e428249ed7020c27e3c8abc52a2"/><file name="Key.php" hash="598f412c1dd9350a919e947d3f981d12"/><dir name="Lib"><dir name="Varien"><dir name="Simplexml"><file name="Config.php" hash="eba1dfcc303065cf5b3c9067d87dd35a"/><file name="Element.php" hash="24cb3b7db31ae8e2c813485a6b6ef749"/></dir></dir></dir><dir name="Mysql4"><dir name="Core"><file name="Config.php" hash="c0a59f8ff1f747224655de39b217abde"/></dir></dir><dir name="Path"><dir name="Locator"><file name="Array.php" hash="722f4125eb1cbd5fbc2be05facd44cd4"/><file name="Factory.php" hash="5a57006974d9870affbcbafa6ed00175"/><file name="IteratorAbstract.php" hash="adba5c801c91efdbc5afa493d353224a"/><file name="LocatorInterface.php" hash="30571ef5c7ebf942870a0ddd2ab341cb"/><file name="Stack.php" hash="73a27e38db4768019613c99407205771"/></dir></dir><dir name="Resource"><dir name="Core"><file name="Config.php" hash="14736455e9f006a69dc638e4b93f7e6e"/></dir><dir name="Db"><file name="Abstract.php" hash="3874d4c5cc4b1af30a550cc792bbe22f"/></dir></dir><file name="Sharetracking.php" hash="05f4fe212dfd53027525bae6321ea641"/><file name="Urltracking.php" hash="d4e7e48cbb8168c2baab17e1edde1eac"/><file name="Verify.php" hash="3e385480fdfdfb3b1219ba48c1ef1644"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConflictcheckerController.php" hash="28bf9f8cca4f3e63ea90c575c424deb0"/></dir><file name="indexController.php" hash="ca84b19b9ee9ea2678ba6ef5a6d23afa"/></dir><dir name="etc"><file name="config.xml" hash="263ed86240397f1ae3a1c1d0a1d2dc48"/><file name="system.xml" hash="2f980139f06c219fc2c1d1169a89883f"/></dir><dir name="log"><file name="log.log" hash="be8a8d092fd7ba1381cfbe23eda18c2e"/></dir><file name=".DS_Store" hash="e49cca224ac24efb7898b1adf5d52aaf"/></dir><file name=".DS_Store" hash="a27a5b993e15852172640eb72dabed84"/></dir></target><target name="mageetc"><dir name="modules"><file name="Betaout_Amplify.xml" hash="a8228fbbf2d0a09dc90cd7c80b4692f0"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="betaout_amplify.xml" hash="328dab6359ba6464621e558238610035"/></dir><dir name="template"><dir name="betaout_amplify"><file name="amplify.phtml" hash="ce94f7e9e16d3c519bc8efcf4541716c"/><file name="conflict.phtml" hash="43277d57972e4f750d8b65e0bfb5bcb8"/><file name="logo.phtml" hash="0af4376bf5074d24519ab7e9d3ea035b"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="betaout_amplify"><file name="checkout.phtml" hash="1d7652b352f2d7a3edb1f3bb48bc858e"/><file name="head.phtml" hash="f1e2aec315b8049593a4a299231d2713"/></dir></dir><dir name="layout"><file name="betaout_amplify.xml" hash="f262133af716b7e0c33ebc044e06518c"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="amplify"><dir name="images"><file name="Users.png" hash="96e906660b1fbd8a17831bd3049dbcfa"/><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="ajax-loader.gif" hash="e2a38f1e23288e315af3c55416bc1ce7"/><file name="btn.png" hash="769b6736cb1bb8cb91ad7526ce9d9db8"/><file name="check.png" hash="252fd93a83e2a412ecd3b6eac01500b7"/><file name="com-app.png" hash="1f241f552bdbe1f86763981c79c8d85f"/><file name="db-1.png" hash="840d96bd5679bf4fa2d6a9577f7d3539"/><file name="engage-app.png" hash="888cde6a10a3dd9abcfccd1a5f0c8fde"/><file name="icon.png" hash="22ea725b0bee73cb03f63b063b02469f"/><file name="large_bracket.png" hash="d2e8da8266e513bd5f15b0c9855be058"/><file name="mini_bracket.png" hash="e844112e5e5173f64b3385a4a140bdeb"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Betaout</name>
4
+ <version>2.2.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Helping Ecommerce Companies drive more sales and customer happiness. </summary>
10
  <description>Helping Ecommerce Companies drive more sales and customer happiness. </description>
11
+ <notes>Increase plugin support for betaout version v2.</notes>
12
  <authors><author><name>jitendra</name><user>jitendra</user><email>jitendra@getamplify.com</email></author></authors>
13
+ <date>2016-02-29</date>
14
+ <time>12:28:17</time>
15
+ <contents><target name="magecommunity"><dir name="Betaout"><dir name="Amplify"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="About.php" hash="5d714a88c93aa83a3cdfed81712a1611"/><dir name="Form"><dir name="Field"><file name="Conflict.php" hash="6f91b2528452ee1a96440d3a9da43962"/></dir></dir><file name="Logo.php" hash="40f74b3fab0f1bed08315ae83abb4d42"/></dir></dir><dir name="Widget"><dir name="Button"><file name="Conflict.php" hash="903c3c00124ae86bde48f7ce2ad2f066"/></dir></dir></dir><file name="Conflictprinter.php" hash="ce0256621be50bfe02bf01a80ac11b20"/></dir><dir name="Helper"><file name="Conflictchecker.php" hash="a03e8cff4427d5a7ed28f06530f75838"/><file name="Data.php" hash="ab8d5234d07dd762f516169f3be73fe8"/></dir><dir name="Model"><file name="Amplify.php" hash="ca4d8b3a4c588f2e6ab007dc4ee651fa"/><file name="Amplifyconnectwidget.php" hash="904cedccd8685cb3f4e801b81802ec6d"/><dir name="Config"><file name="Blocks.php" hash="d32094f94f70ddc75f4ecb4ea90bdc16"/><file name="Checker.php" hash="b2b4fc113e7511f23360dc01ca3dc7e3"/><file name="ConfigAbstract.php" hash="b19f0f25177fbea91c817758886d6373"/><file name="ConfigInterface.php" hash="85c1b11953b73728feb498ae81711c29"/><file name="Datastore.php" hash="f8a8c60c2f4e1801941c334ebe45cc1a"/><file name="Helpers.php" hash="f337bdceb3fb867f7e2aa8ad90b1216e"/><file name="Models.php" hash="500a145c160beb6797f7450d03069637"/><file name="Printer.php" hash="577801efaeb6bc6dd8bd096875fda08b"/><file name="Resources.php" hash="1f14e467d10ba2afbd2354f78c0047e7"/></dir><dir name="Core"><dir name="Config"><file name="Base.php" hash="7bccfac5cac9b19f1073bb97568958f8"/><file name="Element.php" hash="d2ce6a9a5840dbe335514b7455c60688"/></dir><file name="Config.php" hash="4222a35a2c71b3702199efbfddbee701"/></dir><file name="CronStatus.php" hash="298e6e428249ed7020c27e3c8abc52a2"/><file name="Key.php" hash="baf05389e9ec82d9ea06a055eaefdc2f"/><dir name="Lib"><dir name="Varien"><dir name="Simplexml"><file name="Config.php" hash="eba1dfcc303065cf5b3c9067d87dd35a"/><file name="Element.php" hash="24cb3b7db31ae8e2c813485a6b6ef749"/></dir></dir></dir><dir name="Mysql4"><dir name="Core"><file name="Config.php" hash="c0a59f8ff1f747224655de39b217abde"/></dir></dir><dir name="Path"><dir name="Locator"><file name="Array.php" hash="722f4125eb1cbd5fbc2be05facd44cd4"/><file name="Factory.php" hash="5a57006974d9870affbcbafa6ed00175"/><file name="IteratorAbstract.php" hash="adba5c801c91efdbc5afa493d353224a"/><file name="LocatorInterface.php" hash="30571ef5c7ebf942870a0ddd2ab341cb"/><file name="Stack.php" hash="73a27e38db4768019613c99407205771"/></dir></dir><dir name="Resource"><dir name="Core"><file name="Config.php" hash="14736455e9f006a69dc638e4b93f7e6e"/></dir><dir name="Db"><file name="Abstract.php" hash="3874d4c5cc4b1af30a550cc792bbe22f"/></dir></dir><file name="Sharetracking.php" hash="05f4fe212dfd53027525bae6321ea641"/><file name="Urltracking.php" hash="d4e7e48cbb8168c2baab17e1edde1eac"/><file name="Verify.php" hash="3e385480fdfdfb3b1219ba48c1ef1644"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConflictcheckerController.php" hash="28bf9f8cca4f3e63ea90c575c424deb0"/></dir><file name="betaoutorderController.php" hash="880f9c072d64fc7d5a6724db334ee2da"/><file name="indexController.php" hash="ca84b19b9ee9ea2678ba6ef5a6d23afa"/></dir><dir name="etc"><file name="config.xml" hash="196aeeac6eb735f7fab3e31b275505c2"/><file name="system.xml" hash="ab04a67f8f609367f042c1fad57ace6e"/></dir><dir name="log"><file name="log.log" hash="be8a8d092fd7ba1381cfbe23eda18c2e"/></dir><file name=".DS_Store" hash="e49cca224ac24efb7898b1adf5d52aaf"/></dir><file name=".DS_Store" hash="a27a5b993e15852172640eb72dabed84"/></dir></target><target name="mageetc"><dir name="modules"><file name="Betaout_Amplify.xml" hash="a8228fbbf2d0a09dc90cd7c80b4692f0"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="betaout_amplify.xml" hash="328dab6359ba6464621e558238610035"/></dir><dir name="template"><dir name="betaout_amplify"><file name="amplify.phtml" hash="ce94f7e9e16d3c519bc8efcf4541716c"/><file name="conflict.phtml" hash="43277d57972e4f750d8b65e0bfb5bcb8"/><file name="logo.phtml" hash="0af4376bf5074d24519ab7e9d3ea035b"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="betaout_amplify"><file name="checkout.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="head.phtml" hash="8ae6673a3b2ea1f7e46249b49449133d"/></dir></dir><dir name="layout"><file name="betaout_amplify.xml" hash="f262133af716b7e0c33ebc044e06518c"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="amplify"><dir name="images"><file name="Users.png" hash="96e906660b1fbd8a17831bd3049dbcfa"/><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="ajax-loader.gif" hash="e2a38f1e23288e315af3c55416bc1ce7"/><file name="btn.png" hash="769b6736cb1bb8cb91ad7526ce9d9db8"/><file name="check.png" hash="252fd93a83e2a412ecd3b6eac01500b7"/><file name="com-app.png" hash="1f241f552bdbe1f86763981c79c8d85f"/><file name="db-1.png" hash="840d96bd5679bf4fa2d6a9577f7d3539"/><file name="engage-app.png" hash="888cde6a10a3dd9abcfccd1a5f0c8fde"/><file name="icon.png" hash="22ea725b0bee73cb03f63b063b02469f"/><file name="large_bracket.png" hash="d2e8da8266e513bd5f15b0c9855be058"/><file name="mini_bracket.png" hash="e844112e5e5173f64b3385a4a140bdeb"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
18
  </package>