MocoInsight_Mocoauto - Version 1.5.2.9

Version Notes

1.5.2.9

customers:v1.0.0 - Add ship and bill address.
products:v1.0.0 - Add stock_backorders status

1.5.2.8

Non critical update to product support.

1.5.2.7

Gift card info for EE customers.
Additional stock info for products.
Slight speed improvement for all customers.

1.5.2.4

Non critical update to anytables added created query option.

1.5.2.4

Non critical update to anytables support.

1.5.2.2

Update to ordersAction - don't return shipping_label info as very large and not needed.

Also new Actions to support custom tables

1.5.2.0

Fix warning notice of Undefined variable: TEMANDO_FLAG. No change to functionality

1.5.1.9

Removed shipping label (data) from test_orders shippments.

1.5.1.8

test_orders promoted to live.
shipment and temando support now available

1.5.1.7

uncoverted_carts upgrade
test_orders shipment and temando support

1.5.1.6

Testing direct SQL test_unconvertedcarts for BNKR

1.5.1.5

Skipping carts with customer_id = 0 for BNKR

1.5.1.4

Fixed problem with empty unconvertedcarts

1.5.1.3

test_unconvertedcartsAction.

1.5.1.2

Avoid exception if unconvertedcarts product type
fails.

1.5.1.1

Check if Mage::getEdition(); exists before calling.

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


Code changes from version 1.5.2.8 to 1.5.2.9

app/code/community/MocoInsight/Mocoauto/controllers/ApiController.php CHANGED
@@ -38,7 +38,7 @@
38
  // list_modulesAction
39
  // giftcardsAction
40
 
41
- define("apiversion","1.5.2.8");
42
 
43
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
44
  {
@@ -700,6 +700,142 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
700
  return $this;
701
  }
702
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
703
 
704
 
705
  public function eavinfo_catalogAction()
@@ -797,6 +933,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
797
 
798
  public function customersAction()
799
  {
 
 
800
  if(!$this->_authorise()) {
801
  return $this;
802
  }
@@ -823,6 +961,9 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
823
  }
824
 
825
  $customers = array();
 
 
 
826
 
827
  foreach($_customerCol as $_customer) {
828
 
@@ -854,58 +995,36 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
854
  }
855
  }
856
 
857
- $taxClassId = $_customer->getTaxClassId();
858
- $taxClass = Mage::getModel('tax/class')->load($taxClassId);
859
- $customer['moco_customer_tax_class'] = $taxClass->getClassName();
860
-
861
-
862
- $customers[] = $customer;
863
- }
864
-
865
- $this->getResponse()
866
- ->setBody(json_encode($customers))
867
- ->setHttpResponseCode(200)
868
- ->setHeader('Content-type', 'application/json', true);
869
- return $this;
870
- }
871
-
872
- public function categoriesAction()
873
- {
874
- if(!$this->_authorise()) {
875
- return $this;
876
- }
877
-
878
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
879
-
880
- $offset = $this->getRequest()->getParam('offset', 0);
881
- $page_size = $this->getRequest()->getParam('page_size', 20);
882
- $since = $this->getRequest()->getParam('since', 'ALL');
883
-
884
- // Need to set store to admin so as to get all web site products.
885
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
886
-
887
- $_categoryCol = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*');
888
- $_categoryCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
889
 
890
- if($since != 'ALL'){
891
- $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
892
- }
 
 
 
893
 
894
- $categories = array();
 
 
 
 
 
895
 
896
- foreach($_categoryCol as $_category) {
897
- $categories[] = $_category->toArray();
898
  }
899
 
900
  $this->getResponse()
901
- ->setBody(json_encode($categories))
902
  ->setHttpResponseCode(200)
903
  ->setHeader('Content-type', 'application/json', true);
904
  return $this;
905
  }
906
 
907
 
908
- public function ex_productsAction()
909
  {
910
  if(!$this->_authorise()) {
911
  return $this;
@@ -918,127 +1037,103 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
918
  $since = $this->getRequest()->getParam('since', 'ALL');
919
  $gTE = $this->getRequest()->getParam('gte', 'ALL');
920
 
921
- $_productCol = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
922
 
923
- if($since != 'ALL'){
924
- $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
925
  }
926
 
927
  if($gTE != 'ALL'){
928
- $_productCol->addFieldToFilter('entity_id', array('gteq' =>$gTE));
929
- $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
930
  }
931
  else{
932
- $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
933
  }
934
 
935
- $products[] = array('success' => 'true');
936
-
937
 
938
- //Mage::log((string) $_productCol->getSelect());
939
 
940
- foreach($_productCol as $_product){
 
 
 
941
 
942
- // get all the custom attributes of the product
943
- $attributes = $_product->getAttributes();
944
-
945
- foreach ($attributes as $attribute) {
946
- $attributeCode = $attribute->getAttributeCode();
947
-
948
  switch ($attributeCode){
949
- case 'in_depth':
950
- break;
951
- case 'description':
952
- break;
953
- case 'short_description':
954
- break;
955
- case 'thumbnail':
956
  break;
957
- case 'small_image':
958
  break;
959
- case 'image':
960
  break;
 
 
 
 
961
  default:
962
  try {
963
- $value = $attribute->getFrontend()->getValue($_product);
964
- $products[] = array($attributeCode => $value);
965
  }
966
  catch (Exception $e) {
967
- $products[] = array('mocoauto_api_error' => 'product attribute ' . $attributeCode . ' ' . $e->getMessage());
968
  }
969
  break;
970
  }
971
- }
972
-
973
- // Get full url to product image
974
-
975
- try{
976
- $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'thumbnail');
977
- $products[] = array('thumbnail' => $full_path_url);
978
- $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'small_image');
979
- $products[] = array('small_image' => $full_path_url);
980
- $full_path_url = (string)Mage::helper('catalog/image')->init($_product, 'image');
981
- $products[] = array('image' => $full_path_url);
982
- }
983
- catch (Exception $e) {
984
- $products[] = array('mocoauto_api_error' => 'full path to image error:' . $e->getMessage());
985
  }
986
-
987
- // get all the categories of the product
988
-
989
- $categories = $_product->getCategoryCollection()->addAttributeToSelect('name');
990
-
991
- foreach ($categories as $category) {
992
- $products[] = array('moco_category' => $category->getID());
993
- }
994
-
995
- // get inventory information
996
 
997
- try{
998
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
999
-
1000
- $products[] = array('stock_managed' => $stock->getManageStock());
1001
- $products[] = array('stock_availability' => $stock->getIsInStock());
1002
- }
1003
- catch (Exception $e) {
1004
- $products[] = array('mocoauto_api_error' => 'moco_product_inventory: ' . $e->getMessage());
1005
- }
1006
 
1007
- // if type is configurable get simple product children
1008
 
1009
- if($_product->getTypeID() == 'configurable'){
1010
- //$assocProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
1011
- $assocProducts = $_product->getTypeInstance()->getUsedProducts();
1012
 
1013
- foreach($assocProducts as $assocProduct){
1014
- $products[] = array('childProductID' => $assocProduct->getID());
1015
- }
1016
- }
 
 
1017
 
1018
- // if type is grouped get associated product children
 
 
 
 
1019
 
1020
- if($_product->getTypeID() == 'grouped'){
1021
 
1022
- $groupedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
 
 
1023
 
1024
- foreach($groupedProducts as $groupedProduct){
1025
- $products[] = array('childProductID' => $groupedProduct->getID());
1026
 
1027
- }
1028
- }
 
 
 
 
1029
 
1030
- // write end of record mark
1031
- $products[] = array('moco_end_of_record' => 'True');
1032
 
 
 
1033
  }
1034
-
1035
  $this->getResponse()
1036
- ->setBody(json_encode(array('products' => $products)))
1037
  ->setHttpResponseCode(200)
1038
  ->setHeader('Content-type', 'application/json', true);
1039
  return $this;
1040
  }
1041
 
 
1042
  public function product_idsAction()
1043
  {
1044
  if(!$this->_authorise()) {
@@ -1061,7 +1156,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1061
  }
1062
 
1063
 
1064
- public function productsAction()
1065
  {
1066
  if(!$this->_authorise()) {
1067
  return $this;
@@ -1200,11 +1295,10 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1200
  return $this;
1201
  }
1202
 
1203
- public function test_productsAction()
1204
  {
1205
  $MocoApiEpVer = '1.0.0'; // First version with version returned.
1206
 
1207
- $time_start = microtime(true);
1208
 
1209
  if(!$this->_authorise()) {
1210
  return $this;
@@ -1234,10 +1328,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1234
  $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1235
  }
1236
 
1237
- $products_output = array();
1238
  $products = array();
1239
- $products_output[] = array('mocoauto_api_end_point_version' => $MocoApiEpVer);
1240
-
1241
 
1242
  //Mage::log((string) $_productCol->getSelect());
1243
 
@@ -1327,7 +1418,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1327
  foreach($assocProducts as $assocProduct){
1328
  $childProducts[] = $assocProduct->getID();
1329
  }
1330
- $product['moco_childProductIDs'] = $childProducts;
1331
  }
1332
 
1333
  // if type is grouped get associated product children
@@ -1339,7 +1430,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1339
  foreach($groupedProducts as $groupedProduct){
1340
  $childProducts[] = $groupedProduct->getID();
1341
  }
1342
- $product['moco_childProductIDs'] = $childProducts;
1343
  }
1344
 
1345
  $product['moco_end_of_record'] = 'True';
@@ -1347,10 +1438,9 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1347
 
1348
  }
1349
 
1350
- $products_output[] = array('moco_API_processing_time' => (microtime(true) - $time_start));
1351
- $products_output[] = $products;
1352
  $this->getResponse()
1353
- ->setBody(json_encode($products_output))
1354
  ->setHttpResponseCode(200)
1355
  ->setHeader('Content-type', 'application/json', true);
1356
  return $this;
38
  // list_modulesAction
39
  // giftcardsAction
40
 
41
+ define("apiversion","1.5.2.9");
42
 
43
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
44
  {
700
  return $this;
701
  }
702
 
703
+ // ordersAction - return all information on a order
704
+ // 1.5.1.9 - only request specified shippment attributes as shipping label can get very big and we don't need it or much else.
705
+ // 1.5.2.0 - request all shipment info execpet label as there are many diffrent shipping plugins.
706
+ //
707
+ public function test_ordersAction()
708
+ {
709
+ //$MocoApiEpVer = '1.0.0'; // First version with version returned. limit to 512 bytes
710
+ $MocoApiEpVer = '1.0.1'; //Return product options.
711
+ if(!$this->_authorise()) {
712
+ return $this;
713
+ }
714
+
715
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
716
+
717
+ $offset = $this->getRequest()->getParam('offset', 0);
718
+ $page_size = $this->getRequest()->getParam('page_size', 20);
719
+ $since = $this->getRequest()->getParam('since','ALL');
720
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
721
+
722
+ $_orderCol = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('*');
723
+
724
+
725
+ if($since != 'ALL'){
726
+ $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
727
+ }
728
+
729
+ if($gTE != 'ALL'){
730
+ $_orderCol->addFieldToFilter('entity_id', array('gteq' =>$gTE));
731
+ $_orderCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
732
+ }
733
+ else{
734
+ $_orderCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
735
+ }
736
+
737
+ //Mage::log('SQL Query: '.$_orderCol->getSelect());
738
+
739
+ // Check if the Termnado tables exsists set flag so we read shipments later on.
740
+ $tablename = 'temando_shipment';
741
+ $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
742
+
743
+ if($_read ->isTableExists($tablename)){ //Table does exist
744
+ $TEMANDO_FLAG='TRUE';
745
+ }
746
+ else{
747
+ $TEMANDO_FLAG='FALSE';
748
+ }
749
+
750
+ $orders = array();
751
+ $orders[] = array('mocoauto_api_end_point_version' => $MocoApiEpVer);
752
+ foreach($_orderCol as $_order) {
753
+
754
+ $order = array();
755
+
756
+ try{
757
+ $order['moco_start_of_order_record'] = 'True';
758
+ $orderdetails = array();
759
+ $orderdetails = $_order->toArray();
760
+ foreach ($orderdetails as $key => $value) {
761
+ $order[$key] = $value;
762
+ }
763
+ if(is_object($_order->getPayment()) && method_exists($_order->getPayment()->getMethodInstance(), 'getTitle')){
764
+ $order['payment_method'] = $_order->getPayment()->getMethodInstance()->getTitle();
765
+ }
766
+ else{
767
+ $order['payment_method'] = 'Unable to get payment_method';
768
+ }
769
+
770
+ if(is_object($_order->getBillingAddress())){
771
+ $_billing_address = $_order->getBillingAddress();
772
+ $billaddrdetails = array();
773
+ $billaddrdetails[] = $_billing_address->toArray();
774
+ $order['moco_address'] = $billaddrdetails;
775
+ }
776
+
777
+ if(is_object($_order->getShippingAddress())){
778
+
779
+ $_shipping_address = $_order->getShippingAddress();
780
+ $shipaddrdetails = array();
781
+ $shipaddrdetails[] = $_shipping_address->toArray();
782
+ $order['moco_ship_address'] = $shipaddrdetails;
783
+ }
784
+
785
+ if(is_object($_order->getShipmentsCollection())){ // check obj exists
786
+ $_orderShipmentsCol = $_order->getShipmentsCollection(); // get collection of shipment objects
787
+ $ordershipments = array();
788
+ foreach($_orderShipmentsCol as $_ordershipment){ // collection of shipment objects
789
+ $shipmentdetails = array();
790
+ $shipmentdetails = $_ordershipment->toArray(); // dump shipment object values to array
791
+ $ordershipment = array();
792
+ foreach($shipmentdetails as $key => $value){ // iterate values array
793
+ //Mage::log('$key = ' . $key . ' $value = '. $value);
794
+ if(strlen($value) < 512){ // if the value is less than 512 it is OK write to output array
795
+ $ordershipment[$key] = $value;
796
+ }
797
+ }
798
+ $ordershipments[] = $ordershipment; // write 1 shippment detail to array with all shipments
799
+ }
800
+ $order['moco_shipments'] = $ordershipments; // write all shipments to main output array.
801
+ }
802
+
803
+ // If the Temanado flag is set then get any shipping records that match the order number.
804
+ if($TEMANDO_FLAG == 'TRUE'){ //Table does exist
805
+ $temandodata = array();
806
+ $query = 'select id, order_id, anticipated_cost, ready_date, ready_time from ' . $tablename . ' where order_id = "' . $_order->getEntityId() . '"';
807
+ //Mage::log('DBG SQL: '. $query);
808
+ $readresults = $_read->fetchAll($query);
809
+ $temandodata = $readresults;
810
+ $order['moco_temandodata'] = $temandodata;
811
+ }
812
+
813
+
814
+ $_orderItemsCol = $_order->getItemsCollection();
815
+ $orderitems = array();
816
+ foreach($_orderItemsCol as $_orderitem){
817
+ $orderitems[] = $_orderitem->toArray();
818
+ $orderitems[] = $_orderitem->getProductOptions();
819
+ }
820
+ $order['moco_tls'] = $orderitems;
821
+
822
+
823
+ $order['moco_end_of_order_record'] = 'True';
824
+ }
825
+ catch (Exception $e) {
826
+ $order['mocoauto_api_error'] = 'order record: ' . $e->getMessage();
827
+ }
828
+ $orders[] = $order;
829
+
830
+ }
831
+
832
+ $this->getResponse()
833
+ ->setBody(json_encode($orders))
834
+ ->setHttpResponseCode(200)
835
+ ->setHeader('Content-type', 'application/json', true);
836
+ return $this;
837
+ }
838
+
839
 
840
 
841
  public function eavinfo_catalogAction()
933
 
934
  public function customersAction()
935
  {
936
+ $MocoApiEpVer = '1.0.0'; // Include customer default billing and delivery address.
937
+
938
  if(!$this->_authorise()) {
939
  return $this;
940
  }
961
  }
962
 
963
  $customers = array();
964
+ $customers[] = array('mocoauto_api_end_point_version' => $MocoApiEpVer);
965
+
966
+
967
 
968
  foreach($_customerCol as $_customer) {
969
 
995
  }
996
  }
997
 
998
+ $taxClassId = $_customer->getTaxClassId();
999
+ $taxClass = Mage::getModel('tax/class')->load($taxClassId);
1000
+ $customer['moco_customer_tax_class'] = $taxClass->getClassName();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1001
 
1002
+ if(is_object($_customer->getPrimaryBillingAddress())){
1003
+ $_billing_address = $_customer->getPrimaryBillingAddress();
1004
+ $billaddrdetails = array();
1005
+ $billaddrdetails[] = $_billing_address->toArray();
1006
+ $customer['moco_bill_address'] = $billaddrdetails;
1007
+ }
1008
 
1009
+ if(is_object($_customer->getPrimaryShippingAddress())){
1010
+ $_shipping_address = $_customer->getPrimaryShippingAddress();
1011
+ $shipaddrdetails = array();
1012
+ $shipaddrdetails[] = $_shipping_address->toArray();
1013
+ $customer['moco_ship_address'] = $shipaddrdetails;
1014
+ }
1015
 
1016
+ $customers[] = $customer;
 
1017
  }
1018
 
1019
  $this->getResponse()
1020
+ ->setBody(json_encode($customers))
1021
  ->setHttpResponseCode(200)
1022
  ->setHeader('Content-type', 'application/json', true);
1023
  return $this;
1024
  }
1025
 
1026
 
1027
+ public function ex_customersAction()
1028
  {
1029
  if(!$this->_authorise()) {
1030
  return $this;
1037
  $since = $this->getRequest()->getParam('since', 'ALL');
1038
  $gTE = $this->getRequest()->getParam('gte', 'ALL');
1039
 
1040
+ $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
1041
 
1042
+ if($since != 'ALL'){
1043
+ $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
1044
  }
1045
 
1046
  if($gTE != 'ALL'){
1047
+ $_customerCol->addFieldToFilter('entity_id', array('gteq' =>$gTE));
1048
+ $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
1049
  }
1050
  else{
1051
+ $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1052
  }
1053
 
1054
+ $customers = array();
 
1055
 
1056
+ foreach($_customerCol as $_customer) {
1057
 
1058
+ $attributes = $_customer->getAttributes();
1059
+ $customer = array();
1060
+ foreach ($attributes as $attribute) {
1061
+ $attributeCode = $attribute->getAttributeCode();
1062
 
 
 
 
 
 
 
1063
  switch ($attributeCode){
1064
+ case 'password_hash':
 
 
 
 
 
 
1065
  break;
1066
+ case 'rp_token':
1067
  break;
1068
+ case 'rp_token_created_at':
1069
  break;
1070
+ case 'store_id':
1071
+ $value = $_customer->getData($attributeCode);
1072
+ $customer[$attributeCode] = $value;
1073
+ break;
1074
  default:
1075
  try {
1076
+ $value = $attribute->getFrontend()->getValue($_customer);
1077
+ $customer[$attributeCode] = $value;
1078
  }
1079
  catch (Exception $e) {
1080
+ $customer['mocoauto_api_error'] = 'customer attribute: ' . $attributeCode . ' - ' . $e->getMessage();
1081
  }
1082
  break;
1083
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1084
  }
 
 
 
 
 
 
 
 
 
 
1085
 
1086
+ $taxClassId = $_customer->getTaxClassId();
1087
+ $taxClass = Mage::getModel('tax/class')->load($taxClassId);
1088
+ $customer['moco_customer_tax_class'] = $taxClass->getClassName();
 
 
 
 
 
 
1089
 
 
1090
 
1091
+ $customers[] = $customer;
1092
+ }
 
1093
 
1094
+ $this->getResponse()
1095
+ ->setBody(json_encode($customers))
1096
+ ->setHttpResponseCode(200)
1097
+ ->setHeader('Content-type', 'application/json', true);
1098
+ return $this;
1099
+ }
1100
 
1101
+ public function categoriesAction()
1102
+ {
1103
+ if(!$this->_authorise()) {
1104
+ return $this;
1105
+ }
1106
 
1107
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1108
 
1109
+ $offset = $this->getRequest()->getParam('offset', 0);
1110
+ $page_size = $this->getRequest()->getParam('page_size', 20);
1111
+ $since = $this->getRequest()->getParam('since', 'ALL');
1112
 
1113
+ // Need to set store to admin so as to get all web site products.
1114
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
1115
 
1116
+ $_categoryCol = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*');
1117
+ $_categoryCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1118
+
1119
+ if($since != 'ALL'){
1120
+ $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
1121
+ }
1122
 
1123
+ $categories = array();
 
1124
 
1125
+ foreach($_categoryCol as $_category) {
1126
+ $categories[] = $_category->toArray();
1127
  }
1128
+
1129
  $this->getResponse()
1130
+ ->setBody(json_encode($categories))
1131
  ->setHttpResponseCode(200)
1132
  ->setHeader('Content-type', 'application/json', true);
1133
  return $this;
1134
  }
1135
 
1136
+
1137
  public function product_idsAction()
1138
  {
1139
  if(!$this->_authorise()) {
1156
  }
1157
 
1158
 
1159
+ public function ex_productsAction()
1160
  {
1161
  if(!$this->_authorise()) {
1162
  return $this;
1295
  return $this;
1296
  }
1297
 
1298
+ public function productsAction()
1299
  {
1300
  $MocoApiEpVer = '1.0.0'; // First version with version returned.
1301
 
 
1302
 
1303
  if(!$this->_authorise()) {
1304
  return $this;
1328
  $_productCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1329
  }
1330
 
 
1331
  $products = array();
 
 
1332
 
1333
  //Mage::log((string) $_productCol->getSelect());
1334
 
1418
  foreach($assocProducts as $assocProduct){
1419
  $childProducts[] = $assocProduct->getID();
1420
  }
1421
+ $product['moco_children'] = $childProducts;
1422
  }
1423
 
1424
  // if type is grouped get associated product children
1430
  foreach($groupedProducts as $groupedProduct){
1431
  $childProducts[] = $groupedProduct->getID();
1432
  }
1433
+ $product['moco_children'] = $childProducts;
1434
  }
1435
 
1436
  $product['moco_end_of_record'] = 'True';
1438
 
1439
  }
1440
 
1441
+
 
1442
  $this->getResponse()
1443
+ ->setBody(json_encode(array('mocoauto_api_end_point_version' => $MocoApiEpVer, 'products' => $products)))
1444
  ->setHttpResponseCode(200)
1445
  ->setHeader('Content-type', 'application/json', true);
1446
  return $this;
app/code/community/MocoInsight/Mocoauto/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
- <version>1.5.2.8</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
+ <version>1.5.2.9</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.2.8</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
@@ -11,7 +11,13 @@
11
  &#xD;
12
  &#xD;
13
  </description>
14
- <notes>1.5.2.8&#xD;
 
 
 
 
 
 
15
  &#xD;
16
  Non critical update to product support.&#xD;
17
  &#xD;
@@ -279,9 +285,9 @@ System date/time&#xD;
279
  added success true for succesful requests&#xD;
280
  changed product category to moco_category</notes>
281
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
282
- <date>2015-10-15</date>
283
- <time>06:05:08</time>
284
- <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="7f0dfb5c171b696906880b8fc0ef4b8e"/></dir><dir name="etc"><file name="config.xml" hash="9ac2978d9c8f94f33df455b244bed162"/><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>
285
  <compatible/>
286
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
287
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
+ <version>1.5.2.9</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.2.9&#xD;
15
+ &#xD;
16
+ customers:v1.0.0 - Add ship and bill address.&#xD;
17
+ products:v1.0.0 - Add stock_backorders status&#xD;
18
+ &#xD;
19
+ &#xD;
20
+ 1.5.2.8&#xD;
21
  &#xD;
22
  Non critical update to product support.&#xD;
23
  &#xD;
285
  added success true for succesful requests&#xD;
286
  changed product category to moco_category</notes>
287
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
288
+ <date>2016-02-04</date>
289
+ <time>08:01:41</time>
290
+ <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="151859384368d63aebf6835777a10990"/></dir><dir name="etc"><file name="config.xml" hash="d3c7311ff55201b5e06b0b47c8b255b9"/><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>
291
  <compatible/>
292
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
293
  </package>