MocoInsight_Mocoauto - Version 1.5.1.0

Version Notes

1.5.1.0

Updates to visits API

1.5.0.6

Updates to visits API

1.5.0.5

New
creditsAction
credit_idsAction

1.5.0.4

Added item id to wishlist items

1.5.0.3

Diagnostic routine for unconverted carts

1.5.0.2

Maintenance release.

1.5.0.0

OrdersNoPaymentAction for sites with non standard payment methods.

1.4.9

Exception handle for payment method.
Updated wishlistsAction
New product_IdsAction
New customer_IdsAction
New order_IdsAction
unconvertedcarts fix for Magento < 1.7

1.4.7

Support for multiple web sites on single Magento instance.

1.4.6

Test actions for multi web site catalog.

1.4.5

Diagnostic: gte - ordered by entity_id

1.4.4

Faster unconvertedcarts.
CustomerTaxClass added to orders and customer Actions

1.4.3

New attrInfoAction and entityTypeInfoAction added to tracked changes in Magento data.

1.4.2

Disconnect API version from module version for sites that cache module XML file

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.5.1.0
Comparing to
See all releases


Code changes from version 1.5.0.4 to 1.5.1.0

app/code/community/MocoInsight/Mocoauto/controllers/ApiController.php CHANGED
@@ -13,13 +13,8 @@
13
  // categoriesAction
14
  // productsAction
15
  // stocklevelsAction
16
- // log_urlAction
17
- // log_url_infoAction
18
- // log_url_joinedAction
19
- // log_visitorAction
20
- // log_visitor_infoAction
21
- // log_visitor_joinedAction
22
- // log_customerAction
23
  // subscribersAction
24
  // storesAction
25
  // unconvertedcartsAction
@@ -32,9 +27,13 @@
32
  // order_idsAction
33
  // customer_idsAction
34
  // product_idsAction
 
 
 
 
35
 
36
 
37
- define("apiversion","1.5.0.4");
38
 
39
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
40
  {
@@ -85,7 +84,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
85
  }
86
 
87
 
88
- public function statsAction()
89
  {
90
  if(!$this->_authorise()) {
91
  return $this;
@@ -179,7 +178,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
179
  return $this;
180
  }
181
 
182
- public function test_statsAction() // test adding edition info
183
  {
184
  if(!$this->_authorise()) {
185
  return $this;
@@ -235,13 +234,17 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
235
  $cartscount = $_cartsCol->getSize();
236
 
237
  $_subscriberCol = Mage::getModel('newsletter/subscriber')-> getCollection();
238
-
239
  $subscribercount = $_subscriberCol->getSize();
240
 
241
  $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
242
-
243
  $rulescount = $_rulesCol->getSize();
244
 
 
 
 
 
 
 
245
 
246
  $magentoVersion = Mage::getVersion();
247
  $moduleversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
@@ -259,6 +262,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
259
  'Unconverted carts' => $cartscount,
260
  'Subscribers' => $subscribercount,
261
  'Cart and Coupon rules' => $rulescount,
 
262
  'System Date Time' => $currentSystemTime,
263
  'Magento Version' => $magentoVersion,
264
  'Magento Edition' => $magentoedition,
@@ -1165,107 +1169,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1165
  }
1166
 
1167
 
1168
-
1169
- public function log_urlAction()
1170
- {
1171
- $tablename = 'log_url'; // Set the table name here
1172
-
1173
- if(!$this->_authorise()) {
1174
- return $this;
1175
- }
1176
-
1177
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1178
-
1179
- $offset = $this->getRequest()->getParam('offset', 0);
1180
- $page_size = $this->getRequest()->getParam('page_size', 20);
1181
- $since = $this->getRequest()->getParam('since', 'ALL');
1182
-
1183
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1184
-
1185
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
1186
- $readresults=array($tablename ." table does not exist");
1187
- }
1188
- else{
1189
- $query = 'select * from ' . $tablename . ' limit ' . $offset . ',' . $page_size;
1190
- $readresults = $_read->fetchAll($query);
1191
- }
1192
-
1193
- $this->getResponse()
1194
- ->setBody(json_encode($readresults))
1195
- ->setHttpResponseCode(200)
1196
- ->setHeader('Content-type', 'application/json', true);
1197
- return $this;
1198
- }
1199
-
1200
- public function log_url_infoAction()
1201
- {
1202
- $tablename = 'log_url_info'; // Set the table name here
1203
-
1204
- if(!$this->_authorise()) {
1205
- return $this;
1206
- }
1207
-
1208
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1209
-
1210
- $offset = $this->getRequest()->getParam('offset', 0);
1211
- $page_size = $this->getRequest()->getParam('page_size', 20);
1212
- $since = $this->getRequest()->getParam('since', 'ALL');
1213
-
1214
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1215
-
1216
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
1217
- $readresults=array($tablename ." table does not exist");
1218
- }
1219
- else{
1220
- $query = 'select * from ' . $tablename . ' limit ' . $offset . ',' . $page_size;
1221
- $readresults = $_read->fetchAll($query);
1222
- }
1223
-
1224
- $this->getResponse()
1225
- ->setBody(json_encode($readresults))
1226
- ->setHttpResponseCode(200)
1227
- ->setHeader('Content-type', 'application/json', true);
1228
- return $this;
1229
-
1230
- }
1231
-
1232
- public function log_url_joinedAction()
1233
- {
1234
- $tablename1 = 'log_url'; // Set the table name here
1235
- $tablename2 = 'log_url_info'; // Set the table name here
1236
-
1237
- if(!$this->_authorise()) {
1238
- return $this;
1239
- }
1240
-
1241
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1242
-
1243
- $offset = $this->getRequest()->getParam('offset', 0);
1244
- $page_size = $this->getRequest()->getParam('page_size', 20);
1245
- $since = $this->getRequest()->getParam('since', 'ALL');
1246
-
1247
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1248
-
1249
- if(!$_read ->isTableExists($tablename1)){ //Table does not exist
1250
- $readresults=array($tablename1 ." table does not exist");
1251
- }
1252
- elseif(!$_read ->isTableExists($tablename2)){ //Table does not exist
1253
- $readresults=array($tablename2 ." table does not exist");
1254
- }
1255
- else{
1256
- $query = 'select visitor_id, visit_time, url, referer from ' . $tablename1 .
1257
- ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.url_id = ' . $tablename2 . '.url_id where url not like "%mocoauto%"';
1258
-
1259
- if($since != 'ALL'){
1260
- $query = $query . ' and visit_time > "' . $since . '"';
1261
- }
1262
-
1263
- $query = $query .' limit ' . $offset . ',' . $page_size;
1264
-
1265
- $readresults = $_read->fetchAll($query);
1266
- }
1267
- }
1268
-
1269
  public function log_all_joinedAction()
1270
  {
1271
  $tablename1 = 'log_url';
@@ -1283,6 +1186,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1283
  $offset = $this->getRequest()->getParam('offset', 0);
1284
  $page_size = $this->getRequest()->getParam('page_size', 20);
1285
  $since = $this->getRequest()->getParam('since', 'ALL');
 
1286
 
1287
  try{
1288
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
@@ -1313,6 +1217,10 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1313
  $query = $query . ' and visit_time > "' . $since . '"';
1314
  }
1315
 
 
 
 
 
1316
  $query = $query .' limit ' . $offset . ',' . $page_size;
1317
 
1318
  //Mage::log('DBG SQL: '. $query);
@@ -1329,53 +1237,30 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1329
  ->setHeader('Content-type', 'application/json', true);
1330
  return $this;
1331
  }
1332
- public function ex_log_all_joinedAction()
1333
- {
1334
- $tablename1 = 'log_url';
1335
- $tablename2 = 'log_url_info';
1336
- $tablename3 = 'log_visitor';
1337
- $tablename4 = 'log_visitor_info';
1338
 
1339
 
 
 
 
1340
  if(!$this->_authorise()) {
1341
  return $this;
1342
  }
1343
-
1344
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1345
-
1346
  $offset = $this->getRequest()->getParam('offset', 0);
1347
  $page_size = $this->getRequest()->getParam('page_size', 20);
1348
  $since = $this->getRequest()->getParam('since', 'ALL');
1349
-
1350
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1351
-
1352
- if(!$_read ->isTableExists($tablename1)){ //Table does not exist
1353
- $readresults=array($tablename1 ." table does not exist");
1354
- }
1355
- elseif(!$_read ->isTableExists($tablename2)){ //Table does not exist
1356
- $readresults=array($tablename2 ." table does not exist");
1357
- }
1358
  else{
1359
- $query = 'select ';
1360
- $query = $query . $tablename1 . '.url_id, ' . $tablename1 . '.visitor_id, visit_time,'; //log_url
1361
- $query = $query . ' url, referer,'; //log_url_info
1362
- $query = $query . ' session_id, first_visit_at, last_visit_at, store_id,'; //log_visitor
1363
- $query = $query . ' http_referer, http_user_agent, server_addr, remote_addr'; //log_visitor_info
1364
- $query = $query . ' from ' . $tablename1;
1365
- $query = $query . ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.url_id = ' . $tablename2 . '.url_id';
1366
- $query = $query . ' Left join ' . $tablename3 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename3 . '.visitor_id';
1367
- $query = $query . ' Left join ' . $tablename4 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename4 . '.visitor_id where url not like "%mocoauto%"';
1368
-
1369
  if($since != 'ALL'){
1370
- $query = $query . ' and visit_time > "' . $since . '"';
1371
  }
1372
-
1373
  $query = $query .' limit ' . $offset . ',' . $page_size;
1374
-
1375
- //Mage::log('DBG SQL: '. $query);
1376
  $readresults = $_read->fetchAll($query);
1377
  }
1378
-
1379
  $this->getResponse()
1380
  ->setBody(json_encode($readresults))
1381
  ->setHttpResponseCode(200)
@@ -1383,9 +1268,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1383
  return $this;
1384
  }
1385
 
1386
- public function log_visitorAction()
1387
  {
1388
- $tablename = 'log_visitor'; // Set the table name here
1389
 
1390
  if(!$this->_authorise()) {
1391
  return $this;
@@ -1394,48 +1278,28 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1394
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1395
 
1396
  $offset = $this->getRequest()->getParam('offset', 0);
1397
- $page_size = $this->getRequest()->getParam('page_size', 20);
1398
- $since = $this->getRequest()->getParam('since', 'ALL');
1399
-
1400
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1401
 
1402
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
1403
- $readresults=array($tablename ." table does not exist");
1404
- }
1405
- else{
1406
- $query = 'select * from ' . $tablename . ' limit ' . $offset . ',' . $page_size;
1407
- $readresults = $_read->fetchAll($query);
1408
- }
 
 
1409
 
1410
- $this->getResponse()
1411
- ->setBody(json_encode($readresults))
1412
- ->setHttpResponseCode(200)
1413
- ->setHeader('Content-type', 'application/json', true);
1414
- return $this;
1415
- }
1416
 
1417
- public function log_visitor_infoAction()
1418
- {
1419
- $tablename = 'log_visitor_info'; // Set the table name here
1420
 
1421
- if(!$this->_authorise()) {
1422
- return $this;
1423
  }
1424
-
1425
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1426
-
1427
- $offset = $this->getRequest()->getParam('offset', 0);
1428
- $page_size = $this->getRequest()->getParam('page_size', 20);
1429
- $since = $this->getRequest()->getParam('since', 'ALL');
1430
-
1431
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1432
-
1433
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
1434
- $readresults=array($tablename ." table does not exist");
1435
- }
1436
- else{
1437
- $query = 'select * from ' . $tablename . ' limit ' . $offset . ',' . $page_size;
1438
- $readresults = $_read->fetchAll($query);
1439
  }
1440
 
1441
  $this->getResponse()
@@ -1443,13 +1307,12 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1443
  ->setHttpResponseCode(200)
1444
  ->setHeader('Content-type', 'application/json', true);
1445
  return $this;
1446
- }
1447
-
1448
 
1449
- public function log_visitor_joinedAction()
1450
  {
1451
- $tablename1 = 'log_visitor'; // Set the table name here
1452
- $tablename2 = 'log_visitor_info'; // Set the table name here
1453
 
1454
  if(!$this->_authorise()) {
1455
  return $this;
@@ -1458,67 +1321,38 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1458
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1459
 
1460
  $offset = $this->getRequest()->getParam('offset', 0);
1461
- $page_size = $this->getRequest()->getParam('page_size', 20);
1462
  $since = $this->getRequest()->getParam('since', 'ALL');
 
1463
 
1464
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1465
-
1466
- if(!$_read ->isTableExists($tablename1)){ //Table does not exist
1467
- $readresults=array($tablename1 ." table does not exist");
1468
- }
1469
- elseif(!$_read ->isTableExists($tablename2)){ //Table does not exist
1470
- $readresults=array($tablename2 ." table does not exist");
1471
- }
1472
- else{
1473
- $query = 'select ' .
1474
- $tablename1 . '.visitor_id, session_id, first_visit_at, last_visit_at, last_url_id, store_id, http_referer, http_user_agent, remote_addr from '
1475
- . $tablename1 . ' Left join ' . $tablename2 . ' on ' . $tablename1 . '.visitor_id = ' . $tablename2 . '.visitor_id';
1476
-
1477
- if($since != 'ALL'){
1478
- $query = $query . ' where last_vist_at > "' . $since . '"';
1479
  }
 
 
 
 
 
1480
 
1481
- $query = $query .' limit ' . $offset . ',' . $page_size;
1482
-
1483
- $readresults = $_read->fetchAll($query);
1484
- }
1485
-
1486
- $this->getResponse()
1487
- ->setBody(json_encode($readresults))
1488
- ->setHttpResponseCode(200)
1489
- ->setHeader('Content-type', 'application/json', true);
1490
- return $this;
1491
- }
1492
-
1493
- public function log_customerAction()
1494
- {
1495
- $tablename = 'log_customer'; // Set the table name here
1496
-
1497
- if(!$this->_authorise()) {
1498
- return $this;
1499
- }
1500
-
1501
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1502
 
1503
- $offset = $this->getRequest()->getParam('offset', 0);
1504
- $page_size = $this->getRequest()->getParam('page_size', 20);
1505
- $since = $this->getRequest()->getParam('since', 'ALL');
1506
 
1507
- $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1508
 
1509
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
1510
- $readresults=array($tablename ." table does not exist");
1511
- }
1512
- else{
1513
- $query = 'select * from ' . $tablename;
1514
 
1515
- if($since != 'ALL'){
1516
- $query = $query . ' where login_at > "' . $since . '"';
1517
  }
1518
-
1519
- $query = $query .' limit ' . $offset . ',' . $page_size;
1520
-
1521
- $readresults = $_read->fetchAll($query);
1522
  }
1523
 
1524
  $this->getResponse()
@@ -2115,4 +1949,98 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2115
  return $this;
2116
  }
2117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2118
  }
13
  // categoriesAction
14
  // productsAction
15
  // stocklevelsAction
16
+ // log_all_joinedAction
17
+ // log_customerAction()
 
 
 
 
 
18
  // subscribersAction
19
  // storesAction
20
  // unconvertedcartsAction
27
  // order_idsAction
28
  // customer_idsAction
29
  // product_idsAction
30
+ // creditsAction
31
+ // credit_idsAction
32
+ // sql_sales_flat_quoteAction()
33
+ // sql_anytableAction()
34
 
35
 
36
+ define("apiversion","1.5.1.0");
37
 
38
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
39
  {
84
  }
85
 
86
 
87
+ public function ex_statsAction()
88
  {
89
  if(!$this->_authorise()) {
90
  return $this;
178
  return $this;
179
  }
180
 
181
+ public function statsAction() // test adding edition info
182
  {
183
  if(!$this->_authorise()) {
184
  return $this;
234
  $cartscount = $_cartsCol->getSize();
235
 
236
  $_subscriberCol = Mage::getModel('newsletter/subscriber')-> getCollection();
 
237
  $subscribercount = $_subscriberCol->getSize();
238
 
239
  $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
 
240
  $rulescount = $_rulesCol->getSize();
241
 
242
+ $_creditCol = Mage::getModel('sales/order_creditmemo')->getCollection();
243
+ if($since != 'ALL'){
244
+ $_creditCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
245
+ }
246
+ $creditcount = $_creditCol->getSize();
247
+
248
 
249
  $magentoVersion = Mage::getVersion();
250
  $moduleversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
262
  'Unconverted carts' => $cartscount,
263
  'Subscribers' => $subscribercount,
264
  'Cart and Coupon rules' => $rulescount,
265
+ 'Credit memos' => $creditcount,
266
  'System Date Time' => $currentSystemTime,
267
  'Magento Version' => $magentoVersion,
268
  'Magento Edition' => $magentoedition,
1169
  }
1170
 
1171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1172
  public function log_all_joinedAction()
1173
  {
1174
  $tablename1 = 'log_url';
1186
  $offset = $this->getRequest()->getParam('offset', 0);
1187
  $page_size = $this->getRequest()->getParam('page_size', 20);
1188
  $since = $this->getRequest()->getParam('since', 'ALL');
1189
+ $ipaddr = $this->getRequest()->getParam('ipaddr', 'ALL');
1190
 
1191
  try{
1192
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1217
  $query = $query . ' and visit_time > "' . $since . '"';
1218
  }
1219
 
1220
+ if($ipaddr != 'ALL'){
1221
+ $query = $query . ' and remote_addr = "' . ip2long($ipaddr) . '"';
1222
+ }
1223
+
1224
  $query = $query .' limit ' . $offset . ',' . $page_size;
1225
 
1226
  //Mage::log('DBG SQL: '. $query);
1237
  ->setHeader('Content-type', 'application/json', true);
1238
  return $this;
1239
  }
 
 
 
 
 
 
1240
 
1241
 
1242
+ public function log_customerAction()
1243
+ {
1244
+ $tablename = 'log_customer'; // Set the table name here
1245
  if(!$this->_authorise()) {
1246
  return $this;
1247
  }
 
1248
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
 
1249
  $offset = $this->getRequest()->getParam('offset', 0);
1250
  $page_size = $this->getRequest()->getParam('page_size', 20);
1251
  $since = $this->getRequest()->getParam('since', 'ALL');
 
1252
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1253
+ if(!$_read ->isTableExists($tablename)){ //Table does not exist
1254
+ $readresults=array($tablename ." table does not exist");
1255
+ }
 
 
 
 
1256
  else{
1257
+ $query = 'select * from ' . $tablename;
 
 
 
 
 
 
 
 
 
1258
  if($since != 'ALL'){
1259
+ $query = $query . ' where login_at > "' . $since . '"';
1260
  }
 
1261
  $query = $query .' limit ' . $offset . ',' . $page_size;
 
 
1262
  $readresults = $_read->fetchAll($query);
1263
  }
 
1264
  $this->getResponse()
1265
  ->setBody(json_encode($readresults))
1266
  ->setHttpResponseCode(200)
1268
  return $this;
1269
  }
1270
 
1271
+ public function sql_anytableAction()
1272
  {
 
1273
 
1274
  if(!$this->_authorise()) {
1275
  return $this;
1278
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1279
 
1280
  $offset = $this->getRequest()->getParam('offset', 0);
1281
+ $page_size = $this->getRequest()->getParam('page_size', 100);
1282
+ $tablename1 = $this->getRequest()->getParam('tablename', 'no table name set');
 
 
1283
 
1284
+ try{
1285
+ $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1286
+ if(!$_read ->showTableStatus(trim($tablename1,"'"))){
1287
+ $readresults=array($tablename1 ." table does not exist");
1288
+ }
1289
+ else{
1290
+ $query = 'select ';
1291
+ $query = $query . '*';
1292
+ $query = $query . ' from ' . $tablename1;
1293
 
1294
+ $query = $query .' limit ' . $offset . ',' . $page_size;
 
 
 
 
 
1295
 
1296
+ //Mage::log('DBG SQL: '. $query);
 
 
1297
 
1298
+ $readresults = $_read->fetchAll($query);
1299
+ }
1300
  }
1301
+ catch(Exception $e) {
1302
+ $readresults[] = array('mocoauto_api_error' => 'error reading ' . $tablename1 . ' : ' . $e->getMessage());
 
 
 
 
 
 
 
 
 
 
 
 
 
1303
  }
1304
 
1305
  $this->getResponse()
1307
  ->setHttpResponseCode(200)
1308
  ->setHeader('Content-type', 'application/json', true);
1309
  return $this;
1310
+ }
 
1311
 
1312
+ public function sql_sales_flat_quoteAction()
1313
  {
1314
+ $tablename1 = 'sales_flat_quote';
1315
+
1316
 
1317
  if(!$this->_authorise()) {
1318
  return $this;
1321
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1322
 
1323
  $offset = $this->getRequest()->getParam('offset', 0);
1324
+ $page_size = $this->getRequest()->getParam('page_size', 100);
1325
  $since = $this->getRequest()->getParam('since', 'ALL');
1326
+ $ipaddr = $this->getRequest()->getParam('ipaddr', 'ALL');
1327
 
1328
+ try{
1329
+ $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1330
+ if(!$_read ->showTableStatus(trim($tablename1,"'"))){
1331
+ $readresults=array($tablename1 ." table does not exist");
 
 
 
 
 
 
 
 
 
 
 
1332
  }
1333
+ else{
1334
+ $query = 'select ';
1335
+ $query = $query . 'entity_id, store_id, created_at, customer_email, remote_ip, reserved_order_id';
1336
+ $query = $query . ' from ' . $tablename1;
1337
+ $query = $query . ' where entity_id > 0';
1338
 
1339
+ if($since != 'ALL'){
1340
+ $query = $query . ' and created_at > "' . $since . '"';
1341
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1342
 
1343
+ if($ipaddr != 'ALL'){
1344
+ $query = $query . ' and remote_ip = "' . $ipaddr . '"';
1345
+ }
1346
 
1347
+ $query = $query .' limit ' . $offset . ',' . $page_size;
1348
 
1349
+ //Mage::log('DBG SQL: '. $query);
 
 
 
 
1350
 
1351
+ $readresults = $_read->fetchAll($query);
 
1352
  }
1353
+ }
1354
+ catch(Exception $e) {
1355
+ $readresults[] = array('mocoauto_api_error' => 'error reading ' . $tablename1 . ' : ' . $e->getMessage());
 
1356
  }
1357
 
1358
  $this->getResponse()
1949
  return $this;
1950
  }
1951
 
1952
+
1953
+ public function creditsAction()
1954
+ {
1955
+ if(!$this->_authorise()) {
1956
+ return $this;
1957
+ }
1958
+
1959
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1960
+
1961
+ $offset = $this->getRequest()->getParam('offset', 0);
1962
+ $page_size = $this->getRequest()->getParam('page_size', 20);
1963
+ $since = $this->getRequest()->getParam('since','ALL');
1964
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
1965
+
1966
+ $_creditCol = Mage::getModel('sales/order_creditmemo')->getCollection()->addAttributeToSelect('*');
1967
+
1968
+
1969
+ if($since != 'ALL'){
1970
+ $_creditCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
1971
+ }
1972
+
1973
+ if($gTE != 'ALL'){
1974
+ $_creditCol->addFieldToFilter('entity_id', array('gteq' =>$gTE));
1975
+ $_creditCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
1976
+ }
1977
+ else{
1978
+ $_creditCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1979
+ }
1980
+
1981
+ //Mage::log('SQL Query: '.$_orderCol->getSelect());
1982
+
1983
+
1984
+ $credits = array();
1985
+
1986
+ foreach($_creditCol as $_credit) {
1987
+
1988
+ $credit = array();
1989
+
1990
+ try{
1991
+ $credit['moco_start_of_credit_record'] = 'True';
1992
+ $creditdetails = array();
1993
+ $creditdetails = $_credit->toArray();
1994
+
1995
+ foreach ($creditdetails as $key => $value) {
1996
+ $credit[$key] = $value;
1997
+ }
1998
+
1999
+
2000
+ $_creditItemsCol = $_credit->getItemsCollection();
2001
+ $credititems = array();
2002
+
2003
+ foreach($_creditItemsCol as $_credititem){
2004
+ $credititems[] = $_credititem->toArray();
2005
+ }
2006
+ $credit['moco_tls'] = $credititems;
2007
+
2008
+
2009
+ $order['moco_end_of_credit_record'] = 'True';
2010
+ }
2011
+ catch (Exception $e) {
2012
+ $order['mocoauto_api_error'] = 'credit record: ' . $e->getMessage();
2013
+ }
2014
+ $credits[] = $credit;
2015
+
2016
+ }
2017
+
2018
+ $this->getResponse()
2019
+ ->setBody(json_encode($credits))
2020
+ ->setHttpResponseCode(200)
2021
+ ->setHeader('Content-type', 'application/json', true);
2022
+ return $this;
2023
+ }
2024
+
2025
+
2026
+
2027
+ public function credit_idsAction()
2028
+ {
2029
+ if(!$this->_authorise()) {
2030
+ return $this;
2031
+ }
2032
+
2033
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
2034
+
2035
+ $offset = $this->getRequest()->getParam('offset', 0);
2036
+ $page_size = $this->getRequest()->getParam('page_size', 20);
2037
+
2038
+ $creditIds = Mage::getModel('sales/order_creditmemo')->getCollection()->getAllIds($limit= $page_size, $offset =($offset * $page_size));
2039
+
2040
+ $this->getResponse()
2041
+ ->setBody(json_encode($creditIds))
2042
+ ->setHttpResponseCode(200)
2043
+ ->setHeader('Content-type', 'application/json', true);
2044
+ return $this;
2045
+ }
2046
  }
app/code/community/MocoInsight/Mocoauto/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
- <version>1.5.0.4</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
+ <version>1.5.1.0</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.5.0.4</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
@@ -11,7 +11,21 @@
11
  &#xD;
12
  &#xD;
13
  </description>
14
- <notes>1.5.0.4&#xD;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  &#xD;
16
  Added item id to wishlist items&#xD;
17
  &#xD;
@@ -195,9 +209,9 @@ System date/time&#xD;
195
  added success true for succesful requests&#xD;
196
  changed product category to moco_category</notes>
197
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
198
- <date>2015-01-13</date>
199
- <time>05:29:36</time>
200
- <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="Api2OrdersController.php" hash="b9fa4922f70212b8b0fbf5ccc12a3e5b"/><file name="ApiController.php" hash="260e85f7a31b845f12ad8b83e5a2cfbc"/></dir><dir name="etc"><file name="config.xml" hash="33d1703f2ad0f7e8377897dcd95f119e"/><file name="orig.config.xml" hash="863bd2bdfefde5ef9f6c9b30691f4bb4"/><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>
201
  <compatible/>
202
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
203
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
+ <version>1.5.1.0</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.5.1.0&#xD;
15
+ &#xD;
16
+ Updates to visits API&#xD;
17
+ &#xD;
18
+ 1.5.0.6&#xD;
19
+ &#xD;
20
+ Updates to visits API&#xD;
21
+ &#xD;
22
+ 1.5.0.5&#xD;
23
+ &#xD;
24
+ New &#xD;
25
+ creditsAction&#xD;
26
+ credit_idsAction&#xD;
27
+ &#xD;
28
+ 1.5.0.4&#xD;
29
  &#xD;
30
  Added item id to wishlist items&#xD;
31
  &#xD;
209
  added success true for succesful requests&#xD;
210
  changed product category to moco_category</notes>
211
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
212
+ <date>2015-02-02</date>
213
+ <time>01:59:45</time>
214
+ <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="Api2OrdersController.php" hash="b9fa4922f70212b8b0fbf5ccc12a3e5b"/><file name="ApiController.php" hash="927610b7339bc82ccd46887f271e948b"/></dir><dir name="etc"><file name="config.xml" hash="9a161b923d7de0b4732cd66c01aaf45b"/><file name="orig.config.xml" hash="863bd2bdfefde5ef9f6c9b30691f4bb4"/><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>
215
  <compatible/>
216
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
217
  </package>