MocoInsight_Mocoauto - Version 1.3.3

Version Notes

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


Code changes from version 1.3.1 to 1.3.3

app/code/community/MocoInsight/Mocoauto/controllers/ApiController.php CHANGED
@@ -514,14 +514,9 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
514
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
515
  }
516
 
517
- // Grab an array of tax rates for lookup later
518
 
519
-
520
- $store = Mage::app()->getStore('default');
521
- $request = Mage::getSingleton('tax/calculation')->getRateRequest(null, null, null, $store);
522
-
523
- $products = array();
524
  $products[] = array('success' => 'true');
 
525
  foreach($_productCol as $_product){
526
 
527
  // get all the attributes of the product
@@ -533,6 +528,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
533
  $value = $attribute->getFrontend()->getValue($_product);
534
 
535
  switch ($attributeCode){
 
 
536
  case 'description':
537
  break;
538
  case 'short_description':
@@ -548,19 +545,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
548
  }
549
 
550
 
551
- // get the tax rate of the product
552
-
553
- $taxclassid = $_product->getData('tax_class_id');
554
- if(isset($taxClasses["value_".$taxclassid])){
555
- $taxpercent = $taxClasses["value_".$taxclassid];
556
- }
557
- else {
558
- $taxpercent = 'not defined';
559
- }
560
-
561
- $taxpercent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxclassid));
562
- $products[] = array('moco_TaxRate:' => $taxpercent);
563
-
564
  // get all the categories of the product
565
 
566
  $categories = $_product->getCategoryCollection()->addAttributeToSelect('name');
@@ -571,15 +555,27 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
571
 
572
  // if type is configurable get simple product children
573
 
574
-
575
-
576
  if($_product->getTypeID() == 'configurable'){
577
- $assocProductIDs = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
 
578
 
579
- foreach($assocProductIDs as $assocProduct){
580
  $products[] = array('childProductID' => $assocProduct->getID());
581
  }
582
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  // write end of record mark
584
  $products[] = array('moco_end_of_record' => 'True');
585
 
@@ -932,6 +928,51 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
932
 
933
  $carts = array();
934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
935
  foreach($_cartsCol as $_cart) {
936
  $carts[] = array('moco_start_of_cart_record' => 'True');
937
  $carts[] = $_cart->toArray();
@@ -1011,10 +1052,54 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1011
  $installinfo[] = array('Home URL' => Mage::getBaseDir());
1012
 
1013
 
 
 
 
 
 
 
 
 
1014
  $this->getResponse()
1015
  ->setBody(json_encode($installinfo))
1016
  ->setHttpResponseCode(200)
1017
  ->setHeader('Content-type', 'application/json', true);
1018
  return $this;
1019
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1020
  }
514
  $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
515
  }
516
 
 
517
 
 
 
 
 
 
518
  $products[] = array('success' => 'true');
519
+
520
  foreach($_productCol as $_product){
521
 
522
  // get all the attributes of the product
528
  $value = $attribute->getFrontend()->getValue($_product);
529
 
530
  switch ($attributeCode){
531
+ case 'in_depth':
532
+ break;
533
  case 'description':
534
  break;
535
  case 'short_description':
545
  }
546
 
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  // get all the categories of the product
549
 
550
  $categories = $_product->getCategoryCollection()->addAttributeToSelect('name');
555
 
556
  // if type is configurable get simple product children
557
 
 
 
558
  if($_product->getTypeID() == 'configurable'){
559
+ //$assocProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
560
+ $assocProducts = $_product->getTypeInstance()->getUsedProducts();
561
 
562
+ foreach($assocProducts as $assocProduct){
563
  $products[] = array('childProductID' => $assocProduct->getID());
564
  }
565
  }
566
+
567
+ // if type is grouped get associated product children
568
+
569
+ if($_product->getTypeID() == 'grouped'){
570
+
571
+ $groupedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
572
+
573
+ foreach($groupedProducts as $groupedProduct){
574
+ $products[] = array('ChildProductID' => $groupedProduct->getID());
575
+
576
+ }
577
+ }
578
+
579
  // write end of record mark
580
  $products[] = array('moco_end_of_record' => 'True');
581
 
928
 
929
  $carts = array();
930
 
931
+ foreach($_cartsCol as $_cart) {
932
+ try {
933
+ $carts[] = array('moco_start_of_cart_record' => 'True');
934
+ $carts[] = $_cart->toArray();
935
+ $_cartItemsCol = $_cart -> getItemsCollection();
936
+
937
+ foreach($_cartItemsCol as $_cartitem){
938
+ $carts[] = array('product_id' => $_cartitem->getProductId());
939
+ $carts[] = array('product_qty' => $_cartitem->getQty());
940
+ $carts[] = array('updated_at' => $_cartitem->getUpdatedAt());
941
+ }
942
+ $carts[] = array('moco_end_of_cart_record' => 'True');
943
+ }
944
+ catch(Exception $e) {
945
+ $carts[] = array('moco_unable_to_read_cart' => 'Mocoauto_error: ' . $e->getMessage());
946
+ }
947
+ }
948
+
949
+ $this->getResponse()
950
+ ->setBody(json_encode($carts))
951
+ ->setHttpResponseCode(200)
952
+ ->setHeader('Content-type', 'application/json', true);
953
+ return $this;
954
+ }
955
+ public function exunconvertedcartsAction()
956
+ {
957
+ if(!$this->_authorise()) {
958
+ return $this;
959
+ }
960
+
961
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
962
+
963
+ $offset = $this->getRequest()->getParam('offset', 0);
964
+ $page_size = $this->getRequest()->getParam('page_size', 20);
965
+ $since = $this->getRequest()->getParam('since', 'All');
966
+
967
+ $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
968
+ $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
969
+
970
+ if($since != 'All'){
971
+ $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
972
+ }
973
+
974
+ $carts = array();
975
+
976
  foreach($_cartsCol as $_cart) {
977
  $carts[] = array('moco_start_of_cart_record' => 'True');
978
  $carts[] = $_cart->toArray();
1052
  $installinfo[] = array('Home URL' => Mage::getBaseDir());
1053
 
1054
 
1055
+
1056
+ $calc = Mage::getSingleton('tax/calculation');
1057
+ $rates = $calc->getRatesForAllProductTaxClasses($calc->getRateRequest());
1058
+
1059
+ foreach ($rates as $class=>$rate) {
1060
+ $installinfo[] = array('Tax rate' => floatval($rate));
1061
+ }
1062
+
1063
  $this->getResponse()
1064
  ->setBody(json_encode($installinfo))
1065
  ->setHttpResponseCode(200)
1066
  ->setHeader('Content-type', 'application/json', true);
1067
  return $this;
1068
  }
1069
+
1070
+ public function rulesAction()
1071
+ {
1072
+ if(!$this->_authorise()) {
1073
+ return $this;
1074
+ }
1075
+
1076
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1077
+
1078
+ $offset = $this->getRequest()->getParam('offset', 0);
1079
+ $page_size = $this->getRequest()->getParam('page_size', 20);
1080
+ $since = $this->getRequest()->getParam('since', 'All');
1081
+
1082
+ $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
1083
+
1084
+
1085
+ foreach ($_rulesCol as $rule) {
1086
+ // print_r($rule->getData());
1087
+ $rulelist[] = array('moco_start_of_rule_record' => 'True');
1088
+ $rulelist[] = array('rule_id' => $rule->getRule_id());
1089
+ $rulelist[] = array('rule_name' => $rule->getName());
1090
+ $rulelist[] = array('rule_description' => $rule->getDescription());
1091
+ $rulelist[] = array('rule_from_date' => $rule->getFrom_date());
1092
+ $rulelist[] = array('rule_to_date' => $rule->getTo_date());
1093
+ $rulelist[] = array('rule_is_active' => $rule->getIsActive());
1094
+ $rulelist[] = array('rule_coupon_type' => $rule->getCoupon_type());
1095
+ $rulelist[] = array('moco_end_of_rule_record' => 'True');
1096
+ }
1097
+
1098
+ $this->getResponse()
1099
+ ->setBody(json_encode($rulelist))
1100
+ ->setHttpResponseCode(200)
1101
+ ->setHeader('Content-type', 'application/json', true);
1102
+ return $this;
1103
+ }
1104
+
1105
  }
app/code/community/MocoInsight/Mocoauto/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
- <version>1.3.1</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
+ <version>1.3.3</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.3.1</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
@@ -11,7 +11,20 @@
11
  &#xD;
12
  &#xD;
13
  </description>
14
- <notes>1.3.1&#xD;
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  &#xD;
16
  Added graceful exception handling for installations that have misconfigured product attributes&#xD;
17
  &#xD;
@@ -108,9 +121,9 @@ System date/time&#xD;
108
  added success true for succesful requests&#xD;
109
  changed product category to moco_category</notes>
110
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
111
- <date>2014-04-15</date>
112
- <time>23:44:14</time>
113
- <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="eeb7279a808b4e16241a7af9d22d0b97"/></dir><dir name="etc"><file name="config.xml" hash="d10f2e9f9459f6ed1e8fb5f62cf335c1"/><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>
114
  <compatible/>
115
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
116
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
+ <version>1.3.3</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.3.3&#xD;
15
+ &#xD;
16
+ Added rulesAction - for details on coupon and shopping carts rule.&#xD;
17
+ &#xD;
18
+ -------------------------------------------------------&#xD;
19
+ 1.3.2&#xD;
20
+ &#xD;
21
+ Exception handles for uncoverted carts.&#xD;
22
+ Changed catalogue tax rate processing.&#xD;
23
+ &#xD;
24
+ &#xD;
25
+ &#xD;
26
+ --------------------------------------------------------&#xD;
27
+ 1.3.1&#xD;
28
  &#xD;
29
  Added graceful exception handling for installations that have misconfigured product attributes&#xD;
30
  &#xD;
121
  added success true for succesful requests&#xD;
122
  changed product category to moco_category</notes>
123
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
124
+ <date>2014-05-06</date>
125
+ <time>05:50:08</time>
126
+ <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="6d7c9d5f428f28af4f098fe07e2cbae1"/></dir><dir name="etc"><file name="config.xml" hash="29bb45820deebb199ebac2ba34629c28"/><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>
127
  <compatible/>
128
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
129
  </package>