MocoInsight_Mocoauto - Version 1.4.0

Version Notes

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


Code changes from version 1.3.8 to 1.4.0

app/code/community/MocoInsight/Mocoauto/controllers/ApiController.php CHANGED
@@ -26,7 +26,7 @@
26
  // wishlistsAction
27
  // installinfoAction
28
  // rulesAction
29
- //
30
 
31
 
32
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
@@ -79,6 +79,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
79
 
80
  return true;
81
  }
 
82
  public function statsAction() // Return the number of Product, Orders and Customers with optional since filter
83
  {
84
  if(!$this->_authorise()) {
@@ -140,6 +141,50 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
140
 
141
  $rulescount = $_rulesCol->getSize();
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
144
 
145
  if (method_exists($_read, 'showTableStatus')){
@@ -180,7 +225,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
180
  $log_visitor_infocount = $_read->fetchOne($query);
181
  }
182
 
183
- $tablename = 'log_customer'; // Set the table name here
184
  if(!$_read ->showTableStatus(trim($tablename,"'"))){
185
  $log_countcount = "table does not exist";
186
  }
@@ -199,30 +244,18 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
199
  }
200
 
201
 
202
- $magentoVersion = Mage::getVersion();
203
  $apiversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
204
- $phpversion = phpversion();
205
 
206
  $stats = array(
207
  'success' => 'true',
208
  'Since' => $since,
209
- 'Products' => $productcount,
210
- 'Orders' => $ordercount,
211
- 'Customers' => $customercount,
212
- 'Categories' => $categorycount,
213
- 'Wish lists' => $wishlistcount,
214
- 'Unconverted carts' => $cartscount,
215
- 'Subscribers' => $subscribercount,
216
- 'Cart and Coupon rules' => $rulescount,
217
  'log_url' => $log_urlcount,
218
  'log_url_info' => $log_url_infocount,
219
  'log_visitor' => $log_visitorcount,
220
  'log_visitor_info' => $log_visitor_infocount,
221
  'log_customer' => $log_customercount,
222
- 'System Date Time' => $currentSystemTime,
223
- 'Magento Version' => $magentoVersion,
224
  'MocoAPI Version' => $apiversion,
225
- 'PHP Version' => $phpversion,
226
  'API processing time' => (microtime(true) - $time_start)
227
  );
228
 
@@ -294,30 +327,21 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
294
 
295
  $rulescount = $_rulesCol->getSize();
296
 
297
- //
298
- // Check size of log files
299
- // 1. Check if isTableExists method is defined (It appears Magento v1.5.0.1 defines it differently)
300
- // 2. Then check if each table exists
301
- // 3. Then get size of the 5 tables.
302
-
303
-
304
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
305
 
306
- if (method_exists($_read, 'isTableExists')){
307
-
308
- $tablename = 'log_url'; // Set the table name here
309
 
310
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
311
- $logurlcount = "table does not exist";
 
312
  }
313
  else{
314
  $query = 'select count(*) AS id from ' . $tablename;
315
  $log_urlcount = $_read->fetchOne($query);
316
  }
317
 
318
- $tablename = 'log_url_info'; // Set the table name here
319
-
320
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
321
  $log_url_infocount = "table does not exist";
322
  }
323
  else{
@@ -325,9 +349,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
325
  $log_url_infocount = $_read->fetchOne($query);
326
  }
327
 
328
- $tablename = 'log_visitor'; // Set the table name here
329
-
330
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
331
  $log_visitorcount = "table does not exist";
332
  }
333
  else{
@@ -335,9 +358,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
335
  $log_visitorcount = $_read->fetchOne($query);
336
  }
337
 
338
- $tablename = 'log_visitor_info'; // Set the table name here
339
-
340
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
341
  $log_visitor_infocount = "table does not exist";
342
  }
343
  else{
@@ -346,31 +368,30 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
346
  }
347
 
348
  $tablename = 'log_customer'; // Set the table name here
349
-
350
- if(!$_read ->isTableExists($tablename)){ //Table does not exist
351
  $log_countcount = "table does not exist";
352
  }
353
  else{
354
  $query = 'select count(*) AS id from ' . $tablename;
355
  $log_customercount = $_read->fetchOne($query);
356
  }
357
-
358
  }
359
  else {
360
- $log_urlcount = "isTableExists is an undefined method";
361
- $log_url_infocount = "isTableExists is an undefined method";
362
- $log_visitorcount = "isTableExists is an undefined method";
363
- $log_visitor_infocount = "isTableExists is an undefined method";
364
- $log_customercount = "isTableExists is an undefined method";
365
 
366
  }
367
 
368
 
369
-
370
  $magentoVersion = Mage::getVersion();
371
  $apiversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
372
  $phpversion = phpversion();
373
 
 
 
374
  $stats = array(
375
  'success' => 'true',
376
  'Since' => $since,
@@ -391,6 +412,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
391
  'Magento Version' => $magentoVersion,
392
  'MocoAPI Version' => $apiversion,
393
  'PHP Version' => $phpversion,
 
394
  'API processing time' => (microtime(true) - $time_start)
395
  );
396
 
@@ -401,7 +423,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
401
  return $this;
402
  }
403
 
404
-
405
  public function ordersAction()
406
  {
407
  if(!$this->_authorise()) {
@@ -519,6 +540,26 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
519
  }
520
 
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  public function customersAction()
523
  {
524
  if(!$this->_authorise()) {
@@ -534,6 +575,69 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
534
  $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
535
  $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  if($since != 'All'){
538
  $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
539
  }
@@ -583,7 +687,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
583
  return $this;
584
  }
585
 
586
- public function productsAction()
587
  {
588
  if(!$this->_authorise()) {
589
  return $this;
@@ -677,6 +781,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
677
  }
678
  }
679
 
 
680
  // write end of record mark
681
  $products[] = array('moco_end_of_record' => 'True');
682
 
@@ -689,7 +794,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
689
  return $this;
690
  }
691
 
692
- public function exproductsAction() // previous version of API
 
693
  {
694
  if(!$this->_authorise()) {
695
  return $this;
@@ -708,29 +814,199 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
708
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
709
  }
710
 
711
- $products = array();
712
  $products[] = array('success' => 'true');
 
713
  foreach($_productCol as $_product){
714
 
715
- // get all the attributes of the product
716
  $attributes = $_product->getAttributes();
717
 
718
  foreach ($attributes as $attribute) {
719
  $attributeCode = $attribute->getAttributeCode();
720
- $value = $attribute->getFrontend()->getValue($_product);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
 
 
 
 
 
 
 
 
 
 
 
722
  switch ($attributeCode){
 
 
723
  case 'description':
724
  break;
725
  case 'short_description':
726
  break;
 
 
 
 
 
 
727
  default:
728
- $products[] = array($attributeCode => $value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
729
  break;
730
  }
731
  }
732
 
 
 
733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734
  // get all the categories of the product
735
 
736
  $categories = $_product->getCategoryCollection()->addAttributeToSelect('name');
@@ -739,15 +1015,45 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
739
  $products[] = array('moco_category' => $category->getID());
740
  }
741
 
 
 
 
 
 
 
 
 
 
 
 
 
 
742
  // if type is configurable get simple product children
743
 
744
  if($_product->getTypeID() == 'configurable'){
745
- $assocProductIDs = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
 
746
 
747
- foreach($assocProductIDs as $assocProduct){
748
  $products[] = array('childProductID' => $assocProduct->getID());
749
  }
750
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
  // write end of record mark
752
  $products[] = array('moco_end_of_record' => 'True');
753
 
@@ -1360,6 +1666,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1360
  $installinfo[] = array('Base URL' => Mage::getBaseUrl());
1361
  $installinfo[] = array('Home URL' => Mage::helper('core/url')->getHomeUrl());
1362
  $installinfo[] = array('Home URL' => Mage::getBaseDir());
 
 
1363
 
1364
 
1365
 
26
  // wishlistsAction
27
  // installinfoAction
28
  // rulesAction
29
+ // eavinfo_catalogAction
30
 
31
 
32
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
79
 
80
  return true;
81
  }
82
+
83
  public function statsAction() // Return the number of Product, Orders and Customers with optional since filter
84
  {
85
  if(!$this->_authorise()) {
141
 
142
  $rulescount = $_rulesCol->getSize();
143
 
144
+
145
+ $magentoVersion = Mage::getVersion();
146
+ $apiversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
147
+ $phpversion = phpversion();
148
+
149
+ $stats = array(
150
+ 'success' => 'true',
151
+ 'Since' => $since,
152
+ 'Products' => $productcount,
153
+ 'Orders' => $ordercount,
154
+ 'Customers' => $customercount,
155
+ 'Categories' => $categorycount,
156
+ 'Wish lists' => $wishlistcount,
157
+ 'Unconverted carts' => $cartscount,
158
+ 'Subscribers' => $subscribercount,
159
+ 'Cart and Coupon rules' => $rulescount,
160
+ 'System Date Time' => $currentSystemTime,
161
+ 'Magento Version' => $magentoVersion,
162
+ 'MocoAPI Version' => $apiversion,
163
+ 'PHP Version' => $phpversion,
164
+ 'API processing time' => (microtime(true) - $time_start)
165
+ );
166
+
167
+ $this->getResponse()
168
+ ->setBody(json_encode($stats))
169
+ ->setHttpResponseCode(200)
170
+ ->setHeader('Content-type', 'application/json', true);
171
+ return $this;
172
+ }
173
+
174
+
175
+ public function logstatsAction() // Return the number size of logs
176
+ {
177
+ if(!$this->_authorise()) {
178
+ return $this;
179
+ }
180
+
181
+ $time_start = microtime(true);
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');
189
 
190
  if (method_exists($_read, 'showTableStatus')){
225
  $log_visitor_infocount = $_read->fetchOne($query);
226
  }
227
 
228
+ $tablename = 'log_customer';
229
  if(!$_read ->showTableStatus(trim($tablename,"'"))){
230
  $log_countcount = "table does not exist";
231
  }
244
  }
245
 
246
 
 
247
  $apiversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
248
+
249
 
250
  $stats = array(
251
  'success' => 'true',
252
  'Since' => $since,
 
 
 
 
 
 
 
 
253
  'log_url' => $log_urlcount,
254
  'log_url_info' => $log_url_infocount,
255
  'log_visitor' => $log_visitorcount,
256
  'log_visitor_info' => $log_visitor_infocount,
257
  'log_customer' => $log_customercount,
 
 
258
  'MocoAPI Version' => $apiversion,
 
259
  'API processing time' => (microtime(true) - $time_start)
260
  );
261
 
327
 
328
  $rulescount = $_rulesCol->getSize();
329
 
 
 
 
 
 
 
 
330
  $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
331
 
332
+ if (method_exists($_read, 'showTableStatus')){
 
 
333
 
334
+ $tablename = 'log_url';
335
+ if(!$_read ->showTableStatus(trim($tablename,"'"))){
336
+ $logurlcount = "table does not exist";
337
  }
338
  else{
339
  $query = 'select count(*) AS id from ' . $tablename;
340
  $log_urlcount = $_read->fetchOne($query);
341
  }
342
 
343
+ $tablename = 'log_url_info';
344
+ if(!$_read ->showTableStatus(trim($tablename,"'"))){
 
345
  $log_url_infocount = "table does not exist";
346
  }
347
  else{
349
  $log_url_infocount = $_read->fetchOne($query);
350
  }
351
 
352
+ $tablename = 'log_visitor';
353
+ if(!$_read ->showTableStatus(trim($tablename,"'"))){
 
354
  $log_visitorcount = "table does not exist";
355
  }
356
  else{
358
  $log_visitorcount = $_read->fetchOne($query);
359
  }
360
 
361
+ $tablename = 'log_visitor_info';
362
+ if(!$_read ->showTableStatus(trim($tablename,"'"))){
 
363
  $log_visitor_infocount = "table does not exist";
364
  }
365
  else{
368
  }
369
 
370
  $tablename = 'log_customer'; // Set the table name here
371
+ if(!$_read ->showTableStatus(trim($tablename,"'"))){
 
372
  $log_countcount = "table does not exist";
373
  }
374
  else{
375
  $query = 'select count(*) AS id from ' . $tablename;
376
  $log_customercount = $_read->fetchOne($query);
377
  }
 
378
  }
379
  else {
380
+ $log_urlcount = "showTableStatus is an undefined method";
381
+ $log_url_infocount = "showTableStatus is an undefined method";
382
+ $log_visitorcount = "showTableStatus is an undefined method";
383
+ $log_visitor_infocount = "showTableStatus is an undefined method";
384
+ $log_customercount = "showTableStatus is an undefined method";
385
 
386
  }
387
 
388
 
 
389
  $magentoVersion = Mage::getVersion();
390
  $apiversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
391
  $phpversion = phpversion();
392
 
393
+ $mediaurl = Mage::getBaseUrl('media');
394
+
395
  $stats = array(
396
  'success' => 'true',
397
  'Since' => $since,
412
  'Magento Version' => $magentoVersion,
413
  'MocoAPI Version' => $apiversion,
414
  'PHP Version' => $phpversion,
415
+ 'Media URL' => $mediaurl,
416
  'API processing time' => (microtime(true) - $time_start)
417
  );
418
 
423
  return $this;
424
  }
425
 
 
426
  public function ordersAction()
427
  {
428
  if(!$this->_authorise()) {
540
  }
541
 
542
 
543
+ public function eavinfo_catalogAction()
544
+ {
545
+ if(!$this->_authorise()) {
546
+ return $this;
547
+ }
548
+
549
+ $eavinfo = array();
550
+
551
+ $attributeCollection = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
552
+ foreach($attributeCollection as $attributeObject){
553
+ $eavinfo[] = $attributeObject->getData();
554
+ }
555
+
556
+ $this->getResponse()
557
+ ->setBody(json_encode($eavinfo))
558
+ ->setHttpResponseCode(200)
559
+ ->setHeader('Content-type', 'application/json', true);
560
+ return $this;
561
+ }
562
+
563
  public function customersAction()
564
  {
565
  if(!$this->_authorise()) {
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) {
585
+
586
+ $attributes = $_customer->getAttributes();
587
+ $customer = array();
588
+ foreach ($attributes as $attribute) {
589
+ $attributeCode = $attribute->getAttributeCode();
590
+
591
+ switch ($attributeCode){
592
+ case 'password_hash':
593
+ break;
594
+ case 'rp_token':
595
+ break;
596
+ case 'rp_token_created_at':
597
+ break;
598
+ case 'store_id':
599
+ $value = $_customer->getData($attributeCode);
600
+ $customer[$attributeCode] = $value;
601
+ break;
602
+ default:
603
+ try {
604
+ $value = $attribute->getFrontend()->getValue($_customer);
605
+ $customer[$attributeCode] = $value;
606
+ }
607
+ catch (Exception $e) {
608
+ $customer['mocoauto_api_error'] = 'customer attribute: ' . $attributeCode . ' - ' . $e->getMessage();
609
+ }
610
+ break;
611
+ }
612
+ }
613
+
614
+ $customers[] = $customer;
615
+ }
616
+
617
+ $this->getResponse()
618
+ ->setBody(json_encode($customers))
619
+ ->setHttpResponseCode(200)
620
+ ->setHeader('Content-type', 'application/json', true);
621
+ return $this;
622
+ }
623
+
624
+
625
+
626
+ public function excustomersAction()
627
+ {
628
+ if(!$this->_authorise()) {
629
+ return $this;
630
+ }
631
+
632
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
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
  }
687
  return $this;
688
  }
689
 
690
+ public function exproductsAction()
691
  {
692
  if(!$this->_authorise()) {
693
  return $this;
781
  }
782
  }
783
 
784
+
785
  // write end of record mark
786
  $products[] = array('moco_end_of_record' => 'True');
787
 
794
  return $this;
795
  }
796
 
797
+
798
+ public function productsAction()
799
  {
800
  if(!$this->_authorise()) {
801
  return $this;
814
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
815
  }
816
 
817
+
818
  $products[] = array('success' => 'true');
819
+
820
  foreach($_productCol as $_product){
821
 
822
+ // get all the custom attributes of the product
823
  $attributes = $_product->getAttributes();
824
 
825
  foreach ($attributes as $attribute) {
826
  $attributeCode = $attribute->getAttributeCode();
827
+
828
+ switch ($attributeCode){
829
+ case 'in_depth':
830
+ break;
831
+ case 'description':
832
+ break;
833
+ case 'short_description':
834
+ break;
835
+ case 'thumbnail':
836
+ break;
837
+ case 'small_image':
838
+ break;
839
+ case 'image':
840
+ break;
841
+ default:
842
+ try {
843
+ $value = $attribute->getFrontend()->getValue($_product);
844
+ $products[] = array($attributeCode => $value);
845
+ }
846
+ catch (Exception $e) {
847
+ $products[] = array('mocoauto_api_error' => 'product attribute ' . $attributeCode . ' ' . $e->getMessage());
848
+ }
849
+ break;
850
+ }
851
+ }
852
+
853
+ // Get full url to product image
854
+
855
+ try{
856
+ $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
857
+ $products[] = array('thumbnail' => $full_path_url);
858
+ $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'small_image');
859
+ $products[] = array('small_image' => $full_path_url);
860
+ $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'image');
861
+ $products[] = array('image' => $full_path_url);
862
+ }
863
+ catch (Exception $e) {
864
+ $products[] = array('mocoauto_api_error' => 'full path to image error:' . $e->getMessage());
865
+ }
866
+
867
+ // get all the categories of the product
868
+
869
+ $categories = $_product->getCategoryCollection()->addAttributeToSelect('name');
870
+
871
+ foreach ($categories as $category) {
872
+ $products[] = array('moco_category' => $category->getID());
873
+ }
874
+
875
+ // get inventory information
876
+
877
+ try{
878
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
879
+
880
+ $products[] = array('stock_managed' => $stock->getManageStock());
881
+ $products[] = array('stock_availability' => $stock->getIsInStock());
882
+ }
883
+ catch (Exception $e) {
884
+ $products[] = array('mocoauto_api_error' => 'moco_product_inventory: ' . $e->getMessage());
885
+ }
886
+
887
+
888
+ // if type is configurable get simple product children
889
+
890
+ if($_product->getTypeID() == 'configurable'){
891
+ //$assocProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
892
+ $assocProducts = $_product->getTypeInstance()->getUsedProducts();
893
+
894
+ foreach($assocProducts as $assocProduct){
895
+ $products[] = array('childProductID' => $assocProduct->getID());
896
+ }
897
+ }
898
+
899
+ // if type is grouped get associated product children
900
+
901
+ if($_product->getTypeID() == 'grouped'){
902
+
903
+ $groupedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
904
+
905
+ foreach($groupedProducts as $groupedProduct){
906
+ $products[] = array('childProductID' => $groupedProduct->getID());
907
+
908
+ }
909
+ }
910
+
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');
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
 
1666
  $installinfo[] = array('Base URL' => Mage::getBaseUrl());
1667
  $installinfo[] = array('Home URL' => Mage::helper('core/url')->getHomeUrl());
1668
  $installinfo[] = array('Home URL' => Mage::getBaseDir());
1669
+ $installinfo[] = array('Media URL' => Mage::getBaseUrl('media'));
1670
+
1671
 
1672
 
1673
 
app/code/community/MocoInsight/Mocoauto/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
- <version>1.3.8</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
+ <version>1.4.0</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
app/code/community/MocoInsight/Mocoauto/etc/rob.config ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ -->
4
+ <config>
5
+ <modules>
6
+ <MocoInsight_Mocoauto>
7
+ <version>1.3.8</version>
8
+ </MocoInsight_Mocoauto>
9
+ </modules>
10
+ <global>
11
+ <models>
12
+ <mocoauto>
13
+ <class>MocoInsight_Mocoauto_Model</class>
14
+ </mocoauto>
15
+ </models>
16
+ <helpers>
17
+ <mocoauto>
18
+ <class>MocoInsight_Mocoauto_Helper</class>
19
+ </mocoauto>
20
+ </helpers>
21
+ <blocks>
22
+ <mocoauto>
23
+ <class>MocoInsight_Mocoauto_Block</class>
24
+ </mocoauto>
25
+ </blocks>
26
+ <resources>
27
+ <mocoauto_setup>
28
+ <setup>
29
+ <module>MocoInsight_Mocoauto</module>
30
+ </setup>
31
+ <connection>
32
+ <use>directory_setup</use>
33
+ </connection>
34
+ </mocoauto_setup>
35
+ <mocoauto_write>
36
+ <connection>
37
+ <use>core_write</use>
38
+ </connection>
39
+ </mocoauto_write>
40
+ <mocoauto_read>
41
+ <connection>
42
+ <use>core_read</use>
43
+ </connection>
44
+ </mocoauto_read>
45
+ </resources>
46
+ </global>
47
+ <frontend>
48
+ <routers>
49
+ <mocoauto>
50
+ <use>standard</use>
51
+ <args>
52
+ <module>MocoInsight_Mocoauto</module>
53
+ <frontName>mocoauto</frontName>
54
+ </args>
55
+ </mocoauto>
56
+ </routers>
57
+ <layout>
58
+ <updates>
59
+ <mocoauto>
60
+ <file>mocoauto.xml</file>
61
+ </mocoauto>
62
+ </updates>
63
+ </layout>
64
+ </frontend>
65
+ <admin>
66
+ <routers>
67
+ <adminhtml>
68
+ <args>
69
+ <modules>
70
+ <MocoInsight_Mocoauto before="Mage_Adminhtml">MocoInsight_Mocoauto_Adminhtml</MocoInsight_Mocoauto>
71
+ </modules>
72
+ </args>
73
+ </adminhtml>
74
+ </routers>
75
+ </admin>
76
+ <adminhtml>
77
+ <layout>
78
+ <updates>
79
+ <mocoauto>
80
+ <file>mocoauto.xml</file>
81
+ </mocoauto>
82
+ </updates>
83
+ </layout>
84
+ <translate>
85
+ <modules>
86
+ <translations>
87
+ <files>
88
+ <default>MocoInsight_Mocoauto.csv</default>
89
+ </files>
90
+ </translations>
91
+ </modules>
92
+ </translate>
93
+ <events>
94
+ <core_block_abstract_prepare_layout_after>
95
+ <observers>
96
+ <mocoauto>
97
+ <class>mocoauto/observer</class>
98
+ <method>setHook</method>
99
+ </mocoauto>
100
+ </observers>
101
+ </core_block_abstract_prepare_layout_after>
102
+ <core_block_abstract_to_html_after>
103
+ <observers>
104
+ <mocoauto>
105
+ <class>mocoauto/observer</class>
106
+ <method>insertBlock</method>
107
+ </mocoauto>
108
+ </observers>
109
+ </core_block_abstract_to_html_after>
110
+ <admin_system_config_changed_section_mocoauto>
111
+ <observers>
112
+ <mocoauto>
113
+ <class>mocoauto/observer</class>
114
+ <method>saveConfig</method>
115
+ </mocoauto>
116
+ </observers>
117
+ </admin_system_config_changed_section_mocoauto>
118
+ </events>
119
+ <menu>
120
+ <mocoauto translate="title" module="mocoauto">
121
+ <title>Mocoauto</title>
122
+ <sort_order>99999</sort_order>
123
+ <children>
124
+ <mocoauto_settings module="mocoauto">
125
+ <title>Settings</title>
126
+ <action>adminhtml/system_config/edit/section/mocoauto</action>
127
+ <sort_order>2</sort_order>
128
+ </mocoauto_settings>
129
+ </children>
130
+ </mocoauto>
131
+ </menu>
132
+ <acl>
133
+ <resources>
134
+ <admin>
135
+ <children>
136
+ <mocoauto>
137
+ <children>
138
+ <mocoauto_settings translate="title" module="mocoauto">
139
+ <title>Settings</title>
140
+ </mocoauto_settings>
141
+ </children>
142
+ </mocoauto>
143
+ <system>
144
+ <children>
145
+ <config>
146
+ <children>
147
+ <mocoauto translate="title" module="mocoauto">
148
+ <title>Mocoauto</title>
149
+ </mocoauto>
150
+ </children>
151
+ </config>
152
+ </children>
153
+ </system>
154
+ </children>
155
+ </admin>
156
+ </resources>
157
+ </acl>
158
+ </adminhtml>
159
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
- <version>1.3.8</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
@@ -11,7 +11,24 @@
11
  &#xD;
12
  &#xD;
13
  </description>
14
- <notes>1.3.8&#xD;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  &#xD;
16
  Changed table exists function&#xD;
17
  mocoauto_api_error - API errors prefix&#xD;
@@ -119,9 +136,9 @@ System date/time&#xD;
119
  added success true for succesful requests&#xD;
120
  changed product category to moco_category</notes>
121
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
122
- <date>2014-06-08</date>
123
- <time>23:45:31</time>
124
- <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="9e109182029f753ff7f0f5b07a640b09"/></dir><dir name="etc"><file name="config.xml" 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>
125
  <compatible/>
126
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
127
  </package>
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
  &#xD;
12
  &#xD;
13
  </description>
14
+ <notes>1.4.0&#xD;
15
+ &#xD;
16
+ Split stats action into&#xD;
17
+ stats and logstats&#xD;
18
+ &#xD;
19
+ Updated customersAction to return custom attributes.&#xD;
20
+ &#xD;
21
+ &#xD;
22
+ 1.3.9 &#xD;
23
+ &#xD;
24
+ Added eavinfo_catalogAction&#xD;
25
+ &#xD;
26
+ Products action now retuns full url of product images.&#xD;
27
+ &#xD;
28
+ testing new testcustomerAction&#xD;
29
+ &#xD;
30
+ &#xD;
31
+ 1.3.8&#xD;
32
  &#xD;
33
  Changed table exists function&#xD;
34
  mocoauto_api_error - API errors prefix&#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>