Glew - Version 1.0.20

Version Notes

Added support for different root categories.
Added store url to config screen
Added single id calls to all api endpoints

Download this release

Release Info

Developer Glew
Extension Glew
Version 1.0.20
Comparing to
See all releases


Code changes from version 1.0.19 to 1.0.20

app/code/community/Glew/Service/Block/StoreUrl.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Glew_Service_Block_StoreUrl extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
9
+ }
10
+ }
11
+
app/code/community/Glew/Service/Helper/Data.php CHANGED
@@ -57,8 +57,7 @@ class Glew_Service_Helper_Data extends Mage_Core_Helper_Abstract
57
 
58
  public function logException($ex, $msg)
59
  {
60
- Mage::logException($ex);
61
- Mage::log($msg.': '.$ex->getMessage(), null, self::$filename);
62
 
63
  return false;
64
  }
@@ -68,6 +67,10 @@ class Glew_Service_Helper_Data extends Mage_Core_Helper_Abstract
68
  return Mage::log($msg, null, self::$filename);
69
  }
70
 
 
 
 
 
71
  public function getStore()
72
  {
73
  if ($this->_store == null) {
57
 
58
  public function logException($ex, $msg)
59
  {
60
+ Mage::log(print_r($ex, true), null, self::$filename);
 
61
 
62
  return false;
63
  }
67
  return Mage::log($msg, null, self::$filename);
68
  }
69
 
70
+ public function getLog() {
71
+ return Mage::getBaseDir('log') . DS . self::$filename;
72
+ }
73
+
74
  public function getStore()
75
  {
76
  if ($this->_store == null) {
app/code/community/Glew/Service/Model/Types/AbandonedCarts.php CHANGED
@@ -5,12 +5,15 @@ class Glew_Service_Model_Types_AbandonedCarts
5
  public $carts = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- if ($startDate && $endDate) {
 
 
 
14
  $filter = array(
15
  'datetime' => 1,
16
  'locale' => 'en_US',
5
  public $carts = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+ if($id) {
14
+ $collection = Mage::getResourceModel('reports/quote_collection')
15
+ ->addFieldToFilter('main_table.entity_id', $id);
16
+ } elseif ($startDate && $endDate) {
17
  $filter = array(
18
  'datetime' => 1,
19
  'locale' => 'en_US',
app/code/community/Glew/Service/Model/Types/Categories.php CHANGED
@@ -5,7 +5,7 @@ class Glew_Service_Model_Types_Categories
5
  public $categories = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
@@ -16,7 +16,10 @@ class Glew_Service_Model_Types_Categories
16
  ->load($rootCategoryId)
17
  ->getPath();
18
 
19
- if ($startDate && $endDate) {
 
 
 
20
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
21
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
22
 
5
  public $categories = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
16
  ->load($rootCategoryId)
17
  ->getPath();
18
 
19
+ if ($id) {
20
+ $categories = Mage::getModel('catalog/category')->getCollection()
21
+ ->addAttributeToFilter('entity_id', $id);
22
+ } elseif ($startDate && $endDate) {
23
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
24
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
25
 
app/code/community/Glew/Service/Model/Types/Customers.php CHANGED
@@ -5,12 +5,15 @@ class Glew_Service_Model_Types_Customers
5
  public $customers = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- if ($startDate && $endDate) {
 
 
 
14
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
15
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
16
 
5
  public $customers = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+ if ($id) {
14
+ $collection = Mage::getModel('customer/customer')->getCollection()
15
+ ->addAttributeToFilter('entity_id', $id);
16
+ } elseif ($startDate && $endDate) {
17
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
18
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
19
 
app/code/community/Glew/Service/Model/Types/Inventory.php CHANGED
@@ -5,12 +5,18 @@ class Glew_Service_Model_Types_Inventory
5
  public $inventory = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- $inventory = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
 
 
 
 
 
 
14
  $inventory->setOrder('entity_id', $sortDir);
15
  $inventory->setCurPage($pageNum);
16
  $inventory->setPageSize($pageSize);
5
  public $inventory = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+ if ($id) {
14
+ $inventory = Mage::getModel('catalog/product')->getCollection()
15
+ ->addAttributeToSelect('*')
16
+ ->addAttributeToFilter('entity_id', $id);
17
+ } else {
18
+ $inventory = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
19
+ }
20
  $inventory->setOrder('entity_id', $sortDir);
21
  $inventory->setCurPage($pageNum);
22
  $inventory->setPageSize($pageSize);
app/code/community/Glew/Service/Model/Types/OrderItems.php CHANGED
@@ -5,7 +5,7 @@ class Glew_Service_Model_Types_OrderItems
5
  public $orderItems = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
@@ -13,7 +13,10 @@ class Glew_Service_Model_Types_OrderItems
13
  $this->pageNum = $pageNum;
14
 
15
  $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'cost');
16
- if ($startDate && $endDate) {
 
 
 
17
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
18
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
19
 
5
  public $orderItems = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
13
  $this->pageNum = $pageNum;
14
 
15
  $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'cost');
16
+ if ($id) {
17
+ $collection = Mage::getModel('sales/order_item')->getCollection()
18
+ ->addAttributeToFilter('main_table.item_id', $id);
19
+ } elseif ($startDate && $endDate) {
20
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
21
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
22
 
app/code/community/Glew/Service/Model/Types/Orders.php CHANGED
@@ -5,13 +5,16 @@ class Glew_Service_Model_Types_Orders
5
  public $orders = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
 
14
- if ($startDate && $endDate) {
 
 
 
15
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
16
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
17
  $collection = Mage::getModel('sales/order')->getCollection()
5
  public $orders = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
 
14
+ if ($id) {
15
+ $collection = Mage::getModel('sales/order')->getCollection()
16
+ ->addAttributeToFilter('main_table.increment_id', $id);
17
+ } elseif ($startDate && $endDate) {
18
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
19
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
20
  $collection = Mage::getModel('sales/order')->getCollection()
app/code/community/Glew/Service/Model/Types/Product.php CHANGED
@@ -10,6 +10,7 @@ class Glew_Service_Model_Types_Product
10
  $this->entity_type_id = $product->getData('entity_type_id');
11
  $this->attribute_set_id = $product->getData('attribute_set_id');
12
  $this->type_id = $product->getData('type_id');
 
13
 
14
  foreach ($productAttributes as $field => $usesSource) {
15
  try {
@@ -36,7 +37,7 @@ class Glew_Service_Model_Types_Product
36
  }
37
  }
38
  if ($field == 'category_ids') {
39
- $value = $product->getCategoryIds();
40
  }
41
 
42
  $this->$field = $value;
10
  $this->entity_type_id = $product->getData('entity_type_id');
11
  $this->attribute_set_id = $product->getData('attribute_set_id');
12
  $this->type_id = $product->getData('type_id');
13
+ $this->category_ids = $product->getCategoryIds();
14
 
15
  foreach ($productAttributes as $field => $usesSource) {
16
  try {
37
  }
38
  }
39
  if ($field == 'category_ids') {
40
+ continue;
41
  }
42
 
43
  $this->$field = $value;
app/code/community/Glew/Service/Model/Types/ProductAlerts.php CHANGED
@@ -5,12 +5,15 @@ class Glew_Service_Model_Types_ProductAlerts
5
  public $alerts = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- if ($startDate && $endDate) {
 
 
 
14
  $condition = "add_date BETWEEN '".date('Y-m-d 00:00:00', strtotime($startDate))."' AND '".date('Y-m-d 23:59:59', strtotime($endDate))."'";
15
  $alerts = Mage::getModel('productalert/stock')->getCollection()
16
  ->addFilter('add_date', $condition, 'string');
5
  public $alerts = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+ if ($id) {
14
+ $alerts = Mage::getModel('productalert/stock')->getCollection()
15
+ ->addFilter('alert_stock_id', $id);
16
+ } elseif ($startDate && $endDate) {
17
  $condition = "add_date BETWEEN '".date('Y-m-d 00:00:00', strtotime($startDate))."' AND '".date('Y-m-d 23:59:59', strtotime($endDate))."'";
18
  $alerts = Mage::getModel('productalert/stock')->getCollection()
19
  ->addFilter('add_date', $condition, 'string');
app/code/community/Glew/Service/Model/Types/Products.php CHANGED
@@ -6,13 +6,17 @@ class Glew_Service_Model_Types_Products
6
  private $productAttributes = array();
7
  private $pageNum;
8
 
9
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
10
  {
11
  $helper = Mage::helper('glew');
12
  $config = $helper->getConfig();
13
  $this->pageNum = $pageNum;
14
  $this->_getProductAttribtues();
15
- if ($startDate && $endDate) {
 
 
 
 
16
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
17
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
18
 
6
  private $productAttributes = array();
7
  private $pageNum;
8
 
9
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
10
  {
11
  $helper = Mage::helper('glew');
12
  $config = $helper->getConfig();
13
  $this->pageNum = $pageNum;
14
  $this->_getProductAttribtues();
15
+ if( $id ) {
16
+ $products = Mage::getModel('catalog/product')->getCollection()
17
+ ->addAttributeToSelect('*')
18
+ ->addAttributeToFilter('entity_id', $id);
19
+ } elseif ($startDate && $endDate) {
20
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
21
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
22
 
app/code/community/Glew/Service/Model/Types/RefundItems.php CHANGED
@@ -5,12 +5,14 @@ class Glew_Service_Model_Types_RefundItems
5
  public $refundItems = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- if ($startDate && $endDate) {
 
 
14
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
15
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
16
 
@@ -20,9 +22,10 @@ class Glew_Service_Model_Types_RefundItems
20
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
21
  }
22
  $refunds->addAttributeToFilter('main_table.store_id', $helper->getStore()->getStoreId());
23
- $resource = Mage::getSingleton('core/resource');
24
- $salesFlatCredMemItem = $resource->getTableName('sales_flat_creditmemo_item');
25
  $refunds->getSelect()->join(array('credit_item' => $salesFlatCredMemItem), 'credit_item.parent_id = main_table.entity_id', array('*'));
 
 
 
26
  $refunds->setOrder('created_at', $sortDir);
27
  $refunds->setCurPage($pageNum);
28
  $refunds->setPageSize($pageSize);
5
  public $refundItems = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+ $resource = Mage::getSingleton('core/resource');
14
+ $salesFlatCredMemItem = $resource->getTableName('sales_flat_creditmemo_item');
15
+ if ($startDate && $endDate && !$id) {
16
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
17
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
18
 
22
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
23
  }
24
  $refunds->addAttributeToFilter('main_table.store_id', $helper->getStore()->getStoreId());
 
 
25
  $refunds->getSelect()->join(array('credit_item' => $salesFlatCredMemItem), 'credit_item.parent_id = main_table.entity_id', array('*'));
26
+ if ($id ) {
27
+ $refunds->addAttributeToFilter('credit_item.entity_id', $id);
28
+ }
29
  $refunds->setOrder('created_at', $sortDir);
30
  $refunds->setCurPage($pageNum);
31
  $refunds->setPageSize($pageSize);
app/code/community/Glew/Service/Model/Types/Refunds.php CHANGED
@@ -5,12 +5,16 @@ class Glew_Service_Model_Types_Refunds
5
  public $refunds = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- if ($startDate && $endDate) {
 
 
 
 
14
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
15
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
16
 
5
  public $refunds = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+
14
+ if ($id) {
15
+ $refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
16
+ ->addAttributeToFilter('entity_id', $id);
17
+ } elseif ($startDate && $endDate) {
18
  $from = date('Y-m-d 00:00:00', strtotime($startDate));
19
  $to = date('Y-m-d 23:59:59', strtotime($endDate));
20
 
app/code/community/Glew/Service/Model/Types/Subscribers.php CHANGED
@@ -5,12 +5,17 @@ class Glew_Service_Model_Types_Subscribers
5
  public $subscribers = array();
6
  private $pageNum;
7
 
8
- public function load($pageSize, $pageNum, $sortDir, $filterBy)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- $subscribers = Mage::getModel('newsletter/subscriber')->getCollection();
 
 
 
 
 
14
  $subscribers->addFilter('store_id', 'store_id = '.$helper->getStore()->getStoreId(), 'string');
15
  $subscribers->setOrder('subscriber_id', $sortDir);
16
  $subscribers->setCurPage($pageNum);
5
  public $subscribers = array();
6
  private $pageNum;
7
 
8
+ public function load($pageSize, $pageNum, $sortDir, $filterBy, $id)
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
+ if ($id) {
14
+ $subscribers = Mage::getModel('newsletter/subscriber')->getCollection()
15
+ ->addFieldToFilter('main_table.subscriber_id', $id);
16
+ } else {
17
+ $subscribers = Mage::getModel('newsletter/subscriber')->getCollection();
18
+ }
19
  $subscribers->addFilter('store_id', 'store_id = '.$helper->getStore()->getStoreId(), 'string');
20
  $subscribers->setOrder('subscriber_id', $sortDir);
21
  $subscribers->setCurPage($pageNum);
app/code/community/Glew/Service/controllers/ModuleController.php CHANGED
@@ -10,6 +10,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
10
  protected $_endDate = null;
11
  protected $_sortDir = 'asc';
12
  protected $_filterField = 'created_at';
 
13
 
14
  protected function _construct()
15
  {
@@ -40,6 +41,9 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
40
  if ((bool) $sortDir = $this->getRequest()->getParam('sort_dir')) {
41
  $this->_sortDir = $sortDir;
42
  }
 
 
 
43
  }
44
 
45
  public function gotoglewAction()
@@ -51,7 +55,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
51
  {
52
  try {
53
  $this->_initRequest();
54
- $collection = Mage::getModel('glew/types_abandonedCarts')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
55
  $this->_sendResponse($collection);
56
  } catch (Exception $e) {
57
  if ($e->getCode() != 401) {
@@ -65,7 +77,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
65
  {
66
  try {
67
  $this->_initRequest();
68
- $collection = Mage::getModel('glew/types_customers')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
69
  $this->_sendResponse($collection);
70
  } catch (Exception $e) {
71
  if ($e->getCode() != 401) {
@@ -79,7 +99,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
79
  {
80
  try {
81
  $this->_initRequest();
82
- $collection = Mage::getModel('glew/types_orders')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
83
  $this->_sendResponse($collection);
84
  } catch (Exception $e) {
85
  if ($e->getCode() != 401) {
@@ -93,7 +121,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
93
  {
94
  try {
95
  $this->_initRequest();
96
- $collection = Mage::getModel('glew/types_orderItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
97
  $this->_sendResponse($collection);
98
  } catch (Exception $e) {
99
  if ($e->getCode() != 401) {
@@ -107,7 +143,10 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
107
  {
108
  try {
109
  $this->_initRequest();
110
- $collection = Mage::getModel('glew/types_stores')->load($this->_pageSize, $this->_pageNum);
 
 
 
111
  $this->_sendResponse($collection);
112
  } catch (Exception $e) {
113
  if ($e->getCode() != 401) {
@@ -121,7 +160,13 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
121
  {
122
  try {
123
  $this->_initRequest();
124
- $collection = Mage::getModel('glew/types_subscribers')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
125
  $this->_sendResponse($collection);
126
  } catch (Exception $e) {
127
  if ($e->getCode() != 401) {
@@ -135,7 +180,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
135
  {
136
  try {
137
  $this->_initRequest();
138
- $collection = Mage::getModel('glew/types_products')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
139
  $this->_sendResponse($collection);
140
  } catch (Exception $e) {
141
  if ($e->getCode() != 401) {
@@ -149,7 +202,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
149
  {
150
  try {
151
  $this->_initRequest();
152
- $collection = Mage::getModel('glew/types_productAlerts')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
153
  $this->_sendResponse($collection);
154
  } catch (Exception $e) {
155
  if ($e->getCode() != 401) {
@@ -163,7 +224,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
163
  {
164
  try {
165
  $this->_initRequest();
166
- $collection = Mage::getModel('glew/types_categories')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
167
  $this->_sendResponse($collection);
168
  } catch (Exception $e) {
169
  if ($e->getCode() != 401) {
@@ -177,7 +246,13 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
177
  {
178
  try {
179
  $this->_initRequest();
180
- $collection = Mage::getModel('glew/types_inventory')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
181
  $this->_sendResponse($collection);
182
  } catch (Exception $e) {
183
  $this->_helper->logException($e, 'inventory');
@@ -202,7 +277,12 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
202
  {
203
  try {
204
  $this->_initRequest();
205
- $collection = Mage::getModel('glew/types_extensions')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
 
 
 
 
 
206
  $this->_sendResponse($collection);
207
  } catch (Exception $e) {
208
  if ($e->getCode() != 401) {
@@ -216,7 +296,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
216
  {
217
  try {
218
  $this->_initRequest();
219
- $collection = Mage::getModel('glew/types_refundItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
220
  $this->_sendResponse($collection);
221
  } catch (Exception $e) {
222
  if ($e->getCode() != 401) {
@@ -230,7 +318,15 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
230
  {
231
  try {
232
  $this->_initRequest();
233
- $collection = Mage::getModel('glew/types_refunds')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
 
 
 
 
 
 
 
 
234
  $this->_sendResponse($collection);
235
  } catch (Exception $e) {
236
  if ($e->getCode() != 401) {
@@ -240,6 +336,35 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
240
  }
241
  }
242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  protected function _sendResponse($items)
244
  {
245
  $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
10
  protected $_endDate = null;
11
  protected $_sortDir = 'asc';
12
  protected $_filterField = 'created_at';
13
+ protected $_id = null;
14
 
15
  protected function _construct()
16
  {
41
  if ((bool) $sortDir = $this->getRequest()->getParam('sort_dir')) {
42
  $this->_sortDir = $sortDir;
43
  }
44
+ if ((bool) $id = $this->getRequest()->getParam('id')) {
45
+ $this->_id = $id;
46
+ }
47
  }
48
 
49
  public function gotoglewAction()
55
  {
56
  try {
57
  $this->_initRequest();
58
+ $collection = Mage::getModel('glew/types_abandonedCarts')->load(
59
+ $this->_pageSize,
60
+ $this->_pageNum,
61
+ $this->_startDate,
62
+ $this->_endDate,
63
+ $this->_sortDir,
64
+ $this->_filterField,
65
+ $this->_id
66
+ );
67
  $this->_sendResponse($collection);
68
  } catch (Exception $e) {
69
  if ($e->getCode() != 401) {
77
  {
78
  try {
79
  $this->_initRequest();
80
+ $collection = Mage::getModel('glew/types_customers')->load(
81
+ $this->_pageSize,
82
+ $this->_pageNum,
83
+ $this->_startDate,
84
+ $this->_endDate,
85
+ $this->_sortDir,
86
+ $this->_filterField,
87
+ $this->_id
88
+ );
89
  $this->_sendResponse($collection);
90
  } catch (Exception $e) {
91
  if ($e->getCode() != 401) {
99
  {
100
  try {
101
  $this->_initRequest();
102
+ $collection = Mage::getModel('glew/types_orders')->load(
103
+ $this->_pageSize,
104
+ $this->_pageNum,
105
+ $this->_startDate,
106
+ $this->_endDate,
107
+ $this->_sortDir,
108
+ $this->_filterField,
109
+ $this->_id
110
+ );
111
  $this->_sendResponse($collection);
112
  } catch (Exception $e) {
113
  if ($e->getCode() != 401) {
121
  {
122
  try {
123
  $this->_initRequest();
124
+ $collection = Mage::getModel('glew/types_orderItems')->load(
125
+ $this->_pageSize,
126
+ $this->_pageNum,
127
+ $this->_startDate,
128
+ $this->_endDate,
129
+ $this->_sortDir,
130
+ $this->_filterField,
131
+ $this->_id
132
+ );
133
  $this->_sendResponse($collection);
134
  } catch (Exception $e) {
135
  if ($e->getCode() != 401) {
143
  {
144
  try {
145
  $this->_initRequest();
146
+ $collection = Mage::getModel('glew/types_stores')->load(
147
+ $this->_pageSize,
148
+ $this->_pageNum
149
+ );
150
  $this->_sendResponse($collection);
151
  } catch (Exception $e) {
152
  if ($e->getCode() != 401) {
160
  {
161
  try {
162
  $this->_initRequest();
163
+ $collection = Mage::getModel('glew/types_subscribers')->load(
164
+ $this->_pageSize,
165
+ $this->_pageNum,
166
+ $this->_sortDir,
167
+ $this->_filterField,
168
+ $this->_id
169
+ );
170
  $this->_sendResponse($collection);
171
  } catch (Exception $e) {
172
  if ($e->getCode() != 401) {
180
  {
181
  try {
182
  $this->_initRequest();
183
+ $collection = Mage::getModel('glew/types_products')->load(
184
+ $this->_pageSize,
185
+ $this->_pageNum,
186
+ $this->_startDate,
187
+ $this->_endDate,
188
+ $this->_sortDir,
189
+ $this->_filterField,
190
+ $this->_id
191
+ );
192
  $this->_sendResponse($collection);
193
  } catch (Exception $e) {
194
  if ($e->getCode() != 401) {
202
  {
203
  try {
204
  $this->_initRequest();
205
+ $collection = Mage::getModel('glew/types_productAlerts')->load(
206
+ $this->_pageSize,
207
+ $this->_pageNum,
208
+ $this->_startDate,
209
+ $this->_endDate,
210
+ $this->_sortDir,
211
+ $this->_filterField,
212
+ $this->_id
213
+ );
214
  $this->_sendResponse($collection);
215
  } catch (Exception $e) {
216
  if ($e->getCode() != 401) {
224
  {
225
  try {
226
  $this->_initRequest();
227
+ $collection = Mage::getModel('glew/types_categories')->load(
228
+ $this->_pageSize,
229
+ $this->_pageNum,
230
+ $this->_startDate,
231
+ $this->_endDate,
232
+ $this->_sortDir,
233
+ $this->_filterField,
234
+ $this->_id
235
+ );
236
  $this->_sendResponse($collection);
237
  } catch (Exception $e) {
238
  if ($e->getCode() != 401) {
246
  {
247
  try {
248
  $this->_initRequest();
249
+ $collection = Mage::getModel('glew/types_inventory')->load(
250
+ $this->_pageSize,
251
+ $this->_pageNum,
252
+ $this->_sortDir,
253
+ $this->_filterField,
254
+ $this->_id
255
+ );
256
  $this->_sendResponse($collection);
257
  } catch (Exception $e) {
258
  $this->_helper->logException($e, 'inventory');
277
  {
278
  try {
279
  $this->_initRequest();
280
+ $collection = Mage::getModel('glew/types_extensions')->load(
281
+ $this->_pageSize,
282
+ $this->_pageNum,
283
+ $this->_sortDir,
284
+ $this->_filterField
285
+ );
286
  $this->_sendResponse($collection);
287
  } catch (Exception $e) {
288
  if ($e->getCode() != 401) {
296
  {
297
  try {
298
  $this->_initRequest();
299
+ $collection = Mage::getModel('glew/types_refundItems')->load(
300
+ $this->_pageSize,
301
+ $this->_pageNum,
302
+ $this->_startDate,
303
+ $this->_endDate,
304
+ $this->_sortDir,
305
+ $this->_filterField,
306
+ $this->_id
307
+ );
308
  $this->_sendResponse($collection);
309
  } catch (Exception $e) {
310
  if ($e->getCode() != 401) {
318
  {
319
  try {
320
  $this->_initRequest();
321
+ $collection = Mage::getModel('glew/types_refunds')->load(
322
+ $this->_pageSize,
323
+ $this->_pageNum,
324
+ $this->_startDate,
325
+ $this->_endDate,
326
+ $this->_sortDir,
327
+ $this->_filterField,
328
+ $this->_id
329
+ );
330
  $this->_sendResponse($collection);
331
  } catch (Exception $e) {
332
  if ($e->getCode() != 401) {
336
  }
337
  }
338
 
339
+ public function get_logAction()
340
+ {
341
+ try {
342
+ $this->_initRequest();
343
+ $logFile = $this->_helper->getLog();
344
+ $lines = array();
345
+ $fp = fopen($logFile, "r");
346
+ if($fp)
347
+ {
348
+ while(!feof($fp))
349
+ {
350
+ $line = fgets($fp, 4096);
351
+ array_push($lines, $line);
352
+ if(count($lines) > 1000) {
353
+ array_shift($lines);
354
+ }
355
+ }
356
+ fclose($fp);
357
+ $this->getResponse()->setBody(implode("<br />", $lines));
358
+ } else {
359
+ $this->getResponse()->setBody('no log file');
360
+ }
361
+ } catch (Exception $e) {
362
+ if ($e->getCode() != 401) {
363
+ print_r($e);
364
+ }
365
+ }
366
+ }
367
+
368
  protected function _sendResponse($items)
369
  {
370
  $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
app/code/community/Glew/Service/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Glew_Service>
5
- <version>1.0.19</version>
6
  <depends>
7
  <Mage_Shipping/>
8
  </depends>
2
  <config>
3
  <modules>
4
  <Glew_Service>
5
+ <version>1.0.20</version>
6
  <depends>
7
  <Mage_Shipping/>
8
  </depends>
app/code/community/Glew/Service/etc/system.xml CHANGED
@@ -51,6 +51,16 @@
51
  <show_in_store>1</show_in_store>
52
  <comment>Must clear cache after changing</comment>
53
  </shownav>
 
 
 
 
 
 
 
 
 
 
54
  <secret translate="label">
55
  <label>Secret Key</label>
56
  <frontend_type>button</frontend_type>
51
  <show_in_store>1</show_in_store>
52
  <comment>Must clear cache after changing</comment>
53
  </shownav>
54
+ <siteurl translate="label">
55
+ <label>Your Store URL</label>
56
+ <frontend_type>button</frontend_type>
57
+ <frontend_model>glew/storeUrl</frontend_model>
58
+ <sort_order>22</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ <comment>Your Secure Store URL</comment>
63
+ </siteurl>
64
  <secret translate="label">
65
  <label>Secret Key</label>
66
  <frontend_type>button</frontend_type>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Glew</name>
4
- <version>1.0.19</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
@@ -19,15 +19,17 @@ Lifetime-Value-based ROAS instead of transaction-based ROAS&#xD;
19
  Value of your At Risk and Lost customers&#xD;
20
  Trending, real-time store performance on a daily, weekly, and yearly, basis.&#xD;
21
  Merchandising,&#xD;
22
- Cost of Goods Sold,&#xD;
23
  Inventory,&#xD;
24
  Supports multi-store configurations&#xD;
25
  And more!</description>
26
- <notes>Add whatever notes are applicable (i.e Bug fix, new features)</notes>
 
 
 
27
  <authors><author><name>Glew</name><user>glewio</user><email>integrations@glew.io</email></author></authors>
28
- <date>2016-03-23</date>
29
- <time>19:18:12</time>
30
- <contents><target name="magecommunity"><dir name="Glew"><dir name="Service"><dir name="Block"><dir name="Adminhtml"><dir name="Widget"><dir name="Info"><file name="Info.php" hash="6f0dd72fec342ae51953d257c292604a"/></dir></dir></dir><file name="SecretKey.php" hash="48b0b811eaea90539ed2527cb7c88894"/></dir><dir name="Helper"><file name="Data.php" hash="2673d30581c4659165d4088f6471a8fc"/></dir><dir name="Model"><file name="Glew.php" hash="b3323852fa360da0f98cf72b43b903c7"/><dir name="Resource"><file name="Setup.php" hash="1608ab53c5846ff80b1413693ad2657e"/></dir><dir name="Types"><file name="AbandonedCart.php" hash="a192370e52bb9e39f17f792b80c15167"/><file name="AbandonedCarts.php" hash="5ed225e62557a892d5ff36168beaf336"/><file name="Address.php" hash="163419049653b6415ae33aaabd182914"/><file name="Categories.php" hash="230054e6b72e2fa42bf8712b2ac43140"/><file name="Category.php" hash="d61c83a8bf843629ea4f9e101b88e24b"/><file name="Customer.php" hash="684dff09fa7ee1825e43a7b19503d5b6"/><file name="Customers.php" hash="8f1a0862ef48f730c6d54c614d827ce3"/><file name="Extension.php" hash="8da4b95f9ca4cd9b1fe39954ed4b2b33"/><file name="Extensions.php" hash="8bdee566c6580d208999b7894ba3a299"/><file name="Inventory.php" hash="588000790c53d7b00a44e33221f2bf58"/><file name="InventoryItem.php" hash="c032188e8142604e5d3987c39e5e955b"/><file name="Order.php" hash="1ec557ba14fb6ddbcce0d68974b1e005"/><file name="OrderItem.php" hash="5f0e331dc8da0b563ffadb85e828e328"/><file name="OrderItems.php" hash="ee02287003e1532f1873d9cf4b77fc10"/><file name="Orders.php" hash="003a50f457e7bfec087ac5e52fb6e832"/><file name="Product.php" hash="3e445cb1f8d32946a8fb1d9cfe3fe451"/><file name="ProductAlert.php" hash="29cf20364651285abf2924f4af6a08f5"/><file name="ProductAlerts.php" hash="9a015b65dbb0d195c670220524d10fb6"/><file name="Products.php" hash="5a864c768c2b12d222b7d7b93d6d9830"/><file name="Refund.php" hash="95b166b72360c23f38b38eea00f1c8be"/><file name="RefundItem.php" hash="2570ba6b14be44a48d0fec222ff7e5d9"/><file name="RefundItems.php" hash="c300052589ef03a32ed1a5ddcf094b6c"/><file name="Refunds.php" hash="e58eb960bd9a5451a84e71444979de18"/><file name="Store.php" hash="e2a6b48ba078d616179a8327f5eede50"/><file name="Stores.php" hash="13419825a201508e996f40429d9e1b58"/><file name="Subscriber.php" hash="7f7f902d7daacc1bd5924899fd7fed9b"/><file name="Subscribers.php" hash="a4ea8fcaf61306cb085f719c414dff1a"/></dir></dir><dir name="controllers"><file name="ModuleController.php" hash="d9d8a8e3acb34778718244097b47cd24"/></dir><dir name="etc"><file name="adminhtml.xml" hash="520835c098aa86d39edf248ce9fa4869"/><file name="config.xml" hash="9ebe14e56762cd4fb6f166151197c17f"/><file name="system.xml" hash="f679528c3b8f435510224624f5ccdd80"/></dir><dir name="sql"><dir name="glew_setup"><file name="mysql4-install-1.0.0.php" hash="29346b603eb9a4cf6e2a43b0a3c25d6a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Glew_Service.xml" hash="a245647f56ed8f1553ee6dc41bb0b223"/></dir></target></contents>
31
  <compatible/>
32
  <dependencies><required><php><min>5.3.0</min><max>9.0.0</max></php></required></dependencies>
33
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Glew</name>
4
+ <version>1.0.20</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
19
  Value of your At Risk and Lost customers&#xD;
20
  Trending, real-time store performance on a daily, weekly, and yearly, basis.&#xD;
21
  Merchandising,&#xD;
 
22
  Inventory,&#xD;
23
  Supports multi-store configurations&#xD;
24
  And more!</description>
25
+ <notes>Added support for different root categories.&#xD;
26
+ Added store url to config screen&#xD;
27
+ Added single id calls to all api endpoints&#xD;
28
+ </notes>
29
  <authors><author><name>Glew</name><user>glewio</user><email>integrations@glew.io</email></author></authors>
30
+ <date>2016-04-06</date>
31
+ <time>14:25:15</time>
32
+ <contents><target name="magecommunity"><dir name="Glew"><dir name="Service"><dir name="Block"><dir name="Adminhtml"><dir name="Widget"><dir name="Info"><file name="Info.php" hash="6f0dd72fec342ae51953d257c292604a"/></dir></dir></dir><file name="SecretKey.php" hash="48b0b811eaea90539ed2527cb7c88894"/><file name="StoreUrl.php" hash="0feb5ecf9041195a2a3241a979333639"/></dir><dir name="Helper"><file name="Data.php" hash="76c2aa275862ee7e6cb61bb01fe9b875"/></dir><dir name="Model"><file name="Glew.php" hash="b3323852fa360da0f98cf72b43b903c7"/><dir name="Resource"><file name="Setup.php" hash="1608ab53c5846ff80b1413693ad2657e"/></dir><dir name="Types"><file name="AbandonedCart.php" hash="a192370e52bb9e39f17f792b80c15167"/><file name="AbandonedCarts.php" hash="bad5b6ca120808e0bce5e477990865b6"/><file name="Address.php" hash="163419049653b6415ae33aaabd182914"/><file name="Categories.php" hash="b178b1476b2e091f52a44284142d9035"/><file name="Category.php" hash="d61c83a8bf843629ea4f9e101b88e24b"/><file name="Customer.php" hash="684dff09fa7ee1825e43a7b19503d5b6"/><file name="Customers.php" hash="aa6566f45263c4cecd0aa292cd6cfe0f"/><file name="Extension.php" hash="8da4b95f9ca4cd9b1fe39954ed4b2b33"/><file name="Extensions.php" hash="8bdee566c6580d208999b7894ba3a299"/><file name="Inventory.php" hash="363ae968f743895924bbea951f0680b3"/><file name="InventoryItem.php" hash="c032188e8142604e5d3987c39e5e955b"/><file name="Order.php" hash="1ec557ba14fb6ddbcce0d68974b1e005"/><file name="OrderItem.php" hash="5f0e331dc8da0b563ffadb85e828e328"/><file name="OrderItems.php" hash="be688a0caff8862a6e07127f5e644beb"/><file name="Orders.php" hash="1adf32e6dc58e1408c5e2d2c24bf9eb5"/><file name="Product.php" hash="46515fdedf672c3908cf6bba6e0baec8"/><file name="ProductAlert.php" hash="29cf20364651285abf2924f4af6a08f5"/><file name="ProductAlerts.php" hash="de7a7f9fc29a0080dfd9b86f8730cff7"/><file name="Products.php" hash="cfb92207911b4eab6f67689a47d68e29"/><file name="Refund.php" hash="95b166b72360c23f38b38eea00f1c8be"/><file name="RefundItem.php" hash="2570ba6b14be44a48d0fec222ff7e5d9"/><file name="RefundItems.php" hash="75b87b708753ffa4d174216266bbbf3c"/><file name="Refunds.php" hash="c4da0487aac0c6d53364a56be9557796"/><file name="Store.php" hash="e2a6b48ba078d616179a8327f5eede50"/><file name="Stores.php" hash="13419825a201508e996f40429d9e1b58"/><file name="Subscriber.php" hash="7f7f902d7daacc1bd5924899fd7fed9b"/><file name="Subscribers.php" hash="3c4e56eac705bc8b2fdc188e9bb1e527"/></dir></dir><dir name="controllers"><file name="ModuleController.php" hash="f72fe76ae78bbf70c14c78b3db29e947"/></dir><dir name="etc"><file name="adminhtml.xml" hash="520835c098aa86d39edf248ce9fa4869"/><file name="config.xml" hash="70d8913c734d94c2bafb3aabe5e492bd"/><file name="system.xml" hash="8950c687c9a83bfbd109a9f0a74367b3"/></dir><dir name="sql"><dir name="glew_setup"><file name="mysql4-install-1.0.0.php" hash="29346b603eb9a4cf6e2a43b0a3c25d6a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Glew_Service.xml" hash="a245647f56ed8f1553ee6dc41bb0b223"/></dir></target></contents>
33
  <compatible/>
34
  <dependencies><required><php><min>5.3.0</min><max>9.0.0</max></php></required></dependencies>
35
  </package>