MocoInsight_Mocoauto - Version 1.5.2.2

Version Notes

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


Code changes from version 1.5.2.0 to 1.5.2.2

app/code/community/MocoInsight/Mocoauto/controllers/ApiController.php CHANGED
@@ -29,11 +29,15 @@
29
  // product_idsAction
30
  // creditsAction
31
  // credit_idsAction
 
 
32
  // sql_sales_flat_quoteAction()
33
  // sql_anytableAction()
 
 
 
34
 
35
-
36
- define("apiversion","1.5.2.0");
37
 
38
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
39
  {
@@ -84,101 +88,14 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
84
  }
85
 
86
 
87
- public function ex_statsAction()
88
- {
89
- if(!$this->_authorise()) {
90
- return $this;
91
- }
92
-
93
- $time_start = microtime(true);
94
-
95
- $currentSystemTime = date('Y-m-d H:i:s', time());
96
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
97
- $since = $this->getRequest()->getParam('since','ALL');
98
-
99
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // set to admin view all sites and stores
100
-
101
- $_productCol = Mage::getModel('catalog/product')->getCollection();
102
- if($since != 'ALL'){
103
- $_productCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
104
- }
105
- $productcount = $_productCol->getSize();
106
-
107
- $_orderCol = Mage::getModel('sales/order')->getCollection();
108
- if($since != 'ALL'){
109
- $_orderCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
110
- }
111
- $ordercount = $_orderCol->getSize();
112
-
113
- $_customerCol = Mage::getModel('customer/customer')->getCollection();
114
- if($since != 'ALL'){
115
- $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
116
- }
117
- $customercount = $_customerCol->getSize();
118
-
119
-
120
- $_categoryCol = Mage::getModel('catalog/category')->getCollection();
121
- if($since != 'ALL'){
122
- $_categoryCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
123
- }
124
- $categorycount = $_categoryCol->getSize();
125
-
126
- $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
127
- if($since != 'ALL'){
128
- $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
129
- }
130
- $wishlistcount = $_wishlistCol->getSize();
131
-
132
- $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1');
133
- if($since != 'ALL'){
134
- $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since));
135
- }
136
- else{
137
- $_cartsCol->addFieldToFilter('items_count', array('neq' => 0));
138
- }
139
-
140
- $cartscount = $_cartsCol->getSize();
141
-
142
- $_subscriberCol = Mage::getModel('newsletter/subscriber')-> getCollection();
143
-
144
- $subscribercount = $_subscriberCol->getSize();
145
-
146
- $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
147
-
148
- $rulescount = $_rulesCol->getSize();
149
-
150
-
151
- $magentoVersion = Mage::getVersion();
152
- $moduleversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
153
- $phpversion = phpversion();
154
-
155
- $stats = array(
156
- 'success' => 'true',
157
- 'Since' => $since,
158
- 'Products' => $productcount,
159
- 'Orders' => $ordercount,
160
- 'Customers' => $customercount,
161
- 'Categories' => $categorycount,
162
- 'Wish lists' => $wishlistcount,
163
- 'Unconverted carts' => $cartscount,
164
- 'Subscribers' => $subscribercount,
165
- 'Cart and Coupon rules' => $rulescount,
166
- 'System Date Time' => $currentSystemTime,
167
- 'Magento Version' => $magentoVersion,
168
- 'MocoAPI Version' => apiversion,
169
- 'Module Version' => $moduleversion,
170
- 'PHP Version' => $phpversion,
171
- 'API processing time' => (microtime(true) - $time_start)
172
- );
173
-
174
- $this->getResponse()
175
- ->setBody(json_encode($stats))
176
- ->setHttpResponseCode(200)
177
- ->setHeader('Content-type', 'application/json', true);
178
- return $this;
179
- }
180
 
181
- public function statsAction() // test adding edition info
 
 
 
 
 
 
182
  {
183
  if(!$this->_authorise()) {
184
  return $this;
@@ -245,6 +162,12 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
245
  }
246
  $creditcount = $_creditCol->getSize();
247
 
 
 
 
 
 
 
248
 
249
  $magentoVersion = Mage::getVersion();
250
  $moduleversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
@@ -269,6 +192,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
269
  'Subscribers' => $subscribercount,
270
  'Cart and Coupon rules' => $rulescount,
271
  'Credit memos' => $creditcount,
 
272
  'System Date Time' => $currentSystemTime,
273
  'Magento Version' => $magentoVersion,
274
  'Magento Edition' => $magentoedition,
@@ -284,7 +208,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
284
  ->setHeader('Content-type', 'application/json', true);
285
  return $this;
286
  }
287
-
288
  public function logstatsAction() // Return the number size of logs
289
  {
290
  if(!$this->_authorise()) {
@@ -689,6 +612,7 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
689
  }
690
  // ordersAction - return all information on a order
691
  // 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.
 
692
  //
693
  public function test_ordersAction()
694
  {
@@ -763,23 +687,25 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
763
  $order['moco_ship_address'] = $shipaddrdetails;
764
  }
765
 
766
-
767
- if(is_object($_order->getShipmentsCollection())){
768
- $_orderShipmentsCol = $_order->getShipmentsCollection();
769
  $ordershipments = array();
770
- foreach($_orderShipmentsCol as $_ordershipment){
771
- $ordershipments['entity_id'] = $_ordershipment->getEntityId();
772
- $ordershipments['order_id'] = $_ordershipment->getOrderId();
773
- $ordershipments['store_id'] = $_ordershipment->getStoreId();
774
- $ordershipments['increment_id'] = $_ordershipment->getIncrementId();
775
- $ordershipments['created_at'] = $_ordershipment->getCreatedAt();
776
- $ordershipments['updated_at'] = $_ordershipment->getUpdatedAt();
 
 
 
 
777
  }
778
- $order['moco_shipments'] = $ordershipments;
779
  }
780
-
781
 
782
- // If the Temanado flag is set then get any shippiong records that match the order number.
783
  if($TEMANDO_FLAG == 'TRUE'){ //Table does exist
784
  $temandodata = array();
785
  $query = 'select id, order_id, anticipated_cost, ready_date, ready_time from ' . $tablename . ' where order_id = "' . $_order->getEntityId() . '"';
@@ -983,40 +909,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
983
  return $this;
984
  }
985
 
986
-
987
-
988
- public function excustomersAction()
989
- {
990
- if(!$this->_authorise()) {
991
- return $this;
992
- }
993
-
994
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
995
-
996
- $offset = $this->getRequest()->getParam('offset', 0);
997
- $page_size = $this->getRequest()->getParam('page_size', 20);
998
- $since = $this->getRequest()->getParam('since', 'ALL');
999
-
1000
- $_customerCol = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
1001
- $_customerCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1002
-
1003
- if($since != 'ALL'){
1004
- $_customerCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
1005
- }
1006
-
1007
- $customers = array();
1008
-
1009
- foreach($_customerCol as $_customer) {
1010
- $customers[] = $_customer->toArray();
1011
- }
1012
-
1013
- $this->getResponse()
1014
- ->setBody(json_encode($customers))
1015
- ->setHttpResponseCode(200)
1016
- ->setHeader('Content-type', 'application/json', true);
1017
- return $this;
1018
- }
1019
-
1020
  public function categoriesAction()
1021
  {
1022
  if(!$this->_authorise()) {
@@ -1607,6 +1499,69 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1607
  return $this;
1608
  }
1609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1610
  public function old_sql_sales_flat_quoteAction()
1611
  {
1612
  $tablename1 = 'sales_flat_quote';
@@ -1845,7 +1800,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1845
  return $this;
1846
  }
1847
 
1848
- public function ex01_unconvertedcartsAction()
 
1849
  {
1850
  if(!$this->_authorise()) {
1851
  return $this;
@@ -1858,15 +1814,15 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1858
  $since = $this->getRequest()->getParam('since', 'ALL');
1859
  $gTE = $this->getRequest()->getParam('gte', 'ALL');
1860
 
 
 
1861
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1'); // 1 = quote has not been conveted to an order
1862
 
1863
  $magentoVersion = Mage::getVersion();
1864
  if (version_compare($magentoVersion, '1.7', '>=')){
1865
- //Mage::log("Version is above check");
1866
- $aboveVersion17Flag = 1;
1867
- }
1868
  else {
1869
- //Mage::log("Version is below check");
1870
  $aboveVersion17Flag = 0;
1871
  }
1872
 
@@ -1877,25 +1833,27 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1877
  'customer_email', //attribute_2 with key 1
1878
  ),
1879
  array(
1880
- array('notnull'=>1), // This form creates a NOT NULL query.
1881
  array('notnull'=>1),
1882
  )
1883
  );
1884
  }
1885
 
1886
- $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1887
-
1888
  if($since != 'ALL'){
1889
- $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since)); // If no date filter include empty carts
1890
  }
1891
  else{
1892
- $_cartsCol->addFieldToFilter('items_count', array('neq' => 0)); // If date filter supplied only include carts with items
1893
  }
1894
 
1895
  // If using gte we want to sort by entity id
1896
-
1897
  if($gTE != 'ALL'){
1898
  $_cartsCol->addFieldToFilter('entity_id', array('gteq' =>$gTE)); // If gte set include records GTE gte
 
 
 
 
1899
  }
1900
 
1901
  //Mage::log((string) $_cartsCol->getSelect());
@@ -1941,13 +1899,14 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1941
  $cartitem['base_cost'] = $_cartitem->getBaseCost();
1942
  $cartitem['base_price_incl_tax'] = $_cartitem->getBasePriceInclTax();
1943
  }
 
1944
  catch(Exception $e) {
1945
  $cartitem['mocoauto_api_error'] = 'moco_unable_to_read_cartitem: ' . $e->getMessage();
1946
  }
1947
 
1948
  $cartitems[] = $cartitem;
1949
  }
1950
-
1951
  $cart['moco_cart_items'] = $cartitems;
1952
  }
1953
 
@@ -1969,7 +1928,8 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1969
  return $this;
1970
  }
1971
 
1972
- public function ex_unconvertedcartsAction()
 
1973
  {
1974
  if(!$this->_authorise()) {
1975
  return $this;
@@ -1982,120 +1942,54 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
1982
  $since = $this->getRequest()->getParam('since', 'ALL');
1983
  $gTE = $this->getRequest()->getParam('gte', 'ALL');
1984
 
1985
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // set to admin view all sites and stores
1986
-
1987
- $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1'); // 1 = quote has not been conveted to an order
1988
-
1989
- $magentoVersion = Mage::getVersion();
1990
- if (version_compare($magentoVersion, '1.7', '>=')){
1991
- $aboveVersion17Flag = 1;
1992
- }
1993
- else {
1994
- $aboveVersion17Flag = 0;
1995
- }
1996
-
1997
- if($aboveVersion17Flag){ // This will only work with Magento > 1.6
1998
- $_cartsCol->addFieldToFilter( // If there is no email or customer id we dont want the cart.
1999
- array(
2000
- 'customer_id', //attribute_1 with key 0
2001
- 'customer_email', //attribute_2 with key 1
2002
- ),
2003
- array(
2004
- array('notnull'=>1), // This form creates a NOT NULL query.
2005
- array('notnull'=>1),
2006
- )
2007
- );
2008
- }
2009
 
2010
  if($since != 'ALL'){
2011
- $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since)); // If date filter supplied include empty carts
2012
- }
2013
- else{
2014
- $_cartsCol->addFieldToFilter('items_count', array('neq' => 0)); // If no date filter supplied (ALL) only include carts with items
2015
  }
2016
 
2017
- // If using gte we want to sort by entity id
2018
-
2019
  if($gTE != 'ALL'){
2020
- $_cartsCol->addFieldToFilter('entity_id', array('gteq' =>$gTE)); // If gte set include records GTE gte
2021
- $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
2022
  }
2023
  else{
2024
- $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2025
  }
2026
 
2027
- //Mage::log((string) $_cartsCol->getSelect());
2028
-
2029
- $carts = array();
2030
-
2031
-
2032
- foreach($_cartsCol as $_cart) {
2033
- $cart = array();
2034
 
2035
- try {
2036
- $cart['moco_start_of_cart_record'] = 'True';
2037
- $cartdetails = array();
2038
-
2039
- if(!$aboveVersion17Flag && !$_cart->getCustomerId() && !$_cart->getCustomerEmail()){
2040
- //Mage::log($_cart->getEntityId() . " " . $_cart->getCustomerEmail() . " " . $_cart->getCustomerId());
2041
- $cart['moco_no_cart_identification_information'] = 'True';
2042
- }
2043
- else{
2044
- $cartdetails = $_cart->toArray();
2045
-
2046
- foreach ($cartdetails as $key =>$value){
2047
- $cart[$key] = $value;
2048
- }
2049
-
2050
- $_cartItemsCol = $_cart -> getItemsCollection();
2051
- $cartitems = array();
2052
-
2053
- foreach($_cartItemsCol as $_cartitem){
2054
- $cartitem = array();
2055
- try{
2056
- $cartitem['item_id'] = $_cartitem->getItemId();
2057
- $cartitem['parent_id'] = $_cartitem->getParentId();
2058
- $cartitem['product_id'] = $_cartitem->getProductId();
2059
- $cartitem['product_sku'] = $_cartitem->getSku();
2060
- $cartitem['product_qty'] = $_cartitem->getQty();
2061
- $cartitem['updated_at'] = $_cartitem->getUpdatedAt();
2062
- $cartitem['product_name'] = $_cartitem->getName();
2063
- $cartitem['product_type'] = $_cartitem->getProductType();
2064
- $cartitem['base_price'] = $_cartitem->getBasePrice();
2065
- $cartitem['base_tax_amount'] = $_cartitem->getBaseTaxAmount();
2066
- $cartitem['base_discount_amount'] = $_cartitem->getBaseDiscountAmount();
2067
- $cartitem['base_cost'] = $_cartitem->getBaseCost();
2068
- $cartitem['base_price_incl_tax'] = $_cartitem->getBasePriceInclTax();
2069
- }
2070
- catch(Exception $e) {
2071
- $cartitem['mocoauto_api_error'] = 'moco_unable_to_read_cartitem: ' . $e->getMessage();
2072
- }
2073
-
2074
- $cartitems[] = $cartitem;
2075
- }
2076
-
2077
- $cart['moco_cart_items'] = $cartitems;
2078
- }
2079
-
2080
- $cart['moco_end_of_cart_record'] = 'True';
2081
 
2082
- }
2083
- catch(Exception $e) {
2084
- $cart['mocoauto_api_error'] = 'moco_unable_to_read_cart: ' . $e->getMessage();
 
 
 
 
 
2085
  }
2086
 
2087
- $carts[] = $cart;
2088
-
 
2089
  }
2090
 
2091
  $this->getResponse()
2092
- ->setBody(json_encode($carts))
2093
  ->setHttpResponseCode(200)
2094
  ->setHeader('Content-type', 'application/json', true);
2095
  return $this;
2096
  }
2097
 
2098
- public function unconvertedcartsAction()
2099
  {
2100
  if(!$this->_authorise()) {
2101
  return $this;
@@ -2103,127 +1997,32 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2103
 
2104
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
2105
 
2106
- $offset = $this->getRequest()->getParam('offset', 0);
2107
- $page_size = $this->getRequest()->getParam('page_size', 20);
2108
- $since = $this->getRequest()->getParam('since', 'ALL');
2109
- $gTE = $this->getRequest()->getParam('gte', 'ALL');
2110
-
2111
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // set to admin view all sites and stores
2112
-
2113
- $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1'); // 1 = quote has not been conveted to an order
2114
-
2115
- $magentoVersion = Mage::getVersion();
2116
- if (version_compare($magentoVersion, '1.7', '>=')){
2117
- $aboveVersion17Flag = 1;
2118
- }
2119
- else {
2120
- $aboveVersion17Flag = 0;
2121
- }
2122
-
2123
- if($aboveVersion17Flag){ // This will only work with Magento > 1.6
2124
- $_cartsCol->addFieldToFilter( // If there is no email or customer id we dont want the cart.
2125
- array(
2126
- 'customer_id', //attribute_1 with key 0
2127
- 'customer_email', //attribute_2 with key 1
2128
- ),
2129
- array(
2130
- array('gteq'=> 1), // This form creates a NOT NULL query.
2131
- array('notnull'=>1),
2132
- )
2133
- );
2134
- }
2135
-
2136
- if($since != 'ALL'){
2137
- $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since)); // If date filter supplied include empty carts
2138
- }
2139
- else{
2140
- $_cartsCol->addFieldToFilter('items_count', array('neq' => 0)); // If no date filter supplied (ALL) only include carts with items
2141
- }
2142
-
2143
- // If using gte we want to sort by entity id
2144
-
2145
- if($gTE != 'ALL'){
2146
- $_cartsCol->addFieldToFilter('entity_id', array('gteq' =>$gTE)); // If gte set include records GTE gte
2147
- $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
2148
- }
2149
- else{
2150
- $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2151
- }
2152
-
2153
- //Mage::log((string) $_cartsCol->getSelect());
2154
-
2155
- $carts = array();
2156
-
2157
-
2158
- foreach($_cartsCol as $_cart) {
2159
- $cart = array();
2160
-
2161
- try {
2162
- $cart['moco_start_of_cart_record'] = 'True';
2163
- $cartdetails = array();
2164
-
2165
- if(!$aboveVersion17Flag && !$_cart->getCustomerId() && !$_cart->getCustomerEmail()){
2166
- //Mage::log($_cart->getEntityId() . " " . $_cart->getCustomerEmail() . " " . $_cart->getCustomerId());
2167
- $cart['moco_no_cart_identification_information'] = 'True';
2168
- }
2169
- else{
2170
- $cartdetails = $_cart->toArray();
2171
-
2172
- foreach ($cartdetails as $key =>$value){
2173
- $cart[$key] = $value;
2174
- }
2175
-
2176
- $_cartItemsCol = $_cart -> getItemsCollection();
2177
- $cartitems = array();
2178
-
2179
- foreach($_cartItemsCol as $_cartitem){
2180
- $cartitem = array();
2181
- try{
2182
- $cartitem['item_id'] = $_cartitem->getItemId();
2183
- $cartitem['parent_id'] = $_cartitem->getParentId();
2184
- $cartitem['product_id'] = $_cartitem->getProductId();
2185
- $cartitem['product_sku'] = $_cartitem->getSku();
2186
- $cartitem['product_qty'] = $_cartitem->getQty();
2187
- $cartitem['updated_at'] = $_cartitem->getUpdatedAt();
2188
- $cartitem['product_name'] = $_cartitem->getName();
2189
- $cartitem['product_type'] = $_cartitem->getProductType();
2190
- $cartitem['base_price'] = $_cartitem->getBasePrice();
2191
- $cartitem['base_tax_amount'] = $_cartitem->getBaseTaxAmount();
2192
- $cartitem['base_discount_amount'] = $_cartitem->getBaseDiscountAmount();
2193
- $cartitem['base_cost'] = $_cartitem->getBaseCost();
2194
- $cartitem['base_price_incl_tax'] = $_cartitem->getBasePriceInclTax();
2195
- }
2196
-
2197
- catch(Exception $e) {
2198
- $cartitem['mocoauto_api_error'] = 'moco_unable_to_read_cartitem: ' . $e->getMessage();
2199
- }
2200
-
2201
- $cartitems[] = $cartitem;
2202
- }
2203
 
2204
- $cart['moco_cart_items'] = $cartitems;
2205
- }
 
 
 
2206
 
2207
- $cart['moco_end_of_cart_record'] = 'True';
2208
 
2209
- }
2210
- catch(Exception $e) {
2211
- $cart['mocoauto_api_error'] = 'moco_unable_to_read_cart: ' . $e->getMessage();
2212
- }
2213
 
2214
- $carts[] = $cart;
 
2215
 
 
 
2216
  }
2217
 
2218
  $this->getResponse()
2219
- ->setBody(json_encode($carts))
2220
  ->setHttpResponseCode(200)
2221
  ->setHeader('Content-type', 'application/json', true);
2222
  return $this;
2223
  }
2224
 
2225
-
2226
- public function wishlistsAction()
2227
  {
2228
  if(!$this->_authorise()) {
2229
  return $this;
@@ -2234,56 +2033,33 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2234
  $offset = $this->getRequest()->getParam('offset', 0);
2235
  $page_size = $this->getRequest()->getParam('page_size', 20);
2236
  $since = $this->getRequest()->getParam('since', 'ALL');
2237
- $gTE = $this->getRequest()->getParam('gte', 'ALL');
2238
-
2239
- $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
2240
-
2241
- if($since != 'ALL'){
2242
- $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
2243
- }
2244
-
2245
- if($gTE != 'ALL'){
2246
- $_wishlistCol->addFieldToFilter('wishlist_id', array('gteq' =>$gTE));
2247
- $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('wishlist_id');
2248
- }
2249
- else{
2250
- $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2251
- }
2252
-
2253
- $wishlists = array();
2254
 
2255
- foreach($_wishlistCol as $_wishlist) {
2256
- $wishlist = array();
2257
- $wishlist['moco_start_of_wishlist_record'] = 'True';
2258
- $wishlist['wishlist_id'] = $_wishlist->getId();
2259
- $wishlist['customer_id'] = $_wishlist->getCustomerId();
2260
- $wishlist['updated_at'] = $_wishlist->getUpdatedAt();
2261
- $_wishlistitemsCol = $_wishlist->getItemCollection();
2262
- $wishlistitems = array();
2263
 
2264
- foreach($_wishlistitemsCol as $_wishlistitem){
2265
- $wishlistitem = array();
2266
- $wishlistitem['item_id'] = $_wishlistitem->getId();
2267
- $wishlistitem['store_id'] = $_wishlistitem->getStoreId();
2268
- $wishlistitem['product_id'] = $_wishlistitem->getProductId();
2269
- $wishlistitem['product_qty'] = $_wishlistitem->getQty();
2270
- $wishlistitem['added_at'] = $_wishlistitem->getAddedAt();
2271
- $wishlistitems[] = $wishlistitem;
2272
- }
2273
 
2274
- $wishlist['wish_list_items'] = $wishlistitems;
2275
- $wishlist['moco_end_of_wishlist_record'] = 'True';
2276
- $wishlists[] = $wishlist;
 
 
 
 
 
 
 
 
2277
  }
2278
 
2279
  $this->getResponse()
2280
- ->setBody(json_encode($wishlists))
2281
  ->setHttpResponseCode(200)
2282
  ->setHeader('Content-type', 'application/json', true);
2283
  return $this;
2284
  }
2285
 
2286
- public function ex_wishlistsAction()
 
 
2287
  {
2288
  if(!$this->_authorise()) {
2289
  return $this;
@@ -2293,72 +2069,68 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2293
 
2294
  $offset = $this->getRequest()->getParam('offset', 0);
2295
  $page_size = $this->getRequest()->getParam('page_size', 20);
2296
- $since = $this->getRequest()->getParam('since', 'ALL');
 
 
 
2297
 
2298
- $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
2299
- $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2300
 
2301
  if($since != 'ALL'){
2302
- $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
2303
  }
2304
 
2305
- $wishlists = array();
 
 
 
 
 
 
2306
 
2307
- foreach($_wishlistCol as $_wishlist) {
2308
- $wishlists[] = array('moco_start_of_wishlist_record' => 'True');
2309
- $wishlists[] = $_wishlist->toArray();
2310
- $_wishlistitemsCol = $_wishlist->getItemCollection();
2311
- foreach($_wishlistitemsCol as $_wishlistitem){
2312
- $wishlists[] = array('wishlist_item_id' => $_wishlistitem->getId());
2313
- $wishlists[] = array('product_id' => $_wishlistitem->getProductId());
2314
- $wishlists[] = array('product_qty' => $_wishlistitem->getQty());
2315
- $wishlists[] = array('added_at' => $_wishlistitem->getAddedAt());
2316
- }
2317
 
2318
- $wishlists[] = array('moco_end_of_wishlist_record' => 'True');
2319
- }
2320
 
2321
- $this->getResponse()
2322
- ->setBody(json_encode($wishlists))
2323
- ->setHttpResponseCode(200)
2324
- ->setHeader('Content-type', 'application/json', true);
2325
- return $this;
2326
- }
2327
 
2328
- public function installinfoAction()
2329
- {
2330
- if(!$this->_authorise()) {
2331
- return $this;
2332
- }
2333
 
2334
- $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
 
 
2335
 
2336
- $installinfo = array();
2337
 
2338
- $installinfo[] = array('moco install info' => 'True');
2339
- $installinfo[] = array('Base URL' => Mage::getBaseUrl());
2340
- $installinfo[] = array('Home URL' => Mage::helper('core/url')->getHomeUrl());
2341
- $installinfo[] = array('Home URL' => Mage::getBaseDir());
2342
- $installinfo[] = array('Media URL' => Mage::getBaseUrl('media'));
2343
 
2344
-
 
 
 
2345
 
2346
 
2347
- $calc = Mage::getSingleton('tax/calculation');
2348
- $rates = $calc->getRatesForAllProductTaxClasses($calc->getRateRequest());
 
 
 
 
2349
 
2350
- foreach ($rates as $class=>$rate) {
2351
- $installinfo[] = array('Tax rate' => floatval($rate));
2352
  }
2353
 
2354
  $this->getResponse()
2355
- ->setBody(json_encode($installinfo))
2356
  ->setHttpResponseCode(200)
2357
  ->setHeader('Content-type', 'application/json', true);
2358
  return $this;
2359
  }
2360
 
2361
- public function rulesAction()
 
 
2362
  {
2363
  if(!$this->_authorise()) {
2364
  return $this;
@@ -2368,32 +2140,16 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2368
 
2369
  $offset = $this->getRequest()->getParam('offset', 0);
2370
  $page_size = $this->getRequest()->getParam('page_size', 20);
2371
- $since = $this->getRequest()->getParam('since', 'ALL');
2372
-
2373
- $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
2374
 
2375
-
2376
- foreach ($_rulesCol as $rule) {
2377
- // print_r($rule->getData());
2378
- $rulelist[] = array('moco_start_of_rule_record' => 'True');
2379
- $rulelist[] = array('rule_id' => $rule->getRule_id());
2380
- $rulelist[] = array('rule_name' => $rule->getName());
2381
- $rulelist[] = array('rule_description' => $rule->getDescription());
2382
- $rulelist[] = array('rule_from_date' => $rule->getFrom_date());
2383
- $rulelist[] = array('rule_to_date' => $rule->getTo_date());
2384
- $rulelist[] = array('rule_is_active' => $rule->getIsActive());
2385
- $rulelist[] = array('rule_coupon_type' => $rule->getCoupon_type());
2386
- $rulelist[] = array('moco_end_of_rule_record' => 'True');
2387
- }
2388
 
2389
  $this->getResponse()
2390
- ->setBody(json_encode($rulelist))
2391
  ->setHttpResponseCode(200)
2392
  ->setHeader('Content-type', 'application/json', true);
2393
  return $this;
2394
  }
2395
 
2396
-
2397
  public function creditsAction()
2398
  {
2399
  if(!$this->_authorise()) {
@@ -2422,8 +2178,6 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2422
  $_creditCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2423
  }
2424
 
2425
- //Mage::log('SQL Query: '.$_orderCol->getSelect());
2426
-
2427
 
2428
  $credits = array();
2429
 
@@ -2487,4 +2241,29 @@ class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Acti
2487
  ->setHeader('Content-type', 'application/json', true);
2488
  return $this;
2489
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2490
  }
29
  // product_idsAction
30
  // creditsAction
31
  // credit_idsAction
32
+ // invoicesAction
33
+ // invoice_idsAction
34
  // sql_sales_flat_quoteAction()
35
  // sql_anytableAction()
36
+ // sql_describeAction
37
+ // sql_showtablesAction
38
+ // list_modulesAction
39
 
40
+ define("apiversion","1.5.2.2");
 
41
 
42
  class MocoInsight_Mocoauto_ApiController extends Mage_Core_Controller_Front_Action
43
  {
88
  }
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////
93
+ // statsAction - returns size of data
94
+ //
95
+ // 1.5.2.2 - adding a count for invoices
96
+ //
97
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
98
+ public function statsAction()
99
  {
100
  if(!$this->_authorise()) {
101
  return $this;
162
  }
163
  $creditcount = $_creditCol->getSize();
164
 
165
+ $_invoiceCol = Mage::getModel('sales/order_invoice')->getCollection();
166
+ if($since != 'ALL'){
167
+ $_invoiceCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
168
+ }
169
+ $invoicecount = $_invoiceCol->getSize();
170
+
171
 
172
  $magentoVersion = Mage::getVersion();
173
  $moduleversion = (String)Mage::getConfig()->getNode()->modules->MocoInsight_Mocoauto->version;
192
  'Subscribers' => $subscribercount,
193
  'Cart and Coupon rules' => $rulescount,
194
  'Credit memos' => $creditcount,
195
+ 'Invoices' => $invoicecount,
196
  'System Date Time' => $currentSystemTime,
197
  'Magento Version' => $magentoVersion,
198
  'Magento Edition' => $magentoedition,
208
  ->setHeader('Content-type', 'application/json', true);
209
  return $this;
210
  }
 
211
  public function logstatsAction() // Return the number size of logs
212
  {
213
  if(!$this->_authorise()) {
612
  }
613
  // ordersAction - return all information on a order
614
  // 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.
615
+ // 1.5.2.0 - request all shipment info execpet label as there are many diffrent shipping plugins.
616
  //
617
  public function test_ordersAction()
618
  {
687
  $order['moco_ship_address'] = $shipaddrdetails;
688
  }
689
 
690
+ if(is_object($_order->getShipmentsCollection())){ // check obj exists
691
+ $_orderShipmentsCol = $_order->getShipmentsCollection(); // get collection of shipment objects
 
692
  $ordershipments = array();
693
+ foreach($_orderShipmentsCol as $_ordershipment){ // collection of shipment objects
694
+ $shipmentdetails = array();
695
+ $shipmentdetails = $_ordershipment->toArray(); // dump shipment object values to array
696
+ $ordershipment = array();
697
+ foreach($shipmentdetails as $key => $value){ // iterate values array
698
+ //Mage::log('$key = ' . $key . ' $value = '. $value);
699
+ if($key != 'shipping_label'){ // if keuy is OK write to output array
700
+ $ordershipment[$key] = $value;
701
+ }
702
+ }
703
+ $ordershipments[] = $ordershipment; // write 1 shippment detail to array with all shipments
704
  }
705
+ $order['moco_shipments'] = $ordershipments; // write all shipments to main output array.
706
  }
 
707
 
708
+ // If the Temanado flag is set then get any shipping records that match the order number.
709
  if($TEMANDO_FLAG == 'TRUE'){ //Table does exist
710
  $temandodata = array();
711
  $query = 'select id, order_id, anticipated_cost, ready_date, ready_time from ' . $tablename . ' where order_id = "' . $_order->getEntityId() . '"';
909
  return $this;
910
  }
911
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  public function categoriesAction()
913
  {
914
  if(!$this->_authorise()) {
1499
  return $this;
1500
  }
1501
 
1502
+ public function sql_describeAction()
1503
+ {
1504
+
1505
+ if(!$this->_authorise()) {
1506
+ return $this;
1507
+ }
1508
+
1509
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1510
+ $tablename1 = $this->getRequest()->getParam('tablename', 'no table name set');
1511
+
1512
+ try{
1513
+ $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1514
+ if(!$_read ->showTableStatus(trim($tablename1,"'"))){
1515
+ $readresults=array($tablename1 ." table does not exist");
1516
+ }
1517
+ else{
1518
+ $query = 'describe ';
1519
+ $query = $query . $tablename1;
1520
+
1521
+ //Mage::log('DBG SQL: '. $query);
1522
+
1523
+ $readresults = $_read->fetchAll($query);
1524
+ }
1525
+ }
1526
+ catch(Exception $e) {
1527
+ $readresults[] = array('mocoauto_api_error' => 'error reading ' . $tablename1 . ' : ' . $e->getMessage());
1528
+ }
1529
+
1530
+ $this->getResponse()
1531
+ ->setBody(json_encode($readresults))
1532
+ ->setHttpResponseCode(200)
1533
+ ->setHeader('Content-type', 'application/json', true);
1534
+ return $this;
1535
+ }
1536
+
1537
+ public function sql_showtablesAction()
1538
+ {
1539
+
1540
+ if(!$this->_authorise()) {
1541
+ return $this;
1542
+ }
1543
+
1544
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1545
+
1546
+ try{
1547
+ $_read = Mage::getSingleton('core/resource')->getConnection('core_read');
1548
+ $query = 'show tables';
1549
+
1550
+ //Mage::log('DBG SQL: '. $query);
1551
+
1552
+ $readresults = $_read->fetchAll($query);
1553
+ }
1554
+ catch(Exception $e) {
1555
+ $readresults[] = array('mocoauto_api_error' => 'show tables error ' . ' : ' . $e->getMessage());
1556
+ }
1557
+
1558
+ $this->getResponse()
1559
+ ->setBody(json_encode($readresults))
1560
+ ->setHttpResponseCode(200)
1561
+ ->setHeader('Content-type', 'application/json', true);
1562
+ return $this;
1563
+ }
1564
+
1565
  public function old_sql_sales_flat_quoteAction()
1566
  {
1567
  $tablename1 = 'sales_flat_quote';
1800
  return $this;
1801
  }
1802
 
1803
+
1804
+ public function unconvertedcartsAction()
1805
  {
1806
  if(!$this->_authorise()) {
1807
  return $this;
1814
  $since = $this->getRequest()->getParam('since', 'ALL');
1815
  $gTE = $this->getRequest()->getParam('gte', 'ALL');
1816
 
1817
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // set to admin view all sites and stores
1818
+
1819
  $_cartsCol = Mage::getResourceModel('sales/quote_collection')->addFieldToFilter('is_active', '1'); // 1 = quote has not been conveted to an order
1820
 
1821
  $magentoVersion = Mage::getVersion();
1822
  if (version_compare($magentoVersion, '1.7', '>=')){
1823
+ $aboveVersion17Flag = 1;
1824
+ }
 
1825
  else {
 
1826
  $aboveVersion17Flag = 0;
1827
  }
1828
 
1833
  'customer_email', //attribute_2 with key 1
1834
  ),
1835
  array(
1836
+ array('gteq'=> 1), // This form creates a NOT NULL query.
1837
  array('notnull'=>1),
1838
  )
1839
  );
1840
  }
1841
 
 
 
1842
  if($since != 'ALL'){
1843
+ $_cartsCol->addFieldToFilter('updated_at', array('gteq' =>$since)); // If date filter supplied include empty carts
1844
  }
1845
  else{
1846
+ $_cartsCol->addFieldToFilter('items_count', array('neq' => 0)); // If no date filter supplied (ALL) only include carts with items
1847
  }
1848
 
1849
  // If using gte we want to sort by entity id
1850
+
1851
  if($gTE != 'ALL'){
1852
  $_cartsCol->addFieldToFilter('entity_id', array('gteq' =>$gTE)); // If gte set include records GTE gte
1853
+ $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
1854
+ }
1855
+ else{
1856
+ $_cartsCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1857
  }
1858
 
1859
  //Mage::log((string) $_cartsCol->getSelect());
1899
  $cartitem['base_cost'] = $_cartitem->getBaseCost();
1900
  $cartitem['base_price_incl_tax'] = $_cartitem->getBasePriceInclTax();
1901
  }
1902
+
1903
  catch(Exception $e) {
1904
  $cartitem['mocoauto_api_error'] = 'moco_unable_to_read_cartitem: ' . $e->getMessage();
1905
  }
1906
 
1907
  $cartitems[] = $cartitem;
1908
  }
1909
+
1910
  $cart['moco_cart_items'] = $cartitems;
1911
  }
1912
 
1928
  return $this;
1929
  }
1930
 
1931
+
1932
+ public function wishlistsAction()
1933
  {
1934
  if(!$this->_authorise()) {
1935
  return $this;
1942
  $since = $this->getRequest()->getParam('since', 'ALL');
1943
  $gTE = $this->getRequest()->getParam('gte', 'ALL');
1944
 
1945
+ $_wishlistCol = Mage::getModel('wishlist/wishlist')-> getCollection();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1946
 
1947
  if($since != 'ALL'){
1948
+ $_wishlistCol->addFieldToFilter('updated_at', array('gteq' =>$since));
 
 
 
1949
  }
1950
 
 
 
1951
  if($gTE != 'ALL'){
1952
+ $_wishlistCol->addFieldToFilter('wishlist_id', array('gteq' =>$gTE));
1953
+ $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('wishlist_id');
1954
  }
1955
  else{
1956
+ $_wishlistCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
1957
  }
1958
 
1959
+ $wishlists = array();
 
 
 
 
 
 
1960
 
1961
+ foreach($_wishlistCol as $_wishlist) {
1962
+ $wishlist = array();
1963
+ $wishlist['moco_start_of_wishlist_record'] = 'True';
1964
+ $wishlist['wishlist_id'] = $_wishlist->getId();
1965
+ $wishlist['customer_id'] = $_wishlist->getCustomerId();
1966
+ $wishlist['updated_at'] = $_wishlist->getUpdatedAt();
1967
+ $_wishlistitemsCol = $_wishlist->getItemCollection();
1968
+ $wishlistitems = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1969
 
1970
+ foreach($_wishlistitemsCol as $_wishlistitem){
1971
+ $wishlistitem = array();
1972
+ $wishlistitem['item_id'] = $_wishlistitem->getId();
1973
+ $wishlistitem['store_id'] = $_wishlistitem->getStoreId();
1974
+ $wishlistitem['product_id'] = $_wishlistitem->getProductId();
1975
+ $wishlistitem['product_qty'] = $_wishlistitem->getQty();
1976
+ $wishlistitem['added_at'] = $_wishlistitem->getAddedAt();
1977
+ $wishlistitems[] = $wishlistitem;
1978
  }
1979
 
1980
+ $wishlist['wish_list_items'] = $wishlistitems;
1981
+ $wishlist['moco_end_of_wishlist_record'] = 'True';
1982
+ $wishlists[] = $wishlist;
1983
  }
1984
 
1985
  $this->getResponse()
1986
+ ->setBody(json_encode($wishlists))
1987
  ->setHttpResponseCode(200)
1988
  ->setHeader('Content-type', 'application/json', true);
1989
  return $this;
1990
  }
1991
 
1992
+ public function installinfoAction()
1993
  {
1994
  if(!$this->_authorise()) {
1995
  return $this;
1997
 
1998
  $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
1999
 
2000
+ $installinfo = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2001
 
2002
+ $installinfo[] = array('moco install info' => 'True');
2003
+ $installinfo[] = array('Base URL' => Mage::getBaseUrl());
2004
+ $installinfo[] = array('Home URL' => Mage::helper('core/url')->getHomeUrl());
2005
+ $installinfo[] = array('Home URL' => Mage::getBaseDir());
2006
+ $installinfo[] = array('Media URL' => Mage::getBaseUrl('media'));
2007
 
2008
+
2009
 
 
 
 
 
2010
 
2011
+ $calc = Mage::getSingleton('tax/calculation');
2012
+ $rates = $calc->getRatesForAllProductTaxClasses($calc->getRateRequest());
2013
 
2014
+ foreach ($rates as $class=>$rate) {
2015
+ $installinfo[] = array('Tax rate' => floatval($rate));
2016
  }
2017
 
2018
  $this->getResponse()
2019
+ ->setBody(json_encode($installinfo))
2020
  ->setHttpResponseCode(200)
2021
  ->setHeader('Content-type', 'application/json', true);
2022
  return $this;
2023
  }
2024
 
2025
+ public function rulesAction()
 
2026
  {
2027
  if(!$this->_authorise()) {
2028
  return $this;
2033
  $offset = $this->getRequest()->getParam('offset', 0);
2034
  $page_size = $this->getRequest()->getParam('page_size', 20);
2035
  $since = $this->getRequest()->getParam('since', 'ALL');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2036
 
2037
+ $_rulesCol = Mage::getModel('salesrule/rule')->getCollection();
 
 
 
 
 
 
 
2038
 
 
 
 
 
 
 
 
 
 
2039
 
2040
+ foreach ($_rulesCol as $rule) {
2041
+ // print_r($rule->getData());
2042
+ $rulelist[] = array('moco_start_of_rule_record' => 'True');
2043
+ $rulelist[] = array('rule_id' => $rule->getRule_id());
2044
+ $rulelist[] = array('rule_name' => $rule->getName());
2045
+ $rulelist[] = array('rule_description' => $rule->getDescription());
2046
+ $rulelist[] = array('rule_from_date' => $rule->getFrom_date());
2047
+ $rulelist[] = array('rule_to_date' => $rule->getTo_date());
2048
+ $rulelist[] = array('rule_is_active' => $rule->getIsActive());
2049
+ $rulelist[] = array('rule_coupon_type' => $rule->getCoupon_type());
2050
+ $rulelist[] = array('moco_end_of_rule_record' => 'True');
2051
  }
2052
 
2053
  $this->getResponse()
2054
+ ->setBody(json_encode($rulelist))
2055
  ->setHttpResponseCode(200)
2056
  ->setHeader('Content-type', 'application/json', true);
2057
  return $this;
2058
  }
2059
 
2060
+ // 1.5.2.1 first version with this action
2061
+
2062
+ public function invoicesAction()
2063
  {
2064
  if(!$this->_authorise()) {
2065
  return $this;
2069
 
2070
  $offset = $this->getRequest()->getParam('offset', 0);
2071
  $page_size = $this->getRequest()->getParam('page_size', 20);
2072
+ $since = $this->getRequest()->getParam('since','ALL');
2073
+ $gTE = $this->getRequest()->getParam('gte', 'ALL');
2074
+
2075
+ $_invoiceCol = Mage::getModel('sales/order_invoice')->getCollection()->addAttributeToSelect('*');
2076
 
 
 
2077
 
2078
  if($since != 'ALL'){
2079
+ $_invoiceCol->addAttributeToFilter('updated_at', array('gteq' =>$since));
2080
  }
2081
 
2082
+ if($gTE != 'ALL'){
2083
+ $_invoiceCol->addFieldToFilter('entity_id', array('gteq' =>$gTE));
2084
+ $_invoiceCol->getSelect()->limit($page_size, ($offset * $page_size))->order('entity_id');
2085
+ }
2086
+ else{
2087
+ $_invoiceCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2088
+ }
2089
 
2090
+ $invoices = array();
 
 
 
 
 
 
 
 
 
2091
 
2092
+ foreach($_invoiceCol as $_invoice) {
 
2093
 
2094
+ $invoice = array();
 
 
 
 
 
2095
 
2096
+ try{
2097
+ $invoice['moco_start_of_invoice_record'] = 'True';
2098
+ $invoicedetails = array();
2099
+ $invoicedetails = $_invoice->toArray();
 
2100
 
2101
+ foreach ($invoicedetails as $key => $value) {
2102
+ $invoice[$key] = $value;
2103
+ }
2104
 
 
2105
 
2106
+ $_invoiceItemsCol = $_invoice->getItemsCollection();
2107
+ $invoiceitems = array();
 
 
 
2108
 
2109
+ foreach($_invoiceItemsCol as $_invoiceitem){
2110
+ $invoiceitems[] = $_invoiceitem->toArray();
2111
+ }
2112
+ $invoice['moco_tls'] = $invoiceitems;
2113
 
2114
 
2115
+ $order['moco_end_of_invoice_record'] = 'True';
2116
+ }
2117
+ catch (Exception $e) {
2118
+ $order['mocoauto_api_error'] = 'invoice record: ' . $e->getMessage();
2119
+ }
2120
+ $invoices[] = $invoice;
2121
 
 
 
2122
  }
2123
 
2124
  $this->getResponse()
2125
+ ->setBody(json_encode($invoices))
2126
  ->setHttpResponseCode(200)
2127
  ->setHeader('Content-type', 'application/json', true);
2128
  return $this;
2129
  }
2130
 
2131
+ // 1.5.2.1 first verstion with this action
2132
+
2133
+ public function invoice_idsAction()
2134
  {
2135
  if(!$this->_authorise()) {
2136
  return $this;
2140
 
2141
  $offset = $this->getRequest()->getParam('offset', 0);
2142
  $page_size = $this->getRequest()->getParam('page_size', 20);
 
 
 
2143
 
2144
+ $invoiceIds = Mage::getModel('sales/order_invoice')->getCollection()->getAllIds($limit= $page_size, $offset =($offset * $page_size));
 
 
 
 
 
 
 
 
 
 
 
 
2145
 
2146
  $this->getResponse()
2147
+ ->setBody(json_encode($invoiceIds))
2148
  ->setHttpResponseCode(200)
2149
  ->setHeader('Content-type', 'application/json', true);
2150
  return $this;
2151
  }
2152
 
 
2153
  public function creditsAction()
2154
  {
2155
  if(!$this->_authorise()) {
2178
  $_creditCol->getSelect()->limit($page_size, ($offset * $page_size))->order('updated_at');
2179
  }
2180
 
 
 
2181
 
2182
  $credits = array();
2183
 
2241
  ->setHeader('Content-type', 'application/json', true);
2242
  return $this;
2243
  }
2244
+
2245
+
2246
+ public function list_modulesAction()
2247
+ {
2248
+
2249
+ if(!$this->_authorise()) {
2250
+ return $this;
2251
+ }
2252
+
2253
+ $sections = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
2254
+
2255
+ try{
2256
+ $modules = Mage::getConfig()->getNode('modules')->children();
2257
+ }
2258
+ catch(Exception $e) {
2259
+ $readresults[] = array('mocoauto_api_error' => 'list installed modules error ' . ' : ' . $e->getMessage());
2260
+ }
2261
+
2262
+ $this->getResponse()
2263
+ ->setBody(json_encode($modules))
2264
+ ->setHttpResponseCode(200)
2265
+ ->setHeader('Content-type', 'application/json', true);
2266
+ return $this;
2267
+ }
2268
+
2269
  }
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.0</version>
8
  </MocoInsight_Mocoauto>
9
  </modules>
10
  <global>
4
  <config>
5
  <modules>
6
  <MocoInsight_Mocoauto>
7
+ <version>1.5.2.2</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.0</version>
5
  <stability>stable</stability>
6
  <license>OSL v1.0.0</license>
7
  <channel>community</channel>
@@ -11,7 +11,14 @@
11
  &#xD;
12
  &#xD;
13
  </description>
14
- <notes>1.5.2.0&#xD;
 
 
 
 
 
 
 
15
  &#xD;
16
  Fix warning notice of Undefined variable: TEMANDO_FLAG. No change to functionality&#xD;
17
  &#xD;
@@ -254,9 +261,9 @@ System date/time&#xD;
254
  added success true for succesful requests&#xD;
255
  changed product category to moco_category</notes>
256
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
257
- <date>2015-05-28</date>
258
- <time>04:44:27</time>
259
- <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="69c858d1e3792e5c36d9da2398a96e66"/></dir><dir name="etc"><file name="config.xml" hash="c97ecb047b73feb0f802d6403e72d01e"/><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>
260
  <compatible/>
261
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
262
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>MocoInsight_Mocoauto</name>
4
+ <version>1.5.2.2</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.2&#xD;
15
+ &#xD;
16
+ Update to ordersAction - don't return shipping_label info as very large and not needed.&#xD;
17
+ &#xD;
18
+ Also new Actions to support custom tables&#xD;
19
+ &#xD;
20
+ &#xD;
21
+ 1.5.2.0&#xD;
22
  &#xD;
23
  Fix warning notice of Undefined variable: TEMANDO_FLAG. No change to functionality&#xD;
24
  &#xD;
261
  added success true for succesful requests&#xD;
262
  changed product category to moco_category</notes>
263
  <authors><author><name>Rob Davies</name><user>mocoinsight</user><email>rob.davies@mocoinsight.com</email></author></authors>
264
+ <date>2015-07-13</date>
265
+ <time>06:29:08</time>
266
+ <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="1a0b4455ea220797e3dc26fccfcfb25a"/></dir><dir name="etc"><file name="config.xml" hash="26aeab58eadbaa8b7a72f55c88f47997"/><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>
267
  <compatible/>
268
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
269
  </package>