analytics-and-reports - Version 1.0.0

Version Notes

Freento Analytics & Reports extension for Magento. Allows to analyze live Magento store

Download this release

Release Info

Developer Freento.com
Extension analytics-and-reports
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (51) hide show
  1. app/code/community/Freento/Aconnector/Block/Adminhtml/System/Config/Form/GenerateKeys.php +30 -0
  2. app/code/community/Freento/Aconnector/Controller/Abstract.php +14 -0
  3. app/code/community/Freento/Aconnector/Crypt.php +76 -0
  4. app/code/community/Freento/Aconnector/Helper/Data.php +58 -0
  5. app/code/community/Freento/Aconnector/Model/Aconnector.php +224 -0
  6. app/code/community/Freento/Aconnector/Model/Customer.php +171 -0
  7. app/code/community/Freento/Aconnector/Model/Customer/Group.php +54 -0
  8. app/code/community/Freento/Aconnector/Model/Log.php +60 -0
  9. app/code/community/Freento/Aconnector/Model/Order.php +69 -0
  10. app/code/community/Freento/Aconnector/Model/Product.php +118 -0
  11. app/code/community/Freento/Aconnector/Model/Report/Abstract.php +264 -0
  12. app/code/community/Freento/Aconnector/Model/Report/AllCustomers.php +67 -0
  13. app/code/community/Freento/Aconnector/Model/Report/AllProducts.php +74 -0
  14. app/code/community/Freento/Aconnector/Model/Report/BestCategory.php +33 -0
  15. app/code/community/Freento/Aconnector/Model/Report/BestCoupons.php +30 -0
  16. app/code/community/Freento/Aconnector/Model/Report/Bestsellers.php +23 -0
  17. app/code/community/Freento/Aconnector/Model/Report/Comparable.php +43 -0
  18. app/code/community/Freento/Aconnector/Model/Report/CustomerPurchases.php +49 -0
  19. app/code/community/Freento/Aconnector/Model/Report/DaysForTheFirstPurchase.php +45 -0
  20. app/code/community/Freento/Aconnector/Model/Report/Grouped/Abstract.php +40 -0
  21. app/code/community/Freento/Aconnector/Model/Report/MostRefunded.php +23 -0
  22. app/code/community/Freento/Aconnector/Model/Report/NewCustomersByPeriod.php +26 -0
  23. app/code/community/Freento/Aconnector/Model/Report/ProductsByCustomer.php +13 -0
  24. app/code/community/Freento/Aconnector/Model/Report/RefundsPercent.php +25 -0
  25. app/code/community/Freento/Aconnector/Model/Report/Sales.php +20 -0
  26. app/code/community/Freento/Aconnector/Model/Report/SalesByCategory.php +41 -0
  27. app/code/community/Freento/Aconnector/Model/Report/SalesByCountry.php +34 -0
  28. app/code/community/Freento/Aconnector/Model/Report/SalesByCustomer.php +41 -0
  29. app/code/community/Freento/Aconnector/Model/Report/SalesByCustomerGroup.php +45 -0
  30. app/code/community/Freento/Aconnector/Model/Report/SalesByDayOfWeek.php +19 -0
  31. app/code/community/Freento/Aconnector/Model/Report/SalesByHour.php +20 -0
  32. app/code/community/Freento/Aconnector/Model/Report/SalesByMonth.php +19 -0
  33. app/code/community/Freento/Aconnector/Model/Report/SalesByPeriodOfTime.php +19 -0
  34. app/code/community/Freento/Aconnector/Model/Report/SalesByProduct.php +29 -0
  35. app/code/community/Freento/Aconnector/Model/Report/SalesByQuarter.php +19 -0
  36. app/code/community/Freento/Aconnector/Model/Report/SalesByState.php +39 -0
  37. app/code/community/Freento/Aconnector/Model/Report/SalesByWeek.php +20 -0
  38. app/code/community/Freento/Aconnector/Model/Report/SalesByYear.php +20 -0
  39. app/code/community/Freento/Aconnector/Model/Report/SalesDetailed.php +14 -0
  40. app/code/community/Freento/Aconnector/controllers/Adminhtml/Freentoaconnectoradmin/System/ConfigController.php +41 -0
  41. app/code/community/Freento/Aconnector/controllers/CustomerController.php +18 -0
  42. app/code/community/Freento/Aconnector/controllers/CustomerGroupController.php +18 -0
  43. app/code/community/Freento/Aconnector/controllers/IndexController.php +29 -0
  44. app/code/community/Freento/Aconnector/controllers/OrderController.php +11 -0
  45. app/code/community/Freento/Aconnector/controllers/ProductController.php +18 -0
  46. app/code/community/Freento/Aconnector/etc/adminhtml.xml +25 -0
  47. app/code/community/Freento/Aconnector/etc/config.xml +83 -0
  48. app/code/community/Freento/Aconnector/etc/system.xml +61 -0
  49. app/etc/modules/Freento_Aconnector.xml +9 -0
  50. js/freento_aconnector/clipboard.min.js +7 -0
  51. package.xml +18 -0
app/code/community/Freento/Aconnector/Block/Adminhtml/System/Config/Form/GenerateKeys.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Block_Adminhtml_System_Config_Form_GenerateKeys extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ public function render(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $element->unsScope()
9
+ ->unsCanUseWebsiteValue()
10
+ ->unsCanUseDefaultValue()
11
+ ;
12
+ return parent::render($element);
13
+ }
14
+
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
16
+ {
17
+ $this->setElement($element);
18
+ $url = $this->getUrl('adminhtml/freentoaconnectoradmin_system_config/generateKeys');
19
+
20
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
21
+ ->setType('button')
22
+ ->setClass('scalable')
23
+ ->setLabel(Mage::helper('freento_aconnector')->__('Generate Keys'))
24
+ ->setOnClick("setLocation('$url');")
25
+ ->toHtml();
26
+
27
+ return $html;
28
+ }
29
+
30
+ }
app/code/community/Freento/Aconnector/Controller/Abstract.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Controller_Abstract extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ protected function _prepareEncodedResponse($body)
7
+ {
8
+ $encryptor = new Freento_Aconnector_Crypt();
9
+ $key = Mage::getStoreConfig('aconnector/global/generate_keys');
10
+ return $this->getResponse()->setBody($encryptor->encrypt($key, $body, false));
11
+ }
12
+
13
+
14
+ }
app/code/community/Freento/Aconnector/Crypt.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Crypt
4
+ {
5
+ protected function _getKeyResource($key, $public = true)
6
+ {
7
+ if ($public) {
8
+ $keyResource = openssl_pkey_get_public($key);
9
+ } else {
10
+ $keyResource = openssl_pkey_get_private($key);
11
+ }
12
+ return $keyResource;
13
+ }
14
+
15
+ public function encrypt($keyPlain, $plaintext, $public = true)
16
+ {
17
+ $key = $this->_getKeyResource($keyPlain, $public);
18
+ $a_key = openssl_pkey_get_details($key);
19
+
20
+ // Encrypt the data in small chunks and then combine and send it.
21
+ $chunkSize = ceil($a_key['bits'] / 8) - 11;
22
+ $output = '';
23
+
24
+ while ($plaintext)
25
+ {
26
+ $chunk = substr($plaintext, 0, $chunkSize);
27
+ $plaintext = substr($plaintext, $chunkSize);
28
+ $encrypted = '';
29
+ if ($public) {
30
+ if (!openssl_public_encrypt($chunk, $encrypted, $key))
31
+ {
32
+ die('Failed to encrypt data');
33
+ }
34
+ } else {
35
+ if (!openssl_private_encrypt($chunk, $encrypted, $key))
36
+ {
37
+ die('Failed to encrypt data');
38
+ }
39
+ }
40
+ $output .= $encrypted;
41
+ }
42
+ openssl_free_key($key);
43
+ return $output;
44
+ }
45
+
46
+ public function decrypt($keyPlain, $encrypted, $public = true)
47
+ {
48
+ $key = $this->_getKeyResource($keyPlain, $public);
49
+ $a_key = openssl_pkey_get_details($key);
50
+
51
+ // Decrypt the data in the small chunks
52
+ $chunkSize = ceil($a_key['bits'] / 8);
53
+ $output = '';
54
+
55
+ while ($encrypted)
56
+ {
57
+ $chunk = substr($encrypted, 0, $chunkSize);
58
+ $encrypted = substr($encrypted, $chunkSize);
59
+ $decrypted = '';
60
+ if ($public) {
61
+ if (!openssl_public_decrypt($chunk, $decrypted, $key))
62
+ {
63
+ die('Failed to decrypt data');
64
+ }
65
+ } else {
66
+ if (!openssl_private_decrypt($chunk, $decrypted, $key))
67
+ {
68
+ die('Failed to decrypt data');
69
+ }
70
+ }
71
+ $output .= $decrypted;
72
+ }
73
+ openssl_free_key($key);
74
+ return $output;
75
+ }
76
+ }
app/code/community/Freento/Aconnector/Helper/Data.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ public function getExtensionVersion()
6
+ {
7
+ return Mage::getConfig()->getModuleConfig('Freento_Aconnector')->version;
8
+ }
9
+
10
+ public function isEnabled() {
11
+ return parent::isModuleOutputEnabled() && Mage::getStoreConfig('aconnector/global/enabled');
12
+ }
13
+
14
+ public function validateDate($date, $format = 'Y-m-d H:i:s')
15
+ {
16
+ $d = DateTime::createFromFormat($format, $date);
17
+ return $d && $d->format($format) == $date;
18
+ }
19
+
20
+ public function getSkuList($reportResult)
21
+ {
22
+ $skuList = array();
23
+ foreach ($reportResult as $item) {
24
+ if (isset($item['sku'])) {
25
+ $skuList[] = $item['sku'];
26
+ }
27
+ }
28
+ return $skuList;
29
+ }
30
+
31
+ public function getList($reportResult, $attribute)
32
+ {
33
+ $list = array();
34
+ foreach ($reportResult as $item) {
35
+ if (isset($item[$attribute])) {
36
+ $list[] = $item[$attribute];
37
+ }
38
+ }
39
+ return $list;
40
+ }
41
+
42
+ public function getParamList($reportResult, $param)
43
+ {
44
+ $skuList = array();
45
+ foreach ($reportResult as $item) {
46
+ if (isset($item[$param])) {
47
+ $skuList[] = $item[$param];
48
+ }
49
+ }
50
+ return $skuList;
51
+ }
52
+
53
+ public function getLogger()
54
+ {
55
+ return Mage::getSingleton('freento_aconnector/log');
56
+ }
57
+
58
+ }
app/code/community/Freento/Aconnector/Model/Aconnector.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Aconnector extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ protected $_reports = array(
7
+ 'bestsellers',
8
+ 'sales',
9
+ 'salesByCountry',
10
+ 'bestCoupons',
11
+ 'bestCategory',
12
+ 'salesByCustomerGroup',
13
+ 'salesByCustomer',
14
+ 'newCustomersByPeriod',
15
+ 'salesByHour',
16
+ 'salesByMonth',
17
+ 'salesByDayOfWeek',
18
+ 'salesByWeek',
19
+ 'salesByQuarter',
20
+ 'salesByYear',
21
+ 'salesByPeriodOfTime',
22
+ 'mostRefunded',
23
+ 'salesDetailed',
24
+ 'allProducts',
25
+ 'allCustomers',
26
+ 'salesByProduct',
27
+ 'salesByCategory',
28
+ 'refundsPercent',
29
+ 'salesByState',
30
+ 'customerPurchases',
31
+ 'daysForTheFirstPurchase',
32
+ );
33
+
34
+ public static function methodIsAllowedForAproxy($method)
35
+ {
36
+ return in_array($method, array('getReportData', 'getStores'));
37
+ }
38
+
39
+ public static function getStores()
40
+ {
41
+ $options = array();
42
+ $options[] = array(
43
+ 'label' => Mage::helper('adminhtml')->__('All Store Views'),
44
+ 'value' => 0,
45
+ 'level' => 0
46
+ );
47
+
48
+ $nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
49
+
50
+ foreach (Mage::app()->getWebsites() as $website) {
51
+ $options[] = array(
52
+ 'label' => $website->getName(),
53
+ 'value' => implode(',', $website->getStoreIds()),
54
+ 'level' => 0
55
+ );
56
+ foreach ($website->getGroups() as $group) {
57
+ if ($website->getId() != $group->getWebsiteId()) {
58
+ continue;
59
+ }
60
+ $options[] = array(
61
+ 'label' => $group->getName(),
62
+ 'value' => implode(',', $group->getStoreIds()),
63
+ 'level' => 1
64
+ );
65
+ foreach (Mage::app()->getStores() as $store) {
66
+ if ($group->getId() != $store->getGroupId()) {
67
+ continue;
68
+ }
69
+ $options[] = array(
70
+ 'label' => $store->getName(),
71
+ 'value' => $store->getId(),
72
+ 'level' => 2
73
+ );
74
+ }
75
+ }
76
+ }
77
+ return $options;
78
+ }
79
+
80
+ public static function getReport($type)
81
+ {
82
+ if( ! Mage::getModel('freento_aconnector/aconnector')->validateReport($type)) {
83
+ throw new Exception('Report model not found.');
84
+ }
85
+
86
+ return Mage::getModel('freento_aconnector/report_' . $type);
87
+ }
88
+
89
+ public static function getReportData($params)
90
+ {
91
+ $result = array();
92
+
93
+ try {
94
+ $reportType = $params['report_type'];
95
+ $dateFrom = isset($params['date_from']) ? $params['date_from'] : null;
96
+ $dateTo = isset($params['date_to']) ? $params['date_to'] : null;
97
+ $dateFromCompare = isset($params['date_from_compare']) ? $params['date_from_compare'] : null;
98
+ $dateToCompare = isset($params['date_to_compare']) ? $params['date_to_compare'] : null;
99
+ $page = (int)$params['page'];
100
+ $limit = (int)$params['limit'];
101
+ $storeIds = isset($params['store_ids']) ? explode(',', $params['store_ids']) : array(0);
102
+ $sortField = isset($params['sort_field']) ? $params['sort_field'] : null;
103
+ $sortDirection = isset($params['sort_direction']) ? $params['sort_direction'] : null;
104
+ $filter = isset($params['filter']) ? json_decode($params['filter']) : array();
105
+ $groupPeriod = isset($params['group_period']) ? $params['group_period'] : null;
106
+
107
+ $standardParams = array(
108
+ 'report_type',
109
+ 'date_from',
110
+ 'date_to',
111
+ 'date_from_compare',
112
+ 'date_to_compare',
113
+ 'page',
114
+ 'limit',
115
+ 'store_ids',
116
+ 'sort_field',
117
+ 'sort_direction',
118
+ 'filter'
119
+ );
120
+
121
+ $additionalParams = array();
122
+ foreach($params as $key => $value) {
123
+ if(!in_array($key, $standardParams)) {
124
+ $additionalParams[$key] = $value;
125
+ }
126
+ }
127
+
128
+ $result['main'] = Freento_Aconnector_Model_Aconnector::getReport($reportType)
129
+ ->addDateFromTo($dateFrom, $dateTo)
130
+ ->setLimit($limit)
131
+ ->setPage($page)
132
+ ->setStoreIds($storeIds)
133
+ ->setSortDirection($sortDirection)
134
+ ->setSortField($sortField)
135
+ ->setFilter($filter)
136
+ ->setAdditionalParams($additionalParams)
137
+ ->process();
138
+
139
+ if ($dateFromCompare && $dateToCompare) {
140
+ $compare = Freento_Aconnector_Model_Aconnector::getReport($reportType)
141
+ ->addDateFromTo($dateFromCompare, $dateToCompare)
142
+ ->setLimit($limit)
143
+ ->setPage(1)
144
+ ->setStoreIds($storeIds)
145
+ ->setMainReportResults($result['main'])
146
+ ->setSortDirection($sortDirection)
147
+ ->setSortField($sortField)
148
+ ->setFilter($filter)
149
+ ->setAdditionalParams($additionalParams)
150
+ ->process();
151
+
152
+ if(is_null($groupPeriod) || (empty($result['main']) && empty($compare))) {
153
+ foreach ($compare as $rowKey => $row) {
154
+ foreach ($row as $rowColumn => $column) {
155
+ $result['main'][$rowKey][$rowColumn . '_compare'] = $column;
156
+ }
157
+ }
158
+ } else {
159
+ $result['main'] = self::_prepareGroupedCompareResult($groupPeriod, $result['main'], $compare);
160
+ }
161
+
162
+ }
163
+
164
+ $result['count'] = Freento_Aconnector_Model_Aconnector::getReport($reportType)
165
+ ->setLimit($limit)
166
+ ->setPage($page)
167
+ ->setStoreIds($storeIds)
168
+ ->setSortDirection($sortDirection)
169
+ ->setSortField($sortField)
170
+ ->addDateFromTo($dateFrom, $dateTo)
171
+ ->setFilter($filter)
172
+ ->setAdditionalParams($additionalParams)
173
+ ->getRecordsCount();
174
+ } catch (Exception $ex) {
175
+ $result['error'] = $ex->getMessage();
176
+ }
177
+ return json_encode($result);
178
+ }
179
+
180
+ protected static function _prepareGroupedCompareResult($period, $result, $compare)
181
+ {
182
+ $emptyItem = array();
183
+ $keys = empty($result) ? array_keys(reset($compare)) : array_keys(reset($result));
184
+ foreach($keys as $key) {
185
+ $emptyItem[$key] = '';
186
+ $emptyItem[$key . '_compare'] = '';
187
+ }
188
+
189
+ $toReturn = array();
190
+ foreach ($result as $row) {
191
+ if(!isset($toReturn[$row[$period]])) {
192
+ $toReturn[$row[$period]] = $emptyItem;
193
+ }
194
+
195
+ foreach($row as $k => $v) {
196
+ $toReturn[$row[$period]][$k] = $v;
197
+ }
198
+ }
199
+ foreach ($compare as $row) {
200
+ if(!isset($toReturn[$row[$period]])) {
201
+ $toReturn[$row[$period]] = $emptyItem;
202
+ }
203
+
204
+ foreach($row as $k => $v) {
205
+ $toReturn[$row[$period]][$k . '_compare'] = $v;
206
+ }
207
+
208
+ if(!$toReturn[$row[$period]][$period]) {
209
+ $toReturn[$row[$period]][$period] = $row[$period];
210
+ }
211
+ }
212
+
213
+ return $toReturn;
214
+ }
215
+
216
+ public function validateReport($report)
217
+ {
218
+ //сопоставить имя модели со списком доступных, что бы не было фатала
219
+ if( ! in_array($report, $this->_reports)) {
220
+ return false;
221
+ }
222
+ return true;
223
+ }
224
+ }
app/code/community/Freento/Aconnector/Model/Customer.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Customer
4
+ {
5
+
6
+ public function getCustomersList($params)
7
+ {
8
+ $result = array('main' => array(), 'count' => 0);
9
+
10
+ if (empty($params)) {
11
+ return $result;
12
+ }
13
+
14
+ $firstnameAttr = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'firstname');
15
+ $lastnameAttr = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'lastname');
16
+
17
+ $collection = Mage::getModel('customer/customer')->getCollection();
18
+ $collection->addAttributeToSelect('email');
19
+
20
+ $collection->getSelect()
21
+ ->joinLeft(array('ce1' => Mage::getSingleton('core/resource')->getTableName('customer_entity_varchar')), 'ce1.entity_id = e.entity_id', array())
22
+ ->where('ce1.attribute_id = ' . $firstnameAttr->getAttributeId())
23
+ ->joinLeft(array('ce2' => Mage::getSingleton('core/resource')->getTableName('customer_entity_varchar')), 'ce2.entity_id = e.entity_id', array())
24
+ ->where('ce2.attribute_id = ' . $lastnameAttr->getAttributeId())
25
+ ->columns(new Zend_Db_Expr('CONCAT(ce1.value, \' \',ce2.value) AS name'))
26
+ ;
27
+
28
+ $collection
29
+ ->setPageSize($params['limit'])
30
+ ->setCurPage($params['page']);
31
+
32
+ if (isset($params['query'])) {
33
+ $collection->addAttributeToFilter(
34
+ array(
35
+ array('attribute'=> 'email', 'like' => '%'. $params['query'] . '%')
36
+ )
37
+ );
38
+ }
39
+
40
+ foreach ($collection as $customer) {
41
+ $result['main'][] = array(
42
+ 'id' => $customer->getId(),
43
+ 'email' => $customer->getEmail(),
44
+ 'name' => $customer->getData('name')
45
+ );
46
+ }
47
+ $result['count'] = $collection->getSize();
48
+ return $result;
49
+ }
50
+
51
+ public function getAttributes()
52
+ {
53
+ $attributes = Mage::getModel('customer/customer')->getAttributes();
54
+
55
+ $result = array(
56
+ 'name' => array(
57
+ 'label' => 'Name',
58
+ 'type' => 'string'
59
+ )
60
+ );
61
+ foreach ($attributes as $attribute) {
62
+
63
+ if(!$attribute->getFrontendLabel()) {
64
+ continue;
65
+ }
66
+
67
+ $type = '';
68
+ /** @todo add type for selects */
69
+ switch($attribute->getFrontendInput()) {
70
+ case 'text':
71
+ case 'textarea':
72
+ $type = 'string';
73
+ break;
74
+ case 'date':
75
+ case 'datetime':
76
+ $type = 'datetime';
77
+ break;
78
+ default:
79
+ $type = 'string';
80
+ }
81
+
82
+ $result[$attribute->getAttributeCode()] = array(
83
+ 'label' => $attribute->getFrontendLabel(),
84
+ 'type' => $type
85
+ );
86
+ }
87
+
88
+ if(isset($result['default_billing'])) {
89
+ unset($result['default_billing']);
90
+ }
91
+ if(isset($result['default_shipping'])) {
92
+ unset($result['default_shipping']);
93
+ }
94
+
95
+ $addressesAttributes = array(
96
+ 'billing_street' => array(
97
+ 'label' => 'Default Billing: Street',
98
+ 'type' => 'string'
99
+ ),
100
+ 'billing_postcode' => array(
101
+ 'label' => 'Default Billing: Postcode',
102
+ 'type' => 'string'
103
+ ),
104
+ 'billing_city' => array(
105
+ 'label' => 'Default Billing: City',
106
+ 'type' => 'string'
107
+ ),
108
+ 'billing_telephone' => array(
109
+ 'label' => 'Default Billing: Telephone',
110
+ 'type' => 'string'
111
+ ),
112
+ 'billing_fax' => array(
113
+ 'label' => 'Default Billing: Fax',
114
+ 'type' => 'string'
115
+ ),
116
+ 'billing_region' => array(
117
+ 'label' => 'Default Billing: Region',
118
+ 'type' => 'string'
119
+ ),
120
+ 'billing_country_code' => array(
121
+ 'label' => 'Default Billing: Country Code',
122
+ 'type' => 'string'
123
+ ),
124
+ 'shipping_street' => array(
125
+ 'label' => 'Default Shipping: Street',
126
+ 'type' => 'string'
127
+ ),
128
+ 'shipping_postcode' => array(
129
+ 'label' => 'Default Shipping: Postcode',
130
+ 'type' => 'string'
131
+ ),
132
+ 'shipping_city' => array(
133
+ 'label' => 'Default Shipping: City',
134
+ 'type' => 'string'
135
+ ),
136
+ 'shipping_telephone' => array(
137
+ 'label' => 'Default Shipping: Telephone',
138
+ 'type' => 'string'
139
+ ),
140
+ 'shipping_fax' => array(
141
+ 'label' => 'Default Shipping: Fax',
142
+ 'type' => 'string'
143
+ ),
144
+ 'shipping_region' => array(
145
+ 'label' => 'Default Shipping: Region',
146
+ 'type' => 'string'
147
+ ),
148
+ 'shipping_country_code' => array(
149
+ 'label' => 'Default Shipping: Country Code',
150
+ 'type' => 'string'
151
+ ),
152
+ );
153
+
154
+ return array_merge($result, $addressesAttributes);
155
+ }
156
+
157
+ public function getAttributesList()
158
+ {
159
+ $toReturn = array();
160
+ foreach ($this->getAttributes() as $attributeCode => $attribute) {
161
+ $toReturn[] = array(
162
+ 'id' => $attributeCode,
163
+ 'attribute_code' => $attributeCode,
164
+ 'attribute_label' => $attribute['label'],
165
+ 'attribute_type' => $attribute['type']
166
+ );
167
+ }
168
+ return array('main' => $toReturn);
169
+ }
170
+
171
+ }
app/code/community/Freento/Aconnector/Model/Customer/Group.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Customer_Group
4
+ {
5
+
6
+ public function getCustomerGroupsList($params)
7
+ {
8
+ $result = array('main' => array(), 'count' => 0);
9
+
10
+ if (empty($params)) {
11
+ return $result;
12
+ }
13
+
14
+ $collection = Mage::getModel('customer/group')->getCollection();
15
+
16
+ $collection
17
+ ->setPageSize($params['limit'])
18
+ ->setCurPage($params['page']);
19
+
20
+ if (isset($params['query'])) {
21
+ $collection->addFieldToFilter(
22
+ 'customer_group_code', array('like' => '%'. $params['query'] . '%')
23
+ );
24
+ }
25
+
26
+ foreach ($collection as $customer) {
27
+ $result['main'][] = array(
28
+ 'id' => $customer->getCustomerGroupId(),
29
+ 'customer_group_code' => $customer->getCustomerGroupCode()
30
+ );
31
+ }
32
+ $result['count'] = $collection->getSize();
33
+ return $result;
34
+ }
35
+
36
+ public function getAttributesList()
37
+ {
38
+ $toReturn = array(
39
+ array(
40
+ 'attribute_code' => 'customer_group_id',
41
+ 'attribute_label' => 'Group ID',
42
+ 'attribute_type' => 'string'
43
+ ),
44
+ array(
45
+ 'attribute_code' => 'customer_group_code',
46
+ 'attribute_label' => 'Group Code',
47
+ 'attribute_type' => 'string'
48
+ )
49
+ );
50
+
51
+ return array('main' => $toReturn);
52
+ }
53
+
54
+ }
app/code/community/Freento/Aconnector/Model/Log.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Log
4
+ {
5
+
6
+ const LOG_FILE_NAME = 'freento_aconnector.log';
7
+
8
+ protected $_enableTestsLog = false;
9
+ protected $_log = array();
10
+ protected $_isLogEnabled = null;
11
+
12
+ public function getEnableTestsLog()
13
+ {
14
+ return $this->_enableTestsLog;
15
+ }
16
+
17
+ public function setEnableTestsLog($value)
18
+ {
19
+ $this->_enableTestsLog = $value;
20
+ }
21
+
22
+ public function getLog()
23
+ {
24
+ return $this->_log;
25
+ }
26
+
27
+ public function getLogRecord($key) {
28
+ return isset($this->_log[$key]) ? $this->_log[$key] : false;
29
+ }
30
+
31
+ public function addRowToLog($value, $key = null)
32
+ {
33
+ if(is_null($key)) {
34
+ $this->_log[] = $value;
35
+ } else {
36
+ $this->_log[$key] = $value;
37
+ }
38
+ }
39
+
40
+ public function isLogEnabled()
41
+ {
42
+ if(is_null($this->_isLogEnabled)) {
43
+ $this->_isLogEnabled = Mage::getStoreConfig('aconnector/global/log_enabled');
44
+ }
45
+
46
+ return $this->_isLogEnabled;
47
+ }
48
+
49
+ public function log($message, $key = null)
50
+ {
51
+ if($this->getEnableTestsLog()) {
52
+ $this->addRowToLog($message, $key);
53
+ }
54
+
55
+ if($this->isLogEnabled()) {
56
+ Mage::log($message, Zend_Log::DEBUG, self::LOG_FILE_NAME);
57
+ }
58
+ }
59
+
60
+ }
app/code/community/Freento/Aconnector/Model/Order.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Order
4
+ {
5
+ public $_orderAttributes = array(
6
+ 'entity_id' => array('label' => 'ID', 'type' => 'numeric'),
7
+ 'increment_id' => array('label' => 'Increment ID', 'type' => 'string'),
8
+ 'state' => array('label' => 'State', 'type' => 'string'),
9
+ 'status' => array('label' => 'Status', 'type' => 'string'),
10
+ 'coupon_code' => array('label' => 'Coupon Code', 'type' => 'string'),
11
+ 'customer_id' => array('label' => 'Customer ID', 'type' => 'numeric'),
12
+ 'base_discount_amount' => array('label' => 'Base Discount Amount', 'type' => 'price'),
13
+ 'discount_description' => array('label' => 'Discount Description', 'type' => 'string'),
14
+ 'base_grand_total' => array('label' => 'Base Grand Total', 'type' => 'price'),
15
+ 'base_shipping_amount' => array('label' => 'Base Shipping Amount', 'type' => 'price'),
16
+ 'base_subtotal' => array('label' => 'Base Subtotal', 'type' => 'price'),
17
+ 'base_tax_amount' => array('label' => 'Base Tax Amount', 'type' => 'price'),
18
+ 'base_total_canceled' => array('label' => 'Base Total Cancelled', 'type' => 'price'),
19
+ 'base_total_invoiced' => array('label' => 'Base Total Invoiced', 'type' => 'price'),
20
+ 'base_total_invoiced_cost' => array('label' => 'Base Total Invoiced Cost', 'type' => 'price'),
21
+ 'base_total_paid' => array('label' => 'Base Total Paid', 'type' => 'price'),
22
+ 'base_total_qty_ordered' => array('label' => 'Base Total Qty Ordered', 'type' => 'numeric'),
23
+ 'base_total_refunded' => array('label' => 'Base Total Refunded', 'type' => 'price'),
24
+ 'shipping_amount' => array('label' => 'Shipping Amount', 'type' => 'price'),
25
+ 'subtotal' => array('label' => 'Subtotal', 'type' => 'price'),
26
+ 'tax_amount' => array('label' => 'Tax Amount', 'type' => 'price'),
27
+ 'total_canceled' => array('label' => 'Total Cancelled', 'type' => 'price'),
28
+ 'total_invoiced' => array('label' => 'Total Invoiced', 'type' => 'price'),
29
+ 'base_total_invoiced_cost' => array('label' => 'Base Total Invoiced Cost', 'type' => 'price'),
30
+ 'total_paid' => array('label' => 'Total Paid', 'type' => 'price'),
31
+ 'total_qty_ordered' => array('label' => 'Total Qty Ordered', 'type' => 'numeric'),
32
+ 'total_refunded' => array('label' => 'Total Refunded', 'type' => 'price'),
33
+ 'email_sent' => array('label' => 'Email Sent', 'type' => 'string'),
34
+ 'customer_email' => array('label' => 'Customer Email', 'type' => 'string'),
35
+ 'customer_prefix' => array('label' => 'Customer Prefix', 'type' => 'string'),
36
+ 'customer_firstname' => array('label' => 'Customer Firstname', 'type' => 'string'),
37
+ 'customer_middlename' => array('label' => 'Customer Middlename', 'type' => 'string'),
38
+ 'customer_lastname' => array('label' => 'Customer Lastname', 'type' => 'string'),
39
+ 'customer_suffix' => array('label' => 'Customer Suffix', 'type' => 'string'),
40
+ 'customer_taxvat' => array('label' => 'Customer Taxvat', 'type' => 'string'),
41
+ 'customer_dob' => array('label' => 'Customer Date of Birth', 'type' => 'date'),
42
+ 'order_currency_code' => array('label' => 'Order Currency Code', 'type' => 'string'),
43
+ 'shipping_method' => array('label' => 'Shipping Method', 'type' => 'string'),
44
+ 'customer_note' => array('label' => 'Customer Note', 'type' => 'string'),
45
+ 'created_at' => array('label' => 'Created At', 'type' => 'datetime'),
46
+ 'updated_at' => array('label' => 'Updated At', 'type' => 'datetime'),
47
+ 'total_item_count' => array('label' => 'Total Item Count', 'type' => 'numeric'),
48
+ 'coupon_rule_name' => array('label' => 'Coupon Rule Name', 'type' => 'string'),
49
+ );
50
+
51
+ public function getAttributes()
52
+ {
53
+ return $this->_orderAttributes;
54
+ }
55
+
56
+ public function getAttributesList()
57
+ {
58
+ $toReturn = array();
59
+ foreach ($this->getAttributes() as $attributeCode => $attribute) {
60
+ $toReturn[] = array(
61
+ 'id' => $attributeCode,
62
+ 'attribute_code' => $attributeCode,
63
+ 'attribute_label' => $attribute['label'],
64
+ 'attribute_type' => $attribute['type']
65
+ );
66
+ }
67
+ return array('main' => $toReturn);
68
+ }
69
+ }
app/code/community/Freento/Aconnector/Model/Product.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Product
4
+ {
5
+
6
+ public function getProductsList($params)
7
+ {
8
+ $result = array('main' => array(), 'count' => 0);
9
+
10
+ if (empty($params)) {
11
+ return $result;
12
+ }
13
+
14
+ $collection = Mage::getModel('catalog/product')->getCollection();
15
+ $collection->addAttributeToSelect('name');
16
+
17
+ $collection
18
+ ->setPageSize($params['limit'])
19
+ ->setCurPage($params['page']);
20
+
21
+ if (isset($params['query'])) {
22
+ $collection->addAttributeToFilter(
23
+ array(
24
+ array('attribute'=> 'sku', 'like' => '%'. $params['query'] . '%'),
25
+ array('attribute'=> 'name', 'like' => '%'. $params['query'] . '%')
26
+ )
27
+ );
28
+ }
29
+
30
+ foreach ($collection as $product) {
31
+ $result['main'][] = array(
32
+ 'id' => $product->getId(),
33
+ 'product_name' => $product->getName(),
34
+ 'sku' => $product->getSku()
35
+ );
36
+ }
37
+ $result['count'] = $collection->getSize();
38
+ return $result;
39
+ }
40
+
41
+ public function getAttributes()
42
+ {
43
+ $attributes = Mage::getModel('catalog/product')->getAttributes();
44
+
45
+ $result = array(
46
+ 'attribute_set_id' => array(
47
+ 'label' => 'Attribute Set',
48
+ 'type' => 'string'
49
+ ),
50
+ 'store_id' => array(
51
+ 'label' => 'Store',
52
+ 'type' => 'string'
53
+ ),
54
+ 'final_price' => array(
55
+ 'label' => 'Final Price',
56
+ 'type' => 'price'
57
+ ),
58
+ 'min_price' => array(
59
+ 'label' => 'Minimal Price',
60
+ 'type' => 'price'
61
+ ),
62
+ 'max_price' => array(
63
+ 'label' => 'Maximal Price',
64
+ 'type' => 'price'
65
+ ),
66
+ );
67
+
68
+ foreach($attributes as $attr) {
69
+ // skip attributes without label
70
+ if(!$attr->getFrontendLabel()) {
71
+ continue;
72
+ }
73
+
74
+ $type = '';
75
+ /** @todo add type for selects */
76
+ switch($attr->getFrontendInput()) {
77
+ case 'text':
78
+ case 'textarea':
79
+ $type = 'string';
80
+ break;
81
+ case 'price':
82
+ $type = 'price';
83
+ break;
84
+ case 'weight':
85
+ $type = 'numeric';
86
+ break;
87
+ case 'date':
88
+ case 'datetime':
89
+ $type = 'datetime';
90
+ break;
91
+ default:
92
+ $type = 'string';
93
+ }
94
+
95
+ $result[$attr->getAttributeCode()] = array(
96
+ 'label' => $attr->getFrontendLabel(),
97
+ 'type' => $type
98
+ );
99
+ }
100
+
101
+ return $result;
102
+ }
103
+
104
+ public function getAttributesList()
105
+ {
106
+ $toReturn = array();
107
+ foreach ($this->getAttributes() as $attributeCode => $attribute) {
108
+ $toReturn[] = array(
109
+ 'id' => $attributeCode,
110
+ 'attribute_code' => $attributeCode,
111
+ 'attribute_label' => $attribute['label'],
112
+ 'attribute_type' => $attribute['type']
113
+ );
114
+ }
115
+ return array('main' => $toReturn);
116
+ }
117
+
118
+ }
app/code/community/Freento/Aconnector/Model/Report/Abstract.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Freento_Aconnector_Model_Report_Abstract extends Mage_Core_Model_Abstract
3
+ {
4
+ const MAX_PAGES_COUNT = 10000;
5
+ const MAX_LIMIT = 1000;
6
+
7
+ protected $_select;
8
+ protected $_dateFrom;
9
+ protected $_dateTo;
10
+ protected $_page;
11
+ protected $_limit;
12
+ protected $_sortDirection;
13
+ protected $_sortField;
14
+ protected $_storeIds = array();
15
+ protected $_mainReportResults;
16
+
17
+ protected $_mainTablePrefix = 'main_table';
18
+
19
+ protected function _getMainTablePrefix()
20
+ {
21
+ if ($this->_mainTablePrefix) {
22
+ return $this->_mainTablePrefix . '.';
23
+ }
24
+ return '';
25
+ }
26
+
27
+ protected function _helper()
28
+ {
29
+ return Mage::helper('freento_aconnector');
30
+ }
31
+
32
+ protected function _getTable($name)
33
+ {
34
+ return Mage::getResourceModel($name)->getMainTable();
35
+ }
36
+
37
+ public function setDateFrom($dateFrom)
38
+ {
39
+ if (!$this->_helper()->validateDate($dateFrom)) {
40
+ throw new Exception('Incorrect date from');
41
+ }
42
+ $this->_dateFrom = $dateFrom;
43
+ return $this;
44
+ }
45
+
46
+ public function getDateFrom()
47
+ {
48
+ return $this->_dateFrom;
49
+ }
50
+
51
+ public function setDateTo($dateTo)
52
+ {
53
+ if (!$this->_helper()->validateDate($dateTo)) {
54
+ throw new Exception('Incorrect date to');
55
+ }
56
+ $this->_dateTo = $dateTo;
57
+ return $this;
58
+ }
59
+
60
+ public function addDateFromTo($dateFrom, $dateTo) {
61
+ if ($dateFrom && $dateTo) {
62
+ $this
63
+ ->setDateFrom($dateFrom)
64
+ ->setDateTo($dateTo);
65
+ }
66
+ return $this;
67
+ }
68
+
69
+ public function getDateTo()
70
+ {
71
+ return $this->_dateTo;
72
+ }
73
+
74
+ public function setPage($page)
75
+ {
76
+ if (!is_integer($page) || $page <= 0 || $page > self::MAX_PAGES_COUNT) {
77
+ throw new Exception('Incorrect page');
78
+ }
79
+ $this->_page = $page;
80
+ return $this;
81
+ }
82
+
83
+ public function getPage()
84
+ {
85
+ return $this->_page;
86
+ }
87
+
88
+ public function setLimit($limit)
89
+ {
90
+ if (!is_integer($limit) || $limit <= 0 || $limit > self::MAX_LIMIT) {
91
+ throw new Exception('Incorrect limit');
92
+ }
93
+ $this->_limit = $limit;
94
+ return $this;
95
+ }
96
+
97
+ public function getLimit()
98
+ {
99
+ return $this->_limit;
100
+ }
101
+
102
+ public function setStoreIds($storeIds)
103
+ {
104
+ if (!is_array($storeIds)) {
105
+ throw new Exception('Incorrect store ids');
106
+ }
107
+ $readyStoreIds = array();
108
+ foreach($storeIds as $storeId) {
109
+ $readyStoreIds[] = (int)$storeId;
110
+ }
111
+ $this->_storeIds = $readyStoreIds;
112
+ return $this;
113
+ }
114
+
115
+ public function getStoreIds()
116
+ {
117
+ return $this->_storeIds;
118
+ }
119
+
120
+ public function setMainReportResults($mainReportResults)
121
+ {
122
+ $this->_mainReportResults = $mainReportResults;
123
+ return $this;
124
+ }
125
+
126
+ public function getMainReportResults()
127
+ {
128
+ return $this->_mainReportResults;
129
+ }
130
+
131
+ public function setSortDirection($sortDirection)
132
+ {
133
+ if ($sortDirection) {
134
+ $this->_sortDirection = $sortDirection;
135
+ }
136
+ return $this;
137
+ }
138
+
139
+ public function getSortDirection()
140
+ {
141
+ return $this->_sortDirection;
142
+ }
143
+
144
+ public function setSortField($sortField)
145
+ {
146
+ if ($sortField) {
147
+ $this->_sortField = $sortField;
148
+ }
149
+ return $this;
150
+ }
151
+
152
+ public function getSortField()
153
+ {
154
+ return $this->_sortField;
155
+ }
156
+
157
+ public function process()
158
+ {
159
+ $this->_mysqlRequest();
160
+ return $this->_processData();
161
+ }
162
+
163
+ public function getRecordsCount()
164
+ {
165
+ $this->_mysqlRequest();
166
+ $this
167
+ ->getSelect()
168
+ ->reset(Zend_Db_Select::LIMIT_COUNT)
169
+ ->reset(Zend_Db_Select::LIMIT_OFFSET);
170
+
171
+ $countSelect = clone $this->getSelect();
172
+ $countSelect->reset();
173
+ $countSelect
174
+ ->from(array('alias' => new Zend_Db_Expr(sprintf('(%s)', $this->getSelect()))), array())
175
+ ->columns('COUNT(*)');
176
+
177
+ Mage::helper('freento_aconnector')->getLogger()->log($countSelect->assemble());
178
+
179
+ return Mage::getSingleton('core/resource')->getConnection('sales_read')->fetchOne($countSelect);
180
+ }
181
+
182
+ protected function _prepareWhere()
183
+ {
184
+ if ($this->getDateFrom() && $this->getDateTo()) {
185
+ $this
186
+ ->getSelect()
187
+ ->where($this->_getMainTablePrefix() . "created_at >= ?", $this->getDateFrom())
188
+ ->where($this->_getMainTablePrefix() . "created_at <= ?", $this->getDateTo());
189
+ }
190
+
191
+ $this->_addFilters();
192
+
193
+ if (is_array($this->getStoreIds()) && !in_array(0, $this->getStoreIds())) {
194
+ $this->getSelect()->where($this->_getMainTablePrefix() . 'store_id IN (?)', $this->getStoreIds() );
195
+ }
196
+ return $this->getSelect();
197
+ }
198
+
199
+ protected function _prepareSort()
200
+ {
201
+ if ($this->getSortField() && $this->getSortDirection()) {
202
+ $this
203
+ ->getSelect()
204
+ ->order($this->getSortField() . ' ' . $this->getSortDirection());
205
+ }
206
+ return $this->getSelect();
207
+ }
208
+
209
+ protected function _mysqlRequest()
210
+ {
211
+ $this->_prepareWhere();
212
+
213
+ Mage::helper('freento_aconnector')->getLogger()->log($this->getSelect()->assemble());
214
+
215
+ return $this->getSelect();
216
+ }
217
+
218
+ protected function _processData() {
219
+ return $this->getSelect()->query()->fetchAll();
220
+ }
221
+
222
+
223
+ public function getSelect() {
224
+ if( !$this->_select) {
225
+ $this->_select = Mage::getSingleton('core/resource')->getConnection('sales_read')->select();
226
+ $this->_select->limitPage($this->getPage(), $this->getLimit());
227
+ }
228
+ return $this->_select;
229
+ }
230
+
231
+ protected function _addFilters()
232
+ {
233
+ $filters = $this->getFilter();
234
+
235
+ if(!empty($filters)) {
236
+ foreach($filters as $filter) {
237
+ $this->_addFilter($filter);
238
+ }
239
+ }
240
+ }
241
+
242
+ protected function _addFilter($filter)
243
+ {
244
+ $operator = '';
245
+ switch($filter->operator) {
246
+ case 'lt':
247
+ $operator = '<';
248
+ break;
249
+ case 'gt':
250
+ $operator = '>';
251
+ break;
252
+ case 'eq':
253
+ $operator = '=';
254
+ break;
255
+ case 'neq':
256
+ $operator = '!=';
257
+ break;
258
+ }
259
+
260
+ $this->getSelect()
261
+ ->having("{$filter->property} {$operator} ?", $filter->value)
262
+ ;
263
+ }
264
+ }
app/code/community/Freento/Aconnector/Model/Report/AllCustomers.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_AllCustomers extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _getTable($name)
5
+ {
6
+ return Mage::getResourceModel($name)->getEntityTable();
7
+ }
8
+
9
+ protected function _mysqlRequest()
10
+ {
11
+ if(!$this->_select) {
12
+ $this->_collection = Mage::getResourceModel('customer/customer_collection')
13
+ ->addNameToSelect()
14
+ ->addAttributeToSelect('*')
15
+
16
+ ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
17
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
18
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
19
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
20
+ ->joinAttribute('billing_fax', 'customer_address/fax', 'default_billing', null, 'left')
21
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
22
+ ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')
23
+
24
+ ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
25
+ ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
26
+ ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
27
+ ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
28
+ ->joinAttribute('shipping_fax', 'customer_address/fax', 'default_shipping', null, 'left')
29
+ ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
30
+ ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left')
31
+
32
+ ->joinAttribute('taxvat', 'customer/taxvat', 'entity_id', null, 'left')
33
+ ;
34
+ $this->_select = $this->_collection->getSelect();
35
+ $this->_select->limitPage($this->getPage(), $this->getLimit());
36
+ }
37
+
38
+ $this->_prepareSort();
39
+
40
+ Mage::helper('freento_aconnector')->getLogger()->log($this->getSelect()->assemble());
41
+ }
42
+
43
+ protected function _processData() {
44
+ $return = array();
45
+ foreach ($this->_collection as $item) {
46
+ $formattedData = array();
47
+ foreach($item->getData() as $key => $record) {
48
+ if (is_string($record)) {
49
+ $formattedData[$key] = htmlentities(substr($record, 0, 150));
50
+ } elseif(is_null($record)) {
51
+ $formattedData[$key] = '';
52
+ } else {
53
+ $formattedData[$key] = 'not available';
54
+ }
55
+ }
56
+ $return[] = $formattedData;
57
+ }
58
+ return $return;
59
+ }
60
+
61
+ protected function _prepareSort()
62
+ {
63
+ if ($this->getSortField() && $this->getSortDirection()) {
64
+ $this->_collection->addAttributeToSort($this->getSortField(), $this->getSortDirection());
65
+ }
66
+ }
67
+ }
app/code/community/Freento/Aconnector/Model/Report/AllProducts.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_AllProducts extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ /**
5
+ *
6
+ * @var Mage_Catalog_Model_Resource_Product_Collection products collection
7
+ */
8
+ protected $_collection = null;
9
+
10
+ protected function _getTable($name)
11
+ {
12
+ return Mage::getResourceModel($name)->getEntityTable();
13
+ }
14
+
15
+ /**
16
+ * returns product collection instead of select
17
+ * @return Mage_Catalog_Model_Resource_Product_Collection
18
+ */
19
+ protected function _mysqlRequest()
20
+ {
21
+ if(!$this->_select) {
22
+ $this->_collection = Mage::getModel('catalog/product')->getCollection()
23
+ ->setPageSize($this->getLimit())
24
+ ->setCurPage($this->getPage())
25
+ ->addAttributeToSelect('*')
26
+ ->addMinimalPrice()
27
+ ->addFinalPrice()
28
+ ->addTaxPercents()
29
+ ->addCategoryIds()
30
+ ->addUrlRewrite()
31
+ ->joinAttribute(
32
+ 'name',
33
+ 'catalog_product/name',
34
+ 'entity_id',
35
+ null,
36
+ 'inner',
37
+ Mage_Core_Model_App::ADMIN_STORE_ID
38
+ )
39
+ ;
40
+
41
+ $this->_select = $this->_collection->getSelect();
42
+ }
43
+
44
+ $this->_prepareSort();
45
+
46
+ Mage::helper('freento_aconnector')->getLogger()->log($this->getSelect()->assemble());
47
+ }
48
+
49
+ protected function _processData() {
50
+ $return = array();
51
+ foreach ($this->_collection as $item) {
52
+ $formattedData = array();
53
+ foreach($item->getData() as $key => $record) {
54
+ if (is_string($record)) {
55
+ $formattedData[$key] = htmlentities(substr($record, 0, 150));
56
+ } elseif(is_null($record)) {
57
+ $formattedData[$key] = '';
58
+ } else {
59
+ $formattedData[$key] = 'not available';
60
+ }
61
+ }
62
+ $return[] = $formattedData;
63
+ }
64
+ return $return;
65
+ }
66
+
67
+ protected function _prepareSort()
68
+ {
69
+ if ($this->getSortField() && $this->getSortDirection()) {
70
+ $this->_collection->addAttributeToSort($this->getSortField(), $this->getSortDirection());
71
+ }
72
+ }
73
+
74
+ }
app/code/community/Freento/Aconnector/Model/Report/BestCategory.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_BestCategory extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+
5
+ protected $_compareAttribute = 'category_id';
6
+
7
+ protected function _mysqlRequest()
8
+ {
9
+ $this->getSelect()
10
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
11
+ array(
12
+ 'qty' => 'sum(qty_invoiced) - sum(qty_refunded)',
13
+ 'total' => 'sum(qty_invoiced*price) - sum(qty_refunded*price) - sum(' . $this->_mainTablePrefix . '.base_discount_invoiced)',
14
+ )
15
+ )
16
+ ->join(
17
+ array('ccp' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product')),
18
+ 'ccp.product_id = ' . $this->_mainTablePrefix . '.product_id',
19
+ array('category_id')
20
+ )
21
+ ->join(
22
+ array('ccev' =>Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')),
23
+ 'ccev.entity_id = ccp.category_id',
24
+ array('category_name' => 'value')
25
+ )
26
+ ->group('ccp.category_id')
27
+ ;
28
+ $this->_prepareSort();
29
+
30
+ return parent::_mysqlRequest();
31
+ }
32
+
33
+ }
app/code/community/Freento/Aconnector/Model/Report/BestCoupons.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_BestCoupons extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+ protected $_compareAttribute = 'coupon_code';
5
+
6
+ protected function _mysqlRequest()
7
+ {
8
+ $this->getSelect(true)
9
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order')),
10
+ array(
11
+ 'coupon_code',
12
+ 'qty' => 'COUNT(*)',
13
+ 'total' => 'SUM(base_grand_total)',
14
+ )
15
+ )
16
+ ->group('coupon_code')
17
+ ;
18
+ $this->_prepareWhere();
19
+
20
+ $this->_prepareSort();
21
+
22
+ return parent::_mysqlRequest();
23
+ }
24
+
25
+ protected function _prepareWhere()
26
+ {
27
+ $this->getSelect()->where('coupon_code IS NOT NULL');
28
+ parent::_prepareWhere();
29
+ }
30
+ }
app/code/community/Freento/Aconnector/Model/Report/Bestsellers.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_Bestsellers extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+ protected $_sortField = 'total';
5
+ protected $_sortDirection = 'DESC';
6
+
7
+ protected function _mysqlRequest()
8
+ {
9
+ $this->getSelect()
10
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
11
+ array(
12
+ 'qty' => 'sum(qty_invoiced) - sum(qty_refunded)',
13
+ 'total' => 'sum(qty_invoiced*price) - sum(qty_refunded*price) - sum(base_discount_invoiced)',
14
+ 'sku',
15
+ 'name'
16
+ )
17
+ )
18
+ ->group('sku');
19
+ $this->_prepareSort();
20
+
21
+ return parent::_mysqlRequest();
22
+ }
23
+ }
app/code/community/Freento/Aconnector/Model/Report/Comparable.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Model_Report_Comparable extends Freento_Aconnector_Model_Report_Abstract
4
+ {
5
+
6
+ const CONDITION_WHERE = 'where';
7
+ const CONDITION_HAVING = 'having';
8
+
9
+ protected $_compareCondition = self::CONDITION_WHERE;
10
+ protected $_compareAttribute = 'sku';
11
+
12
+ protected function _mysqlRequest()
13
+ {
14
+ $mainReportResults = $this->getMainReportResults();
15
+ if (!empty($mainReportResults)) {
16
+ if($this->_compareCondition == self::CONDITION_HAVING) {
17
+ $this->getSelect()->having($this->_compareAttribute . ' IN (?)', $this->_helper()->getList($mainReportResults, $this->_compareAttribute));
18
+ } else {
19
+ $this->getSelect()->where($this->_compareAttribute . ' IN (?)', $this->_helper()->getList($mainReportResults, $this->_compareAttribute));
20
+ }
21
+ }
22
+
23
+ return parent::_mysqlRequest();
24
+ }
25
+
26
+ /**
27
+ * Sort Compare array based on Main results array
28
+ * @return array
29
+ */
30
+ protected function _processData() {
31
+ $result = $this->getSelect()->query()->fetchAll();
32
+ if ($mainReportResults = $this->getMainReportResults()) {
33
+ $toReturn = array();
34
+ $list = $this->_helper()->getList($mainReportResults, $this->_compareAttribute);
35
+ foreach ($result as $row) {
36
+ $toReturn[array_search($row[$this->_compareAttribute], $list)] = $row;
37
+ }
38
+ $result = $toReturn;
39
+ }
40
+ return $result;
41
+ }
42
+
43
+ }
app/code/community/Freento/Aconnector/Model/Report/CustomerPurchases.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_CustomerPurchases extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+
5
+ protected function _mysqlRequest()
6
+ {
7
+ $attribute = Mage::getModel('eav/entity')->setType('catalog_product')->getAttribute('name');
8
+ $this->getSelect()
9
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')))
10
+ ->joinLeft(
11
+ array('orders' => $this->_getTable('sales/order')),
12
+ 'orders.entity_id = e.order_id',
13
+ array('increment_id')
14
+ )
15
+ ->join(
16
+ array('products' => Mage::getSingleton('core/resource')->getTableName('catalog/product')),
17
+ $this->_mainTablePrefix . '.product_id = products.entity_id',
18
+ array()
19
+ )
20
+ ->joinLeft(
21
+ array('at_name_default' => $attribute->getBackend()->getTable()),
22
+ "at_name_default.entity_id = {$this->_mainTablePrefix}.product_id AND at_name_default.attribute_id = {$attribute->getId()} AND at_name_default.store_id = 0",
23
+ array('product_info' => new Zend_Db_Expr('IF(at_name_store.value_id > 0, at_name_store.value, at_name_default.value)'))
24
+ )
25
+ ->joinLeft(
26
+ array('at_name_store' => $attribute->getBackend()->getTable()),
27
+ "at_name_store.entity_id = e.product_id AND at_name_store.attribute_id = {$attribute->getId()}",
28
+ array()
29
+ )
30
+ ->join(
31
+ array('payments' => $this->_getTable('sales/order_payment')),
32
+ 'orders.entity_id = payments.parent_id',
33
+ array('method')
34
+ )
35
+ ->where('at_name_store.store_id IN (?)', $this->getStoreIds())
36
+ ->where($this->_mainTablePrefix . '.parent_item_id is NULL')
37
+ ->group('order_id')
38
+ ;
39
+ $this->_prepareSort();
40
+
41
+ $additionalParams = $this->getAdditionalParams();
42
+ if (isset($additionalParams['email']) && $additionalParams['email']) {
43
+ $this->getSelect()->where('orders.customer_email = ?', $additionalParams['email']);
44
+ }
45
+
46
+ return parent::_mysqlRequest();
47
+ }
48
+
49
+ }
app/code/community/Freento/Aconnector/Model/Report/DaysForTheFirstPurchase.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_DaysForTheFirstPurchase extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+
5
+ protected $_mainTablePrefix = 'subselect';
6
+ protected $_compareAttribute = 'total';
7
+ protected $_compareCondition = self::CONDITION_HAVING;
8
+
9
+ protected function _mysqlRequest()
10
+ {
11
+
12
+ // START prepare subselect
13
+ $subselect = Mage::getSingleton('core/resource')->getConnection('sales_read')->select()
14
+ ->from(
15
+ array('e' => Mage::getSingleton('core/resource')->getTableName('customer/entity'))
16
+ )
17
+ ->join(
18
+ array('orders' => $this->_getTable('sales/order')),
19
+ 'orders.customer_id = e.entity_id',
20
+ array()
21
+ )
22
+
23
+ ->columns(new Zend_Db_Expr('DATEDIFF(orders.created_at, e.created_at) AS days'))
24
+
25
+ ->group('e.entity_id')
26
+ ->order('created_at', 'ASC')
27
+
28
+ ;
29
+ // END prepare subselect
30
+
31
+ $this->getSelect()
32
+ ->from(
33
+ array($this->_mainTablePrefix => $subselect),
34
+ array('total' => 'days', 'qty' => 'COUNT(days)')
35
+ )
36
+ ->group('days')
37
+ ->order('days', 'DESC')
38
+ ;
39
+
40
+ $this->_prepareSort();
41
+
42
+ return parent::_mysqlRequest();
43
+ }
44
+
45
+ }
app/code/community/Freento/Aconnector/Model/Report/Grouped/Abstract.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Freento_Aconnector_Model_Report_Grouped_Abstract extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected $_fromParams = array();
5
+
6
+ protected function _prepareGroup()
7
+ {
8
+ $additionalParams = $this->getAdditionalParams();
9
+ if (isset($additionalParams['group_period']) && $additionalParams['group_period']) {
10
+ switch ($additionalParams['group_period']){
11
+ case 'hour':
12
+ $this->_fromParams['hour'] = 'HOUR(' . $this->_getMainTablePrefix() . 'created_at)';
13
+ $groupBy = 'hour';
14
+ break;
15
+ case 'weekday':
16
+ $this->_fromParams['weekday'] = 'DAYNAME(' . $this->_getMainTablePrefix() . 'created_at)';
17
+ $groupBy = 'weekday';
18
+ break;
19
+ case 'month':
20
+ $this->_fromParams['month'] = 'MONTHNAME(' . $this->_getMainTablePrefix() . 'created_at)';
21
+ $groupBy = 'month';
22
+ break;
23
+ case 'quarter':
24
+ $this->_fromParams['quarter'] = 'QUARTER(' . $this->_getMainTablePrefix() . 'created_at)';
25
+ $groupBy = 'quarter';
26
+ break;
27
+ case 'year':
28
+ $this->_fromParams['year'] = 'YEAR(' . $this->_getMainTablePrefix() . 'created_at)';
29
+ $groupBy = 'year';
30
+ break;
31
+ default: throw Exception('Invalid group period');
32
+ }
33
+
34
+ $this
35
+ ->getSelect()
36
+ ->group($groupBy)
37
+ ;
38
+ }
39
+ }
40
+ }
app/code/community/Freento/Aconnector/Model/Report/MostRefunded.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_MostRefunded extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+ protected $_sortField = 'qty';
5
+ protected $_sortDirection = 'DESC';
6
+
7
+ protected function _mysqlRequest()
8
+ {
9
+ $this->getSelect()
10
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
11
+ array(
12
+ 'qty' => 'sum(qty_refunded)',
13
+ 'total' => 'sum(base_amount_refunded)',
14
+ 'sku',
15
+ 'name'
16
+ )
17
+ )
18
+ ->group('sku');
19
+ $this->_prepareSort();
20
+
21
+ return parent::_mysqlRequest();
22
+ }
23
+ }
app/code/community/Freento/Aconnector/Model/Report/NewCustomersByPeriod.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_NewCustomersByPeriod extends Freento_Aconnector_Model_Report_Grouped_Abstract
3
+ {
4
+
5
+ protected $_mainTablePrefix = 'customers';
6
+
7
+ protected function _mysqlRequest()
8
+ {
9
+ $this->_fromParams = array(
10
+ 'qty' => 'count(*)'
11
+ );
12
+
13
+ $this->_prepareGroup();
14
+
15
+ $this->getSelect()
16
+ ->from(array($this->_mainTablePrefix => Mage::getModel('customer/customer')->getResource()->getEntityTable()),
17
+ $this->_fromParams
18
+ )
19
+ ;
20
+
21
+ $this->_prepareSort();
22
+
23
+ return parent::_mysqlRequest();
24
+ }
25
+
26
+ }
app/code/community/Freento/Aconnector/Model/Report/ProductsByCustomer.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_ProductsByCustomer extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+
7
+ }
8
+
9
+ protected function _prepareWhere()
10
+ {
11
+
12
+ }
13
+ }
app/code/community/Freento/Aconnector/Model/Report/RefundsPercent.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_RefundsPercent extends Freento_Aconnector_Model_Report_Grouped_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->_fromParams = array(
7
+ 'refunds_percent' => 'IF(SUM(qty_invoiced), SUM(qty_refunded) / SUM(qty_invoiced) * 100, 0)',
8
+ 'total_invoiced' => 'SUM(row_invoiced)',
9
+ 'total_refunded' => 'SUM(amount_refunded)'
10
+ );
11
+
12
+ $this->_prepareGroup();
13
+
14
+ $this->getSelect()
15
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
16
+ $this->_fromParams
17
+ )
18
+ ;
19
+
20
+ $this->_prepareSort();
21
+
22
+ return parent::_mysqlRequest();
23
+ }
24
+
25
+ }
app/code/community/Freento/Aconnector/Model/Report/Sales.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_Sales extends Freento_Aconnector_Model_Report_Grouped_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->_fromParams = array(
7
+ 'qty' => 'sum(qty_invoiced) - sum(qty_refunded)',
8
+ 'total' => 'sum(qty_invoiced*price) - sum(qty_refunded*price) - sum(base_discount_invoiced)'
9
+ );
10
+
11
+ $this->_prepareGroup();
12
+
13
+ $this->getSelect()->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')), $this->_fromParams);
14
+
15
+ $this->_prepareSort();
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+
20
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByCategory.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByCategory extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $additionalParams = $this->getAdditionalParams();
7
+ if (isset($additionalParams['category_id']) && $additionalParams['category_id']) {
8
+ $this->getSelect()
9
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
10
+ array(
11
+ 'qty' => 'sum(qty_invoiced) - sum(qty_refunded)',
12
+ 'total' => 'sum(qty_invoiced*price) - sum(qty_refunded*price) - sum(' . $this->_mainTablePrefix . '.base_discount_invoiced)',
13
+ 'sku',
14
+ 'name',
15
+ )
16
+ )
17
+ ->joinLeft(
18
+ array('ccp' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product')),
19
+ 'ccp.product_id = ' . $this->_mainTablePrefix . '.product_id',
20
+ array()
21
+ )
22
+ ->joinLeft(
23
+ array('so' => $this->_getTable('sales/order')),
24
+ 'so.entity_id = ' . $this->_mainTablePrefix . '.order_id',
25
+ array('increment_id')
26
+ )
27
+ ->where('ccp.category_id = ?', $additionalParams['category_id'])
28
+ ->group('order_id')
29
+ ;
30
+ $this->_prepareSort();
31
+ } else {
32
+ $this->getSelect()
33
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')))
34
+ ->where('0')
35
+ ;
36
+ }
37
+
38
+ return parent::_mysqlRequest();
39
+ }
40
+
41
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByCountry.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesbyCountry extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+ protected $_sortField = 'qty';
5
+ protected $_sortDirection = 'DESC';
6
+ protected $_compareAttribute = 'country_id';
7
+
8
+ protected function _mysqlRequest()
9
+ {
10
+
11
+ $this->_fromParams = array(
12
+ 'qty' => 'sum(qty_refunded)',
13
+ 'total' => 'sum(base_amount_refunded)'
14
+ );
15
+
16
+ $this->getSelect()
17
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')), $this->_fromParams)
18
+ ->joinLeft(
19
+ array('address' => $this->_getTable('sales/order_address')),
20
+ 'address.parent_id = ' . $this->_mainTablePrefix . '.order_id',
21
+ array('country_id')
22
+ )
23
+ ->group('address.country_id');
24
+ $this->_prepareSort();
25
+
26
+ return parent::_mysqlRequest();
27
+ }
28
+
29
+ protected function _prepareWhere()
30
+ {
31
+ $this->getSelect()->where('address.address_type = ?','billing');
32
+ return parent::_prepareWhere();
33
+ }
34
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByCustomer.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByCustomer extends Freento_Aconnector_Model_Report_Grouped_Abstract
3
+ {
4
+
5
+ protected $_mainTablePrefix = 'orders';
6
+
7
+ protected function _mysqlRequest()
8
+ {
9
+
10
+ $additionalParams = $this->getAdditionalParams();
11
+ if (isset($additionalParams['customer_ids']) && $additionalParams['customer_ids']) {
12
+ $this->_fromParams = array(
13
+ 'total' => 'SUM(' . $this->_mainTablePrefix . '.base_grand_total)',
14
+ 'qty' => 'SUM(items.qty_ordered)',
15
+ );
16
+
17
+ $this->_prepareGroup();
18
+
19
+ $this->getSelect()
20
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order')), $this->_fromParams)
21
+
22
+ ->joinLeft(array('items' => $this->_getTable('sales/order_item')),
23
+ 'items.order_id = ' . $this->_mainTablePrefix . '.entity_id',array())
24
+ ->joinLeft(array('customers' => Mage::getSingleton('core/resource')->getTableName('customer/entity')),
25
+ 'customers.entity_id = ' . $this->_mainTablePrefix . '.customer_id')
26
+ ;
27
+
28
+ $this->getSelect()->where('customers.entity_id IN (?)', explode(',', $additionalParams['customer_ids']));
29
+
30
+ $this->_prepareSort();
31
+ } else {
32
+ $this->getSelect()
33
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order')))
34
+ ->where('0')
35
+ ;
36
+ }
37
+
38
+ return parent::_mysqlRequest();
39
+ }
40
+
41
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByCustomerGroup.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByCustomerGroup extends Freento_Aconnector_Model_Report_Grouped_Abstract
3
+ {
4
+ protected $_sortField = 'qty';
5
+ protected $_sortDirection = 'DESC';
6
+
7
+ protected $_mainTablePrefix = 'orders';
8
+
9
+ protected function _mysqlRequest()
10
+ {
11
+
12
+ $additionalParams = $this->getAdditionalParams();
13
+ if (isset($additionalParams['group_ids']) && $additionalParams['group_ids']) {
14
+ $this->_fromParams = array(
15
+ 'total' => 'SUM(' . $this->_mainTablePrefix . '.base_grand_total)',
16
+ 'qty' => 'SUM(items.qty_ordered)',
17
+ );
18
+
19
+ $this->_prepareGroup();
20
+
21
+ $this->getSelect(true)
22
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order')), $this->_fromParams)
23
+ ->joinLeft(array('groups' => $this->_getTable('customer/group')),
24
+ 'groups.customer_group_id = ' . $this->_mainTablePrefix . '.customer_group_id',
25
+ array()
26
+ )
27
+ ->joinLeft(array('items' => $this->_getTable('sales/order_item')),
28
+ 'items.order_id = ' . $this->_mainTablePrefix . '.entity_id',
29
+ array()
30
+ )
31
+ ->where('groups.customer_group_id IN (?)', explode(',', $additionalParams['group_ids']))
32
+ ;
33
+
34
+ $this->_prepareSort();
35
+ } else {
36
+ $this->getSelect()
37
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order')))
38
+ ->where('0')
39
+ ;
40
+ }
41
+
42
+ return parent::_mysqlRequest();
43
+ }
44
+
45
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByDayOfWeek.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByDayOfWeek extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'weekday' => 'WEEKDAY(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('weekday')
15
+ ->order('weekday ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByHour.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByHour extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'hour' => 'HOUR(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('hour')
15
+ ->order('hour ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+
20
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByMonth.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByMonth extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'month' => 'MONTH(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('month')
15
+ ->order('month ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByPeriodOfTime.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByPeriodOfTime extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'date' => 'DATE(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('date')
15
+ ->order('date ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByProduct.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByProduct extends Freento_Aconnector_Model_Report_Grouped_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $additionalParams = $this->getAdditionalParams();
7
+ if (isset($additionalParams['skus']) && $additionalParams['skus']) {
8
+ $this->_fromParams = array(
9
+ 'qty' => 'sum(qty_invoiced) - sum(qty_refunded)',
10
+ 'total' => 'sum(qty_invoiced*price) - sum(qty_refunded*price) - sum(' . $this->_mainTablePrefix . '.base_discount_invoiced)'
11
+ );
12
+
13
+ $this->_prepareGroup();
14
+
15
+ $this->getSelect()
16
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')), $this->_fromParams)
17
+ ->where('sku IN (?)', explode(',', $additionalParams['skus']))
18
+ ;
19
+ $this->_prepareSort();
20
+ } else {
21
+ $this->getSelect()
22
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')))
23
+ ->where('0')
24
+ ;
25
+ }
26
+
27
+ return parent::_mysqlRequest();
28
+ }
29
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByQuarter.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByQuarter extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'quarter' => 'QUARTER(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('quarter')
15
+ ->order('quarter ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByState.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByState extends Freento_Aconnector_Model_Report_Comparable
3
+ {
4
+ protected $_sortField = 'region';
5
+ protected $_sortDirection = 'ASC';
6
+ protected $_compareAttribute = 'country_region';
7
+ protected $_compareCondition = self::CONDITION_HAVING;
8
+
9
+ protected function _mysqlRequest()
10
+ {
11
+ $this->_fromParams = array(
12
+ 'qty' => 'sum(qty_invoiced) - sum(qty_refunded)',
13
+ 'total' => 'sum(qty_invoiced * price) - sum(qty_refunded * price) - sum(base_discount_invoiced)'
14
+ );
15
+
16
+ $this->getSelect()
17
+ ->from(
18
+ array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
19
+ $this->_fromParams
20
+ )
21
+ ->joinLeft(
22
+ array('address' => $this->_getTable('sales/order_address')),
23
+ 'address.parent_id = ' . $this->_mainTablePrefix . '.order_id',
24
+ array()
25
+ )
26
+ ->columns(new Zend_Db_Expr('IF(address.region IS NULL, address.country_id, CONCAT(address.country_id, \': \', address.region)) AS country_region'))
27
+ ->group('country_region')
28
+ ;
29
+ $this->_prepareSort();
30
+
31
+ return parent::_mysqlRequest();
32
+ }
33
+
34
+ protected function _prepareWhere()
35
+ {
36
+ $this->getSelect()->where('address.address_type = ?','billing');
37
+ return parent::_prepareWhere();
38
+ }
39
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByWeek.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByWeek extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'week' => 'WEEKOFYEAR(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('week')
15
+ ->order('week ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+
20
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesByYear.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesByYear extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order_item')),
8
+ array(
9
+ 'year' => 'YEAR(created_at)',
10
+ 'qty' => 'SUM(qty_invoiced) - SUM(qty_refunded)',
11
+ 'total' => 'SUM(qty_invoiced*price) - SUM(qty_refunded*price) - SUM(base_discount_invoiced)',
12
+ )
13
+ )
14
+ ->group('year')
15
+ ->order('year ASC');
16
+
17
+ return parent::_mysqlRequest();
18
+ }
19
+
20
+ }
app/code/community/Freento/Aconnector/Model/Report/SalesDetailed.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_Model_Report_SalesDetailed extends Freento_Aconnector_Model_Report_Abstract
3
+ {
4
+ protected function _mysqlRequest()
5
+ {
6
+ $this->getSelect()
7
+ ->from(array($this->_mainTablePrefix => $this->_getTable('sales/order')),
8
+ array_keys(Mage::getModel('freento_aconnector/order')->getAttributes())
9
+ )
10
+ ;
11
+ $this->_prepareSort();
12
+ return parent::_mysqlRequest();
13
+ }
14
+ }
app/code/community/Freento/Aconnector/controllers/Adminhtml/Freentoaconnectoradmin/System/ConfigController.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Freento_Aconnector_Adminhtml_Freentoaconnectoradmin_System_ConfigController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ public function generateKeysAction()
7
+ {
8
+ try {
9
+ $key = openssl_pkey_new(array(
10
+ 'private_key_bits' => 2048,
11
+ 'private_key_type' => OPENSSL_KEYTYPE_RSA,
12
+ ));
13
+
14
+ $privateKey = '';
15
+ openssl_pkey_export($key, $privateKey);
16
+
17
+ $publicKey = openssl_pkey_get_details($key);
18
+ $publicKey = $publicKey['key'];
19
+ Mage::getModel('core/config')->saveConfig('aconnector/global/generate_keys', $privateKey);
20
+
21
+ openssl_free_key($key);
22
+ } catch(Exception $e) {
23
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
+ }
25
+
26
+ /**
27
+ * @todo replace #URL# with correct analytics URL
28
+ */
29
+ $result = '<script type="text/javascript">var clipboard = new Clipboard("#freento_aconnector_api_key_btn");</script>';
30
+ $result .= Mage::helper('freento_aconnector')->__('Here is your API key. Enter it in <a href="%s">Analytics service</a>.<pre><span id="freento_aconnector_api_key">%s</span></pre>', '#URL#', $publicKey);
31
+ $result .= Mage::helper('freento_aconnector')->__('<button id="freento_aconnector_api_key_btn" data-clipboard-target="#freento_aconnector_api_key">%s</button>', 'Copy to clipboard');
32
+
33
+ Mage::app()->getCacheInstance()->cleanType('config');
34
+ Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
35
+
36
+ Mage::getSingleton('adminhtml/session')->addSuccess($result);
37
+
38
+ $this->_redirectReferer();
39
+ }
40
+
41
+ }
app/code/community/Freento/Aconnector/controllers/CustomerController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_CustomerController extends Freento_Aconnector_Controller_Abstract
3
+ {
4
+ public function attributesAction()
5
+ {
6
+ $response = json_encode(Mage::getModel('freento_aconnector/customer')->getAttributesList());
7
+
8
+ $this->_prepareEncodedResponse($response);
9
+ }
10
+
11
+ public function listAction()
12
+ {
13
+ $response = json_encode(Mage::getModel('freento_aconnector/customer')->getCustomersList(Mage::app()->getRequest()->getParams()));
14
+
15
+ $this->_prepareEncodedResponse($response);
16
+ }
17
+ }
18
+
app/code/community/Freento/Aconnector/controllers/CustomerGroupController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_CustomerGroupController extends Freento_Aconnector_Controller_Abstract
3
+ {
4
+ public function attributesAction()
5
+ {
6
+ $response = json_encode(Mage::getModel('freento_aconnector/customer_group')->getAttributesList());
7
+
8
+ $this->_prepareEncodedResponse($response);
9
+ }
10
+
11
+ public function listAction()
12
+ {
13
+ $response = json_encode(Mage::getModel('freento_aconnector/customer_group')->getCustomerGroupsList(Mage::app()->getRequest()->getParams()));
14
+
15
+ $this->_prepareEncodedResponse($response);
16
+ }
17
+ }
18
+
app/code/community/Freento/Aconnector/controllers/IndexController.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_IndexController extends Freento_Aconnector_Controller_Abstract
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $response = Freento_Aconnector_Model_Aconnector::getReportData(
7
+ $this->getRequest()->getParams()
8
+ );
9
+
10
+ $this->_prepareEncodedResponse($response);
11
+ }
12
+
13
+ public function storesAction()
14
+ {
15
+ $result = array();
16
+ $result[] = array('store_id' => 0, 'store_name' => 'Admin');
17
+ foreach (Mage::app()->getStores() as $store) {
18
+ $result[] = array('store_id' => $store->getId(), 'store_name' => $store->getName());
19
+ }
20
+
21
+ $this->_prepareEncodedResponse(json_encode($result));
22
+ }
23
+
24
+ public function versionAction()
25
+ {
26
+ $this->getResponse()->setBody(Mage::helper('freento_aconnector')->getExtensionVersion());
27
+ }
28
+
29
+ }
app/code/community/Freento/Aconnector/controllers/OrderController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_OrderController extends Freento_Aconnector_Controller_Abstract
3
+ {
4
+ public function attributesAction()
5
+ {
6
+ $response = json_encode(Mage::getModel('freento_aconnector/order')->getAttributesList());
7
+
8
+ $this->_prepareEncodedResponse($response);
9
+ }
10
+ }
11
+
app/code/community/Freento/Aconnector/controllers/ProductController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freento_Aconnector_ProductController extends Freento_Aconnector_Controller_Abstract
3
+ {
4
+ public function attributesAction()
5
+ {
6
+ $response = json_encode(Mage::getModel('freento_aconnector/product')->getAttributesList());
7
+
8
+ $this->_prepareEncodedResponse($response);
9
+ }
10
+
11
+ public function listAction()
12
+ {
13
+ $response = json_encode(Mage::getModel('freento_aconnector/product')->getProductsList(Mage::app()->getRequest()->getParams()));
14
+
15
+ $this->_prepareEncodedResponse($response);
16
+ }
17
+ }
18
+
app/code/community/Freento/Aconnector/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <aconnector>
15
+ <title>Freento - Connector</title>
16
+ </aconnector>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/Freento/Aconnector/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Freento_Aconnector>
5
+ <version>1.0.0</version>
6
+ </Freento_Aconnector>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <freento_aconnector>
11
+ <class>Freento_Aconnector_Block</class>
12
+ </freento_aconnector>
13
+ </blocks>
14
+ <helpers>
15
+ <freento_aconnector>
16
+ <class>Freento_Aconnector_Helper</class>
17
+ </freento_aconnector>
18
+ </helpers>
19
+ <models>
20
+ <freento_aconnector>
21
+ <class>Freento_Aconnector_Model</class>
22
+ </freento_aconnector>
23
+ </models>
24
+ <resources>
25
+ <freento_aconnector_setup>
26
+ <setup>
27
+ <module>Freento_Aconnector</module>
28
+ </setup>
29
+ <connection>
30
+ <use>core_setup</use>
31
+ </connection>
32
+ </freento_aconnector_setup>
33
+ <freento_aconnector_write>
34
+ <connection>
35
+ <use>core_write</use>
36
+ </connection>
37
+ </freento_aconnector_write>
38
+ <freento_aconnector_read>
39
+ <connection>
40
+ <use>core_read</use>
41
+ </connection>
42
+ </freento_aconnector_read>
43
+ </resources>
44
+ </global>
45
+ <frontend>
46
+ <routers>
47
+ <freento_aconnector>
48
+ <use>standard</use>
49
+ <args>
50
+ <module>Freento_Aconnector</module>
51
+ <frontName>aconnector</frontName>
52
+ </args>
53
+ </freento_aconnector>
54
+ </routers>
55
+ </frontend>
56
+ <admin>
57
+ <routers>
58
+ <adminhtml>
59
+ <args>
60
+ <modules>
61
+ <freentoaconnectoradmin before="Mage_Adminhtml">Freento_Aconnector_Adminhtml</freentoaconnectoradmin>
62
+ </modules>
63
+ </args>
64
+ </adminhtml>
65
+ </routers>
66
+ </admin>
67
+ <adminhtml>
68
+ <layout>
69
+ <updates>
70
+ <freento_aconnector>
71
+ <file>freento_aconnector.xml</file>
72
+ </freento_aconnector>
73
+ </updates>
74
+ </layout>
75
+ </adminhtml>
76
+ <default>
77
+ <aconnector>
78
+ <global>
79
+ <log_enabled>0</log_enabled>
80
+ </global>
81
+ </aconnector>
82
+ </default>
83
+ </config>
app/code/community/Freento/Aconnector/etc/system.xml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <freento translate="label" module="freento_aconnector">
5
+ <label>Freento</label>
6
+ <sort_order>101</sort_order>
7
+ </freento>
8
+ </tabs>
9
+ <sections>
10
+ <aconnector translate="label" module="freento_aconnector">
11
+ <label>Connector</label>
12
+ <tab>freento</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>99</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
+ <global translate="label">
20
+ <label>Settings</label>
21
+ <expanded>1</expanded>
22
+ <sort_order>100</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
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enabled</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>0</show_in_website>
34
+ <show_in_store>0</show_in_store>
35
+ <comment></comment>
36
+ </enabled>
37
+ <generate_keys translate="button_label">
38
+ <button_label>Generate Keys</button_label>
39
+ <frontend_type>button</frontend_type>
40
+ <frontend_model>freento_aconnector/adminhtml_system_config_form_generateKeys</frontend_model>
41
+ <sort_order>30</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>0</show_in_website>
44
+ <show_in_store>0</show_in_store>
45
+ </generate_keys>
46
+ <log_enabled translate="label">
47
+ <label>Enable Log</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>50</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>0</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ <comment></comment>
55
+ </log_enabled>
56
+ </fields>
57
+ </global>
58
+ </groups>
59
+ </aconnector>
60
+ </sections>
61
+ </config>
app/etc/modules/Freento_Aconnector.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Freento_Aconnector>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Freento_Aconnector>
8
+ </modules>
9
+ </config>
js/freento_aconnector/clipboard.min.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /*!
2
+ * clipboard.js v1.5.12
3
+ * https://zenorocha.github.io/clipboard.js
4
+ *
5
+ * Licensed MIT © Zeno Rocha
6
+ */
7
+ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t,e,n){var o=t("matches-selector");e.exports=function(t,e,n){for(var i=n?t:t.parentNode;i&&i!==document;){if(o(i,e))return i;i=i.parentNode}}},{"matches-selector":5}],2:[function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e,!0),n.delegateTarget&&o.call(t,n)}}var r=t("closest");e.exports=o},{closest:1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return i(t,e,n);if(c.nodeList(t))return r(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return s(document.body,t,e,n)}var c=t("./is"),s=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t,e){if(r)return r.call(t,e);for(var n=t.parentNode.querySelectorAll(e),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var i=Element.prototype,r=i.matchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector;e.exports=o},{}],6:[function(t,e,n){function o(t){var e;if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)t.focus(),t.setSelectionRange(0,t.value.length),e=t.value;else{t.hasAttribute("contenteditable")&&t.focus();var n=window.getSelection(),o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o),e=n.toString()}return e}e.exports=o},{}],7:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;i>o;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;a>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function t(){this.text?this.selectFake():this.target&&this.selectTarget()},t.prototype.selectFake=function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()},t.prototype.removeFake=function t(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function t(){this.selectedText=(0,i.default)(this.target),this.copyText()},t.prototype.copyText=function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function t(){this.removeFake()},a(t,[{key:"action",set:function t(){var e=arguments.length<=0||void 0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==("undefined"==typeof e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=c})},{select:6}],9:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var l=i(e),u=i(n),f=i(o),d=function(t){function e(n,o){r(this,e);var i=a(this,t.call(this));return i.resolveOptions(o),i.listenClick(n),i}return c(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.listenClick=function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})},e.prototype.onClick=function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})},e.prototype.defaultAction=function t(e){return s("action",e)},e.prototype.defaultTarget=function t(e){var n=s("target",e);return n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return s("text",e)},e.prototype.destroy=function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(u.default);t.exports=d})},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)});
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>analytics-and-reports</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://freento.com/license.html">Freento.com license</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Freento Analytics &amp; Reports extension for Magento. Allows to analyze live Magento store</summary>
10
+ <description>Freento Analytics &amp; Reports extension for Magento. Allows to analyze live Magento store</description>
11
+ <notes>Freento Analytics &amp; Reports extension for Magento. Allows to analyze live Magento store</notes>
12
+ <authors><author><name>Freento.com</name><user>Freento</user><email>support@freento.com</email></author></authors>
13
+ <date>2016-10-04</date>
14
+ <time>08:15:49</time>
15
+ <contents><target name="magecommunity"><dir name="Freento"><dir name="Aconnector"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="GenerateKeys.php" hash="246651edf24861be2590621d0f319bf3"/></dir></dir></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="7294ac42149bee4662b9e357b6deb680"/></dir><file name="Crypt.php" hash="7f5383aa5f67a861f5d11506c26a98dd"/><dir name="Helper"><file name="Data.php" hash="ec8f16f0f19ee213938c3eca6cdf8a86"/></dir><dir name="Model"><file name="Aconnector.php" hash="2bfa93dd6895205b5fa16781f343bae7"/><dir name="Customer"><file name="Group.php" hash="b4abaad78527d0e6238b47daa127c4e0"/></dir><file name="Customer.php" hash="751006e79f343a3f6226fef78dcefc51"/><file name="Log.php" hash="a8f927a896b37b755cc7e806527518a6"/><file name="Order.php" hash="18f180332401bbbd9fa9250121594961"/><file name="Product.php" hash="3c6f4d2d16e91c8af6af3c8bfbf8a116"/><dir name="Report"><file name="Abstract.php" hash="866ba57591577bcdbf6189b71b6533a7"/><file name="AllCustomers.php" hash="89795190f055d5f80ab85d9d12749b84"/><file name="AllProducts.php" hash="7cbabab3219575c1b95c298b7e968f50"/><file name="BestCategory.php" hash="fc60d224e2180b48aff078e325c50afe"/><file name="BestCoupons.php" hash="e7dc3b5ccb587915e9326976c49c018d"/><file name="Bestsellers.php" hash="61598e5629e708cc85c05de2eb7722c1"/><file name="Comparable.php" hash="baf2b5469417dd21a62057c48279fbb4"/><file name="CustomerPurchases.php" hash="cd79762ec0a9b9900eeedd42387d22fb"/><file name="DaysForTheFirstPurchase.php" hash="80878e657c48a9181c77fdaf04645dbb"/><dir name="Grouped"><file name="Abstract.php" hash="dce3a5d4913a2b3be523dc21209c8c2d"/></dir><file name="MostRefunded.php" hash="c84b559084a24cdeb267682adeb914b8"/><file name="NewCustomersByPeriod.php" hash="49648fa2dbdd7ada7c577bf000db0f88"/><file name="ProductsByCustomer.php" hash="8d62a1238b646112d524f2394ed88019"/><file name="RefundsPercent.php" hash="7288e240a7127b4a2505215d5e534312"/><file name="Sales.php" hash="4995e4abd2fc27e9a64e838002989725"/><file name="SalesByCategory.php" hash="80ee21055a58ef9d7025983da84289c9"/><file name="SalesByCountry.php" hash="2fd1d9e5869081e102aff12bc33abaff"/><file name="SalesByCustomer.php" hash="4e41b9c9c44ea3fe621137a51cfe4bd8"/><file name="SalesByCustomerGroup.php" hash="cf78058322a52b640eb0d498d627e1d2"/><file name="SalesByDayOfWeek.php" hash="7905703253012838532bc03e49acc1f9"/><file name="SalesByHour.php" hash="bbb2af36c59e35c907c4eee02de991a7"/><file name="SalesByMonth.php" hash="18b2704c19d6cf36dd3af7268c2a964d"/><file name="SalesByPeriodOfTime.php" hash="e381a045488cd40581ead10feb5f906e"/><file name="SalesByProduct.php" hash="4a0856ade173bf5ec49dc2b5f76e6354"/><file name="SalesByQuarter.php" hash="8a69485150620316a145567e7730160c"/><file name="SalesByState.php" hash="4e85aef8ab322d506aafdb679df538f8"/><file name="SalesByWeek.php" hash="dfa5268f3f52b83697c25aea05c9b9fc"/><file name="SalesByYear.php" hash="21e87b6af89d5a69b1b2827273eafc36"/><file name="SalesDetailed.php" hash="76873c534a0f25ac849133508f462b68"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Freentoaconnectoradmin"><dir name="System"><file name="ConfigController.php" hash="f9c89e43254e81b1371d5b3a57482ed8"/></dir></dir></dir><file name="CustomerController.php" hash="e3214f8885f340dca32d426dd633c508"/><file name="CustomerGroupController.php" hash="72a43f857d480d816a5aa750f9e85681"/><file name="IndexController.php" hash="544d275d3b410e0f7b911f4a41ebe3db"/><file name="OrderController.php" hash="65dba278031a5395b019e247489fd544"/><file name="ProductController.php" hash="4850a1a5734cbf8a842e0496f04fc861"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1f0c3a964989668fe3563e9a7326b39d"/><file name="config.xml" hash="75537a958d1fb4d8b33dd45fbad1d114"/><file name="system.xml" hash="741c63bdad57426f7a232f86961a66c8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Freento_Aconnector.xml" hash="6ed931f4a1d7db685e90488895278de7"/></dir></target><target name="mage"><dir name="js"><dir name="freento_aconnector"><file name="clipboard.min.js" hash="bd70fd596a2300dc1ace73e46f9b2f7e"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.4.0</min><max>7.1.0</max></php></required></dependencies>
18
+ </package>