Version Notes
-Couple enhancements to 1.0.0
Download this release
Release Info
Developer | Glew |
Extension | Glew |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- app/code/community/Glew/Service/Model/Resource/Mysql4/Setup.php +1 -0
- app/code/community/Glew/Service/Model/Types/AbandonedCarts.php +3 -3
- app/code/community/Glew/Service/Model/Types/Categories.php +7 -7
- app/code/community/Glew/Service/Model/Types/Customers.php +7 -7
- app/code/community/Glew/Service/Model/Types/Extensions.php +6 -6
- app/code/community/Glew/Service/Model/Types/Inventory.php +2 -2
- app/code/community/Glew/Service/Model/Types/Order.php +6 -5
- app/code/community/Glew/Service/Model/Types/OrderItems.php +47 -47
- app/code/community/Glew/Service/Model/Types/Orders.php +6 -6
- app/code/community/Glew/Service/Model/Types/Product.php +2 -2
- app/code/community/Glew/Service/Model/Types/ProductAlerts.php +2 -2
- app/code/community/Glew/Service/Model/Types/Products.php +8 -9
- app/code/community/Glew/Service/Model/Types/RefundItems.php +7 -7
- app/code/community/Glew/Service/Model/Types/Refunds.php +7 -7
- app/code/community/Glew/Service/Model/Types/Stores.php +7 -7
- app/code/community/Glew/Service/Model/Types/Subscribers.php +8 -8
- app/code/community/Glew/Service/controllers/ModuleController.php +51 -32
- app/code/community/Glew/Service/etc/config.xml +4 -8
- package.xml +22 -9
app/code/community/Glew/Service/Model/Resource/Mysql4/Setup.php
CHANGED
@@ -21,5 +21,6 @@ class Glew_Service_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_
|
|
21 |
{
|
22 |
Mage::app()->getStore()->setConfig('glew_settings/general/security_token', $token);
|
23 |
Mage::getModel('core/config')->saveConfig('glew_settings/general/security_token', $token);
|
|
|
24 |
}
|
25 |
}
|
21 |
{
|
22 |
Mage::app()->getStore()->setConfig('glew_settings/general/security_token', $token);
|
23 |
Mage::getModel('core/config')->saveConfig('glew_settings/general/security_token', $token);
|
24 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
25 |
}
|
26 |
}
|
app/code/community/Glew/Service/Model/Types/AbandonedCarts.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_AbandonedCarts
|
4 |
{
|
5 |
-
public $carts;
|
6 |
private $pageNum;
|
7 |
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
$config = $helper->getConfig();
|
@@ -18,7 +18,7 @@ class Glew_Service_Model_Types_AbandonedCarts
|
|
18 |
);
|
19 |
|
20 |
$collection = Mage::getResourceModel('reports/quote_collection')
|
21 |
-
->addFieldToFilter('main_table.
|
22 |
} else {
|
23 |
$collection = Mage::getResourceModel('reports/quote_collection');
|
24 |
}
|
2 |
|
3 |
class Glew_Service_Model_Types_AbandonedCarts
|
4 |
{
|
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();
|
18 |
);
|
19 |
|
20 |
$collection = Mage::getResourceModel('reports/quote_collection')
|
21 |
+
->addFieldToFilter('main_table.' . $filterBy, $filter);
|
22 |
} else {
|
23 |
$collection = Mage::getResourceModel('reports/quote_collection');
|
24 |
}
|
app/code/community/Glew/Service/Model/Types/Categories.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_Categories
|
4 |
{
|
5 |
-
public $categories;
|
6 |
private $pageNum;
|
7 |
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
@@ -13,7 +13,7 @@ class Glew_Service_Model_Types_Categories
|
|
13 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
14 |
|
15 |
$categories = Mage::getModel('catalog/category')->getCollection()
|
16 |
-
->addAttributeToFilter(
|
17 |
} else {
|
18 |
$categories = Mage::getModel('catalog/category')->getCollection();
|
19 |
}
|
@@ -21,18 +21,18 @@ class Glew_Service_Model_Types_Categories
|
|
21 |
$categories->setOrder('created_at', $sortDir);
|
22 |
$categories->setCurPage($pageNum);
|
23 |
$categories->setPageSize($pageSize);
|
24 |
-
|
25 |
if($categories->getLastPageNumber() < $pageNum){
|
26 |
return $this;
|
27 |
}
|
28 |
-
|
29 |
foreach ($categories as $category){
|
30 |
$model = Mage::getModel('glew/types_category')->parse($category);
|
31 |
if ($model) {
|
32 |
$this->categories[] = $model;
|
33 |
-
}
|
34 |
}
|
35 |
return $this;
|
36 |
}
|
37 |
-
|
38 |
}
|
2 |
|
3 |
class Glew_Service_Model_Types_Categories
|
4 |
{
|
5 |
+
public $categories = array();
|
6 |
private $pageNum;
|
7 |
|
8 |
+
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
13 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
14 |
|
15 |
$categories = Mage::getModel('catalog/category')->getCollection()
|
16 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
17 |
} else {
|
18 |
$categories = Mage::getModel('catalog/category')->getCollection();
|
19 |
}
|
21 |
$categories->setOrder('created_at', $sortDir);
|
22 |
$categories->setCurPage($pageNum);
|
23 |
$categories->setPageSize($pageSize);
|
24 |
+
|
25 |
if($categories->getLastPageNumber() < $pageNum){
|
26 |
return $this;
|
27 |
}
|
28 |
+
|
29 |
foreach ($categories as $category){
|
30 |
$model = Mage::getModel('glew/types_category')->parse($category);
|
31 |
if ($model) {
|
32 |
$this->categories[] = $model;
|
33 |
+
}
|
34 |
}
|
35 |
return $this;
|
36 |
}
|
37 |
+
|
38 |
}
|
app/code/community/Glew/Service/Model/Types/Customers.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Glew_Service_Model_Types_Customers
|
4 |
{
|
5 |
-
public $customers;
|
6 |
private $pageNum;
|
7 |
-
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
$config = $helper->getConfig();
|
@@ -14,7 +14,7 @@ class Glew_Service_Model_Types_Customers
|
|
14 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
15 |
|
16 |
$collection = Mage::getModel('customer/customer')->getCollection()
|
17 |
-
->addAttributeToFilter(
|
18 |
} else {
|
19 |
$collection = Mage::getModel('customer/customer')->getCollection();
|
20 |
}
|
@@ -35,8 +35,8 @@ class Glew_Service_Model_Types_Customers
|
|
35 |
}
|
36 |
}
|
37 |
}
|
38 |
-
|
39 |
return $this;
|
40 |
}
|
41 |
-
|
42 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Glew_Service_Model_Types_Customers
|
4 |
{
|
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();
|
14 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
15 |
|
16 |
$collection = Mage::getModel('customer/customer')->getCollection()
|
17 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
18 |
} else {
|
19 |
$collection = Mage::getModel('customer/customer')->getCollection();
|
20 |
}
|
35 |
}
|
36 |
}
|
37 |
}
|
38 |
+
|
39 |
return $this;
|
40 |
}
|
41 |
+
|
42 |
}
|
app/code/community/Glew/Service/Model/Types/Extensions.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Glew_Service_Model_Types_Extensions
|
4 |
{
|
5 |
-
public $extensions;
|
6 |
private $pageNum;
|
7 |
-
|
8 |
-
public function load($pageSize, $pageNum, $sortDir)
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
$config = $helper->getConfig();
|
@@ -19,8 +19,8 @@ class Glew_Service_Model_Types_Extensions
|
|
19 |
$this->extensions[] = $model;
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
return $this;
|
24 |
}
|
25 |
-
|
26 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Glew_Service_Model_Types_Extensions
|
4 |
{
|
5 |
+
public $extensions = array();
|
6 |
private $pageNum;
|
7 |
+
|
8 |
+
public function load($pageSize, $pageNum, $sortDir, $filterBy)
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
$config = $helper->getConfig();
|
19 |
$this->extensions[] = $model;
|
20 |
}
|
21 |
}
|
22 |
+
|
23 |
return $this;
|
24 |
}
|
25 |
+
|
26 |
}
|
app/code/community/Glew/Service/Model/Types/Inventory.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_Inventory
|
4 |
{
|
5 |
-
public $inventory;
|
6 |
private $pageNum;
|
7 |
|
8 |
-
public function load($pageSize, $pageNum, $sortDir)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
$inventory = Mage::getModel('cataloginventory/stock_item')->getCollection();
|
2 |
|
3 |
class Glew_Service_Model_Types_Inventory
|
4 |
{
|
5 |
+
public $inventory = array();
|
6 |
private $pageNum;
|
7 |
|
8 |
+
public function load($pageSize, $pageNum, $sortDir, $filterBy)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
$inventory = Mage::getModel('cataloginventory/stock_item')->getCollection();
|
app/code/community/Glew/Service/Model/Types/Order.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
-
class Glew_Service_Model_Types_Order
|
4 |
{
|
5 |
public function parse($order)
|
6 |
{
|
@@ -12,6 +12,7 @@ class Glew_Service_Model_Types_Order
|
|
12 |
$customerGroup = Mage::getModel('customer/group')->load( $order->getCustomerGroupId() );
|
13 |
$this->customer_group = $customerGroup->getCode();
|
14 |
$this->created_at = $order->getCreatedAt();
|
|
|
15 |
$this->state = $order->getState();
|
16 |
$this->status = $order->getStatus();
|
17 |
$this->customer_is_guest = $order->getCustomerIsGuest();
|
@@ -23,14 +24,14 @@ class Glew_Service_Model_Types_Order
|
|
23 |
$this->shipping_tax = round($order->getShippingTaxAmount(), 2);
|
24 |
$this->shipping_description = $order->getShippingDescription();
|
25 |
$this->payment_method = $order->getPayment()->getMethodInstance()->getTitle();
|
26 |
-
|
27 |
$this->discount_amount = round($order->getDiscountAmount(), 2);
|
28 |
$this->discount_description = $order->getDiscountDescription();
|
29 |
$this->weight = $order->getWeight();
|
30 |
$this->remote_ip = $order->getRemoteIp();
|
31 |
$this->store = $order->getStore()->getCode();
|
32 |
-
|
33 |
return $this;
|
34 |
}
|
35 |
-
|
36 |
}
|
1 |
+
<?php
|
2 |
|
3 |
+
class Glew_Service_Model_Types_Order
|
4 |
{
|
5 |
public function parse($order)
|
6 |
{
|
12 |
$customerGroup = Mage::getModel('customer/group')->load( $order->getCustomerGroupId() );
|
13 |
$this->customer_group = $customerGroup->getCode();
|
14 |
$this->created_at = $order->getCreatedAt();
|
15 |
+
$this->updated_at = $order->getUpdatedAt();
|
16 |
$this->state = $order->getState();
|
17 |
$this->status = $order->getStatus();
|
18 |
$this->customer_is_guest = $order->getCustomerIsGuest();
|
24 |
$this->shipping_tax = round($order->getShippingTaxAmount(), 2);
|
25 |
$this->shipping_description = $order->getShippingDescription();
|
26 |
$this->payment_method = $order->getPayment()->getMethodInstance()->getTitle();
|
27 |
+
|
28 |
$this->discount_amount = round($order->getDiscountAmount(), 2);
|
29 |
$this->discount_description = $order->getDiscountDescription();
|
30 |
$this->weight = $order->getWeight();
|
31 |
$this->remote_ip = $order->getRemoteIp();
|
32 |
$this->store = $order->getStore()->getCode();
|
33 |
+
|
34 |
return $this;
|
35 |
}
|
36 |
+
|
37 |
}
|
app/code/community/Glew/Service/Model/Types/OrderItems.php
CHANGED
@@ -1,47 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Glew_Service_Model_Types_OrderItems
|
4 |
-
{
|
5 |
-
public $orderItems;
|
6 |
-
private $pageNum;
|
7 |
-
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
-
{
|
10 |
-
$helper = Mage::helper('glew');
|
11 |
-
$config = $helper->getConfig();
|
12 |
-
$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'cost');
|
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 |
-
|
17 |
-
$collection = Mage::getModel('sales/order_item')->getCollection()
|
18 |
-
->addAttributeToFilter(
|
19 |
-
} else {
|
20 |
-
$collection = Mage::getModel('sales/order_item')->getCollection();
|
21 |
-
}
|
22 |
-
$collection->getSelect()->joinLeft(
|
23 |
-
array('cost' => 'catalog_product_entity_decimal'),
|
24 |
-
"main_table.product_id = cost.entity_id AND cost.attribute_id = {$attribute->getId()}",
|
25 |
-
array('cost' => 'value')
|
26 |
-
);
|
27 |
-
$collection->setOrder('created_at', $sortDir);
|
28 |
-
$this->pageNum = $pageNum;
|
29 |
-
$collection->setCurPage($pageNum);
|
30 |
-
$collection->setPageSize($pageSize);
|
31 |
-
if($collection->getLastPageNumber() < $pageNum){
|
32 |
-
return $this;
|
33 |
-
}
|
34 |
-
|
35 |
-
foreach($collection as $orderItem) {
|
36 |
-
if ($orderItem && $orderItem->getId()) {
|
37 |
-
$model = Mage::getModel('glew/types_orderItem')->parse($orderItem);
|
38 |
-
if ($model) {
|
39 |
-
$this->orderItems[] = $model;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
return $this;
|
45 |
-
}
|
46 |
-
|
47 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Glew_Service_Model_Types_OrderItems
|
4 |
+
{
|
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();
|
12 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'cost');
|
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 |
+
|
17 |
+
$collection = Mage::getModel('sales/order_item')->getCollection()
|
18 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
19 |
+
} else {
|
20 |
+
$collection = Mage::getModel('sales/order_item')->getCollection();
|
21 |
+
}
|
22 |
+
$collection->getSelect()->joinLeft(
|
23 |
+
array('cost' => 'catalog_product_entity_decimal'),
|
24 |
+
"main_table.product_id = cost.entity_id AND cost.attribute_id = {$attribute->getId()}",
|
25 |
+
array('cost' => 'value')
|
26 |
+
);
|
27 |
+
$collection->setOrder('created_at', $sortDir);
|
28 |
+
$this->pageNum = $pageNum;
|
29 |
+
$collection->setCurPage($pageNum);
|
30 |
+
$collection->setPageSize($pageSize);
|
31 |
+
if($collection->getLastPageNumber() < $pageNum){
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
foreach($collection as $orderItem) {
|
36 |
+
if ($orderItem && $orderItem->getId()) {
|
37 |
+
$model = Mage::getModel('glew/types_orderItem')->parse($orderItem);
|
38 |
+
if ($model) {
|
39 |
+
$this->orderItems[] = $model;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Glew/Service/Model/Types/Orders.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_Orders
|
4 |
{
|
5 |
-
public $orders;
|
6 |
private $pageNum;
|
7 |
-
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
$config = $helper->getConfig();
|
@@ -14,7 +14,7 @@ class Glew_Service_Model_Types_Orders
|
|
14 |
$from = date('Y-m-d 00:00:00', strtotime($startDate));
|
15 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
16 |
$collection = Mage::getModel('sales/order')->getCollection()
|
17 |
-
->addAttributeToFilter(
|
18 |
} else {
|
19 |
$collection = Mage::getModel('sales/order')->getCollection();
|
20 |
}
|
@@ -34,8 +34,8 @@ class Glew_Service_Model_Types_Orders
|
|
34 |
}
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
return $this;
|
39 |
}
|
40 |
-
|
41 |
}
|
2 |
|
3 |
class Glew_Service_Model_Types_Orders
|
4 |
{
|
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();
|
14 |
$from = date('Y-m-d 00:00:00', strtotime($startDate));
|
15 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
16 |
$collection = Mage::getModel('sales/order')->getCollection()
|
17 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
18 |
} else {
|
19 |
$collection = Mage::getModel('sales/order')->getCollection();
|
20 |
}
|
34 |
}
|
35 |
}
|
36 |
}
|
37 |
+
|
38 |
return $this;
|
39 |
}
|
40 |
+
|
41 |
}
|
app/code/community/Glew/Service/Model/Types/Product.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
class Glew_Service_Model_Types_Product
|
4 |
{
|
@@ -19,7 +19,7 @@ class Glew_Service_Model_Types_Product
|
|
19 |
continue;
|
20 |
}
|
21 |
|
22 |
-
if($field == 'image') {
|
23 |
$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $value;
|
24 |
$this->$field = $imageUrl;
|
25 |
continue;
|
1 |
+
<?php
|
2 |
|
3 |
class Glew_Service_Model_Types_Product
|
4 |
{
|
19 |
continue;
|
20 |
}
|
21 |
|
22 |
+
if($field == 'image' && $value) {
|
23 |
$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $value;
|
24 |
$this->$field = $imageUrl;
|
25 |
continue;
|
app/code/community/Glew/Service/Model/Types/ProductAlerts.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_ProductAlerts
|
4 |
{
|
5 |
-
public $alerts;
|
6 |
private $pageNum;
|
7 |
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
2 |
|
3 |
class Glew_Service_Model_Types_ProductAlerts
|
4 |
{
|
5 |
+
public $alerts = array();
|
6 |
private $pageNum;
|
7 |
|
8 |
+
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
app/code/community/Glew/Service/Model/Types/Products.php
CHANGED
@@ -2,11 +2,11 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_Products
|
4 |
{
|
5 |
-
public $products;
|
6 |
private $productAttributes = array();
|
7 |
private $pageNum;
|
8 |
|
9 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
10 |
{
|
11 |
$config = Mage::helper('glew')->getConfig();
|
12 |
$this->_getProductAttribtues();
|
@@ -15,7 +15,7 @@ class Glew_Service_Model_Types_Products
|
|
15 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
16 |
|
17 |
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')
|
18 |
-
->addAttributeToFilter(
|
19 |
} else {
|
20 |
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
|
21 |
}
|
@@ -23,11 +23,11 @@ class Glew_Service_Model_Types_Products
|
|
23 |
$products->setOrder('updated_at', $sortDir);
|
24 |
$products->setCurPage($pageNum);
|
25 |
$products->setPageSize($pageSize);
|
26 |
-
|
27 |
if($products->getLastPageNumber() < $pageNum){
|
28 |
return $this;
|
29 |
}
|
30 |
-
|
31 |
foreach ($products as $product){
|
32 |
$productId = $product->getId();
|
33 |
$model = Mage::getModel('glew/types_product')->parse($productId, $this->productAttributes);
|
@@ -36,7 +36,7 @@ class Glew_Service_Model_Types_Products
|
|
36 |
$model->up_sell_products = $this->_getUpSellProducts($product);
|
37 |
$model->related_products = $this->_getRelatedProducts($product);
|
38 |
$this->products[] = $model;
|
39 |
-
}
|
40 |
}
|
41 |
return $this;
|
42 |
}
|
@@ -57,8 +57,7 @@ class Glew_Service_Model_Types_Products
|
|
57 |
protected function _getCrossSellProducts($product)
|
58 |
{
|
59 |
$productArray = array();
|
60 |
-
$collection = $product->getCrossSellProductCollection()
|
61 |
-
->addAttributetoSort('position', 'asc');
|
62 |
if($collection) {
|
63 |
foreach($collection as $item) {
|
64 |
$productArray[] = $item->getId();
|
@@ -78,7 +77,7 @@ class Glew_Service_Model_Types_Products
|
|
78 |
}
|
79 |
return $productArray;
|
80 |
}
|
81 |
-
|
82 |
protected function _getRelatedProducts($product)
|
83 |
{
|
84 |
$productArray = array();
|
2 |
|
3 |
class Glew_Service_Model_Types_Products
|
4 |
{
|
5 |
+
public $products = array();
|
6 |
private $productAttributes = array();
|
7 |
private $pageNum;
|
8 |
|
9 |
+
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
|
10 |
{
|
11 |
$config = Mage::helper('glew')->getConfig();
|
12 |
$this->_getProductAttribtues();
|
15 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
16 |
|
17 |
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')
|
18 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
19 |
} else {
|
20 |
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
|
21 |
}
|
23 |
$products->setOrder('updated_at', $sortDir);
|
24 |
$products->setCurPage($pageNum);
|
25 |
$products->setPageSize($pageSize);
|
26 |
+
|
27 |
if($products->getLastPageNumber() < $pageNum){
|
28 |
return $this;
|
29 |
}
|
30 |
+
|
31 |
foreach ($products as $product){
|
32 |
$productId = $product->getId();
|
33 |
$model = Mage::getModel('glew/types_product')->parse($productId, $this->productAttributes);
|
36 |
$model->up_sell_products = $this->_getUpSellProducts($product);
|
37 |
$model->related_products = $this->_getRelatedProducts($product);
|
38 |
$this->products[] = $model;
|
39 |
+
}
|
40 |
}
|
41 |
return $this;
|
42 |
}
|
57 |
protected function _getCrossSellProducts($product)
|
58 |
{
|
59 |
$productArray = array();
|
60 |
+
$collection = $product->getCrossSellProductCollection();
|
|
|
61 |
if($collection) {
|
62 |
foreach($collection as $item) {
|
63 |
$productArray[] = $item->getId();
|
77 |
}
|
78 |
return $productArray;
|
79 |
}
|
80 |
+
|
81 |
protected function _getRelatedProducts($product)
|
82 |
{
|
83 |
$productArray = array();
|
app/code/community/Glew/Service/Model/Types/RefundItems.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_RefundItems
|
4 |
{
|
5 |
-
public $refundItems;
|
6 |
private $pageNum;
|
7 |
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
@@ -13,7 +13,7 @@ class Glew_Service_Model_Types_RefundItems
|
|
13 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
14 |
|
15 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
|
16 |
-
->addAttributeToFilter(
|
17 |
} else {
|
18 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
|
19 |
}
|
@@ -22,18 +22,18 @@ class Glew_Service_Model_Types_RefundItems
|
|
22 |
$this->pageNum = $pageNum;
|
23 |
$refunds->setCurPage($pageNum);
|
24 |
$refunds->setPageSize($pageSize);
|
25 |
-
|
26 |
if($refunds->getLastPageNumber() < $pageNum){
|
27 |
return $this;
|
28 |
}
|
29 |
-
|
30 |
foreach ($refunds as $refund){
|
31 |
$model = Mage::getModel('glew/types_refundItem')->parse($refund);
|
32 |
if ($model) {
|
33 |
$this->refundItems[] = $model;
|
34 |
-
}
|
35 |
}
|
36 |
return $this;
|
37 |
}
|
38 |
-
|
39 |
}
|
2 |
|
3 |
class Glew_Service_Model_Types_RefundItems
|
4 |
{
|
5 |
+
public $refundItems = array();
|
6 |
private $pageNum;
|
7 |
|
8 |
+
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
13 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
14 |
|
15 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
|
16 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
17 |
} else {
|
18 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
|
19 |
}
|
22 |
$this->pageNum = $pageNum;
|
23 |
$refunds->setCurPage($pageNum);
|
24 |
$refunds->setPageSize($pageSize);
|
25 |
+
|
26 |
if($refunds->getLastPageNumber() < $pageNum){
|
27 |
return $this;
|
28 |
}
|
29 |
+
|
30 |
foreach ($refunds as $refund){
|
31 |
$model = Mage::getModel('glew/types_refundItem')->parse($refund);
|
32 |
if ($model) {
|
33 |
$this->refundItems[] = $model;
|
34 |
+
}
|
35 |
}
|
36 |
return $this;
|
37 |
}
|
38 |
+
|
39 |
}
|
app/code/community/Glew/Service/Model/Types/Refunds.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_Refunds
|
4 |
{
|
5 |
-
public $refunds;
|
6 |
private $pageNum;
|
7 |
|
8 |
-
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
@@ -13,7 +13,7 @@ class Glew_Service_Model_Types_Refunds
|
|
13 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
14 |
|
15 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
|
16 |
-
->addAttributeToFilter(
|
17 |
} else {
|
18 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
|
19 |
}
|
@@ -21,18 +21,18 @@ class Glew_Service_Model_Types_Refunds
|
|
21 |
$this->pageNum = $pageNum;
|
22 |
$refunds->setCurPage($pageNum);
|
23 |
$refunds->setPageSize($pageSize);
|
24 |
-
|
25 |
if($refunds->getLastPageNumber() < $pageNum){
|
26 |
return $this;
|
27 |
}
|
28 |
-
|
29 |
foreach ($refunds as $refund){
|
30 |
$model = Mage::getModel('glew/types_refund')->parse($refund);
|
31 |
if ($model) {
|
32 |
$this->refunds[] = $model;
|
33 |
-
}
|
34 |
}
|
35 |
return $this;
|
36 |
}
|
37 |
-
|
38 |
}
|
2 |
|
3 |
class Glew_Service_Model_Types_Refunds
|
4 |
{
|
5 |
+
public $refunds = array();
|
6 |
private $pageNum;
|
7 |
|
8 |
+
public function load($pageSize, $pageNum, $startDate = null, $endDate = null, $sortDir, $filterBy)
|
9 |
{
|
10 |
$config = Mage::helper('glew')->getConfig();
|
11 |
if($startDate && $endDate) {
|
13 |
$to = date('Y-m-d 23:59:59', strtotime($endDate));
|
14 |
|
15 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
|
16 |
+
->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
|
17 |
} else {
|
18 |
$refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
|
19 |
}
|
21 |
$this->pageNum = $pageNum;
|
22 |
$refunds->setCurPage($pageNum);
|
23 |
$refunds->setPageSize($pageSize);
|
24 |
+
|
25 |
if($refunds->getLastPageNumber() < $pageNum){
|
26 |
return $this;
|
27 |
}
|
28 |
+
|
29 |
foreach ($refunds as $refund){
|
30 |
$model = Mage::getModel('glew/types_refund')->parse($refund);
|
31 |
if ($model) {
|
32 |
$this->refunds[] = $model;
|
33 |
+
}
|
34 |
}
|
35 |
return $this;
|
36 |
}
|
37 |
+
|
38 |
}
|
app/code/community/Glew/Service/Model/Types/Stores.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Glew_Service_Model_Types_Stores
|
4 |
{
|
5 |
-
public $stores;
|
6 |
private $pageNum;
|
7 |
-
|
8 |
public function load()
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
-
$config = $helper->getConfig();
|
12 |
|
13 |
$stores = Mage::app()->getStores();
|
14 |
foreach ($stores as $store){
|
15 |
$model = Mage::getModel('glew/types_store')->parse($store);
|
16 |
if ($model) {
|
17 |
-
$this->stores[] = $model;
|
18 |
-
}
|
19 |
}
|
20 |
return $this;
|
21 |
}
|
22 |
-
|
23 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Glew_Service_Model_Types_Stores
|
4 |
{
|
5 |
+
public $stores = array();
|
6 |
private $pageNum;
|
7 |
+
|
8 |
public function load()
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
+
$config = $helper->getConfig();
|
12 |
|
13 |
$stores = Mage::app()->getStores();
|
14 |
foreach ($stores as $store){
|
15 |
$model = Mage::getModel('glew/types_store')->parse($store);
|
16 |
if ($model) {
|
17 |
+
$this->stores[] = $model;
|
18 |
+
}
|
19 |
}
|
20 |
return $this;
|
21 |
}
|
22 |
+
|
23 |
}
|
app/code/community/Glew/Service/Model/Types/Subscribers.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
class Glew_Service_Model_Types_Subscribers
|
4 |
{
|
5 |
-
public $subscribers;
|
6 |
private $pageNum;
|
7 |
-
|
8 |
-
public function load($pageSize, $pageNum, $sortDir)
|
9 |
{
|
10 |
$helper = Mage::helper('glew');
|
11 |
$config = $helper->getConfig();
|
@@ -14,18 +14,18 @@ class Glew_Service_Model_Types_Subscribers
|
|
14 |
$subscribers->setOrder('subscriber_id', $sortDir);
|
15 |
$subscribers->setCurPage($pageNum);
|
16 |
$subscribers->setPageSize($pageSize);
|
17 |
-
|
18 |
if($subscribers->getLastPageNumber() < $pageNum){
|
19 |
return $this;
|
20 |
}
|
21 |
-
|
22 |
foreach ($subscribers as $subscriber){
|
23 |
$model = Mage::getModel('glew/types_subscriber')->parse($subscriber);
|
24 |
if ($model) {
|
25 |
-
$this->subscribers[] = $model;
|
26 |
-
}
|
27 |
}
|
28 |
return $this;
|
29 |
}
|
30 |
-
|
31 |
}
|
2 |
|
3 |
class Glew_Service_Model_Types_Subscribers
|
4 |
{
|
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();
|
14 |
$subscribers->setOrder('subscriber_id', $sortDir);
|
15 |
$subscribers->setCurPage($pageNum);
|
16 |
$subscribers->setPageSize($pageSize);
|
17 |
+
|
18 |
if($subscribers->getLastPageNumber() < $pageNum){
|
19 |
return $this;
|
20 |
}
|
21 |
+
|
22 |
foreach ($subscribers as $subscriber){
|
23 |
$model = Mage::getModel('glew/types_subscriber')->parse($subscriber);
|
24 |
if ($model) {
|
25 |
+
$this->subscribers[] = $model;
|
26 |
+
}
|
27 |
}
|
28 |
return $this;
|
29 |
}
|
30 |
+
|
31 |
}
|
app/code/community/Glew/Service/controllers/ModuleController.php
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
4 |
{
|
5 |
protected $_helper = null;
|
6 |
protected $_config = null;
|
7 |
protected $_pageSize = null;
|
8 |
-
protected $_pageNum =
|
9 |
protected $_startDate = null;
|
10 |
protected $_endDate = null;
|
11 |
protected $_sortDir = 'asc';
|
|
|
12 |
|
13 |
protected function _construct()
|
14 |
{
|
@@ -22,9 +23,19 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
22 |
}
|
23 |
if (!!$startDate = $this->getRequest()->getParam('start_date')) {
|
24 |
$this->_startDate = $startDate;
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
if (!!$sortDir = $this->getRequest()->getParam('sort_dir')) {
|
30 |
$this->_sortDir = $sortDir;
|
@@ -39,41 +50,41 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
39 |
{
|
40 |
try {
|
41 |
$this->_initRequest();
|
42 |
-
$collection = Mage::getModel('glew/types_abandonedCarts')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
43 |
$this->_sendResponse($collection);
|
44 |
} catch(Exception $e) {
|
45 |
$this->_helper->logException($e, 'abandonedCarts');
|
46 |
}
|
47 |
}
|
48 |
-
|
49 |
public function customersAction()
|
50 |
{
|
51 |
try {
|
52 |
$this->_initRequest();
|
53 |
-
$collection = Mage::getModel('glew/types_customers')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
54 |
$this->_sendResponse($collection);
|
55 |
} catch(Exception $e) {
|
56 |
$this->_helper->logException($e, 'customers');
|
57 |
}
|
58 |
}
|
59 |
|
60 |
-
|
61 |
public function ordersAction()
|
62 |
{
|
63 |
try {
|
64 |
$this->_initRequest();
|
65 |
-
$collection = Mage::getModel('glew/types_orders')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
66 |
$this->_sendResponse($collection);
|
67 |
} catch(Exception $e) {
|
68 |
$this->_helper->logException($e, 'orders');
|
69 |
}
|
70 |
}
|
71 |
-
|
72 |
public function order_itemsAction()
|
73 |
{
|
74 |
try {
|
75 |
$this->_initRequest();
|
76 |
-
$collection = Mage::getModel('glew/types_orderItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
77 |
$this->_sendResponse($collection);
|
78 |
} catch(Exception $e) {
|
79 |
$this->_helper->logException($e, 'orderItems');
|
@@ -95,7 +106,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
95 |
{
|
96 |
try {
|
97 |
$this->_initRequest();
|
98 |
-
$collection = Mage::getModel('glew/types_subscribers')->load($this->_pageSize, $this->_pageNum, $this->_sortDir);
|
99 |
$this->_sendResponse($collection);
|
100 |
} catch(Exception $e) {
|
101 |
$this->_helper->logException($e, 'subscribers');
|
@@ -106,7 +117,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
106 |
{
|
107 |
try {
|
108 |
$this->_initRequest();
|
109 |
-
$collection = Mage::getModel('glew/types_products')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
110 |
$this->_sendResponse($collection);
|
111 |
} catch(Exception $e) {
|
112 |
$this->_helper->logException($e, 'products');
|
@@ -117,7 +128,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
117 |
{
|
118 |
try {
|
119 |
$this->_initRequest();
|
120 |
-
$collection = Mage::getModel('glew/types_productAlerts')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
121 |
$this->_sendResponse($collection);
|
122 |
} catch(Exception $e) {
|
123 |
$this->_helper->logException($e, 'productAlerts');
|
@@ -128,7 +139,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
128 |
{
|
129 |
try {
|
130 |
$this->_initRequest();
|
131 |
-
$collection = Mage::getModel('glew/types_categories')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
132 |
$this->_sendResponse($collection);
|
133 |
} catch(Exception $e) {
|
134 |
$this->_helper->logException($e, 'categories');
|
@@ -138,7 +149,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
138 |
public function inventoryAction() {
|
139 |
try {
|
140 |
$this->_initRequest();
|
141 |
-
$collection = Mage::getModel('glew/types_inventory')->load($this->_pageSize, $this->_pageNum, $this->_sortDir);
|
142 |
$this->_sendResponse($collection);
|
143 |
} catch(Exception $e) {
|
144 |
$this->_helper->logException($e, 'inventory');
|
@@ -146,12 +157,14 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
146 |
}
|
147 |
|
148 |
|
149 |
-
|
150 |
public function versionAction()
|
151 |
{
|
152 |
try {
|
153 |
$obj = new stdClass();
|
154 |
-
$obj->
|
|
|
|
|
155 |
$this->_sendResponse($obj);
|
156 |
} catch(Exception $ex) {
|
157 |
$this->_helper->logException($ex, 'version');
|
@@ -162,7 +175,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
162 |
{
|
163 |
try {
|
164 |
$this->_initRequest();
|
165 |
-
$collection = Mage::getModel('glew/types_extensions')->load($this->_pageSize, $this->_pageNum, $this->_sortDir);
|
166 |
$this->_sendResponse($collection);
|
167 |
} catch(Exception $e) {
|
168 |
$this->_helper->logException($e, 'extensions');
|
@@ -173,7 +186,7 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
173 |
{
|
174 |
try {
|
175 |
$this->_initRequest();
|
176 |
-
$collection = Mage::getModel('glew/types_refundItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
177 |
$this->_sendResponse($collection);
|
178 |
} catch(Exception $e) {
|
179 |
$this->_helper->logException($e, 'refund items');
|
@@ -184,44 +197,50 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
|
184 |
{
|
185 |
try {
|
186 |
$this->_initRequest();
|
187 |
-
$collection = Mage::getModel('glew/types_refunds')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir);
|
188 |
$this->_sendResponse($collection);
|
189 |
} catch(Exception $e) {
|
190 |
$this->_helper->logException($e, 'refunds');
|
191 |
}
|
192 |
}
|
193 |
-
|
194 |
|
195 |
protected function _sendResponse($items)
|
196 |
{
|
197 |
$this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
|
198 |
$this->getResponse()->setBody(json_encode($items));
|
199 |
}
|
200 |
-
|
201 |
private function _initRequest()
|
202 |
{
|
203 |
-
if
|
204 |
$this->_reject();
|
205 |
return true;
|
206 |
}
|
207 |
|
208 |
-
if
|
209 |
$setup = Mage::getModel('glew/resource_mysql4_setup');
|
210 |
-
$setup->createSecurityToken();
|
|
|
|
|
211 |
}
|
212 |
|
213 |
-
$authToken = $_SERVER['
|
|
|
|
|
|
|
|
|
214 |
|
215 |
-
if
|
216 |
-
Mage::log('Glew feed request with invalid security token: ' . $this->getRequest()->getParam('token'));
|
217 |
$this->_reject();
|
218 |
}
|
219 |
}
|
220 |
-
|
221 |
private function _reject()
|
222 |
{
|
223 |
$this->getResponse()->setHttpResponseCode(401)->setBody('Invalid security token or module disabled');
|
224 |
throw new Exception('Invalid security token or module disabled');
|
225 |
}
|
226 |
-
|
227 |
}
|
1 |
+
<?php
|
2 |
|
3 |
class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
|
4 |
{
|
5 |
protected $_helper = null;
|
6 |
protected $_config = null;
|
7 |
protected $_pageSize = null;
|
8 |
+
protected $_pageNum = 0;
|
9 |
protected $_startDate = null;
|
10 |
protected $_endDate = null;
|
11 |
protected $_sortDir = 'asc';
|
12 |
+
protected $_filterField = 'created_at';
|
13 |
|
14 |
protected function _construct()
|
15 |
{
|
23 |
}
|
24 |
if (!!$startDate = $this->getRequest()->getParam('start_date')) {
|
25 |
$this->_startDate = $startDate;
|
26 |
+
if (!!$endDate = $this->getRequest()->getParam('end_date')) {
|
27 |
+
$this->_endDate = $endDate;
|
28 |
+
} else {
|
29 |
+
$this->_endDate = date("Y-m-d");
|
30 |
+
}
|
31 |
+
} elseif (!!$updatedStartDate = $this->getRequest()->getParam('updated_start_date')) {
|
32 |
+
$this->_filterField = 'updated_at';
|
33 |
+
$this->_startDate = $updatedStartDate;
|
34 |
+
if (!!$updatedEndDate = $this->getRequest()->getParam('updated_end_date')) {
|
35 |
+
$this->_endDate = $updatedEndDate;
|
36 |
+
} else {
|
37 |
+
$this->_endDate = date("Y-m-d");
|
38 |
+
}
|
39 |
}
|
40 |
if (!!$sortDir = $this->getRequest()->getParam('sort_dir')) {
|
41 |
$this->_sortDir = $sortDir;
|
50 |
{
|
51 |
try {
|
52 |
$this->_initRequest();
|
53 |
+
$collection = Mage::getModel('glew/types_abandonedCarts')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
54 |
$this->_sendResponse($collection);
|
55 |
} catch(Exception $e) {
|
56 |
$this->_helper->logException($e, 'abandonedCarts');
|
57 |
}
|
58 |
}
|
59 |
+
|
60 |
public function customersAction()
|
61 |
{
|
62 |
try {
|
63 |
$this->_initRequest();
|
64 |
+
$collection = Mage::getModel('glew/types_customers')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
65 |
$this->_sendResponse($collection);
|
66 |
} catch(Exception $e) {
|
67 |
$this->_helper->logException($e, 'customers');
|
68 |
}
|
69 |
}
|
70 |
|
71 |
+
|
72 |
public function ordersAction()
|
73 |
{
|
74 |
try {
|
75 |
$this->_initRequest();
|
76 |
+
$collection = Mage::getModel('glew/types_orders')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
77 |
$this->_sendResponse($collection);
|
78 |
} catch(Exception $e) {
|
79 |
$this->_helper->logException($e, 'orders');
|
80 |
}
|
81 |
}
|
82 |
+
|
83 |
public function order_itemsAction()
|
84 |
{
|
85 |
try {
|
86 |
$this->_initRequest();
|
87 |
+
$collection = Mage::getModel('glew/types_orderItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
88 |
$this->_sendResponse($collection);
|
89 |
} catch(Exception $e) {
|
90 |
$this->_helper->logException($e, 'orderItems');
|
106 |
{
|
107 |
try {
|
108 |
$this->_initRequest();
|
109 |
+
$collection = Mage::getModel('glew/types_subscribers')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
|
110 |
$this->_sendResponse($collection);
|
111 |
} catch(Exception $e) {
|
112 |
$this->_helper->logException($e, 'subscribers');
|
117 |
{
|
118 |
try {
|
119 |
$this->_initRequest();
|
120 |
+
$collection = Mage::getModel('glew/types_products')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
121 |
$this->_sendResponse($collection);
|
122 |
} catch(Exception $e) {
|
123 |
$this->_helper->logException($e, 'products');
|
128 |
{
|
129 |
try {
|
130 |
$this->_initRequest();
|
131 |
+
$collection = Mage::getModel('glew/types_productAlerts')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
132 |
$this->_sendResponse($collection);
|
133 |
} catch(Exception $e) {
|
134 |
$this->_helper->logException($e, 'productAlerts');
|
139 |
{
|
140 |
try {
|
141 |
$this->_initRequest();
|
142 |
+
$collection = Mage::getModel('glew/types_categories')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
143 |
$this->_sendResponse($collection);
|
144 |
} catch(Exception $e) {
|
145 |
$this->_helper->logException($e, 'categories');
|
149 |
public function inventoryAction() {
|
150 |
try {
|
151 |
$this->_initRequest();
|
152 |
+
$collection = Mage::getModel('glew/types_inventory')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
|
153 |
$this->_sendResponse($collection);
|
154 |
} catch(Exception $e) {
|
155 |
$this->_helper->logException($e, 'inventory');
|
157 |
}
|
158 |
|
159 |
|
160 |
+
|
161 |
public function versionAction()
|
162 |
{
|
163 |
try {
|
164 |
$obj = new stdClass();
|
165 |
+
$obj->glewPluginVersion = (string)Mage::getConfig()->getNode()->modules->Glew_Service->version;
|
166 |
+
$obj->magentoVersion = (string)Mage::getVersion();
|
167 |
+
$obj->phpVersion = (string)phpversion();
|
168 |
$this->_sendResponse($obj);
|
169 |
} catch(Exception $ex) {
|
170 |
$this->_helper->logException($ex, 'version');
|
175 |
{
|
176 |
try {
|
177 |
$this->_initRequest();
|
178 |
+
$collection = Mage::getModel('glew/types_extensions')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
|
179 |
$this->_sendResponse($collection);
|
180 |
} catch(Exception $e) {
|
181 |
$this->_helper->logException($e, 'extensions');
|
186 |
{
|
187 |
try {
|
188 |
$this->_initRequest();
|
189 |
+
$collection = Mage::getModel('glew/types_refundItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
190 |
$this->_sendResponse($collection);
|
191 |
} catch(Exception $e) {
|
192 |
$this->_helper->logException($e, 'refund items');
|
197 |
{
|
198 |
try {
|
199 |
$this->_initRequest();
|
200 |
+
$collection = Mage::getModel('glew/types_refunds')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
|
201 |
$this->_sendResponse($collection);
|
202 |
} catch(Exception $e) {
|
203 |
$this->_helper->logException($e, 'refunds');
|
204 |
}
|
205 |
}
|
206 |
+
|
207 |
|
208 |
protected function _sendResponse($items)
|
209 |
{
|
210 |
$this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
|
211 |
$this->getResponse()->setBody(json_encode($items));
|
212 |
}
|
213 |
+
|
214 |
private function _initRequest()
|
215 |
{
|
216 |
+
if(!$this->_config['enabled']) {
|
217 |
$this->_reject();
|
218 |
return true;
|
219 |
}
|
220 |
|
221 |
+
if(!$this->_config['security_token']) {
|
222 |
$setup = Mage::getModel('glew/resource_mysql4_setup');
|
223 |
+
$token = $setup->createSecurityToken();
|
224 |
+
} else {
|
225 |
+
$token = $this->_config['security_token'];
|
226 |
}
|
227 |
|
228 |
+
$authToken = (isset($_SERVER['HTTP_X_GLEW_TOKEN']) ? $_SERVER['HTTP_X_GLEW_TOKEN'] : $_SERVER['X_GLEW_TOKEN']);
|
229 |
+
|
230 |
+
if(empty($authToken)) {
|
231 |
+
$this->_reject();
|
232 |
+
}
|
233 |
|
234 |
+
if(trim( $token ) != trim($authToken)) {
|
235 |
+
Mage::log('Glew feed request with invalid security token: ' . $this->getRequest()->getParam('token') . ' compared to stored token: ' . $token);
|
236 |
$this->_reject();
|
237 |
}
|
238 |
}
|
239 |
+
|
240 |
private function _reject()
|
241 |
{
|
242 |
$this->getResponse()->setHttpResponseCode(401)->setBody('Invalid security token or module disabled');
|
243 |
throw new Exception('Invalid security token or module disabled');
|
244 |
}
|
245 |
+
|
246 |
}
|
app/code/community/Glew/Service/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Glew_Service>
|
5 |
-
<version>
|
6 |
<depends>
|
7 |
<Mage_Shipping />
|
8 |
</depends>
|
@@ -61,11 +61,8 @@
|
|
61 |
</general>
|
62 |
</glew_settings>
|
63 |
</default>
|
64 |
-
|
65 |
<frontend>
|
66 |
-
<secure_url>
|
67 |
-
<glew>/glew/</glew>
|
68 |
-
</secure_url>
|
69 |
<routers>
|
70 |
<glew>
|
71 |
<use>standard</use>
|
@@ -76,7 +73,7 @@
|
|
76 |
</glew>
|
77 |
</routers>
|
78 |
</frontend>
|
79 |
-
|
80 |
<admin>
|
81 |
<routers>
|
82 |
<adminhtml>
|
@@ -113,7 +110,7 @@
|
|
113 |
</acl>
|
114 |
</adminhtml>
|
115 |
|
116 |
-
|
117 |
<menu>
|
118 |
<glew translate="title" module="glew">
|
119 |
<title>Glew</title>
|
@@ -132,4 +129,3 @@
|
|
132 |
</resources>
|
133 |
</acl>
|
134 |
</config>
|
135 |
-
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Glew_Service>
|
5 |
+
<version>1.0.5</version>
|
6 |
<depends>
|
7 |
<Mage_Shipping />
|
8 |
</depends>
|
61 |
</general>
|
62 |
</glew_settings>
|
63 |
</default>
|
64 |
+
|
65 |
<frontend>
|
|
|
|
|
|
|
66 |
<routers>
|
67 |
<glew>
|
68 |
<use>standard</use>
|
73 |
</glew>
|
74 |
</routers>
|
75 |
</frontend>
|
76 |
+
|
77 |
<admin>
|
78 |
<routers>
|
79 |
<adminhtml>
|
110 |
</acl>
|
111 |
</adminhtml>
|
112 |
|
113 |
+
|
114 |
<menu>
|
115 |
<glew translate="title" module="glew">
|
116 |
<title>Glew</title>
|
129 |
</resources>
|
130 |
</acl>
|
131 |
</config>
|
|
package.xml
CHANGED
@@ -1,18 +1,31 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Glew</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>Glew
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Glew</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Glew provides reporting, insights and predictive tools that enable growth and drive profitability.</summary>
|
10 |
+
<description>To put it simply, Glew translates data into decisions. We provide a comprehensive view of your store’s data, bringing together information that is difficult to collect, combine and analyze. This means you can understand key performance indicators across your business and maximize your store’s profitability. We know you want to keep growing; Glew wants to help get you there.
|
11 |
+

|
12 |
+
Glew empowers you with the ability to measure:
|
13 |
+

|
14 |
+
-New Customer Acquisition Cost
|
15 |
+
-Lifetime Value of a customer
|
16 |
+
-Profit Margin after advertising expenses
|
17 |
+
-Customer Purchase Frequency
|
18 |
+
-Lifetime-Value-based ROAS instead of transaction-based ROAS
|
19 |
+
-Value of your At Risk and Lost Customers
|
20 |
+
-Trending store performance on a daily, weekly, monthly, and yearly basis
|
21 |
+
-And more...
|
22 |
+

|
23 |
+
http://glew.io/</description>
|
24 |
+
<notes>-Couple enhancements to 1.0.0</notes>
|
25 |
+
<authors><author><name>Glew</name><user>jedyoung</user><email>jed.young@glew.io</email></author></authors>
|
26 |
+
<date>2015-10-16</date>
|
27 |
+
<time>15:09:41</time>
|
28 |
+
<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="cb7f32c9a9d9032d9af801834e4ed5af"/></dir></dir></dir><file name="SecretKey.php" hash="22ecb01340e09eec8708abccea746637"/></dir><dir name="Helper"><file name="Data.php" hash="29d28355f96e4ddc9a35ca320a297249"/></dir><dir name="Model"><file name="Glew.php" hash="66742d93d1fe3d0f56dc1d4e32eae93f"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="1d14cfc8543e118ba7420af63ee31762"/></dir></dir><dir name="Types"><file name="AbandonedCart.php" hash="ca99b85c3b2b93795013e1929a0d3613"/><file name="AbandonedCarts.php" hash="ef3a30f2a3d38bfd62fc77a2b23476ea"/><file name="Address.php" hash="dac4e96501d687ce8c84ddfcc18a8327"/><file name="Categories.php" hash="b01bd1e07f22e1774e7051897e931dac"/><file name="Category.php" hash="a75878be202411265d91a20dd4afa457"/><file name="Customer.php" hash="e1f2058d9358d89a48715f151ab45755"/><file name="Customers.php" hash="c932bc753514548798c3f3b5b3a652cb"/><file name="Extension.php" hash="3a0bc967154cfd1ac5e9534ae96921fc"/><file name="Extensions.php" hash="c3cb76d52ac1b1dbf92723bd10ebf752"/><file name="Inventory.php" hash="b982cc0e6d066a4ebc0059a887596626"/><file name="InventoryItem.php" hash="01403ce6dd1f0042654d0c8f0bb18e7a"/><file name="Order.php" hash="f17622408310699e6cbccbb4b02e1ac3"/><file name="OrderItem.php" hash="26158c6d23d695ed6cd377bdd12f544f"/><file name="OrderItems.php" hash="baa7f98e9895e118164c28a28e63d4de"/><file name="Orders.php" hash="289850161d53317c87d20b73bba21a2e"/><file name="Product.php" hash="188167c24400632bbd848f406d671125"/><file name="ProductAlert.php" hash="e7ca7668907dad5547d80ad581519e78"/><file name="ProductAlerts.php" hash="1cf09e9adef0f08a0bfcddc8372f6e80"/><file name="Products.php" hash="3279d1410b9918a51e4b2d1f20084ead"/><file name="Refund.php" hash="1b79b89a2ac66cc0dfb05e1f3100f98c"/><file name="RefundItem.php" hash="1d43007ec2bb990eb08b8d0a2812f4ca"/><file name="RefundItems.php" hash="6174242752705fbdf5283e39b3e3b6e9"/><file name="Refunds.php" hash="e35ea9d6570f2bb7bffe8977abe1ed19"/><file name="Store.php" hash="455923168b5d2550af6b862d776db3f2"/><file name="Stores.php" hash="f69cb94c13a8f85665a034b5dd581b90"/><file name="Subscriber.php" hash="727153725fc7be3fd093422d6a67dfa1"/><file name="Subscribers.php" hash="834e26d8aa73020819e46c930429c54c"/></dir></dir><dir name="controllers"><file name="ModuleController.php" hash="b4c5aabb0e6e6e89b71ad7ebe3de1ff2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d2d95c59dc81f92df0ed6adaba801a52"/><file name="config.xml" hash="50df81690d59a5e520a3b58fb40abccb"/><file name="system.xml" hash="07aa4da88108940bf267cb2abb854eab"/></dir><dir name="sql"><dir name="glew_setup"><file name="mysql4-install-0.0.2.php" hash="b403d80422a7f4d80957d0405d55e2d7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Glew_Service.xml" hash="db2470cc1c1c36b01cea61416a3f6f37"/></dir></target></contents>
|
29 |
<compatible/>
|
30 |
+
<dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php><package><name>Glew</name><channel>community</channel><min>1.5</min><max>1.9</max></package><extension><name>Core</name><min>5.0</min><max>6.0</max></extension></required></dependencies>
|
31 |
</package>
|