Glew - Version 1.0.16

Version Notes

Fixed issue with inventory levels and configurable products
Fixed issue with inventory for customers with multiple stores
Added ability to disable Glew in menu

Download this release

Release Info

Developer Glew
Extension Glew
Version 1.0.16
Comparing to
See all releases


Code changes from version 1.0.15 to 1.0.16

Files changed (38) hide show
  1. app/code/community/Glew/Service/Block/Adminhtml/Widget/Info/Info.php +4 -3
  2. app/code/community/Glew/Service/Block/SecretKey.php +2 -0
  3. app/code/community/Glew/Service/Helper/Data.php +80 -72
  4. app/code/community/Glew/Service/Model/Glew.php +2 -2
  5. app/code/community/Glew/Service/Model/Types/AbandonedCart.php +3 -4
  6. app/code/community/Glew/Service/Model/Types/AbandonedCarts.php +13 -13
  7. app/code/community/Glew/Service/Model/Types/Address.php +31 -30
  8. app/code/community/Glew/Service/Model/Types/Categories.php +12 -10
  9. app/code/community/Glew/Service/Model/Types/Category.php +2 -2
  10. app/code/community/Glew/Service/Model/Types/Customer.php +8 -8
  11. app/code/community/Glew/Service/Model/Types/Customers.php +6 -6
  12. app/code/community/Glew/Service/Model/Types/Extension.php +3 -3
  13. app/code/community/Glew/Service/Model/Types/Extensions.php +3 -3
  14. app/code/community/Glew/Service/Model/Types/Inventory.php +6 -5
  15. app/code/community/Glew/Service/Model/Types/InventoryItem.php +8 -9
  16. app/code/community/Glew/Service/Model/Types/Order.php +3 -3
  17. app/code/community/Glew/Service/Model/Types/OrderItem.php +39 -41
  18. app/code/community/Glew/Service/Model/Types/OrderItems.php +20 -7
  19. app/code/community/Glew/Service/Model/Types/Orders.php +6 -6
  20. app/code/community/Glew/Service/Model/Types/Product.php +6 -7
  21. app/code/community/Glew/Service/Model/Types/ProductAlert.php +4 -4
  22. app/code/community/Glew/Service/Model/Types/ProductAlerts.php +7 -6
  23. app/code/community/Glew/Service/Model/Types/Products.php +24 -18
  24. app/code/community/Glew/Service/Model/Types/Refund.php +3 -3
  25. app/code/community/Glew/Service/Model/Types/RefundItem.php +2 -2
  26. app/code/community/Glew/Service/Model/Types/RefundItems.php +11 -10
  27. app/code/community/Glew/Service/Model/Types/Refunds.php +11 -10
  28. app/code/community/Glew/Service/Model/Types/Store.php +6 -5
  29. app/code/community/Glew/Service/Model/Types/Stores.php +7 -6
  30. app/code/community/Glew/Service/Model/Types/Subscriber.php +6 -5
  31. app/code/community/Glew/Service/Model/Types/Subscribers.php +10 -9
  32. app/code/community/Glew/Service/controllers/ModuleController.php +51 -52
  33. app/code/community/Glew/Service/etc/adminhtml.xml +7 -3
  34. app/code/community/Glew/Service/etc/config.xml +114 -112
  35. app/code/community/Glew/Service/etc/system.xml +64 -57
  36. app/code/community/Glew/Service/sql/glew_setup/mysql4-install-1.0.0.php +5 -2
  37. app/etc/modules/Glew_Service.xml +0 -9
  38. package.xml +11 -6
app/code/community/Glew/Service/Block/Adminhtml/Widget/Info/Info.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
 
3
- class Glew_Service_Block_Adminhtml_Widget_Info_Info extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
4
-
5
  public function render(Varien_Data_Form_Element_Abstract $element)
6
  {
7
- $html = '<div style="background:url(\'http://glew.io/wp-content/uploads/2015/04/Glew-white_Artboard7.png\') no-repeat scroll 15px center #EAF0EE;background-size:160px;border:1px solid #CCCCCC;margin-bottom:10px;padding:10px 5px 5px 200px;">
8
  <h4>About Glew.&trade;</h4>
9
  <p>Glew.&trade; Empowers Marketers to Take Action, Increase Team Efficiency and Maximize Revenue.<br>
10
  <br />
@@ -23,3 +23,4 @@ class Glew_Service_Block_Adminhtml_Widget_Info_Info extends Mage_Adminhtml_Block
23
  return $html;
24
  }
25
  }
 
1
  <?php
2
 
3
+ class Glew_Service_Block_Adminhtml_Widget_Info_Info extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
4
+ {
5
  public function render(Varien_Data_Form_Element_Abstract $element)
6
  {
7
+ $html = '<div style="background:url(\'http://glew.io/wp-content/uploads/2015/04/Glew-white_Artboard7.png\') no-repeat scroll 15px center #EAF0EE;background-size:160px;border:1px solid #CCCCCC;margin-bottom:10px;padding:10px 5px 5px 200px;">
8
  <h4>About Glew.&trade;</h4>
9
  <p>Glew.&trade; Empowers Marketers to Take Action, Increase Team Efficiency and Maximize Revenue.<br>
10
  <br />
23
  return $html;
24
  }
25
  }
26
+
app/code/community/Glew/Service/Block/SecretKey.php CHANGED
@@ -8,6 +8,8 @@ class Glew_Service_Block_SecretKey extends Mage_Adminhtml_Block_System_Config_Fo
8
  $helper = Mage::helper('glew');
9
  $config = $helper->getConfig();
10
  $token = $config['security_token'];
 
11
  return trim($token);
12
  }
13
  }
 
8
  $helper = Mage::helper('glew');
9
  $config = $helper->getConfig();
10
  $token = $config['security_token'];
11
+
12
  return trim($token);
13
  }
14
  }
15
+
app/code/community/Glew/Service/Helper/Data.php CHANGED
@@ -2,78 +2,86 @@
2
 
3
  class Glew_Service_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
- private static $connRead;
6
- private static $connWrite;
7
- private static $filename = "glew.log";
8
- private static $debug = true;
9
- private $_config;
10
- protected $_store = null;
11
-
12
- public function getBaseDir()
13
- {
14
- return Mage::getBaseDir() . '/app/code/community/Glew/';
15
- }
16
-
17
- public function getDatabaseConnection()
18
- {
19
- return Mage::getSingleton('core/resource')->getConnection('glew_write');
20
- }
21
-
22
- public function getDatabaseReadConnection()
23
- {
24
- return Mage::getSingleton('core/resource')->getConnection('glew_read');
25
- }
26
-
27
- public function getConfig()
28
- {
29
- $config = array();
30
- $config['enabled'] = Mage::getStoreConfig('glew_settings/general/enabled');
31
- $config['security_token'] = Mage::getStoreConfig('glew_settings/general/security_token');
32
-
33
- $this->_config = $config;
34
- return $config;
35
- }
36
-
37
- public function formatDate($str)
38
- {
39
- if ($str) {
40
- if (stripos($str, ' ')) {
41
- $str = substr($str, 0, stripos($str, ' '));
42
- }
43
  }
44
- return $str;
45
- }
46
-
47
- public function toArray($value, $create = false)
48
- {
49
- if ($value !== false) {
50
- return is_array($value) ? $value : array($value);
51
- } else {
52
- return $create ? array() : $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
- }
55
-
56
- public function logException($ex, $msg)
57
- {
58
- Mage::logException($ex);
59
- Mage::log($msg . ': ' . $ex->getMessage(), null, self::$filename);
60
- return false;
61
- }
62
-
63
- public function log($msg)
64
- {
65
- return Mage::log($msg, null, self::$filename);
66
- }
67
-
68
- public function getStore() {
69
- if($this->_store == null) {
70
- $this->_store = Mage::app()->getStore();
71
- }
72
- return $this->_store;
73
- }
74
-
75
- public function paginate($array, $pageNumber, $pageSize) {
76
- $start = $pageNumber * $pageSize;
77
- return array_slice($array, $start, $pageSize);
78
- }
79
  }
 
2
 
3
  class Glew_Service_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
+ private static $connRead;
6
+ private static $connWrite;
7
+ private static $filename = 'glew.log';
8
+ private static $debug = true;
9
+ private $_config;
10
+ protected $_store = null;
11
+
12
+ public function getBaseDir()
13
+ {
14
+ return Mage::getBaseDir().'/app/code/community/Glew/';
15
+ }
16
+
17
+ public function getDatabaseConnection()
18
+ {
19
+ return Mage::getSingleton('core/resource')->getConnection('glew_write');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
+
22
+ public function getDatabaseReadConnection()
23
+ {
24
+ return Mage::getSingleton('core/resource')->getConnection('glew_read');
25
+ }
26
+
27
+ public function getConfig()
28
+ {
29
+ $config = array();
30
+ $config['enabled'] = Mage::getStoreConfig('glew_settings/general/enabled');
31
+ $config['security_token'] = Mage::getStoreConfig('glew_settings/general/security_token');
32
+
33
+ $this->_config = $config;
34
+
35
+ return $config;
36
+ }
37
+
38
+ public function formatDate($str)
39
+ {
40
+ if ($str) {
41
+ if (stripos($str, ' ')) {
42
+ $str = substr($str, 0, stripos($str, ' '));
43
+ }
44
+ }
45
+
46
+ return $str;
47
+ }
48
+
49
+ public function toArray($value, $create = false)
50
+ {
51
+ if ($value !== false) {
52
+ return is_array($value) ? $value : array($value);
53
+ } else {
54
+ return $create ? array() : $value;
55
+ }
56
+ }
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
+ }
65
+
66
+ public function log($msg)
67
+ {
68
+ return Mage::log($msg, null, self::$filename);
69
+ }
70
+
71
+ public function getStore()
72
+ {
73
+ if ($this->_store == null) {
74
+ $this->_store = Mage::app()->getStore();
75
+ }
76
+
77
+ return $this->_store;
78
+ }
79
+
80
+ public function paginate($array, $pageNumber, $pageSize)
81
+ {
82
+ $start = $pageNumber * $pageSize;
83
+
84
+ return array_slice($array, $start, $pageSize);
85
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
+
app/code/community/Glew/Service/Model/Glew.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class Glew_Service_Model_Glew
4
  {
5
-
6
  private $_helper;
7
  private $_config;
8
 
@@ -15,7 +14,8 @@ class Glew_Service_Model_Glew
15
  private function _isGenerated()
16
  {
17
  $securityToken = $this->_config['security_token'];
 
18
  return !empty($securityToken);
19
  }
20
-
21
  }
 
2
 
3
  class Glew_Service_Model_Glew
4
  {
 
5
  private $_helper;
6
  private $_config;
7
 
14
  private function _isGenerated()
15
  {
16
  $securityToken = $this->_config['security_token'];
17
+
18
  return !empty($securityToken);
19
  }
 
20
  }
21
+
app/code/community/Glew/Service/Model/Types/AbandonedCart.php CHANGED
@@ -4,10 +4,9 @@ class Glew_Service_Model_Types_AbandonedCart
4
  {
5
  public function parse($cart)
6
  {
7
-
8
  $products = array();
9
 
10
- foreach($cart->getAllItems() as $item) {
11
  $obj = new stdClass();
12
  $obj->product_id = $item->getProduct()->getId();
13
  $obj->qty = $item->getQty();
@@ -18,7 +17,7 @@ class Glew_Service_Model_Types_AbandonedCart
18
  $this->email = $cart->getCustomerEmail();
19
  $this->customer_id = $cart->getCustomerId() ? $cart->getCustomerId() : 0;
20
  $this->customer_group_id = $cart->getCustomerGroupId() ? $cart->getCustomerGroupId() : null;
21
- $customerGroup = Mage::getModel('customer/group')->load( $cart->getCustomerGroupId() );
22
  $this->customer_group = $customerGroup->getCode();
23
  $this->created_at = $cart->getCreatedAt();
24
  $this->updated_at = $cart->getUpdatedAt();
@@ -37,5 +36,5 @@ class Glew_Service_Model_Types_AbandonedCart
37
 
38
  return $this;
39
  }
40
-
41
  }
 
4
  {
5
  public function parse($cart)
6
  {
 
7
  $products = array();
8
 
9
+ foreach ($cart->getAllItems() as $item) {
10
  $obj = new stdClass();
11
  $obj->product_id = $item->getProduct()->getId();
12
  $obj->qty = $item->getQty();
17
  $this->email = $cart->getCustomerEmail();
18
  $this->customer_id = $cart->getCustomerId() ? $cart->getCustomerId() : 0;
19
  $this->customer_group_id = $cart->getCustomerGroupId() ? $cart->getCustomerGroupId() : null;
20
+ $customerGroup = Mage::getModel('customer/group')->load($cart->getCustomerGroupId());
21
  $this->customer_group = $customerGroup->getCode();
22
  $this->created_at = $cart->getCreatedAt();
23
  $this->updated_at = $cart->getUpdatedAt();
36
 
37
  return $this;
38
  }
 
39
  }
40
+
app/code/community/Glew/Service/Model/Types/AbandonedCarts.php CHANGED
@@ -10,16 +10,16 @@ class Glew_Service_Model_Types_AbandonedCarts
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',
17
- 'from' => new Zend_Date(strtotime($startDate), Zend_Date::TIMESTAMP),
18
- 'to' => new Zend_Date(strtotime($endDate), Zend_Date::TIMESTAMP),
19
- );
20
 
21
- $collection = Mage::getResourceModel('reports/quote_collection')
22
- ->addFieldToFilter('main_table.' . $filterBy, $filter);
23
  } else {
24
  $collection = Mage::getResourceModel('reports/quote_collection');
25
  }
@@ -29,11 +29,11 @@ class Glew_Service_Model_Types_AbandonedCarts
29
  $collection->setCurPage($pageNum);
30
  $collection->setPageSize($pageSize);
31
 
32
- if($collection->getLastPageNumber() < $pageNum){
33
- return $this;
34
  }
35
 
36
- foreach($collection as $cart) {
37
  if ($cart) {
38
  $model = Mage::getModel('glew/types_abandonedCart')->parse($cart);
39
  if ($model) {
@@ -44,5 +44,5 @@ class Glew_Service_Model_Types_AbandonedCarts
44
 
45
  return $this;
46
  }
47
-
48
  }
 
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',
17
+ 'from' => new Zend_Date(strtotime($startDate), Zend_Date::TIMESTAMP),
18
+ 'to' => new Zend_Date(strtotime($endDate), Zend_Date::TIMESTAMP),
19
+ );
20
 
21
+ $collection = Mage::getResourceModel('reports/quote_collection')
22
+ ->addFieldToFilter('main_table.'.$filterBy, $filter);
23
  } else {
24
  $collection = Mage::getResourceModel('reports/quote_collection');
25
  }
29
  $collection->setCurPage($pageNum);
30
  $collection->setPageSize($pageSize);
31
 
32
+ if ($collection->getLastPageNumber() < $pageNum) {
33
+ return $this;
34
  }
35
 
36
+ foreach ($collection as $cart) {
37
  if ($cart) {
38
  $model = Mage::getModel('glew/types_abandonedCart')->parse($cart);
39
  if ($model) {
44
 
45
  return $this;
46
  }
 
47
  }
48
+
app/code/community/Glew/Service/Model/Types/Address.php CHANGED
@@ -5,41 +5,42 @@ class Glew_Service_Model_Types_Address
5
  const BILLING_ADDRESS_TYPE = 1;
6
  const SHIPPING_ADDRESS_TYPE = 2;
7
  public $address_id;
8
- public $address_type;
9
- public $firstname;
10
- public $lastname;
11
- public $e_mail;
12
- public $company;
13
- public $street;
14
- public $zip_code;
15
- public $city;
16
- public $state;
17
- public $country_id;
18
- public $telephone;
19
- public $fax;
20
-
21
  public function parse($address)
22
  {
23
- $this->address_id = $address['entity_id'];
24
- $this->address_type = $address['address_type'] == self::BILLING_ADDRESS_TYPE ? 'billing' : 'shipping';
25
- $this->firstname = $address['firstname'];
26
- $this->lastname = $address['lastname'];
27
- $this->e_mail = $address['email'];
28
- if (isset($address['company'])) {
29
- $this->company = $address['company'];
30
- }
31
  $this->street = Mage::helper('glew')->toArray($address['street']);
32
  if ($this->street) {
33
  $this->street = implode(', ', $this->street);
34
  }
35
- $this->zip_code = $address['postcode'];
36
- $this->city = $address['city'];
37
- $region = Mage::getModel('directory/region')->loadByName($address['region'], $address['country_id']);
38
- $this->state = $region->getData('code');
39
- $this->country_id = $address['country_id'];
40
- $this->telephone = $address['telephone'];
41
- $this->fax = $address['fax'];
42
- return $this;
 
43
  }
44
-
45
  }
 
5
  const BILLING_ADDRESS_TYPE = 1;
6
  const SHIPPING_ADDRESS_TYPE = 2;
7
  public $address_id;
8
+ public $address_type;
9
+ public $firstname;
10
+ public $lastname;
11
+ public $e_mail;
12
+ public $company;
13
+ public $street;
14
+ public $zip_code;
15
+ public $city;
16
+ public $state;
17
+ public $country_id;
18
+ public $telephone;
19
+ public $fax;
20
+
21
  public function parse($address)
22
  {
23
+ $this->address_id = $address['entity_id'];
24
+ $this->address_type = $address['address_type'] == self::BILLING_ADDRESS_TYPE ? 'billing' : 'shipping';
25
+ $this->firstname = $address['firstname'];
26
+ $this->lastname = $address['lastname'];
27
+ $this->e_mail = $address['email'];
28
+ if (isset($address['company'])) {
29
+ $this->company = $address['company'];
30
+ }
31
  $this->street = Mage::helper('glew')->toArray($address['street']);
32
  if ($this->street) {
33
  $this->street = implode(', ', $this->street);
34
  }
35
+ $this->zip_code = $address['postcode'];
36
+ $this->city = $address['city'];
37
+ $region = Mage::getModel('directory/region')->loadByName($address['region'], $address['country_id']);
38
+ $this->state = $region->getData('code');
39
+ $this->country_id = $address['country_id'];
40
+ $this->telephone = $address['telephone'];
41
+ $this->fax = $address['fax'];
42
+
43
+ return $this;
44
  }
 
45
  }
46
+
app/code/community/Glew/Service/Model/Types/Categories.php CHANGED
@@ -16,30 +16,32 @@ 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
 
23
  $categories = Mage::getModel('catalog/category')->getCollection()
24
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
25
  } else {
26
  $categories = Mage::getModel('catalog/category')->getCollection();
27
  }
28
- $categories->addAttributeToFilter('path', array("like"=>$rootpath."/"."%"));
29
  $categories->setOrder('created_at', $sortDir);
30
  $categories->setCurPage($pageNum);
31
  $categories->setPageSize($pageSize);
32
 
33
- if($categories->getLastPageNumber() < $pageNum){
34
- return $this;
35
  }
36
 
37
- foreach ($categories as $category){
38
- $model = Mage::getModel('glew/types_category')->parse($category);
39
- if ($model) {
40
- $this->categories[] = $model;
41
- }
42
  }
 
43
  return $this;
44
  }
45
  }
 
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
 
23
  $categories = Mage::getModel('catalog/category')->getCollection()
24
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
25
  } else {
26
  $categories = Mage::getModel('catalog/category')->getCollection();
27
  }
28
+ $categories->addAttributeToFilter('path', array('like' => $rootpath.'/'.'%'));
29
  $categories->setOrder('created_at', $sortDir);
30
  $categories->setCurPage($pageNum);
31
  $categories->setPageSize($pageSize);
32
 
33
+ if ($categories->getLastPageNumber() < $pageNum) {
34
+ return $this;
35
  }
36
 
37
+ foreach ($categories as $category) {
38
+ $model = Mage::getModel('glew/types_category')->parse($category);
39
+ if ($model) {
40
+ $this->categories[] = $model;
41
+ }
42
  }
43
+
44
  return $this;
45
  }
46
  }
47
+
app/code/community/Glew/Service/Model/Types/Category.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  class Glew_Service_Model_Types_Category
4
  {
@@ -23,5 +23,5 @@ class Glew_Service_Model_Types_Category
23
 
24
  return $this;
25
  }
26
-
27
  }
 
1
+ <?php
2
 
3
  class Glew_Service_Model_Types_Category
4
  {
23
 
24
  return $this;
25
  }
 
26
  }
27
+
app/code/community/Glew/Service/Model/Types/Customer.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
 
3
- class Glew_Service_Model_Types_Customer
4
  {
5
  public function parse($customer)
6
  {
@@ -18,9 +18,9 @@ class Glew_Service_Model_Types_Customer
18
  $this->name = $customer->getName();
19
  $this->first_name = $customer->getFirstname();
20
  $this->last_name = $customer->getLastname();
21
- $this->gender = (!!$customer->getGender()) ? $customer->getGender() : "";
22
- $this->dob = (!!$customer->getDob()) ? Mage::helper('glew')->formatDate($customer->getDob()) : "";
23
- $this->store = (!!$customer->getStore()->getCode()) ? $customer->getStore()->getCode() : "";
24
  $this->addresses = array();
25
 
26
  if ($customer->getPrimaryShippingAddress()) {
@@ -31,12 +31,12 @@ class Glew_Service_Model_Types_Customer
31
  $address = Mage::getModel('glew/types_address')->parse($customer->getPrimaryBillingAddress());
32
  $this->addresses[] = $address;
33
  }
34
- }else{
35
- $address =Mage::getModel('glew/types_address');
36
  $this->addresses[] = $address;
37
  }
38
 
39
  return $this;
40
  }
41
-
42
  }
 
1
+ <?php
2
 
3
+ class Glew_Service_Model_Types_Customer
4
  {
5
  public function parse($customer)
6
  {
18
  $this->name = $customer->getName();
19
  $this->first_name = $customer->getFirstname();
20
  $this->last_name = $customer->getLastname();
21
+ $this->gender = ((bool) $customer->getGender()) ? $customer->getGender() : '';
22
+ $this->dob = ((bool) $customer->getDob()) ? Mage::helper('glew')->formatDate($customer->getDob()) : '';
23
+ $this->store = ((bool) $customer->getStore()->getCode()) ? $customer->getStore()->getCode() : '';
24
  $this->addresses = array();
25
 
26
  if ($customer->getPrimaryShippingAddress()) {
31
  $address = Mage::getModel('glew/types_address')->parse($customer->getPrimaryBillingAddress());
32
  $this->addresses[] = $address;
33
  }
34
+ } else {
35
+ $address = Mage::getModel('glew/types_address');
36
  $this->addresses[] = $address;
37
  }
38
 
39
  return $this;
40
  }
 
41
  }
42
+
app/code/community/Glew/Service/Model/Types/Customers.php CHANGED
@@ -10,12 +10,12 @@ class Glew_Service_Model_Types_Customers
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
 
17
  $collection = Mage::getModel('customer/customer')->getCollection()
18
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
19
  } else {
20
  $collection = Mage::getModel('customer/customer')->getCollection();
21
  }
@@ -24,10 +24,10 @@ class Glew_Service_Model_Types_Customers
24
  $collection->setCurPage($pageNum);
25
  $collection->setPageSize($pageSize);
26
 
27
- if($collection->getLastPageNumber() < $pageNum){
28
- return $this;
29
  }
30
- foreach($collection as $customer) {
31
  $customer = Mage::getModel('customer/customer')->load($customer->getId());
32
  if ($customer && $customer->getId()) {
33
  $model = Mage::getModel('glew/types_customer')->parse($customer);
@@ -39,5 +39,5 @@ class Glew_Service_Model_Types_Customers
39
 
40
  return $this;
41
  }
42
-
43
  }
 
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
 
17
  $collection = Mage::getModel('customer/customer')->getCollection()
18
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
19
  } else {
20
  $collection = Mage::getModel('customer/customer')->getCollection();
21
  }
24
  $collection->setCurPage($pageNum);
25
  $collection->setPageSize($pageSize);
26
 
27
+ if ($collection->getLastPageNumber() < $pageNum) {
28
+ return $this;
29
  }
30
+ foreach ($collection as $customer) {
31
  $customer = Mage::getModel('customer/customer')->load($customer->getId());
32
  if ($customer && $customer->getId()) {
33
  $model = Mage::getModel('glew/types_customer')->parse($customer);
39
 
40
  return $this;
41
  }
 
42
  }
43
+
app/code/community/Glew/Service/Model/Types/Extension.php CHANGED
@@ -5,10 +5,10 @@ class Glew_Service_Model_Types_Extension
5
  public function parse($extension, $attr)
6
  {
7
  $this->name = $extension;
8
- $this->active = (string)$attr->active;
9
- $this->version = (string)$attr->version;
10
 
11
  return $this;
12
  }
13
-
14
  }
 
5
  public function parse($extension, $attr)
6
  {
7
  $this->name = $extension;
8
+ $this->active = (string) $attr->active;
9
+ $this->version = (string) $attr->version;
10
 
11
  return $this;
12
  }
 
13
  }
14
+
app/code/community/Glew/Service/Model/Types/Extensions.php CHANGED
@@ -14,14 +14,14 @@ class Glew_Service_Model_Types_Extensions
14
  $collection = (array) Mage::getConfig()->getNode('modules')->children();
15
  $collection = $helper->paginate($collection, $pageNum, $pageSize);
16
 
17
- foreach($collection as $extension => $attributes) {
18
  $model = Mage::getModel('glew/types_extension')->parse($extension, $attributes);
19
- if($model) {
20
  $this->extensions[] = $model;
21
  }
22
  }
23
 
24
  return $this;
25
  }
26
-
27
  }
 
14
  $collection = (array) Mage::getConfig()->getNode('modules')->children();
15
  $collection = $helper->paginate($collection, $pageNum, $pageSize);
16
 
17
+ foreach ($collection as $extension => $attributes) {
18
  $model = Mage::getModel('glew/types_extension')->parse($extension, $attributes);
19
+ if ($model) {
20
  $this->extensions[] = $model;
21
  }
22
  }
23
 
24
  return $this;
25
  }
 
26
  }
27
+
app/code/community/Glew/Service/Model/Types/Inventory.php CHANGED
@@ -10,22 +10,23 @@ class Glew_Service_Model_Types_Inventory
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
  $this->pageNum = $pageNum;
13
- $inventory = Mage::getModel('cataloginventory/stock_item')->getCollection();
14
  $inventory->setOrder('entity_id', $sortDir);
15
  $inventory->setCurPage($pageNum);
16
  $inventory->setPageSize($pageSize);
17
 
18
- if($inventory->getLastPageNumber() < $pageNum){
19
  return $this;
20
  }
21
 
22
- foreach ($inventory as $inventoryItem){
23
- $model = Mage::getModel('glew/types_inventoryItem')->parse($inventoryItem);
24
  if ($model) {
25
  $this->inventory[] = $model;
26
  }
27
  }
 
28
  return $this;
29
  }
30
-
31
  }
 
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);
17
 
18
+ if ($inventory->getLastPageNumber() < $pageNum) {
19
  return $this;
20
  }
21
 
22
+ foreach ($inventory as $product) {
23
+ $model = Mage::getModel('glew/types_inventoryItem')->parse($product);
24
  if ($model) {
25
  $this->inventory[] = $model;
26
  }
27
  }
28
+
29
  return $this;
30
  }
 
31
  }
32
+
app/code/community/Glew/Service/Model/Types/InventoryItem.php CHANGED
@@ -2,17 +2,16 @@
2
 
3
  class Glew_Service_Model_Types_InventoryItem
4
  {
5
- public function parse($item)
6
  {
7
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
8
- $this->id = $item->getItemId();
9
- $this->product_id = $item->getProductId();
10
- $this->qty = $item->getQty();
11
- $this->price = $product->getPrice();
12
- $this->cost = $product->getCost();
13
 
14
- return $this;
15
  }
16
-
17
  }
18
 
2
 
3
  class Glew_Service_Model_Types_InventoryItem
4
  {
5
+ public function parse($product)
6
  {
7
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
8
+ $this->id = $stock->getItemId();
9
+ $this->product_id = $product->getId();
10
+ $this->qty = $stock->getQty();
11
+ $this->price = $product->getPrice();
12
+ $this->cost = $product->getCost();
13
 
14
+ return $this;
15
  }
 
16
  }
17
 
app/code/community/Glew/Service/Model/Types/Order.php CHANGED
@@ -9,14 +9,14 @@ class Glew_Service_Model_Types_Order
9
  $this->increment_id = $order->getIncrementId();
10
  $this->customer_id = $order->getCustomerId() ? $order->getCustomerId() : 0;
11
  $this->customer_group_id = $order->getCustomerGroupId() ? $order->getCustomerGroupId() : null;
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();
19
- $this->total_qty_ordered = (int)$order->getTotalQtyOrdered();
20
  $this->currency = $order->getOrderCurrencyCode();
21
  $this->total = round($order->getGrandTotal(), 2);
22
  $this->tax = round($order->getTaxAmount(), 2);
@@ -33,5 +33,5 @@ class Glew_Service_Model_Types_Order
33
 
34
  return $this;
35
  }
36
-
37
  }
 
9
  $this->increment_id = $order->getIncrementId();
10
  $this->customer_id = $order->getCustomerId() ? $order->getCustomerId() : 0;
11
  $this->customer_group_id = $order->getCustomerGroupId() ? $order->getCustomerGroupId() : null;
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();
19
+ $this->total_qty_ordered = (int) $order->getTotalQtyOrdered();
20
  $this->currency = $order->getOrderCurrencyCode();
21
  $this->total = round($order->getGrandTotal(), 2);
22
  $this->tax = round($order->getTaxAmount(), 2);
33
 
34
  return $this;
35
  }
 
36
  }
37
+
app/code/community/Glew/Service/Model/Types/OrderItem.php CHANGED
@@ -1,12 +1,9 @@
1
- <?php
2
 
3
- class Glew_Service_Model_Types_OrderItem
4
  {
5
  public function parse($orderItem)
6
  {
7
- if($orderItem->getParentItemId()) {
8
- return;
9
- }
10
  $this->order_item_id = $orderItem->getId();
11
  $this->order_id = $orderItem->getOrderId();
12
  $this->created_at = $orderItem->getCreatedAt();
@@ -20,12 +17,12 @@ class Glew_Service_Model_Types_OrderItem
20
  $this->brand = '';
21
  $this->website_names = '';
22
  $this->store = $orderItem->getOrder()->getStore()->getCode();
23
-
24
- $this->qty_ordered = (int)$orderItem->getQtyOrdered();
25
- $this->qty_refunded = (int)$orderItem->getQtyRefunded();
26
- $this->qty_shipped = (int)$orderItem->getQtyShipped();
27
- $this->qty_backordered = (int)$orderItem->getQtyBackordered();
28
-
29
  $this->price = round($orderItem->getPrice(), 2);
30
  $this->original_price = round($orderItem->getOriginalPrice(), 2);
31
  $this->cost = round($orderItem->getCost(), 2);
@@ -34,55 +31,56 @@ class Glew_Service_Model_Types_OrderItem
34
  $this->tax_amount = round($orderItem->getTaxAmount(), 2);
35
  $this->discount_percent = round($orderItem->getDiscountPercent(), 2);
36
  $this->discount_amount = round($orderItem->getDiscountAmount(), 2);
37
-
38
  $this->weight = round($orderItem->getWeight(), 2);
39
  $this->row_weight = round($orderItem->getRowWeight(), 2);
40
  $this->additional_data = $orderItem->getAdditionalData();
 
41
  return $this;
42
  }
43
 
44
  private function _getSelectAttributeLabel($attrCode, $value)
45
  {
46
  try {
47
- $api = Mage::getSingleton('catalog/product_attribute_api');
48
- $info = $api->info($attrCode);
49
- if ($info) {
50
- if (isset($info['options'])) {
51
- foreach($info['options'] as $option) {
52
- $label = str_ireplace(' ', '', $option['label']);
53
- if ($option['value'] == $value) {
54
- return $label;
 
55
  }
56
  }
57
  }
58
- }
59
- return '';
60
- } catch(Exception $ex) {
61
  $helper = Mage::helper('glew');
62
  $helper->ex($ex, 'process');
63
  }
64
-
65
  }
66
-
67
  protected function _getProductCategories($product)
68
  {
69
- $maxlevel = 0;
70
- foreach($product->getCategoryIds() as $k => $categoryId) {
71
- $category = Mage::getModel('catalog/category')->
72
- load($categoryId);
73
- $level = $category->getLevel();
74
 
75
- if($category->getLevel() > $maxlevel){
76
- while($level >= 2){
77
- $categoryK = 'category'.($level - 1);
78
- if($level <= 4){
79
- $this->$categoryK = $category->getName();
80
- }
81
- $category = Mage::getModel('catalog/category')->load($category->parent_id);
82
- $level = $category->getLevel();
83
- }
84
- }
85
- }
86
  }
87
  }
88
 
1
+ <?php
2
 
3
+ class Glew_Service_Model_Types_OrderItem
4
  {
5
  public function parse($orderItem)
6
  {
 
 
 
7
  $this->order_item_id = $orderItem->getId();
8
  $this->order_id = $orderItem->getOrderId();
9
  $this->created_at = $orderItem->getCreatedAt();
17
  $this->brand = '';
18
  $this->website_names = '';
19
  $this->store = $orderItem->getOrder()->getStore()->getCode();
20
+
21
+ $this->qty_ordered = (int) $orderItem->getQtyOrdered();
22
+ $this->qty_refunded = (int) $orderItem->getQtyRefunded();
23
+ $this->qty_shipped = (int) $orderItem->getQtyShipped();
24
+ $this->qty_backordered = (int) $orderItem->getQtyBackordered();
25
+
26
  $this->price = round($orderItem->getPrice(), 2);
27
  $this->original_price = round($orderItem->getOriginalPrice(), 2);
28
  $this->cost = round($orderItem->getCost(), 2);
31
  $this->tax_amount = round($orderItem->getTaxAmount(), 2);
32
  $this->discount_percent = round($orderItem->getDiscountPercent(), 2);
33
  $this->discount_amount = round($orderItem->getDiscountAmount(), 2);
34
+
35
  $this->weight = round($orderItem->getWeight(), 2);
36
  $this->row_weight = round($orderItem->getRowWeight(), 2);
37
  $this->additional_data = $orderItem->getAdditionalData();
38
+
39
  return $this;
40
  }
41
 
42
  private function _getSelectAttributeLabel($attrCode, $value)
43
  {
44
  try {
45
+ $api = Mage::getSingleton('catalog/product_attribute_api');
46
+ $info = $api->info($attrCode);
47
+ if ($info) {
48
+ if (isset($info['options'])) {
49
+ foreach ($info['options'] as $option) {
50
+ $label = str_ireplace(' ', '', $option['label']);
51
+ if ($option['value'] == $value) {
52
+ return $label;
53
+ }
54
  }
55
  }
56
  }
57
+
58
+ return '';
59
+ } catch (Exception $ex) {
60
  $helper = Mage::helper('glew');
61
  $helper->ex($ex, 'process');
62
  }
 
63
  }
64
+
65
  protected function _getProductCategories($product)
66
  {
67
+ $maxlevel = 0;
68
+ foreach ($product->getCategoryIds() as $k => $categoryId) {
69
+ $category = Mage::getModel('catalog/category')->
70
+ load($categoryId);
71
+ $level = $category->getLevel();
72
 
73
+ if ($category->getLevel() > $maxlevel) {
74
+ while ($level >= 2) {
75
+ $categoryK = 'category'.($level - 1);
76
+ if ($level <= 4) {
77
+ $this->$categoryK = $category->getName();
78
+ }
79
+ $category = Mage::getModel('catalog/category')->load($category->parent_id);
80
+ $level = $category->getLevel();
81
+ }
82
+ }
83
+ }
84
  }
85
  }
86
 
app/code/community/Glew/Service/Model/Types/OrderItems.php CHANGED
@@ -9,15 +9,16 @@ class Glew_Service_Model_Types_OrderItems
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
 
12
  $this->pageNum = $pageNum;
13
 
14
  $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'cost');
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
 
19
  $collection = Mage::getModel('sales/order_item')->getCollection()
20
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
21
  } else {
22
  $collection = Mage::getModel('sales/order_item')->getCollection();
23
  }
@@ -26,18 +27,30 @@ class Glew_Service_Model_Types_OrderItems
26
  $catProdEntDecTable = $resource->getTableName('catalog_product_entity_decimal');
27
  $collection->getSelect()->joinLeft(
28
  array('cost' => $catProdEntDecTable),
29
- "main_table.product_id = cost.entity_id AND cost.attribute_id = {$attribute->getId()}",
30
  array('cost' => 'value')
31
  );
32
  $collection->setOrder('created_at', $sortDir);
33
  $collection->setCurPage($pageNum);
34
  $collection->setPageSize($pageSize);
35
- if($collection->getLastPageNumber() < $pageNum){
36
- return $this;
37
  }
38
 
39
- foreach($collection as $orderItem) {
 
40
  if ($orderItem && $orderItem->getId()) {
 
 
 
 
 
 
 
 
 
 
 
41
  $model = Mage::getModel('glew/types_orderItem')->parse($orderItem);
42
  if ($model) {
43
  $this->orderItems[] = $model;
@@ -47,5 +60,5 @@ class Glew_Service_Model_Types_OrderItems
47
 
48
  return $this;
49
  }
50
-
51
  }
 
9
  {
10
  $helper = Mage::helper('glew');
11
  $config = $helper->getConfig();
12
+ $store = $helper->getStore();
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
 
20
  $collection = Mage::getModel('sales/order_item')->getCollection()
21
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
22
  } else {
23
  $collection = Mage::getModel('sales/order_item')->getCollection();
24
  }
27
  $catProdEntDecTable = $resource->getTableName('catalog_product_entity_decimal');
28
  $collection->getSelect()->joinLeft(
29
  array('cost' => $catProdEntDecTable),
30
+ "main_table.product_id = cost.entity_id AND cost.attribute_id = {$attribute->getId()} AND cost.store_id = {$store->getStoreId()}",
31
  array('cost' => 'value')
32
  );
33
  $collection->setOrder('created_at', $sortDir);
34
  $collection->setCurPage($pageNum);
35
  $collection->setPageSize($pageSize);
36
+ if ($collection->getLastPageNumber() < $pageNum) {
37
+ return $this;
38
  }
39
 
40
+ foreach ($collection as $orderItem) {
41
+ $continue = true;
42
  if ($orderItem && $orderItem->getId()) {
43
+ if ($orderItem->getParentItemId()) {
44
+ foreach ($this->orderItems as $key => $oi) {
45
+ if ($orderItem->getParentItemId() == $this->orderItems[$key]->order_item_id) {
46
+ $this->orderItems[$key]->product_id = $orderItem->getProductId();
47
+ $continue = false;
48
+ }
49
+ }
50
+ if (!$continue) {
51
+ continue;
52
+ }
53
+ }
54
  $model = Mage::getModel('glew/types_orderItem')->parse($orderItem);
55
  if ($model) {
56
  $this->orderItems[] = $model;
60
 
61
  return $this;
62
  }
 
63
  }
64
+
app/code/community/Glew/Service/Model/Types/Orders.php CHANGED
@@ -11,11 +11,11 @@ class Glew_Service_Model_Types_Orders
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()
18
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
19
  } else {
20
  $collection = Mage::getModel('sales/order')->getCollection();
21
  }
@@ -24,10 +24,10 @@ class Glew_Service_Model_Types_Orders
24
  $collection->setCurPage($pageNum);
25
  $collection->setPageSize($pageSize);
26
 
27
- if($collection->getLastPageNumber() < $pageNum){
28
- return $this;
29
  }
30
- foreach($collection as $order) {
31
  if ($order && $order->getId()) {
32
  $model = Mage::getModel('glew/types_order')->parse($order);
33
  if ($model) {
@@ -38,5 +38,5 @@ class Glew_Service_Model_Types_Orders
38
 
39
  return $this;
40
  }
41
-
42
  }
 
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()
18
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
19
  } else {
20
  $collection = Mage::getModel('sales/order')->getCollection();
21
  }
24
  $collection->setCurPage($pageNum);
25
  $collection->setPageSize($pageSize);
26
 
27
+ if ($collection->getLastPageNumber() < $pageNum) {
28
+ return $this;
29
  }
30
+ foreach ($collection as $order) {
31
  if ($order && $order->getId()) {
32
  $model = Mage::getModel('glew/types_order')->parse($order);
33
  if ($model) {
38
 
39
  return $this;
40
  }
 
41
  }
42
+
app/code/community/Glew/Service/Model/Types/Product.php CHANGED
@@ -11,15 +11,15 @@ class Glew_Service_Model_Types_Product
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 {
16
  $value = $product->getData($field);
17
- if(is_array($value) || is_object($value)){
18
  continue;
19
  }
20
 
21
- if($field == 'image' && $value) {
22
- $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $value;
23
  $this->$field = $imageUrl;
24
  continue;
25
  }
@@ -35,18 +35,17 @@ class Glew_Service_Model_Types_Product
35
  $value = $option;
36
  }
37
  }
38
- if($field == 'category_ids'){
39
  $value = $product->getCategoryIds();
40
  }
41
 
42
  $this->$field = $value;
43
- } catch(Exception $e) {
44
  continue;
45
  }
46
  }
47
 
48
  return $this;
49
  }
50
-
51
  }
52
 
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 {
16
  $value = $product->getData($field);
17
+ if (is_array($value) || is_object($value)) {
18
  continue;
19
  }
20
 
21
+ if ($field == 'image' && $value) {
22
+ $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$value;
23
  $this->$field = $imageUrl;
24
  continue;
25
  }
35
  $value = $option;
36
  }
37
  }
38
+ if ($field == 'category_ids') {
39
  $value = $product->getCategoryIds();
40
  }
41
 
42
  $this->$field = $value;
43
+ } catch (Exception $e) {
44
  continue;
45
  }
46
  }
47
 
48
  return $this;
49
  }
 
50
  }
51
 
app/code/community/Glew/Service/Model/Types/ProductAlert.php CHANGED
@@ -1,15 +1,15 @@
1
- <?php
2
 
3
  class Glew_Service_Model_Types_ProductAlert
4
  {
5
  public function parse($alert)
6
  {
7
- $this->id = $alert->getAlertStockId();
8
  $this->customer_id = $alert->getCustomerId();
9
  $this->product_id = $alert->getProductId();
10
  $this->created_at = $alert->getAddDate();
11
-
12
  return $this;
13
  }
14
-
15
  }
 
1
+ <?php
2
 
3
  class Glew_Service_Model_Types_ProductAlert
4
  {
5
  public function parse($alert)
6
  {
7
+ $this->id = $alert->getAlertStockId();
8
  $this->customer_id = $alert->getCustomerId();
9
  $this->product_id = $alert->getProductId();
10
  $this->created_at = $alert->getAddDate();
11
+
12
  return $this;
13
  }
 
14
  }
15
+
app/code/community/Glew/Service/Model/Types/ProductAlerts.php CHANGED
@@ -10,29 +10,30 @@ class Glew_Service_Model_Types_ProductAlerts
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');
17
  } else {
18
  $alerts = Mage::getModel('productalert/stock')->getCollection();
19
  }
20
- $alerts->addFilter('website_id', "website_id = " . $helper->getStore()->getWebsiteId(), 'string');
21
  $alerts->setOrder('add_date', $sortDir);
22
  $alerts->setCurPage($pageNum);
23
  $alerts->setPageSize($pageSize);
24
 
25
- if($alerts->getLastPageNumber() < $pageNum){
26
  return $this;
27
  }
28
 
29
- foreach ($alerts as $alert){
30
  $model = Mage::getModel('glew/types_productAlert')->parse($alert);
31
  if ($model) {
32
  $this->alerts[] = $model;
33
  }
34
  }
 
35
  return $this;
36
  }
37
-
38
  }
 
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');
17
  } else {
18
  $alerts = Mage::getModel('productalert/stock')->getCollection();
19
  }
20
+ $alerts->addFilter('website_id', 'website_id = '.$helper->getStore()->getWebsiteId(), 'string');
21
  $alerts->setOrder('add_date', $sortDir);
22
  $alerts->setCurPage($pageNum);
23
  $alerts->setPageSize($pageSize);
24
 
25
+ if ($alerts->getLastPageNumber() < $pageNum) {
26
  return $this;
27
  }
28
 
29
+ foreach ($alerts as $alert) {
30
  $model = Mage::getModel('glew/types_productAlert')->parse($alert);
31
  if ($model) {
32
  $this->alerts[] = $model;
33
  }
34
  }
35
+
36
  return $this;
37
  }
 
38
  }
39
+
app/code/community/Glew/Service/Model/Types/Products.php CHANGED
@@ -12,42 +12,44 @@ class Glew_Service_Model_Types_Products
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
 
19
  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')
20
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
21
  } else {
22
  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
23
  }
 
24
  $products->setStoreId($helper->getStore()->getStoreId());
25
  $products->setOrder('updated_at', $sortDir);
26
  $products->setCurPage($pageNum);
27
  $products->setPageSize($pageSize);
28
 
29
- if($products->getLastPageNumber() < $pageNum){
30
- return $this;
31
  }
32
 
33
- foreach($products as $product) {
34
  $productId = $product->getId();
35
  $model = Mage::getModel('glew/types_product')->parse($productId, $this->productAttributes);
36
- if($model) {
37
- $model->cross_sell_products = $this->_getCrossSellProducts($product);
38
- $model->up_sell_products = $this->_getUpSellProducts($product);
39
- $model->related_products = $this->_getRelatedProducts($product);
40
- $this->products[] = $model;
41
  }
42
  }
 
43
  return $this;
44
  }
45
 
46
  protected function _getProductAttribtues()
47
  {
48
- if(!$this->productAttributes){
49
  $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
50
- foreach ($attributes as $attribute){
51
  if (!$attribute) {
52
  continue;
53
  }
@@ -60,11 +62,12 @@ class Glew_Service_Model_Types_Products
60
  {
61
  $productArray = array();
62
  $collection = $product->getCrossSellProductCollection();
63
- if($collection) {
64
- foreach($collection as $item) {
65
  $productArray[] = $item->getId();
66
  }
67
  }
 
68
  return $productArray;
69
  }
70
 
@@ -72,11 +75,12 @@ class Glew_Service_Model_Types_Products
72
  {
73
  $productArray = array();
74
  $collection = $product->getUpSellProductCollection();
75
- if($collection) {
76
- foreach($collection as $item) {
77
  $productArray[] = $item->getId();
78
  }
79
  }
 
80
  return $productArray;
81
  }
82
 
@@ -84,11 +88,13 @@ class Glew_Service_Model_Types_Products
84
  {
85
  $productArray = array();
86
  $collection = $product->getRelatedProductCollection();
87
- if($collection) {
88
- foreach($collection as $item) {
89
  $productArray[] = $item->getId();
90
  }
91
  }
 
92
  return $productArray;
93
  }
94
  }
 
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
 
19
  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')
20
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
21
  } else {
22
  $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
23
  }
24
+ $products->setVisibility(null);
25
  $products->setStoreId($helper->getStore()->getStoreId());
26
  $products->setOrder('updated_at', $sortDir);
27
  $products->setCurPage($pageNum);
28
  $products->setPageSize($pageSize);
29
 
30
+ if ($products->getLastPageNumber() < $pageNum) {
31
+ return $this;
32
  }
33
 
34
+ foreach ($products as $product) {
35
  $productId = $product->getId();
36
  $model = Mage::getModel('glew/types_product')->parse($productId, $this->productAttributes);
37
+ if ($model) {
38
+ $model->cross_sell_products = $this->_getCrossSellProducts($product);
39
+ $model->up_sell_products = $this->_getUpSellProducts($product);
40
+ $model->related_products = $this->_getRelatedProducts($product);
41
+ $this->products[] = $model;
42
  }
43
  }
44
+
45
  return $this;
46
  }
47
 
48
  protected function _getProductAttribtues()
49
  {
50
+ if (!$this->productAttributes) {
51
  $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
52
+ foreach ($attributes as $attribute) {
53
  if (!$attribute) {
54
  continue;
55
  }
62
  {
63
  $productArray = array();
64
  $collection = $product->getCrossSellProductCollection();
65
+ if ($collection) {
66
+ foreach ($collection as $item) {
67
  $productArray[] = $item->getId();
68
  }
69
  }
70
+
71
  return $productArray;
72
  }
73
 
75
  {
76
  $productArray = array();
77
  $collection = $product->getUpSellProductCollection();
78
+ if ($collection) {
79
+ foreach ($collection as $item) {
80
  $productArray[] = $item->getId();
81
  }
82
  }
83
+
84
  return $productArray;
85
  }
86
 
88
  {
89
  $productArray = array();
90
  $collection = $product->getRelatedProductCollection();
91
+ if ($collection) {
92
+ foreach ($collection as $item) {
93
  $productArray[] = $item->getId();
94
  }
95
  }
96
+
97
  return $productArray;
98
  }
99
  }
100
+
app/code/community/Glew/Service/Model/Types/Refund.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
 
3
  class Glew_Service_Model_Types_Refund
4
  {
5
  public function parse($refund)
6
  {
7
  $this->refund_id = $refund->getId();
8
- $this->order_id = $refund->getData('order_id');;
9
  $this->amount = $refund->getData('grand_total');
10
  $this->created_at = $refund->getCreatedAt();
11
  $this->updated_at = $refund->getUpdatedAt();
12
 
13
  return $this;
14
  }
15
-
16
  }
 
1
+ <?php
2
 
3
  class Glew_Service_Model_Types_Refund
4
  {
5
  public function parse($refund)
6
  {
7
  $this->refund_id = $refund->getId();
8
+ $this->order_id = $refund->getData('order_id');
9
  $this->amount = $refund->getData('grand_total');
10
  $this->created_at = $refund->getCreatedAt();
11
  $this->updated_at = $refund->getUpdatedAt();
12
 
13
  return $this;
14
  }
 
15
  }
16
+
app/code/community/Glew/Service/Model/Types/RefundItem.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  class Glew_Service_Model_Types_RefundItem
4
  {
@@ -17,5 +17,5 @@ class Glew_Service_Model_Types_RefundItem
17
 
18
  return $this;
19
  }
20
-
21
  }
 
1
+ <?php
2
 
3
  class Glew_Service_Model_Types_RefundItem
4
  {
17
 
18
  return $this;
19
  }
 
20
  }
21
+
app/code/community/Glew/Service/Model/Types/RefundItems.php CHANGED
@@ -10,12 +10,12 @@ class Glew_Service_Model_Types_RefundItems
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
 
17
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
18
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
19
  } else {
20
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
21
  }
@@ -27,17 +27,18 @@ class Glew_Service_Model_Types_RefundItems
27
  $refunds->setCurPage($pageNum);
28
  $refunds->setPageSize($pageSize);
29
 
30
- if($refunds->getLastPageNumber() < $pageNum){
31
- return $this;
32
  }
33
 
34
- foreach ($refunds as $refund){
35
- $model = Mage::getModel('glew/types_refundItem')->parse($refund);
36
- if ($model) {
37
- $this->refundItems[] = $model;
38
- }
39
  }
 
40
  return $this;
41
  }
42
-
43
  }
 
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
 
17
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
18
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
19
  } else {
20
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
21
  }
27
  $refunds->setCurPage($pageNum);
28
  $refunds->setPageSize($pageSize);
29
 
30
+ if ($refunds->getLastPageNumber() < $pageNum) {
31
+ return $this;
32
  }
33
 
34
+ foreach ($refunds as $refund) {
35
+ $model = Mage::getModel('glew/types_refundItem')->parse($refund);
36
+ if ($model) {
37
+ $this->refundItems[] = $model;
38
+ }
39
  }
40
+
41
  return $this;
42
  }
 
43
  }
44
+
app/code/community/Glew/Service/Model/Types/Refunds.php CHANGED
@@ -10,12 +10,12 @@ class Glew_Service_Model_Types_Refunds
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
 
17
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
18
- ->addAttributeToFilter($filterBy, array('from'=>$from, 'to'=>$to));
19
  } else {
20
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
21
  }
@@ -24,17 +24,18 @@ class Glew_Service_Model_Types_Refunds
24
  $refunds->setCurPage($pageNum);
25
  $refunds->setPageSize($pageSize);
26
 
27
- if($refunds->getLastPageNumber() < $pageNum){
28
- return $this;
29
  }
30
 
31
- foreach ($refunds as $refund){
32
- $model = Mage::getModel('glew/types_refund')->parse($refund);
33
- if ($model) {
34
- $this->refunds[] = $model;
35
- }
36
  }
 
37
  return $this;
38
  }
39
-
40
  }
 
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
 
17
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection')
18
+ ->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
19
  } else {
20
  $refunds = Mage::getResourceModel('sales/order_creditmemo_collection');
21
  }
24
  $refunds->setCurPage($pageNum);
25
  $refunds->setPageSize($pageSize);
26
 
27
+ if ($refunds->getLastPageNumber() < $pageNum) {
28
+ return $this;
29
  }
30
 
31
+ foreach ($refunds as $refund) {
32
+ $model = Mage::getModel('glew/types_refund')->parse($refund);
33
+ if ($model) {
34
+ $this->refunds[] = $model;
35
+ }
36
  }
37
+
38
  return $this;
39
  }
 
40
  }
41
+
app/code/community/Glew/Service/Model/Types/Store.php CHANGED
@@ -1,13 +1,14 @@
1
- <?php
2
 
3
  class Glew_Service_Model_Types_Store
4
  {
5
  public function parse($store)
6
  {
7
- foreach ( $store->getData() as $key => $value){
8
- $this->$key = $value;
9
- }
 
10
  return $this;
11
  }
12
-
13
  }
 
1
+ <?php
2
 
3
  class Glew_Service_Model_Types_Store
4
  {
5
  public function parse($store)
6
  {
7
+ foreach ($store->getData() as $key => $value) {
8
+ $this->$key = $value;
9
+ }
10
+
11
  return $this;
12
  }
 
13
  }
14
+
app/code/community/Glew/Service/Model/Types/Stores.php CHANGED
@@ -13,13 +13,14 @@ class Glew_Service_Model_Types_Stores
13
 
14
  $stores = Mage::app()->getStores();
15
  $stores = $helper->paginate($stores, $pageNum, $pageSize);
16
- foreach($stores as $store) {
17
- $model = Mage::getModel('glew/types_store')->parse($store);
18
- if ($model) {
19
- $this->stores[] = $model;
20
- }
21
  }
 
22
  return $this;
23
  }
24
-
25
  }
 
13
 
14
  $stores = Mage::app()->getStores();
15
  $stores = $helper->paginate($stores, $pageNum, $pageSize);
16
+ foreach ($stores as $store) {
17
+ $model = Mage::getModel('glew/types_store')->parse($store);
18
+ if ($model) {
19
+ $this->stores[] = $model;
20
+ }
21
  }
22
+
23
  return $this;
24
  }
 
25
  }
26
+
app/code/community/Glew/Service/Model/Types/Subscriber.php CHANGED
@@ -1,13 +1,14 @@
1
- <?php
2
 
3
  class Glew_Service_Model_Types_Subscriber
4
  {
5
  public function parse($subscriber)
6
  {
7
- foreach ( $subscriber->getData() as $key => $value){
8
- $this->$key = $value;
9
- }
 
10
  return $this;
11
  }
12
-
13
  }
 
1
+ <?php
2
 
3
  class Glew_Service_Model_Types_Subscriber
4
  {
5
  public function parse($subscriber)
6
  {
7
+ foreach ($subscriber->getData() as $key => $value) {
8
+ $this->$key = $value;
9
+ }
10
+
11
  return $this;
12
  }
 
13
  }
14
+
app/code/community/Glew/Service/Model/Types/Subscribers.php CHANGED
@@ -11,22 +11,23 @@ class Glew_Service_Model_Types_Subscribers
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);
17
  $subscribers->setPageSize($pageSize);
18
 
19
- if($subscribers->getLastPageNumber() < $pageNum){
20
- return $this;
21
  }
22
 
23
- foreach ($subscribers as $subscriber){
24
- $model = Mage::getModel('glew/types_subscriber')->parse($subscriber);
25
- if ($model) {
26
- $this->subscribers[] = $model;
27
- }
28
  }
 
29
  return $this;
30
  }
31
-
32
  }
 
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);
17
  $subscribers->setPageSize($pageSize);
18
 
19
+ if ($subscribers->getLastPageNumber() < $pageNum) {
20
+ return $this;
21
  }
22
 
23
+ foreach ($subscribers as $subscriber) {
24
+ $model = Mage::getModel('glew/types_subscriber')->parse($subscriber);
25
+ if ($model) {
26
+ $this->subscribers[] = $model;
27
+ }
28
  }
29
+
30
  return $this;
31
  }
 
32
  }
33
+
app/code/community/Glew/Service/controllers/ModuleController.php CHANGED
@@ -15,34 +15,35 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
15
  {
16
  $this->_helper = Mage::helper('glew');
17
  $this->_config = $this->_helper->getConfig();
18
- if (!!$pageSize = $this->getRequest()->getParam('page_size')) {
19
  $this->_pageSize = $pageSize;
20
  }
21
- if (!!$pageNum = $this->getRequest()->getParam('page_num')) {
22
  $this->_pageNum = $pageNum;
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;
42
  }
43
  }
44
 
45
- public function gotoglewAction() {
 
46
  $this->_redirectUrl('https://app.glew.io');
47
  }
48
 
@@ -52,8 +53,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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
- if($e->getCode() != 401) {
57
  print_r($e);
58
  }
59
  $this->_helper->logException($e, 'abandonedCarts');
@@ -66,23 +67,22 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
66
  $this->_initRequest();
67
  $collection = Mage::getModel('glew/types_customers')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
68
  $this->_sendResponse($collection);
69
- } catch(Exception $e) {
70
- if($e->getCode() != 401) {
71
  print_r($e);
72
  }
73
  $this->_helper->logException($e, 'customers');
74
  }
75
  }
76
 
77
-
78
  public function ordersAction()
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) {
86
  print_r($e);
87
  }
88
  $this->_helper->logException($e, 'orders');
@@ -95,8 +95,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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) {
100
  print_r($e);
101
  }
102
  $this->_helper->logException($e, 'orderItems');
@@ -109,8 +109,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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) {
114
  print_r($e);
115
  }
116
  $this->_helper->logException($e, 'stores');
@@ -123,8 +123,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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) {
128
  print_r($e);
129
  }
130
  $this->_helper->logException($e, 'subscribers');
@@ -137,8 +137,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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) {
142
  print_r($e);
143
  }
144
  $this->_helper->logException($e, 'products');
@@ -151,8 +151,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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) {
156
  print_r($e);
157
  }
158
  $this->_helper->logException($e, 'productAlerts');
@@ -165,36 +165,35 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
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) {
170
  print_r($e);
171
  }
172
  $this->_helper->logException($e, 'categories');
173
  }
174
  }
175
 
176
- public function inventoryAction() {
 
177
  try {
178
  $this->_initRequest();
179
  $collection = Mage::getModel('glew/types_inventory')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
180
  $this->_sendResponse($collection);
181
- } catch(Exception $e) {
182
  $this->_helper->logException($e, 'inventory');
183
  }
184
  }
185
 
186
-
187
-
188
  public function versionAction()
189
  {
190
  try {
191
  $obj = new stdClass();
192
- $obj->glewPluginVersion = (string)Mage::getConfig()->getNode()->modules->Glew_Service->version;
193
- $obj->magentoVersion = (string)Mage::getVersion();
194
- $obj->phpVersion = (string)phpversion();
195
- $obj->moduleEnabled = $this->_config['enabled'];
196
  $this->_sendResponse($obj);
197
- } catch(Exception $ex) {
198
  $this->_helper->logException($ex, 'version');
199
  }
200
  }
@@ -205,8 +204,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
205
  $this->_initRequest();
206
  $collection = Mage::getModel('glew/types_extensions')->load($this->_pageSize, $this->_pageNum, $this->_sortDir, $this->_filterField);
207
  $this->_sendResponse($collection);
208
- } catch(Exception $e) {
209
- if($e->getCode() != 401) {
210
  print_r($e);
211
  }
212
  $this->_helper->logException($e, 'extensions');
@@ -219,8 +218,8 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
219
  $this->_initRequest();
220
  $collection = Mage::getModel('glew/types_refundItems')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
221
  $this->_sendResponse($collection);
222
- } catch(Exception $e) {
223
- if($e->getCode() != 401) {
224
  print_r($e);
225
  }
226
  $this->_helper->logException($e, 'refund items');
@@ -233,15 +232,14 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
233
  $this->_initRequest();
234
  $collection = Mage::getModel('glew/types_refunds')->load($this->_pageSize, $this->_pageNum, $this->_startDate, $this->_endDate, $this->_sortDir, $this->_filterField);
235
  $this->_sendResponse($collection);
236
- } catch(Exception $e) {
237
- if($e->getCode() != 401) {
238
  print_r($e);
239
  }
240
  $this->_helper->logException($e, 'refunds');
241
  }
242
  }
243
 
244
-
245
  protected function _sendResponse($items)
246
  {
247
  $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
@@ -250,8 +248,9 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
250
 
251
  private function _initRequest()
252
  {
253
- if(!$this->_config['enabled']) {
254
  $this->_reject();
 
255
  return true;
256
  }
257
 
@@ -259,12 +258,12 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
259
 
260
  $authToken = (isset($_SERVER['HTTP_X_GLEW_TOKEN']) ? $_SERVER['HTTP_X_GLEW_TOKEN'] : $_SERVER['X_GLEW_TOKEN']);
261
 
262
- if(empty($authToken)) {
263
- $this->_reject();
264
  }
265
 
266
- if(trim( $token ) != trim($authToken)) {
267
- $this->_helper->log('Glew feed request with invalid security token: ' . $authToken . ' compared to stored token: ' . $token);
268
  $this->_reject();
269
  }
270
  }
@@ -274,5 +273,5 @@ class Glew_Service_ModuleController extends Mage_Core_Controller_Front_Action
274
  $this->getResponse()->setHttpResponseCode(401)->setBody('Invalid security token or module disabled');
275
  throw new Exception('Invalid security token or module disabled', 401);
276
  }
277
-
278
  }
 
15
  {
16
  $this->_helper = Mage::helper('glew');
17
  $this->_config = $this->_helper->getConfig();
18
+ if ((bool) $pageSize = $this->getRequest()->getParam('page_size')) {
19
  $this->_pageSize = $pageSize;
20
  }
21
+ if ((bool) $pageNum = $this->getRequest()->getParam('page_num')) {
22
  $this->_pageNum = $pageNum;
23
  }
24
+ if ((bool) $startDate = $this->getRequest()->getParam('start_date')) {
25
  $this->_startDate = $startDate;
26
+ if ((bool) $endDate = $this->getRequest()->getParam('end_date')) {
27
+ $this->_endDate = $endDate;
28
  } else {
29
+ $this->_endDate = date('Y-m-d');
30
  }
31
+ } elseif ((bool) $updatedStartDate = $this->getRequest()->getParam('updated_start_date')) {
32
  $this->_filterField = 'updated_at';
33
  $this->_startDate = $updatedStartDate;
34
+ if ((bool) $updatedEndDate = $this->getRequest()->getParam('updated_end_date')) {
35
  $this->_endDate = $updatedEndDate;
36
  } else {
37
+ $this->_endDate = date('Y-m-d');
38
  }
39
  }
40
+ if ((bool) $sortDir = $this->getRequest()->getParam('sort_dir')) {
41
  $this->_sortDir = $sortDir;
42
  }
43
  }
44
 
45
+ public function gotoglewAction()
46
+ {
47
  $this->_redirectUrl('https://app.glew.io');
48
  }
49
 
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) {
58
  print_r($e);
59
  }
60
  $this->_helper->logException($e, 'abandonedCarts');
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) {
72
  print_r($e);
73
  }
74
  $this->_helper->logException($e, 'customers');
75
  }
76
  }
77
 
 
78
  public function ordersAction()
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) {
86
  print_r($e);
87
  }
88
  $this->_helper->logException($e, 'orders');
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) {
100
  print_r($e);
101
  }
102
  $this->_helper->logException($e, 'orderItems');
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) {
114
  print_r($e);
115
  }
116
  $this->_helper->logException($e, 'stores');
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) {
128
  print_r($e);
129
  }
130
  $this->_helper->logException($e, 'subscribers');
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) {
142
  print_r($e);
143
  }
144
  $this->_helper->logException($e, 'products');
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) {
156
  print_r($e);
157
  }
158
  $this->_helper->logException($e, 'productAlerts');
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) {
170
  print_r($e);
171
  }
172
  $this->_helper->logException($e, 'categories');
173
  }
174
  }
175
 
176
+ public function inventoryAction()
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');
184
  }
185
  }
186
 
 
 
187
  public function versionAction()
188
  {
189
  try {
190
  $obj = new stdClass();
191
+ $obj->glewPluginVersion = (string) Mage::getConfig()->getNode()->modules->Glew_Service->version;
192
+ $obj->magentoVersion = (string) Mage::getVersion();
193
+ $obj->phpVersion = (string) phpversion();
194
+ $obj->moduleEnabled = $this->_config['enabled'];
195
  $this->_sendResponse($obj);
196
+ } catch (Exception $ex) {
197
  $this->_helper->logException($ex, 'version');
198
  }
199
  }
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) {
209
  print_r($e);
210
  }
211
  $this->_helper->logException($e, 'extensions');
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) {
223
  print_r($e);
224
  }
225
  $this->_helper->logException($e, 'refund items');
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) {
237
  print_r($e);
238
  }
239
  $this->_helper->logException($e, 'refunds');
240
  }
241
  }
242
 
 
243
  protected function _sendResponse($items)
244
  {
245
  $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
248
 
249
  private function _initRequest()
250
  {
251
+ if (!$this->_config['enabled']) {
252
  $this->_reject();
253
+
254
  return true;
255
  }
256
 
258
 
259
  $authToken = (isset($_SERVER['HTTP_X_GLEW_TOKEN']) ? $_SERVER['HTTP_X_GLEW_TOKEN'] : $_SERVER['X_GLEW_TOKEN']);
260
 
261
+ if (empty($authToken)) {
262
+ $this->_reject();
263
  }
264
 
265
+ if (trim($token) != trim($authToken)) {
266
+ $this->_helper->log('Glew feed request with invalid security token: '.$authToken.' compared to stored token: '.$token);
267
  $this->_reject();
268
  }
269
  }
273
  $this->getResponse()->setHttpResponseCode(401)->setBody('Invalid security token or module disabled');
274
  throw new Exception('Invalid security token or module disabled', 401);
275
  }
 
276
  }
277
+
app/code/community/Glew/Service/etc/adminhtml.xml CHANGED
@@ -1,12 +1,15 @@
1
  <config>
2
  <menu>
3
- <glew translate="title" module="glew">
4
  <title>Glew</title>
5
  <sort_order>50</sort_order>
6
  <action>glew/module/gotoglew</action>
 
 
 
7
  </glew>
8
- </menu>
9
- <acl>
10
  <resources>
11
  <admin>
12
  <children>
@@ -18,3 +21,4 @@
18
  </resources>
19
  </acl>
20
  </config>
 
1
  <config>
2
  <menu>
3
+ <glew translate="title" module="glew">
4
  <title>Glew</title>
5
  <sort_order>50</sort_order>
6
  <action>glew/module/gotoglew</action>
7
+ <depends>
8
+ <config>glew_settings/general/shownav</config>
9
+ </depends>
10
  </glew>
11
+ </menu>
12
+ <acl>
13
  <resources>
14
  <admin>
15
  <children>
21
  </resources>
22
  </acl>
23
  </config>
24
+
app/code/community/Glew/Service/etc/config.xml CHANGED
@@ -1,127 +1,128 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <modules>
4
- <Glew_Service>
5
- <version>1.0.15</version>
6
- <depends>
7
- <Mage_Shipping />
8
- </depends>
9
- </Glew_Service>
10
- </modules>
11
- <global>
12
- <models>
13
- <glew>
14
- <class>Glew_Service_Model</class>
15
- </glew>
16
- </models>
17
- <helpers>
18
- <glew>
19
- <class>Glew_Service_Helper</class>
20
- </glew>
21
- </helpers>
22
- <resources>
23
- <glew_setup>
24
- <connection>
25
- <use>core_setup</use>
26
- </connection>
27
- <setup>
28
- <module>Glew_Service</module>
29
- <class>Glew_Service_Model_Resource_Setup</class>
30
- </setup>
31
- </glew_setup>
32
- <glew_read>
33
- <connection>
34
- <use>core_read</use>
35
- </connection>
36
- </glew_read>
37
- <glew_write>
38
- <connection>
39
- <use>core_write</use>
40
- </connection>
41
- </glew_write>
42
- </resources>
43
- <blocks>
44
- <glew><class>Glew_Service_Block</class></glew>
45
- </blocks>
46
- </global>
47
- <default>
48
- <glew_settings>
49
- <behavior>
50
- <order_stock_reduction>1</order_stock_reduction>
51
- <order_invoice_creation>1</order_invoice_creation>
52
- </behavior>
53
- <history>
54
- <limit>100</limit>
55
- </history>
56
- <debug>
57
- <logging>1</logging>
58
- </debug>
59
- <general>
60
- <enabled>1</enabled>
61
- </general>
62
- </glew_settings>
63
- </default>
 
 
64
 
65
- <frontend>
66
- <routers>
67
- <glew>
68
- <use>standard</use>
69
- <args>
70
- <module>Glew_Service</module>
71
- <frontName>glew</frontName>
72
- </args>
73
- </glew>
74
- </routers>
75
- </frontend>
76
-
77
- <admin>
78
- <routers>
79
- <adminhtml>
80
- <args>
81
- <modules>
82
- <glew before="Mage_Adminhtml">Glew_Service</glew>
83
- </modules>
84
- </args>
85
- </adminhtml>
86
- </routers>
87
- </admin>
88
- <adminhtml>
89
- <acl>
90
- <resources>
91
- <all>
92
- <title>Allow Everything</title>
93
- </all>
94
- <admin>
95
- <children>
96
- <system>
97
- <children>
98
- <config>
99
- <children>
100
- <glew_settings>
101
- <title>glew</title>
102
- </glew_settings>
103
- </children>
104
- </config>
105
- </children>
106
- </system>
107
- </children>
108
- </admin>
109
- </resources>
110
- </acl>
111
- </adminhtml>
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  <menu>
115
- <glew translate="title" module="glew">
116
  <title>Glew</title>
117
  <sort_order>99</sort_order>
118
  </glew>
119
- </menu>
120
- <acl>
121
  <resources>
122
  <admin>
123
  <children>
124
- <glew translate="title" module="glew">
125
  <title>Glew</title>
126
  </glew>
127
  </children>
@@ -129,3 +130,4 @@
129
  </resources>
130
  </acl>
131
  </config>
 
1
  <?xml version="1.0"?>
2
  <config>
3
+ <modules>
4
+ <Glew_Service>
5
+ <version>1.0.16</version>
6
+ <depends>
7
+ <Mage_Shipping/>
8
+ </depends>
9
+ </Glew_Service>
10
+ </modules>
11
+ <global>
12
+ <models>
13
+ <glew>
14
+ <class>Glew_Service_Model</class>
15
+ </glew>
16
+ </models>
17
+ <helpers>
18
+ <glew>
19
+ <class>Glew_Service_Helper</class>
20
+ </glew>
21
+ </helpers>
22
+ <resources>
23
+ <glew_setup>
24
+ <connection>
25
+ <use>core_setup</use>
26
+ </connection>
27
+ <setup>
28
+ <module>Glew_Service</module>
29
+ <class>Glew_Service_Model_Resource_Setup</class>
30
+ </setup>
31
+ </glew_setup>
32
+ <glew_read>
33
+ <connection>
34
+ <use>core_read</use>
35
+ </connection>
36
+ </glew_read>
37
+ <glew_write>
38
+ <connection>
39
+ <use>core_write</use>
40
+ </connection>
41
+ </glew_write>
42
+ </resources>
43
+ <blocks>
44
+ <glew>
45
+ <class>Glew_Service_Block</class>
46
+ </glew>
47
+ </blocks>
48
+ </global>
49
+ <default>
50
+ <glew_settings>
51
+ <behavior>
52
+ <order_stock_reduction>1</order_stock_reduction>
53
+ <order_invoice_creation>1</order_invoice_creation>
54
+ </behavior>
55
+ <history>
56
+ <limit>100</limit>
57
+ </history>
58
+ <debug>
59
+ <logging>1</logging>
60
+ </debug>
61
+ <general>
62
+ <enabled>1</enabled>
63
+ </general>
64
+ </glew_settings>
65
+ </default>
66
 
67
+ <frontend>
68
+ <routers>
69
+ <glew>
70
+ <use>standard</use>
71
+ <args>
72
+ <module>Glew_Service</module>
73
+ <frontName>glew</frontName>
74
+ </args>
75
+ </glew>
76
+ </routers>
77
+ </frontend>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
+ <admin>
80
+ <routers>
81
+ <adminhtml>
82
+ <args>
83
+ <modules>
84
+ <glew before="Mage_Adminhtml">Glew_Service</glew>
85
+ </modules>
86
+ </args>
87
+ </adminhtml>
88
+ </routers>
89
+ </admin>
90
+ <adminhtml>
91
+ <acl>
92
+ <resources>
93
+ <all>
94
+ <title>Allow Everything</title>
95
+ </all>
96
+ <admin>
97
+ <children>
98
+ <system>
99
+ <children>
100
+ <config>
101
+ <children>
102
+ <glew_settings>
103
+ <title>glew</title>
104
+ </glew_settings>
105
+ </children>
106
+ </config>
107
+ </children>
108
+ </system>
109
+ </children>
110
+ </admin>
111
+ </resources>
112
+ </acl>
113
+ </adminhtml>
114
 
115
  <menu>
116
+ <glew module="glew" translate="title">
117
  <title>Glew</title>
118
  <sort_order>99</sort_order>
119
  </glew>
120
+ </menu>
121
+ <acl>
122
  <resources>
123
  <admin>
124
  <children>
125
+ <glew module="glew" translate="title">
126
  <title>Glew</title>
127
  </glew>
128
  </children>
130
  </resources>
131
  </acl>
132
  </config>
133
+
app/code/community/Glew/Service/etc/system.xml CHANGED
@@ -1,63 +1,70 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <tabs>
4
- <glew translate="label" module="glew">
5
- <label>Glew</label>
6
- <sort_order>99999</sort_order>
7
- </glew>
8
- </tabs>
9
- <sections>
10
-
11
- <glew_settings translate="label" module="glew" >
12
- <label>Service</label>
13
- <tab>glew</tab>
14
- <frontend_type>text</frontend_type>
15
- <sort_order>1000</sort_order>
16
- <show_in_default>1</show_in_default>
17
- <show_in_website>1</show_in_website>
18
- <show_in_store>1</show_in_store>
19
- <groups>
20
- <info>
21
- <frontend_model>glew/adminhtml_widget_info_info</frontend_model>
22
- <sort_order>1</sort_order>
23
  <show_in_default>1</show_in_default>
24
  <show_in_website>1</show_in_website>
25
  <show_in_store>1</show_in_store>
26
- </info>
27
- <general translate="label">
28
- <label>Glew Settings</label>
29
- <frontend_type>text</frontend_type>
30
- <sort_order>100</sort_order>
31
- <show_in_default>1</show_in_default>
32
- <show_in_website>1</show_in_website>
33
- <show_in_store>1</show_in_store>
34
- <fields>
35
- <enabled translate="label">
36
- <label>Enabled</label>
37
- <frontend_type>select</frontend_type>
38
- <source_model>adminhtml/system_config_source_yesno</source_model>
39
- <sort_order>10</sort_order>
40
- <show_in_default>1</show_in_default>
41
- <show_in_website>1</show_in_website>
42
- <show_in_store>1</show_in_store>
43
- <comment>Is Glew Enabled?</comment>
44
- </enabled>
45
- <secret translate="label">
46
- <label>Secret Key</label>
47
- <frontend_type>button</frontend_type>
48
- <frontend_model>glew/secretKey</frontend_model>
49
- <sort_order>200</sort_order>
50
- <show_in_default>1</show_in_default>
51
- <show_in_website>1</show_in_website>
52
- <show_in_store>1</show_in_store>
53
- <comment>Your Glew Secret Key</comment>
54
- </secret>
55
- </fields>
56
- </general>
57
-
58
- </groups>
59
- </glew_settings>
60
-
61
-
62
- </sections>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  </config>
 
1
  <?xml version="1.0"?>
2
  <config>
3
+ <tabs>
4
+ <glew module="glew" translate="label">
5
+ <label>Glew</label>
6
+ <sort_order>99999</sort_order>
7
+ </glew>
8
+ </tabs>
9
+ <sections>
10
+ <glew_settings module="glew" translate="label">
11
+ <label>Service</label>
12
+ <tab>glew</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
 
 
 
 
 
 
 
 
15
  <show_in_default>1</show_in_default>
16
  <show_in_website>1</show_in_website>
17
  <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <info>
20
+ <frontend_model>glew/adminhtml_widget_info_info</frontend_model>
21
+ <sort_order>1</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ </info>
26
+ <general translate="label">
27
+ <label>Glew Settings</label>
28
+ <frontend_type>text</frontend_type>
29
+ <sort_order>100</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ <fields>
34
+ <enabled translate="label">
35
+ <label>Enabled</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <comment>Is Glew Enabled?</comment>
43
+ </enabled>
44
+ <shownav translate="label">
45
+ <label>Show Glew in Menu</label>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>adminhtml/system_config_source_yesno</source_model>
48
+ <sort_order>11</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
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>
57
+ <frontend_model>glew/secretKey</frontend_model>
58
+ <sort_order>200</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 Glew Secret Key</comment>
63
+ </secret>
64
+ </fields>
65
+ </general>
66
+ </groups>
67
+ </glew_settings>
68
+ </sections>
69
  </config>
70
+
app/code/community/Glew/Service/sql/glew_setup/mysql4-install-1.0.0.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
 
2
  $installer = $this;
3
 
4
  $installer->startSetup();
5
 
6
- $hostname = version_compare(phpversion(),'5.3','>=') ? gethostname() : php_uname('n');
7
  $prefix = md5($hostname);
8
- $token = sha1(uniqid($prefix, true) . rand().microtime());
9
  $installer->setConfigData('glew_settings/general/security_token', $token);
 
10
 
11
  $installer->endSetup();
 
1
  <?php
2
+
3
  $installer = $this;
4
 
5
  $installer->startSetup();
6
 
7
+ $hostname = version_compare(phpversion(), '5.3', '>=') ? gethostname() : php_uname('n');
8
  $prefix = md5($hostname);
9
+ $token = sha1(uniqid($prefix, true).rand().microtime());
10
  $installer->setConfigData('glew_settings/general/security_token', $token);
11
+ $installer->setConfigData('glew_settings/general/shownav', 1);
12
 
13
  $installer->endSetup();
14
+
app/etc/modules/Glew_Service.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Glew_Service>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Glew_Service>
8
- </modules>
9
- </config>
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Glew</name>
4
- <version>1.0.15</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
@@ -18,13 +18,18 @@ Customer Purchase Frequency&#xD;
18
  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
  Supports multi-store configurations&#xD;
22
- And more!</description>
23
- <notes>Fixed issue with getAttributeText where not supported.</notes>
 
 
 
24
  <authors><author><name>Glew</name><user>glewio</user><email>integrations@glew.io</email></author></authors>
25
- <date>2015-12-16</date>
26
- <time>14:23:25</time>
27
- <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="244e68e058d731d96f284a9e9a0bf13a"/></dir><dir name="Helper"><file name="Data.php" hash="e1bcfc59c84b1647949465613a0dd4b4"/></dir><dir name="Model"><file name="Glew.php" hash="e665b255ac5983b937eb60febd4a94bf"/><dir name="Resource"><file name="Setup.php" hash="1608ab53c5846ff80b1413693ad2657e"/></dir><dir name="Types"><file name="AbandonedCart.php" hash="ca99b85c3b2b93795013e1929a0d3613"/><file name="AbandonedCarts.php" hash="05ab68ee8093f149c1ebe7268e0eaf1f"/><file name="Address.php" hash="dac4e96501d687ce8c84ddfcc18a8327"/><file name="Categories.php" hash="7f3bb262405c9a9032688093ba6187aa"/><file name="Category.php" hash="a75878be202411265d91a20dd4afa457"/><file name="Customer.php" hash="e1f2058d9358d89a48715f151ab45755"/><file name="Customers.php" hash="656c31b938429d54c2dc4b8c6d7cb259"/><file name="Extension.php" hash="3a0bc967154cfd1ac5e9534ae96921fc"/><file name="Extensions.php" hash="4982616cd7bb0e5770b692420b8bb6cf"/><file name="Inventory.php" hash="4a6442574e2c4c640a1c88e4ca6b87fb"/><file name="InventoryItem.php" hash="7822e8679d17a4806a41e935dcdf950d"/><file name="Order.php" hash="f17622408310699e6cbccbb4b02e1ac3"/><file name="OrderItem.php" hash="b60ae77da7d234c0feebb347f964f8f1"/><file name="OrderItems.php" hash="3d63cc89cdcb79632183eca0a2c7bd82"/><file name="Orders.php" hash="8f215ef68dfa393acfb4a5380d111f75"/><file name="Product.php" hash="65ded98b28ad64da908f74ce1b3cff69"/><file name="ProductAlert.php" hash="e7ca7668907dad5547d80ad581519e78"/><file name="ProductAlerts.php" hash="767c8c527156a11ab376292c10c8fd5d"/><file name="Products.php" hash="e6890059117a05d6d1006c13ddf15855"/><file name="Refund.php" hash="1b79b89a2ac66cc0dfb05e1f3100f98c"/><file name="RefundItem.php" hash="1d43007ec2bb990eb08b8d0a2812f4ca"/><file name="RefundItems.php" hash="7b7511e30194b13db1f8671027fe913a"/><file name="Refunds.php" hash="1073e14c4e82f00d0f25eb4dcff48669"/><file name="Store.php" hash="455923168b5d2550af6b862d776db3f2"/><file name="Stores.php" hash="5d057d09db03554807d763d29ade16e9"/><file name="Subscriber.php" hash="727153725fc7be3fd093422d6a67dfa1"/><file name="Subscribers.php" hash="a17ea2cc95f206989fd0b3612fd9f9bb"/></dir></dir><dir name="controllers"><file name="ModuleController.php" hash="aacae6db78a87a94e8e6cdfd0798d87f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d2d95c59dc81f92df0ed6adaba801a52"/><file name="config.xml" hash="a7038a582e3c8a5b157c3507b5620df2"/><file name="system.xml" hash="07aa4da88108940bf267cb2abb854eab"/></dir><dir name="sql"><dir name="glew_setup"><file name="mysql4-install-1.0.0.php" hash="d515369cd1867cf970f27352d927e402"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Glew_Service.xml" hash="db2470cc1c1c36b01cea61416a3f6f37"/></dir></target></contents>
28
  <compatible/>
29
  <dependencies><required><php><min>5.3.0</min><max>9.0.0</max></php></required></dependencies>
30
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Glew</name>
4
+ <version>1.0.16</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
18
  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
+ Inventory,&#xD;
23
  Supports multi-store configurations&#xD;
24
+ And more!&#xD;
25
+ </description>
26
+ <notes>Fixed issue with inventory levels and configurable products&#xD;
27
+ Fixed issue with inventory for customers with multiple stores&#xD;
28
+ Added ability to disable Glew in menu</notes>
29
  <authors><author><name>Glew</name><user>glewio</user><email>integrations@glew.io</email></author></authors>
30
+ <date>2016-01-27</date>
31
+ <time>19:31:02</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"/></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="aa32ad322b2eb3dad0a12b49e95667b8"/><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="3772178cd29d8c3df25d28e37423ef16"/><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="4508e4770d921d45c3e6bbe90fded76b"/><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=""/></dir></target></contents>
33
  <compatible/>
34
  <dependencies><required><php><min>5.3.0</min><max>9.0.0</max></php></required></dependencies>
35
  </package>