MocoInsight_Mocoauto - Version 1.4.1

Version Notes

1.4.1

Improved order processing speed.
Multi store URL info.
Shipping address tracked.
gte option for orders,customers, products, carts and subscribers.
Status option for subscribersAction
Update carts action skip non identifed carts.

1.4.0

Split stats action into
stats and logstats

Updated customersAction to return custom attributes.

1.3.9

Added eavinfo_catalogAction

Products action now retuns full url of product images.

testing new testcustomerAction

1.3.8

Changed table exists function
mocoauto_api_error - API errors prefix

1.3.7

Added non sensitive payment info to orderAction

1.3.5

Faster uncovertedcarts

1.3.4

log_all_joined

1.3.3

Added rulesAction - for details on coupon and shopping carts rule.

1.3.2

Exception handles for uncoverted carts.
Changed catalogue tax rate processing.

1.3.1

Added graceful exception handling for installations that have misconfigured product attributes

1.3.0

Check direct SQL methods defined
exproducts
exstats
report version of php

1.2.9

Default tax rate fro products returned with producAction

1.2.8

storesAction now returns store config data

1.2.7

log stats function calculates using direct SQL

1.2.6

StatsAction now returns size of log files

1.2.5

Speed up stocklevelAction, now only returns non zero inventory

WishlistAction now includes wishListItemId

1.2.4

Added wishlistsAction
Added unconvertedcartsAction

Fix - log actions now check if table exists

1.2.3

Fix to Observer.php

1.2.2

Added subscribersAction
Added storesAction

1.2.1

ordersAction - now uses billing address as some products (Virtual) won't have a delivery address and checks that object exists

1.2.0

ordersAction - added shpping address
productsAction - added end of record marker

stocklevelsAction - New

Added log_ actions

1.1.7

Added malformed error

Returns API version number with failed calls

1.1.6

Changed API header name to work with sites that use additional authorisation now:

mocoapi: apikey= THE API KEY

1.1.5
Updated stats API now includes:

Version of magento
System date/time
added success true for succesful requests
changed product category to moco_category

Download this release

Release Info

Developer Rob Davies
Extension MocoInsight_Mocoauto
Version 1.4.1
Comparing to
See all releases


Code changes from version 1.4.0 to 1.4.1

app/code/community/MocoInsight/Mocoauto/controllers/ApiController.php CHANGED
@@ -90,41 +90,41 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
90
 
91
  $currentSystemTime = date('Y-m-d H:i:s', time());
92
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
93
- $since = $this->getRequest()->getParam('since','All');
94
 
95
  $_productCol = Mage::getModel('catalog/product')->getCollection();
96
- if($since != 'All'){
97
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
98
  }
99
  $productcount = $_productCol->getSize();
100
 
101
  $_orderCol = Mage::getModel('sales/order')->getCollection();
102
- if($since != 'All'){
103
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
104
  }
105
  $ordercount = $_orderCol->getSize();
106
 
107
  $_customerCol = Mage::getModel('customer/customer')->getCollection();
108
- if($since != 'All'){
109
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
110
  }
111
  $customercount = $_customerCol->getSize();
112
 
113
 
114
  $_categoryCol = Mage::getModel('catalog/category')->getCollection();
115
- if($since != 'All'){
116
  $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
117
  }
118
  $categorycount = $_categoryCol->getSize();
119
 
120
  $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
121
- if($since != 'All'){
122
  $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
123
  }
124
  $wishlistcount = $_wishlistCol->getSize();
125
 
126
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
127
- if($since != 'All'){
128
  $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
129
  }
130
  else{
@@ -182,7 +182,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
182
 
183
  $currentSystemTime = date('Y-m-d H:i:s', time());
184
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
185
- $since = $this->getRequest()->getParam('since','All');
186
 
187
 
188
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
@@ -276,41 +276,41 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
276
 
277
  $currentSystemTime = date('Y-m-d H:i:s', time());
278
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
279
- $since = $this->getRequest()->getParam('since','All');
280
 
281
  $_productCol = Mage::getModel('catalog/product')->getCollection();
282
- if($since != 'All'){
283
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
284
  }
285
  $productcount = $_productCol->getSize();
286
 
287
  $_orderCol = Mage::getModel('sales/order')->getCollection();
288
- if($since != 'All'){
289
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
290
  }
291
  $ordercount = $_orderCol->getSize();
292
 
293
  $_customerCol = Mage::getModel('customer/customer')->getCollection();
294
- if($since != 'All'){
295
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
296
  }
297
  $customercount = $_customerCol->getSize();
298
 
299
 
300
  $_categoryCol = Mage::getModel('catalog/category')->getCollection();
301
- if($since != 'All'){
302
  $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
303
  }
304
  $categorycount = $_categoryCol->getSize();
305
 
306
  $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
307
- if($since != 'All'){
308
  $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
309
  }
310
  $wishlistcount = $_wishlistCol->getSize();
311
 
312
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
313
- if($since != 'All'){
314
  $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
315
  }
316
  else{
@@ -433,58 +433,65 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
433
 
434
  $offset = $this->getRequest()->getParam('offset', 0);
435
  $page_size = $this->getRequest()->getParam('page_size', 20);
436
- $since = $this->getRequest()->getParam('since','All');
 
437
 
438
  $_orderCol = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('*');
439
  $_orderCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
440
 
441
- if($since != 'All'){
442
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
443
  }
444
 
 
 
 
 
445
  $orders = array();
446
 
447
  foreach($_orderCol as $_order) {
448
 
449
  try{
450
- $orders[] = array('moco_start_of_order_record' => 'True');
451
- $orders[] = $_order->toArray();
 
 
 
 
 
 
452
 
453
- if(is_object($_order->getBillingAddress())){
454
 
 
455
  $_billing_address = $_order->getBillingAddress();
456
- $orders[] = array('moco_start_of_address' => 'True');
457
- $orders[] = $_billing_address->toArray();
458
- $orders[] = array('moco_end_of_address' => 'True');
459
  }
460
 
461
- try{
462
- $_payment_info = $_order->getPayment();
463
- $orders[] = array('moco_start_of_paymentinfo' => 'True');
464
- $paymentinfo[] = $_payment_info->toArray();
465
- foreach($paymentinfo as $key => $value){
466
- unset($paymentinfo[$key]['cc_number_enc']);
467
- unset($paymentinfo[$key]['cc_last4']);
468
- unset($paymentinfo[$key]['cc_exp_month']);
469
- unset($paymentinfo[$key]['cc_exp_year']);
470
- }
471
- $orders[] = array($paymentinfo);
472
 
473
- $orders[] = array('moco_end_of_paymentinfo' => 'True');
 
 
 
474
  }
475
- catch (Exception $e) {
476
- $orders[] = array('mocoauto_api_error' => 'Billing info error: ' . $e->getMessage());
477
- }
478
- $_orderItemsCol = $_order->getItemsCollection();
479
 
 
 
480
  foreach($_orderItemsCol as $_orderitem){
481
- $orders[] = $_orderitem->toArray();
482
- }
483
- $orders[] = array('moco_end_of_order_record' => 'True');
 
 
 
484
  }
485
  catch (Exception $e) {
486
- $orders[] = array('mocoauto_api_error' => 'order record: ' . $e->getMessage());
487
  }
 
 
488
  }
489
 
490
  $this->getResponse()
@@ -504,12 +511,12 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
504
 
505
  $offset = $this->getRequest()->getParam('offset', 0);
506
  $page_size = $this->getRequest()->getParam('page_size', 20);
507
- $since = $this->getRequest()->getParam('since','All');
508
 
509
  $_orderCol = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('*');
510
  $_orderCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
511
 
512
- if($since != 'All'){
513
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
514
  }
515
 
@@ -560,6 +567,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
560
  return $this;
561
  }
562
 
 
563
  public function customersAction()
564
  {
565
  if(!$this->_authorise()) {
@@ -570,15 +578,20 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
570
 
571
  $offset = $this->getRequest()->getParam('offset', 0);
572
  $page_size = $this->getRequest()->getParam('page_size', 20);
573
- $since = $this->getRequest()->getParam('since', 'All');
 
574
 
575
  $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
576
  $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
577
 
578
- if($since != 'All'){
579
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
580
  }
581
 
 
 
 
 
582
  $customers = array();
583
 
584
  foreach($_customerCol as $_customer) {
@@ -633,12 +646,12 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
633
 
634
  $offset = $this->getRequest()->getParam('offset', 0);
635
  $page_size = $this->getRequest()->getParam('page_size', 20);
636
- $since = $this->getRequest()->getParam('since', 'All');
637
 
638
  $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
639
  $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
640
 
641
- if($since != 'All'){
642
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
643
  }
644
 
@@ -665,12 +678,12 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
665
 
666
  $offset = $this->getRequest()->getParam('offset', 0);
667
  $page_size = $this->getRequest()->getParam('page_size', 20);
668
- $since = $this->getRequest()->getParam('since', 'All');
669
 
670
  $_categoryCol = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*');
671
  $_categoryCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
672
 
673
- if($since != 'All'){
674
  $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
675
  }
676
 
@@ -697,16 +710,15 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
697
 
698
  $offset = $this->getRequest()->getParam('offset', 0);
699
  $page_size = $this->getRequest()->getParam('page_size', 20);
700
- $since = $this->getRequest()->getParam('since', 'All');
701
 
702
  $_productCol = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
703
  $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
704
 
705
- if($since != 'All'){
706
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
707
  }
708
 
709
-
710
  $products[] = array('success' => 'true');
711
 
712
  foreach($_productCol as $_product){
@@ -805,15 +817,19 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
805
 
806
  $offset = $this->getRequest()->getParam('offset', 0);
807
  $page_size = $this->getRequest()->getParam('page_size', 20);
808
- $since = $this->getRequest()->getParam('since', 'All');
 
809
 
810
  $_productCol = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
811
  $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
812
 
813
- if($since != 'All'){
814
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
815
  }
816
 
 
 
 
817
 
818
  $products[] = array('success' => 'true');
819
 
@@ -911,149 +927,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
911
 
912
 
913
 
914
- // write end of record mark
915
- $products[] = array('moco_end_of_record' => 'True');
916
-
917
- }
918
-
919
- $this->getResponse()
920
- ->setBody(json_encode(array('products' => $products)))
921
- ->setHttpResponseCode(200)
922
- ->setHeader('Content-type', 'application/json', true);
923
- return $this;
924
- }
925
-
926
- public function testproductsAction()
927
- {
928
- if(!$this->_authorise()) {
929
- return $this;
930
- }
931
-
932
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
933
-
934
- $offset = $this->getRequest()->getParam('offset', 0);
935
- $page_size = $this->getRequest()->getParam('page_size', 20);
936
- $since = $this->getRequest()->getParam('since', 'All');
937
-
938
- $_productCol = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
939
- $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
940
-
941
- if($since != 'All'){
942
- $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
943
- }
944
-
945
-
946
- $products = array('success' => 'true');
947
-
948
- // Let's try and dump the whole product
949
-
950
- foreach($_productCol as $_product){
951
- $product = array();
952
- $product[] = $_product->toArray();
953
-
954
- // get all the custom attributes of the product
955
- $attributes = $_product->getAttributes();
956
-
957
- foreach ($attributes as $attribute) {
958
- $attributeCode = $attribute->getAttributeCode();
959
-
960
- switch ($attributeCode){
961
- case 'in_depth':
962
- break;
963
- case 'description':
964
- break;
965
- case 'short_description':
966
- break;
967
- case 'thumbnail':
968
- break;
969
- case 'small_image':
970
- break;
971
- case 'image':
972
- break;
973
- default:
974
- try {
975
- $frontendinput = $attribute->getFrontendInput();
976
- $frontendvalue = $attribute->getFrontend()->getValue($_product);
977
- $textvalue = $_product->getData($attributeCode);
978
- $attrtextvalue = $_product->getAttributeText($attributeCode);
979
- $product[$attributeCode.' -frontend_input'] = $frontendinput;
980
- $product[$attributeCode.' -frontend'] = $frontendvalue;
981
- $product[$attributeCode.' -text'] = $textvalue;
982
- $product[$attributeCode.' -attrtext'] = $attrtextvalue;
983
-
984
-
985
- }
986
- catch (Exception $e) {
987
- $product['mocoauto_api_error'] = 'product attribute ' . $attributeCode . ' ' . $e->getMessage();
988
- }
989
- break;
990
- }
991
- }
992
-
993
- $products[] = $product;
994
-
995
-
996
- // Get full url to product image
997
-
998
- try{
999
- $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
1000
- $products[] = array('thumbnail' => $full_path_url);
1001
- $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'small_image');
1002
- $products[] = array('small_image' => $full_path_url);
1003
- $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'image');
1004
- $products[] = array('image' => $full_path_url);
1005
- }
1006
- catch (Exception $e) {
1007
- $products[] = array('mocoauto_api_error' => 'full path to image error:' . $e->getMessage());
1008
- }
1009
-
1010
- // get all the categories of the product
1011
-
1012
- $categories = $_product->getCategoryCollection()->addAttributeToSelect('name');
1013
-
1014
- foreach ($categories as $category) {
1015
- $products[] = array('moco_category' => $category->getID());
1016
- }
1017
-
1018
- // get inventory information
1019
-
1020
- try{
1021
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
1022
-
1023
- $products[] = array('stock_managed' => $stock->getManageStock());
1024
- $products[] = array('stock_availability' => $stock->getIsInStock());
1025
- }
1026
- catch (Exception $e) {
1027
- $products[] = array('mocoauto_api_error' => 'moco_product_inventory: ' . $e->getMessage());
1028
- }
1029
-
1030
-
1031
- // if type is configurable get simple product children
1032
-
1033
- if($_product->getTypeID() == 'configurable'){
1034
- //$assocProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
1035
- $assocProducts = $_product->getTypeInstance()->getUsedProducts();
1036
-
1037
- foreach($assocProducts as $assocProduct){
1038
- $products[] = array('childProductID' => $assocProduct->getID());
1039
- }
1040
- }
1041
-
1042
- // if type is grouped get associated product children
1043
-
1044
- if($_product->getTypeID() == 'grouped'){
1045
-
1046
- $groupedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
1047
-
1048
- foreach($groupedProducts as $groupedProduct){
1049
- $products[] = array('childProductID' => $groupedProduct->getID());
1050
-
1051
- }
1052
- }
1053
-
1054
-
1055
-
1056
-
1057
  // write end of record mark
1058
  $products[] = array('moco_end_of_record' => 'True');
1059
 
@@ -1109,7 +982,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1109
 
1110
  $offset = $this->getRequest()->getParam('offset', 0);
1111
  $page_size = $this->getRequest()->getParam('page_size', 20);
1112
- $since = $this->getRequest()->getParam('since', 'All');
1113
 
1114
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1115
 
@@ -1140,7 +1013,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1140
 
1141
  $offset = $this->getRequest()->getParam('offset', 0);
1142
  $page_size = $this->getRequest()->getParam('page_size', 20);
1143
- $since = $this->getRequest()->getParam('since', 'All');
1144
 
1145
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1146
 
@@ -1173,7 +1046,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1173
 
1174
  $offset = $this->getRequest()->getParam('offset', 0);
1175
  $page_size = $this->getRequest()->getParam('page_size', 20);
1176
- $since = $this->getRequest()->getParam('since', 'All');
1177
 
1178
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1179
 
@@ -1187,7 +1060,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1187
  $query = 'select visitor_id, visit_time, url, referer from ' . $tablename1 .
1188
  ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.url_id = ' . $tablename2 . '.url_id where url not like "%mocoauto%"';
1189
 
1190
- if($since != 'All'){
1191
  $query = $query . ' and visit_time > "' . $since . '"';
1192
  }
1193
 
@@ -1213,7 +1086,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1213
 
1214
  $offset = $this->getRequest()->getParam('offset', 0);
1215
  $page_size = $this->getRequest()->getParam('page_size', 20);
1216
- $since = $this->getRequest()->getParam('since', 'All');
1217
 
1218
  try{
1219
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
@@ -1240,7 +1113,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1240
  $query = $query . ' Left join ' . $tablename3 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename3 . '.visitor_id';
1241
  $query = $query . ' Left join ' . $tablename4 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename4 . '.visitor_id where url not like "%mocoauto%"';
1242
 
1243
- if($since != 'All'){
1244
  $query = $query . ' and visit_time > "' . $since . '"';
1245
  }
1246
 
@@ -1276,7 +1149,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1276
 
1277
  $offset = $this->getRequest()->getParam('offset', 0);
1278
  $page_size = $this->getRequest()->getParam('page_size', 20);
1279
- $since = $this->getRequest()->getParam('since', 'All');
1280
 
1281
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1282
 
@@ -1297,7 +1170,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1297
  $query = $query . ' Left join ' . $tablename3 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename3 . '.visitor_id';
1298
  $query = $query . ' Left join ' . $tablename4 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename4 . '.visitor_id where url not like "%mocoauto%"';
1299
 
1300
- if($since != 'All'){
1301
  $query = $query . ' and visit_time > "' . $since . '"';
1302
  }
1303
 
@@ -1326,7 +1199,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1326
 
1327
  $offset = $this->getRequest()->getParam('offset', 0);
1328
  $page_size = $this->getRequest()->getParam('page_size', 20);
1329
- $since = $this->getRequest()->getParam('since', 'All');
1330
 
1331
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1332
 
@@ -1357,7 +1230,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1357
 
1358
  $offset = $this->getRequest()->getParam('offset', 0);
1359
  $page_size = $this->getRequest()->getParam('page_size', 20);
1360
- $since = $this->getRequest()->getParam('since', 'All');
1361
 
1362
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1363
 
@@ -1390,7 +1263,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1390
 
1391
  $offset = $this->getRequest()->getParam('offset', 0);
1392
  $page_size = $this->getRequest()->getParam('page_size', 20);
1393
- $since = $this->getRequest()->getParam('since', 'All');
1394
 
1395
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1396
 
@@ -1405,7 +1278,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1405
  $tablename1 . '.visitor_id, session_id, first_visit_at, last_visit_at, last_url_id, store_id, http_referer, http_user_agent, remote_addr from '
1406
  . $tablename1 . ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename2 . '.visitor_id';
1407
 
1408
- if($since != 'All'){
1409
  $query = $query . ' where last_vist_at > "' . $since . '"';
1410
  }
1411
 
@@ -1433,7 +1306,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1433
 
1434
  $offset = $this->getRequest()->getParam('offset', 0);
1435
  $page_size = $this->getRequest()->getParam('page_size', 20);
1436
- $since = $this->getRequest()->getParam('since', 'All');
1437
 
1438
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1439
 
@@ -1443,7 +1316,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1443
  else{
1444
  $query = 'select * from ' . $tablename;
1445
 
1446
- if($since != 'All'){
1447
  $query = $query . ' where login_at > "' . $since . '"';
1448
  }
1449
 
@@ -1459,7 +1332,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1459
  return $this;
1460
  }
1461
 
1462
- public function subscribersAction()
1463
  {
1464
  if(!$this->_authorise()) {
1465
  return $this;
@@ -1469,7 +1342,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1469
 
1470
  $offset = $this->getRequest()->getParam('offset', 0);
1471
  $page_size = $this->getRequest()->getParam('page_size', 20);
1472
- $since = $this->getRequest()->getParam('since', 'All');
1473
 
1474
  $_subscribersCol = Mage::getModel('newsletter/subscriber')->getCollection(); //->addAttributeToSelect('*');
1475
  $_subscribersCol->getSelect()->limit($page_size, ($offset * $page_size)); //->order('updated_at');
@@ -1487,6 +1360,48 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1487
  return $this;
1488
  }
1489
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1490
  public function storesAction()
1491
  {
1492
  if(!$this->_authorise()) {
@@ -1503,8 +1418,16 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1503
  $_stores = $group->getStores();
1504
  foreach ($_stores as $_store) {
1505
  $storeInfo = $_store->toArray();
1506
- $storeInfo['tax/calculation/price_includes_tax'] = Mage::getStoreConfig('tax/calculation/price_includes_tax', $_store->getStoreId());
1507
- $storeInfo['tax/defaults/country'] = Mage::getStoreConfig('tax/defaults/country', $_store->getStoreId());
 
 
 
 
 
 
 
 
1508
  $stores[] = $storeInfo;
1509
  }
1510
  }
@@ -1517,7 +1440,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1517
  return $this;
1518
  }
1519
 
1520
- public function unconvertedcartsAction()//This query returns only no empty carts when no dat filter applied
1521
  {
1522
  if(!$this->_authorise()) {
1523
  return $this;
@@ -1527,18 +1450,36 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1527
 
1528
  $offset = $this->getRequest()->getParam('offset', 0);
1529
  $page_size = $this->getRequest()->getParam('page_size', 20);
1530
- $since = $this->getRequest()->getParam('since', 'All');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1531
 
1532
- $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
1533
  $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1534
 
1535
- if($since != 'All'){
1536
- $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
1537
  }
1538
  else{
1539
- $_cartsCol->addFieldToFilter('items_count', array('neq' => 0));
1540
- }
1541
-
 
 
 
 
1542
  $carts = array();
1543
 
1544
  foreach($_cartsCol as $_cart) {
@@ -1568,7 +1509,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1568
  ->setHeader('Content-type', 'application/json', true);
1569
  return $this;
1570
  }
1571
- public function exunconvertedcartsAction()
 
1572
  {
1573
  if(!$this->_authorise()) {
1574
  return $this;
@@ -1578,29 +1520,44 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1578
 
1579
  $offset = $this->getRequest()->getParam('offset', 0);
1580
  $page_size = $this->getRequest()->getParam('page_size', 20);
1581
- $since = $this->getRequest()->getParam('since', 'All');
 
1582
 
1583
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
1584
  $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1585
 
1586
- if($since != 'All'){
1587
- $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
 
 
 
 
 
 
 
1588
  }
1589
 
1590
  $carts = array();
1591
 
1592
  foreach($_cartsCol as $_cart) {
1593
- $carts[] = array('moco_start_of_cart_record' => 'True');
1594
- $carts[] = $_cart->toArray();
1595
- $_cartItemsCol = $_cart -> getItemsCollection();
1596
-
1597
- foreach($_cartItemsCol as $_cartitem){
1598
- //$carts[] = $_cartitem->toArray();
1599
- $carts[] = array('product_id' => $_cartitem->getProductId());
1600
- $carts[] = array('product_qty' => $_cartitem->getQty());
1601
- $carts[] = array('updated_at' => $_cartitem->getUpdatedAt());
 
 
 
 
 
 
 
 
1602
  }
1603
- $carts[] = array('moco_end_of_cart_record' => 'True');
1604
  }
1605
 
1606
  $this->getResponse()
@@ -1620,12 +1577,12 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1620
 
1621
  $offset = $this->getRequest()->getParam('offset', 0);
1622
  $page_size = $this->getRequest()->getParam('page_size', 20);
1623
- $since = $this->getRequest()->getParam('since', 'All');
1624
 
1625
  $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
1626
  $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1627
 
1628
- if($since != 'All'){
1629
  $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
1630
  }
1631
 
@@ -1695,7 +1652,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1695
 
1696
  $offset = $this->getRequest()->getParam('offset', 0);
1697
  $page_size = $this->getRequest()->getParam('page_size', 20);
1698
- $since = $this->getRequest()->getParam('since', 'All');
1699
 
1700
  $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
1701
 
90
 
91
  $currentSystemTime = date('Y-m-d H:i:s', time());
92
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
93
+ $since = $this->getRequest()->getParam('since','ALL');
94
 
95
  $_productCol = Mage::getModel('catalog/product')->getCollection();
96
+ if($since != 'ALL'){
97
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
98
  }
99
  $productcount = $_productCol->getSize();
100
 
101
  $_orderCol = Mage::getModel('sales/order')->getCollection();
102
+ if($since != 'ALL'){
103
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
104
  }
105
  $ordercount = $_orderCol->getSize();
106
 
107
  $_customerCol = Mage::getModel('customer/customer')->getCollection();
108
+ if($since != 'ALL'){
109
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
110
  }
111
  $customercount = $_customerCol->getSize();
112
 
113
 
114
  $_categoryCol = Mage::getModel('catalog/category')->getCollection();
115
+ if($since != 'ALL'){
116
  $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
117
  }
118
  $categorycount = $_categoryCol->getSize();
119
 
120
  $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
121
+ if($since != 'ALL'){
122
  $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
123
  }
124
  $wishlistcount = $_wishlistCol->getSize();
125
 
126
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
127
+ if($since != 'ALL'){
128
  $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
129
  }
130
  else{
182
 
183
  $currentSystemTime = date('Y-m-d H:i:s', time());
184
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
185
+ $since = $this->getRequest()->getParam('since','ALL');
186
 
187
 
188
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
276
 
277
  $currentSystemTime = date('Y-m-d H:i:s', time());
278
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
279
+ $since = $this->getRequest()->getParam('since','ALL');
280
 
281
  $_productCol = Mage::getModel('catalog/product')->getCollection();
282
+ if($since != 'ALL'){
283
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
284
  }
285
  $productcount = $_productCol->getSize();
286
 
287
  $_orderCol = Mage::getModel('sales/order')->getCollection();
288
+ if($since != 'ALL'){
289
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
290
  }
291
  $ordercount = $_orderCol->getSize();
292
 
293
  $_customerCol = Mage::getModel('customer/customer')->getCollection();
294
+ if($since != 'ALL'){
295
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
296
  }
297
  $customercount = $_customerCol->getSize();
298
 
299
 
300
  $_categoryCol = Mage::getModel('catalog/category')->getCollection();
301
+ if($since != 'ALL'){
302
  $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
303
  }
304
  $categorycount = $_categoryCol->getSize();
305
 
306
  $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
307
+ if($since != 'ALL'){
308
  $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
309
  }
310
  $wishlistcount = $_wishlistCol->getSize();
311
 
312
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
313
+ if($since != 'ALL'){
314
  $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
315
  }
316
  else{
433
 
434
  $offset = $this->getRequest()->getParam('offset', 0);
435
  $page_size = $this->getRequest()->getParam('page_size', 20);
436
+ $since = $this->getRequest()->getParam('since','ALL');
437
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
438
 
439
  $_orderCol = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('*');
440
  $_orderCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
441
 
442
+ if($since != 'ALL'){
443
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
444
  }
445
 
446
+ if($gTE != 'ALL'){
447
+ $_orderCol->addFieldToFilter('entity_id', array('gteq' =>$gTE));
448
+ }
449
+
450
  $orders = array();
451
 
452
  foreach($_orderCol as $_order) {
453
 
454
  try{
455
+ $order = array();
456
+ $order['moco_start_of_order_record'] = 'True';
457
+ $orderdetails = array();
458
+ $orderdetails = $_order->toArray();
459
+ foreach ($orderdetails as $key => $value) {
460
+ $order[$key] = $value;
461
+ }
462
+ $order['payment_method'] = $_order->getPayment()->getMethodInstance()->getTitle();
463
 
 
464
 
465
+ if(is_object($_order->getBillingAddress())){
466
  $_billing_address = $_order->getBillingAddress();
467
+ $billaddrdetails = array();
468
+ $billaddrdetails[] = $_billing_address->toArray();
469
+ $order['moco_address'] = $billaddrdetails;
470
  }
471
 
472
+ if(is_object($_order->getShippingAddress())){
 
 
 
 
 
 
 
 
 
 
473
 
474
+ $_shipping_address = $_order->getShippingAddress();
475
+ $shipaddrdetails = array();
476
+ $shipaddrdetails[] = $_shipping_address->toArray();
477
+ $order['moco_ship_address'] = $shipaddrdetails;
478
  }
 
 
 
 
479
 
480
+ $_orderItemsCol = $_order->getItemsCollection();
481
+ $orderitems = array();
482
  foreach($_orderItemsCol as $_orderitem){
483
+ $orderitems[] = $_orderitem->toArray();
484
+ }
485
+ $order['moco_tls'] = $orderitems;
486
+
487
+
488
+ $order['moco_end_of_order_record'] = 'True';
489
  }
490
  catch (Exception $e) {
491
+ $order['mocoauto_api_error'] = 'order record: ' . $e->getMessage();
492
  }
493
+ $orders[] = $order;
494
+
495
  }
496
 
497
  $this->getResponse()
511
 
512
  $offset = $this->getRequest()->getParam('offset', 0);
513
  $page_size = $this->getRequest()->getParam('page_size', 20);
514
+ $since = $this->getRequest()->getParam('since','ALL');
515
 
516
  $_orderCol = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('*');
517
  $_orderCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
518
 
519
+ if($since != 'ALL'){
520
  $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
521
  }
522
 
567
  return $this;
568
  }
569
 
570
+
571
  public function customersAction()
572
  {
573
  if(!$this->_authorise()) {
578
 
579
  $offset = $this->getRequest()->getParam('offset', 0);
580
  $page_size = $this->getRequest()->getParam('page_size', 20);
581
+ $since = $this->getRequest()->getParam('since', 'ALL');
582
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
583
 
584
  $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
585
  $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
586
 
587
+ if($since != 'ALL'){
588
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
589
  }
590
 
591
+ if($gTE != 'ALL'){
592
+ $_customerCol->addAttributeToFilter('entity_id', array('gteq' =>$gTE));
593
+ }
594
+
595
  $customers = array();
596
 
597
  foreach($_customerCol as $_customer) {
646
 
647
  $offset = $this->getRequest()->getParam('offset', 0);
648
  $page_size = $this->getRequest()->getParam('page_size', 20);
649
+ $since = $this->getRequest()->getParam('since', 'ALL');
650
 
651
  $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
652
  $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
653
 
654
+ if($since != 'ALL'){
655
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
656
  }
657
 
678
 
679
  $offset = $this->getRequest()->getParam('offset', 0);
680
  $page_size = $this->getRequest()->getParam('page_size', 20);
681
+ $since = $this->getRequest()->getParam('since', 'ALL');
682
 
683
  $_categoryCol = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*');
684
  $_categoryCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
685
 
686
+ if($since != 'ALL'){
687
  $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
688
  }
689
 
710
 
711
  $offset = $this->getRequest()->getParam('offset', 0);
712
  $page_size = $this->getRequest()->getParam('page_size', 20);
713
+ $since = $this->getRequest()->getParam('since', 'ALL');
714
 
715
  $_productCol = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
716
  $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
717
 
718
+ if($since != 'ALL'){
719
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
720
  }
721
 
 
722
  $products[] = array('success' => 'true');
723
 
724
  foreach($_productCol as $_product){
817
 
818
  $offset = $this->getRequest()->getParam('offset', 0);
819
  $page_size = $this->getRequest()->getParam('page_size', 20);
820
+ $since = $this->getRequest()->getParam('since', 'ALL');
821
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
822
 
823
  $_productCol = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
824
  $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
825
 
826
+ if($since != 'ALL'){
827
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
828
  }
829
 
830
+ if($gTE != 'ALL'){
831
+ $_productCol->addAttributeToFilter('entity_id', array('gteq' =>$gTE));
832
+ }
833
 
834
  $products[] = array('success' => 'true');
835
 
927
 
928
 
929
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
930
  // write end of record mark
931
  $products[] = array('moco_end_of_record' => 'True');
932
 
982
 
983
  $offset = $this->getRequest()->getParam('offset', 0);
984
  $page_size = $this->getRequest()->getParam('page_size', 20);
985
+ $since = $this->getRequest()->getParam('since', 'ALL');
986
 
987
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
988
 
1013
 
1014
  $offset = $this->getRequest()->getParam('offset', 0);
1015
  $page_size = $this->getRequest()->getParam('page_size', 20);
1016
+ $since = $this->getRequest()->getParam('since', 'ALL');
1017
 
1018
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1019
 
1046
 
1047
  $offset = $this->getRequest()->getParam('offset', 0);
1048
  $page_size = $this->getRequest()->getParam('page_size', 20);
1049
+ $since = $this->getRequest()->getParam('since', 'ALL');
1050
 
1051
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1052
 
1060
  $query = 'select visitor_id, visit_time, url, referer from ' . $tablename1 .
1061
  ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.url_id = ' . $tablename2 . '.url_id where url not like "%mocoauto%"';
1062
 
1063
+ if($since != 'ALL'){
1064
  $query = $query . ' and visit_time > "' . $since . '"';
1065
  }
1066
 
1086
 
1087
  $offset = $this->getRequest()->getParam('offset', 0);
1088
  $page_size = $this->getRequest()->getParam('page_size', 20);
1089
+ $since = $this->getRequest()->getParam('since', 'ALL');
1090
 
1091
  try{
1092
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1113
  $query = $query . ' Left join ' . $tablename3 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename3 . '.visitor_id';
1114
  $query = $query . ' Left join ' . $tablename4 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename4 . '.visitor_id where url not like "%mocoauto%"';
1115
 
1116
+ if($since != 'ALL'){
1117
  $query = $query . ' and visit_time > "' . $since . '"';
1118
  }
1119
 
1149
 
1150
  $offset = $this->getRequest()->getParam('offset', 0);
1151
  $page_size = $this->getRequest()->getParam('page_size', 20);
1152
+ $since = $this->getRequest()->getParam('since', 'ALL');
1153
 
1154
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1155
 
1170
  $query = $query . ' Left join ' . $tablename3 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename3 . '.visitor_id';
1171
  $query = $query . ' Left join ' . $tablename4 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename4 . '.visitor_id where url not like "%mocoauto%"';
1172
 
1173
+ if($since != 'ALL'){
1174
  $query = $query . ' and visit_time > "' . $since . '"';
1175
  }
1176
 
1199
 
1200
  $offset = $this->getRequest()->getParam('offset', 0);
1201
  $page_size = $this->getRequest()->getParam('page_size', 20);
1202
+ $since = $this->getRequest()->getParam('since', 'ALL');
1203
 
1204
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1205
 
1230
 
1231
  $offset = $this->getRequest()->getParam('offset', 0);
1232
  $page_size = $this->getRequest()->getParam('page_size', 20);
1233
+ $since = $this->getRequest()->getParam('since', 'ALL');
1234
 
1235
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1236
 
1263
 
1264
  $offset = $this->getRequest()->getParam('offset', 0);
1265
  $page_size = $this->getRequest()->getParam('page_size', 20);
1266
+ $since = $this->getRequest()->getParam('since', 'ALL');
1267
 
1268
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1269
 
1278
  $tablename1 . '.visitor_id, session_id, first_visit_at, last_visit_at, last_url_id, store_id, http_referer, http_user_agent, remote_addr from '
1279
  . $tablename1 . ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename2 . '.visitor_id';
1280
 
1281
+ if($since != 'ALL'){
1282
  $query = $query . ' where last_vist_at > "' . $since . '"';
1283
  }
1284
 
1306
 
1307
  $offset = $this->getRequest()->getParam('offset', 0);
1308
  $page_size = $this->getRequest()->getParam('page_size', 20);
1309
+ $since = $this->getRequest()->getParam('since', 'ALL');
1310
 
1311
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1312
 
1316
  else{
1317
  $query = 'select * from ' . $tablename;
1318
 
1319
+ if($since != 'ALL'){
1320
  $query = $query . ' where login_at > "' . $since . '"';
1321
  }
1322
 
1332
  return $this;
1333
  }
1334
 
1335
+ public function exsubscribersAction()
1336
  {
1337
  if(!$this->_authorise()) {
1338
  return $this;
1342
 
1343
  $offset = $this->getRequest()->getParam('offset', 0);
1344
  $page_size = $this->getRequest()->getParam('page_size', 20);
1345
+ $since = $this->getRequest()->getParam('since', 'ALL');
1346
 
1347
  $_subscribersCol = Mage::getModel('newsletter/subscriber')->getCollection(); //->addAttributeToSelect('*');
1348
  $_subscribersCol->getSelect()->limit($page_size, ($offset * $page_size)); //->order('updated_at');
1360
  return $this;
1361
  }
1362
 
1363
+ public function subscribersAction()
1364
+ {
1365
+ /* STATUS_NOT_ACTIVE = 2
1366
+ STATUS_SUBSCRIBED = 1
1367
+ STATUS_UNCONFIRMED = 4
1368
+ STATUS_UNSUBSCRIBED = 3 */
1369
+ if(!$this->_authorise()) {
1370
+ return $this;
1371
+ }
1372
+
1373
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1374
+
1375
+ $offset = $this->getRequest()->getParam('offset', 0);
1376
+ $page_size = $this->getRequest()->getParam('page_size', 20);
1377
+ $since = $this->getRequest()->getParam('since', 'ALL');
1378
+ $subscriber_status= $this->getRequest()->getParam('status', 'ALL');
1379
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
1380
+
1381
+ $_subscribersCol = Mage::getModel('newsletter/subscriber')->getCollection();
1382
+ $_subscribersCol->getSelect()->limit($page_size, ($offset * $page_size));
1383
+
1384
+ if($subscriber_status != 'ALL'){
1385
+ $_subscribersCol->addFieldToFilter('subscriber_status', $subscriber_status);
1386
+ }
1387
+
1388
+ if($gTE != 'ALL'){
1389
+ $_subscribersCol->addFieldToFilter('subscriber_id', array('gteq' =>$gTE));
1390
+ }
1391
+
1392
+ $subscribers = array();
1393
+
1394
+ foreach($_subscribersCol as $_subscriber) {
1395
+ $subscribers[] = $_subscriber->toArray();
1396
+ }
1397
+
1398
+ $this->getResponse()
1399
+ ->setBody(json_encode($subscribers))
1400
+ ->setHttpResponseCode(200)
1401
+ ->setHeader('Content-type', 'application/json', true);
1402
+ return $this;
1403
+ }
1404
+
1405
  public function storesAction()
1406
  {
1407
  if(!$this->_authorise()) {
1418
  $_stores = $group->getStores();
1419
  foreach ($_stores as $_store) {
1420
  $storeInfo = $_store->toArray();
1421
+ $storeID = $_store->getStoreId();
1422
+ $storeInfo['tax/calculation/price_includes_tax'] = Mage::getStoreConfig('tax/calculation/price_includes_tax', $storeID);
1423
+ $storeInfo['tax/defaults/country'] = Mage::getStoreConfig('tax/defaults/country', $storeID);
1424
+ $storeInfo['URL_TYPE_DIRECT_LINK'] = Mage::app()->getStore($storeID)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK);
1425
+ $storeInfo['URL_TYPE_JS'] = Mage::app()->getStore($storeID)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
1426
+ $storeInfo['URL_TYPE_LINK'] = Mage::app()->getStore($storeID)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
1427
+ $storeInfo['URL_TYPE_MEDIA'] = Mage::app()->getStore($storeID)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
1428
+ $storeInfo['URL_TYPE_SKIN'] = Mage::app()->getStore($storeID)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
1429
+ $storeInfo['URL_TYPE_WEB'] = Mage::app()->getStore($storeID)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
1430
+
1431
  $stores[] = $storeInfo;
1432
  }
1433
  }
1440
  return $this;
1441
  }
1442
 
1443
+ public function unconvertedcartsAction()
1444
  {
1445
  if(!$this->_authorise()) {
1446
  return $this;
1450
 
1451
  $offset = $this->getRequest()->getParam('offset', 0);
1452
  $page_size = $this->getRequest()->getParam('page_size', 20);
1453
+ $since = $this->getRequest()->getParam('since', 'ALL');
1454
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
1455
+
1456
+ $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1'); // 1 = quote has not been conveted to an order
1457
+
1458
+
1459
+ $_cartsCol->addFieldToFilter( // If there is no email or customer id we dont want the cart.
1460
+ array(
1461
+ 'customer_id', //attribute_1 with key 0
1462
+ 'customer_email', //attribute_2 with key 1
1463
+ ),
1464
+ array(
1465
+ array('neq'=>Null), //condition for attribute_1 with key 0
1466
+ array('neq'=>null), //condition for attribute_2
1467
+ )
1468
+ );
1469
 
 
1470
  $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1471
 
1472
+ if($since != 'ALL'){
1473
+ $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since)); // If no date filter include empty carts
1474
  }
1475
  else{
1476
+ $_cartsCol->addFieldToFilter('items_count', array('neq' => 0)); // If date filter supplied only include carts with items
1477
+ }
1478
+
1479
+ if($gTE != 'ALL'){
1480
+ $_cartsCol->addFieldToFilter('entity_id', array('gteq' =>$gTE)); // If gte set include records GTE gte
1481
+ }
1482
+
1483
  $carts = array();
1484
 
1485
  foreach($_cartsCol as $_cart) {
1509
  ->setHeader('Content-type', 'application/json', true);
1510
  return $this;
1511
  }
1512
+
1513
+ public function exunconvertedcartsAction()//This query returns only no empty carts when no dat filter applied
1514
  {
1515
  if(!$this->_authorise()) {
1516
  return $this;
1520
 
1521
  $offset = $this->getRequest()->getParam('offset', 0);
1522
  $page_size = $this->getRequest()->getParam('page_size', 20);
1523
+ $since = $this->getRequest()->getParam('since', 'ALL');
1524
+ $entityId = $this->getRequest()->getParam('entity_id', 'ALL');
1525
 
1526
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
1527
  $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1528
 
1529
+ if($since != 'ALL'){
1530
+ $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
1531
+ }
1532
+ else{
1533
+ $_cartsCol->addFieldToFilter('items_count', array('neq' => 0));
1534
+ }
1535
+
1536
+ if($entityId != 'ALL'){
1537
+ $_cartsCol->addFieldToFilter('entity_id', $entityId);
1538
  }
1539
 
1540
  $carts = array();
1541
 
1542
  foreach($_cartsCol as $_cart) {
1543
+ try {
1544
+ $carts[] = array('moco_start_of_cart_record' => 'True');
1545
+ $carts[] = $_cart->toArray();
1546
+ $_cartItemsCol = $_cart -> getItemsCollection();
1547
+
1548
+ foreach($_cartItemsCol as $_cartitem){
1549
+ $carts[] = array('product_id' => $_cartitem->getProductId());
1550
+ $carts[] = array('product_sku' => $_cartitem->getSku());
1551
+ $carts[] = array('product_qty' => $_cartitem->getQty());
1552
+ $carts[] = array('updated_at' => $_cartitem->getUpdatedAt());
1553
+ $carts[] = array('product_type' => $_cartitem->getProductType());
1554
+ //$carts[] = $_cartitem->toArray();
1555
+ }
1556
+ $carts[] = array('moco_end_of_cart_record' => 'True');
1557
+ }
1558
+ catch(Exception $e) {
1559
+ $carts[] = array('mocoauto_api_error' => 'moco_unable_to_read_cart: ' . $e->getMessage());
1560
  }
 
1561
  }
1562
 
1563
  $this->getResponse()
1577
 
1578
  $offset = $this->getRequest()->getParam('offset', 0);
1579
  $page_size = $this->getRequest()->getParam('page_size', 20);
1580
+ $since = $this->getRequest()->getParam('since', 'ALL');
1581
 
1582
  $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
1583
  $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1584
 
1585
+ if($since != 'ALL'){
1586
  $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
1587
  }
1588
 
1652
 
1653
  $offset = $this->getRequest()->getParam('offset', 0);
1654
  $page_size = $this->getRequest()->getParam('page_size', 20);
1655
+ $since = $this->getRequest()->getParam('since', 'ALL');
1656
 
1657
  $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
1658
 
app/code/community/MocoInsight/Mocoauto/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
- <version>1.4.0</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
+ <version>1.4.1</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
- <version>1.4.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
@@ -11,7 +11,16 @@
11
  &#xD;
12
  &#xD;
13
  </description>
14
- <notes>1.4.0&#xD;
 
 
 
 
 
 
 
 
 
15
  &#xD;
16
  Split stats action into&#xD;
17
  stats and logstats&#xD;
@@ -136,9 +145,9 @@ System date/time&#xD;
136
  added success true for succesful requests&#xD;
137
  changed product category to moco_category</notes>
138
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
139
- <date>2014-07-06</date>
140
- <time>23:25:30</time>
141
- <contents><target name="magecommunity"><dir name="MocoInsight"><dir name="Mocoauto"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Buttons"><file name="Generate.php" hash="7690d026d99e31732279e6aa5b6b1def"/></dir></dir><file name="Menu.php" hash="1017af5f89545915f3f28be637e07a0c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4b53061397fec9446830ef218aba4055"/><file name="JWT.php" hash="6610b92191eccedb8edcf993730c3dc0"/></dir><dir name="Model"><file name="Observer.php" hash="c2cc2f396fedd682268457d17dd045b1"/><dir name="Source"><file name="Views.php" hash="c1ddaf4c7bb51c3907dd72b4e21b1897"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="MocoautoController.php" hash="6665fb22806ef20ee59e88a638ca6359"/></dir><file name="ApiController.php" hash="a9d2f0c26b8b3d06c4febb58072b8895"/></dir><dir name="etc"><file name="config.xml" hash="c884b5b0d5d1b5883b01d9ca598c6eb5"/><file name="rob.config" hash="63828905cc2f104275d380d0e7f9ebb3"/><file name="system.xml" hash="5d86b7d939b85826c7ac4d4496f80900"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mocoauto.xml" hash="7dd142354c78e773490c552bbcc3b408"/></dir><dir name="template"><dir name="mocoauto"><dir name="config"><file name="button-generate.phtml" hash="d2ff89c8f1f78e748ac998bd13e61750"/><file name="link.phtml" hash="75c61cac6bdd33ed914f8618b5698598"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mocoauto.xml" hash="a12a0e1dc675b9ac675181373299e36a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MocoInsight_Mocoauto.xml" hash="1ec387f21726f6c7ea3ea216c47340d9"/></dir></target><target name="magelocale"><dir name="en_US"><file name="MocoInsight_Mocoauto.csv" hash="9b508561f871f93fa3158014baebf02b"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="mocoauto"><file name="button.png" hash="58e62edb7f4be46e3b29c0bb774c7ad7"/><file name="icon.png" hash="b5bfce535c987d1e9e604823ac4b3943"/><file name="mocoauto.css" hash="3cd28072e5c2f2b656dd04c06288165b"/></dir></dir></dir></dir></target></contents>
142
  <compatible/>
143
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
144
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
+ <version>1.4.1</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
11
  &#xD;
12
  &#xD;
13
  </description>
14
+ <notes>1.4.1&#xD;
15
+ &#xD;
16
+ Improved order processing speed.&#xD;
17
+ Multi store URL info.&#xD;
18
+ Shipping address tracked.&#xD;
19
+ gte option for orders,customers, products, carts and subscribers.&#xD;
20
+ Status option for subscribersAction&#xD;
21
+ Update carts action skip non identifed carts.&#xD;
22
+ &#xD;
23
+ 1.4.0&#xD;
24
  &#xD;
25
  Split stats action into&#xD;
26
  stats and logstats&#xD;
145
  added success true for succesful requests&#xD;
146
  changed product category to moco_category</notes>
147
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
148
+ <date>2014-08-05</date>
149
+ <time>06:14:25</time>
150
+ <contents><target name="magecommunity"><dir name="MocoInsight"><dir name="Mocoauto"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Buttons"><file name="Generate.php" hash="7690d026d99e31732279e6aa5b6b1def"/></dir></dir><file name="Menu.php" hash="1017af5f89545915f3f28be637e07a0c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4b53061397fec9446830ef218aba4055"/><file name="JWT.php" hash="6610b92191eccedb8edcf993730c3dc0"/></dir><dir name="Model"><file name="Observer.php" hash="c2cc2f396fedd682268457d17dd045b1"/><dir name="Source"><file name="Views.php" hash="c1ddaf4c7bb51c3907dd72b4e21b1897"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="MocoautoController.php" hash="6665fb22806ef20ee59e88a638ca6359"/></dir><file name="ApiController.php" hash="0e6c5674628a96ac7038e08ffa38abd5"/></dir><dir name="etc"><file name="config.xml" hash="50d0d8bcfb966d0f4c02ec83de0dceff"/><file name="rob.config" hash="63828905cc2f104275d380d0e7f9ebb3"/><file name="system.xml" hash="5d86b7d939b85826c7ac4d4496f80900"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mocoauto.xml" hash="7dd142354c78e773490c552bbcc3b408"/></dir><dir name="template"><dir name="mocoauto"><dir name="config"><file name="button-generate.phtml" hash="d2ff89c8f1f78e748ac998bd13e61750"/><file name="link.phtml" hash="75c61cac6bdd33ed914f8618b5698598"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mocoauto.xml" hash="a12a0e1dc675b9ac675181373299e36a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MocoInsight_Mocoauto.xml" hash="1ec387f21726f6c7ea3ea216c47340d9"/></dir></target><target name="magelocale"><dir name="en_US"><file name="MocoInsight_Mocoauto.csv" hash="9b508561f871f93fa3158014baebf02b"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="mocoauto"><file name="button.png" hash="58e62edb7f4be46e3b29c0bb774c7ad7"/><file name="icon.png" hash="b5bfce535c987d1e9e604823ac4b3943"/><file name="mocoauto.css" hash="3cd28072e5c2f2b656dd04c06288165b"/></dir></dir></dir></dir></target></contents>
151
  <compatible/>
152
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
153
  </package>