SimpleRelevance_Integration - Version 0.0.1

Version Notes

-- version 0.0.1
First release

Download this release

Release Info

Developer Magento Core Team
Extension SimpleRelevance_Integration
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

app/code/community/SimpleRelevance/Integration/Helper/Data.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * SimpleRelevance Integration main helper
5
+ *
6
+ * @category SimpleRelevance
7
+ * @package SimpleRelevance_Integration
8
+ */
9
+ class SimpleRelevance_Integration_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+
12
+ /**
13
+ * Get module User-Agent to use on API requests
14
+ *
15
+ * @return string
16
+ */
17
+ public function getUserAgent()
18
+ {
19
+ $modules = Mage::getConfig()->getNode('modules')->children();
20
+ $modulesArray = (array)$modules;
21
+
22
+ $mageType = (array_key_exists('Enterprise_Enterprise', $modulesArray))? 'EE' : 'CE' ;
23
+ $v = (string)Mage::getConfig()->getNode('modules/SimpleRelevance_Integration/version');
24
+
25
+ return (string)'SimpleRelevance' . $v . '/Mage'. $mageType . Mage::getVersion();
26
+ }
27
+
28
+ /**
29
+ * Retrieve configuration data from database
30
+ *
31
+ * @param string $value Value to get
32
+ * @return mixed
33
+ */
34
+ public function config($value)
35
+ {
36
+ return Mage::getStoreConfig("simple_relevance/general/$value");
37
+ }
38
+
39
+ /**
40
+ * Check module status
41
+ *
42
+ * @return bool
43
+ */
44
+ public function enabled()
45
+ {
46
+ return (bool)((int)$this->config('active') === 1);
47
+ }
48
+ }
app/code/community/SimpleRelevance/Integration/Model/Api.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Simple Relevance API wrapper
5
+ *
6
+ * @category SimpleRelevance
7
+ * @package SimpleRelevance_Integration
8
+ */
9
+ class SimpleRelevance_Integration_Model_Api
10
+ {
11
+ /**
12
+ * API version number
13
+ *
14
+ * @var string
15
+ */
16
+ public $version = '2';
17
+
18
+ /**
19
+ * Error Message storage
20
+ *
21
+ * @var string
22
+ */
23
+ public $errorMessage;
24
+
25
+ /**
26
+ * Error Code storage
27
+ *
28
+ * @var integer
29
+ */
30
+ public $errorCode;
31
+
32
+ /**
33
+ * Cache the user api_key so we only have to log in once per client instantiation
34
+ *
35
+ * @var string SimpleRelevance API key
36
+ */
37
+ public $api_key;
38
+
39
+ /**
40
+ * This decides whether the request will wait for completion or start a task and return immediately.
41
+ * Can be 0 (wait) or 1 (asynchronous)
42
+ *
43
+ * @var int
44
+ */
45
+ public $async = 0;
46
+
47
+ /**
48
+ * STS API URL
49
+ *
50
+ * @var string
51
+ */
52
+ public $apiUrl;
53
+
54
+ /**
55
+ * Setup data
56
+ *
57
+ * @param string $apikey Your SimpleRelevance apikey
58
+ * @param string $secure Whether or not this should use a secure connection
59
+ */
60
+ function __construct($apikey = null)
61
+ {
62
+ if($apikey){
63
+ $this->setApiKey($apikey);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Api key setter
69
+ *
70
+ * @param string $key API Key
71
+ * @return SimpleRelevance_Integration_Model_Api
72
+ */
73
+ public function setApiKey($key)
74
+ {
75
+ $this->api_key = $key;
76
+
77
+ $this->apiUrl = "http://www.simplerelevance.com/api/v{$this->version}/";
78
+
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Action: POST
84
+ * Parameters:
85
+ * api_key - email tech@simplerelevance.com if you do not have an api key.
86
+ * item_id (optional-see below) - ID of the item clicked.
87
+ * user_id (optional-see below) - ID of the user clicking the item.
88
+ * timestamp (optional) - UTC Timestamp for the click. If not supplied, the current date/time will be used. Format is like “01/31/2011 14:54:53”.
89
+ * price (optional) - can be a float
90
+ * email (optional) - if you do not include a user_id, you can identify a user by email address
91
+ * item_name (optional) - if you do not include an item_id, you can identify an item by the name with which you input it into SimpleRelevance
92
+ * item_type (optional) - if you are matching by name and not item_id, supplying the same value here which you used on the inital input into SimpleRelevance will help find your item.
93
+ * zipcode (optional) - if the user is not yet in the system, this zipcode will help determine the user’s location.
94
+ * Notes: the timestamp is used to differentiate multiple actions with the same deal and user. If you don’t supply one, the SimpleRelevance system will not create save a new user action, and will simply update the old one with whatever new data you supply (price, for instance).
95
+ */
96
+ public function postClicks()
97
+ {
98
+ }
99
+
100
+ /**
101
+ * Action: POST
102
+ * Parameters:
103
+ * All parameters and notes from the CLICKS hook apply here.
104
+ */
105
+ public function postPurchases($data = array())
106
+ {
107
+ return $this->_callServer('purchases', 'post', $data);
108
+ }
109
+
110
+ /**
111
+ * Action: POST
112
+ * Parameters:
113
+ * api_key
114
+ * item_name - The item’s name - this should be unique across your database if possible.
115
+ * item_id - a unique ID for the item from your database.
116
+ * item_type (optional) - this helps the SimpleRelevance system find semantic data for your item. You can use any string you want here, but ‘business’ should be used for actual, real-world businesses.
117
+ * data_dict - a json encoded dictionary. This can have any attributes at all that apply to your item; the more the better. See below for the list of reserved attribute names - these help SimpleRelevance create semantic connections about your items. Note that these include ‘starts’ and ‘expires’, in case your items are time sensitive.
118
+ */
119
+ public function postItems($itemData = array())
120
+ {
121
+ return $this->_callServer('items', 'post', $itemData);
122
+ }
123
+
124
+ /**
125
+ * Action: POST
126
+ *
127
+ */
128
+ public function postUsers($userData = array())
129
+ {
130
+ return $this->_callServer('users', 'post', $userData);
131
+ }
132
+
133
+
134
+
135
+ /**
136
+ * Action: GET
137
+ * Parameters:
138
+ * api_key
139
+ * email - The email address of the user to return deals for
140
+ * market - the general city or location for which you want items returned. Leave this blank for locationless predictions.
141
+ * num_per (optional) - for business items, the number of items to return per business. For products, the number of products to return per leaf category.
142
+ * starts (optional) - if you have set it when uploading the item data, then only items with a starts value after the one given here will be included in the prediction.
143
+ * expires (optional) - if you have set it in the data dict when uploading item data, then only items with an expires value after the one given here will be included in the prediction.
144
+ * Notes:
145
+ * all returns have the key "data" unless there has been an error.
146
+ * data points to a list of recommendation items.
147
+ * each recommendation item has
148
+ * position - starting at 0, the lower the position, the more highly recommended the item.
149
+ * If positions are the same, both items come from the same business! If your items are not related to businesses and you are not using the reserved key "business_name", or if you set parameter num_per=1, this should not happen.
150
+ * id_type - describes whether the item id number is from our database or yours - if you supply external ids when uploading items, which is currently a requirement, we will always return those same ids
151
+ * id - the item id, hopefully of type "external" so that you can easily find it in your database*
152
+ * @return string JSON dictionary
153
+ */
154
+ public function getItems()
155
+ {
156
+ }
157
+
158
+ /**
159
+ * Actually connect to the server and call the requested methods
160
+ *
161
+ * @param string $method
162
+ * @param array OPTIONAL $params
163
+ * @return object|false
164
+ */
165
+ protected function _callServer($method, $call, $params = array())
166
+ {
167
+
168
+ $this->errorMessage = null;
169
+ $this->errorCode = null;
170
+
171
+ $data = array();
172
+
173
+ //Add API_KEY to request params
174
+ $data['api_key'] = $this->api_key;
175
+
176
+ //This decides whether the request will wait for completion
177
+ //or start a task and return immediately. Can be 0 (wait) or 1 (asynchronous)
178
+ $data['async'] = $this->async;
179
+
180
+ //Request data
181
+ $data['data'] = json_encode(array($params));
182
+
183
+ $url = $this->apiUrl . $method;
184
+ $requestParams = http_build_query($data);
185
+
186
+ $curlSession = curl_init();
187
+
188
+ if($call == 'post'){
189
+ curl_setopt($curlSession, CURLOPT_POST, TRUE);
190
+ curl_setopt($curlSession, CURLOPT_POSTFIELDS, $requestParams);
191
+ }
192
+
193
+ curl_setopt($curlSession, CURLOPT_USERAGENT, Mage::helper('simple_relevance')->getUserAgent());
194
+ curl_setopt($curlSession, CURLOPT_URL, $url);
195
+ curl_setopt($curlSession, CURLOPT_HEADER, FALSE);
196
+
197
+ curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);
198
+
199
+ $result = curl_exec($curlSession);
200
+
201
+ if(!$result){
202
+
203
+ $errstr = curl_error($curlSession);
204
+ $errno = curl_errno($curlSession);
205
+
206
+ $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
207
+ $this->errorCode = "-99";
208
+ return false;
209
+ }
210
+
211
+ // Check that a connection was made
212
+ if (curl_error($curlSession)) {
213
+ $this->errorMessage = curl_error($curlSession);
214
+ $this->errorCode = "-99";
215
+ return false;
216
+ }
217
+
218
+ $httpCode = curl_getinfo($curlSession, CURLINFO_HTTP_CODE);
219
+
220
+ curl_close($curlSession);
221
+
222
+ if($httpCode != 200){
223
+
224
+ Mage::log($result, null, 'SimpleRelevance_Erros.log');
225
+ Mage::log($httpCode, null, 'SimpleRelevance_Erros.log');
226
+
227
+ $this->errorMessage = $result;
228
+ $this->errorCode = "-99";
229
+ return false;
230
+ }
231
+
232
+ return $result;
233
+
234
+ }
235
+
236
+ }
app/code/community/SimpleRelevance/Integration/Model/Observer.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * SimpleRelevance Integration Events observer model
5
+ *
6
+ * @category SimpleRelevance
7
+ * @package SimpleRelevance_Integration
8
+ */
9
+ class SimpleRelevance_Integration_Model_Observer
10
+ {
11
+
12
+ protected $_block;
13
+
14
+ /**
15
+ * Add option to MassAction block in adminhtml
16
+ *
17
+ */
18
+ public function massaction($observer)
19
+ {
20
+ $block = $observer->getEvent()->getBlock();
21
+ $action = $block->getRequest()->getControllerName();
22
+
23
+ if( !Mage::helper('simple_relevance')->enabled() ){
24
+ return $this;
25
+ }
26
+
27
+ if(get_class($block) == 'Mage_Adminhtml_Block_Widget_Grid_Massaction') {
28
+
29
+ $this->_block = $block;
30
+
31
+ switch($action){
32
+ case 'customer':
33
+ $this->_addMassItem('massCustomer');
34
+ break;
35
+ case 'catalog_product':
36
+ $this->_addMassItem('massInventory');
37
+ break;
38
+ case 'sales_order':
39
+ $this->_addMassItem('massOrder');
40
+ break;
41
+ }
42
+
43
+
44
+ }
45
+
46
+ return $observer;
47
+ }
48
+
49
+ /**
50
+ * Add item to block
51
+ *
52
+ * @param string $action
53
+ * @return SimpleRelevance_Integration_Model_Observer
54
+ */
55
+ protected function _addMassItem($action)
56
+ {
57
+ $this->_block->addItem('simple_relevance_send', array(
58
+ 'label' => Mage::helper('simple_relevance')->__('Submit to SimpleRelevance'),
59
+ 'url' => Mage::helper('adminhtml')->getUrl("simple_relevance/adminhtml_export/{$action}")
60
+ ));
61
+ }
62
+
63
+ /**
64
+ * Send new order to SimpleRelevance API
65
+ *
66
+ * @param Varien_Event_Observer $observer
67
+ * @return
68
+ */
69
+ public function pushPurchase(Varien_Event_Observer $observer)
70
+ {
71
+
72
+ if( !Mage::helper('simple_relevance')->enabled() ){
73
+ return $this;
74
+ }
75
+
76
+ $orderId = (int)(Mage::getSingleton('checkout/type_onepage')->getCheckout()->getLastOrderId());
77
+ if($orderId){
78
+ $order = Mage::getModel('sales/order')->load($orderId);
79
+ }
80
+
81
+ if($order->getId()){
82
+
83
+ $purchase = Mage::getModel('simple_relevance/purchase', $order);
84
+ $postData = $purchase->getPostData();
85
+
86
+ $api = Mage::getModel('simple_relevance/api', Mage::helper('simple_relevance')->config('apikey'));
87
+ $api->async = 1;
88
+
89
+ foreach($postData['items'] as $p){
90
+ $api->postPurchases($p);
91
+ }
92
+
93
+ }
94
+
95
+ return $this;
96
+
97
+ }
98
+
99
+ }
app/code/community/SimpleRelevance/Integration/Model/Purchase.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * SimpleRelevance Integration Purchase model
5
+ *
6
+ * @category SimpleRelevance
7
+ * @package SimpleRelevance_Integration
8
+ */
9
+ class SimpleRelevance_Integration_Model_Purchase
10
+ {
11
+ protected $_order = null;
12
+
13
+ function __construct(Mage_Sales_Model_Order $order)
14
+ {
15
+ $this->_order = $order;
16
+ }
17
+
18
+ /**
19
+ * Return post data array to be sent to SimpleRelevance API
20
+ *
21
+ * @return array
22
+ */
23
+ public function getPostData()
24
+ {
25
+ $data = array();
26
+
27
+ /*$data ['total_canceled'] = $this->_order->getTotalCanceled();
28
+ $data ['created_at'] = $this->_order->getCreatedAt();
29
+ $data ['total_paid'] = $this->_order->getTotalPaid();
30
+ $data ['zipcode'] = $this->_order->getBillingAddress()->getPostcode();
31
+ $data ['email'] = $this->_order->getCustomerEmail();*/
32
+ $data ['items'] = $this->getItems();
33
+
34
+ return $data;
35
+ }
36
+
37
+ /**
38
+ * Get items purchased on this order
39
+ *
40
+ * @return array
41
+ */
42
+ public function getItems()
43
+ {
44
+ $items = array();
45
+
46
+ foreach($this->_order->getItemsCollection() as $item){
47
+ $items []= array(
48
+ 'price' => (float)$item->getRowTotalInclTax(),
49
+ 'item_id' => $item->getProductId(),
50
+ 'email' => $this->_order->getCustomerEmail(),
51
+ 'timestamp' => Mage::getModel('core/date')->gmtDate('m/d/Y H:i:s')
52
+ );
53
+ }
54
+
55
+ return $items;
56
+ }
57
+ }
app/code/community/SimpleRelevance/Integration/controllers/Adminhtml/ExportController.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Mass export actions to push data to SimpleRelevance API
5
+ *
6
+ * @category SimpleRelevance
7
+ * @package SimpleRelevance_Integration
8
+ */
9
+ class SimpleRelevance_Integration_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+
12
+ /**
13
+ * Mass send customers to SimpleRelevance
14
+ *
15
+ */
16
+ public function massCustomerAction()
17
+ {
18
+ $customers = $this->getRequest()->getPost('customer', array());
19
+ $sent = 0;
20
+ $notSent = 0;
21
+
22
+ $api = Mage::getModel('simple_relevance/api', Mage::helper('simple_relevance')->config('apikey'));
23
+
24
+ foreach ($customers as $customerId) {
25
+ $customer = Mage::getModel('customer/customer')->load($customerId);
26
+
27
+ $customerData = array(
28
+ 'email' => $customer->getEmail(),
29
+ 'user_id' => $customer->getId(),
30
+ );
31
+
32
+ $result = $api->postUsers($customerData);
33
+
34
+ if (!$api->errorCode) {
35
+ $sent++;
36
+ } else {
37
+ $this->_getSession()->addError($this->__('Error on customer #%s, - %s -', $customer->getId(), $api->errorMessage));
38
+ $notSent++;
39
+ }
40
+ }
41
+ if ($notSent) {
42
+ if ($sent) {
43
+ $this->_getSession()->addError($this->__('%s customer(s) were not sent.', $notSent));
44
+ } else {
45
+ $this->_getSession()->addError($this->__('No customer(s) were sent successfully.'));
46
+ }
47
+ }
48
+ if ($sent) {
49
+ $this->_getSession()->addSuccess($this->__('%s customer(s) have been sent successfully.', $sent));
50
+ }
51
+ $this->_redirect('adminhtml/customer/index');
52
+ }
53
+
54
+ /**
55
+ * Mass send Catalog/Products to SimpleRelevance
56
+ *
57
+ */
58
+ public function massInventoryAction()
59
+ {
60
+ $products = $this->getRequest()->getPost('product', array());
61
+ $sent = 0;
62
+ $notSent = 0;
63
+
64
+ $api = Mage::getModel('simple_relevance/api', Mage::helper('simple_relevance')->config('apikey'));
65
+
66
+ foreach ($products as $productId) {
67
+ $product = Mage::getModel('catalog/product')->load($productId);
68
+
69
+ $smallImageUrl = '';
70
+ if($product->getSmallImage()){
71
+ $smallImageUrl = Mage::helper('catalog/image')->init($product, 'small_image')->resize(75);
72
+ }
73
+
74
+ $dict = array(
75
+ 'url_path' => $product->getUrlPath(),
76
+ 'sku' => $product->getSku(),
77
+ 'category_ids' => $product->getCategoryIds(),
78
+ 'image_url' => (string)$smallImageUrl,
79
+ );
80
+ $data = array(
81
+ 'item_name' => $product->getName(),
82
+ 'item_id' => $product->getId(),
83
+ 'data_dict' => $dict,
84
+ );
85
+
86
+ $result = $api->postItems($data);
87
+
88
+ if (!$api->errorCode) {
89
+ $sent++;
90
+ } else {
91
+ $this->_getSession()->addError($this->__('Error on items #%s, - %s -', $product->getId(), $api->errorMessage));
92
+ $notSent++;
93
+ }
94
+ }
95
+ if ($notSent) {
96
+ if ($sent) {
97
+ $this->_getSession()->addError($this->__('%s item(s) were not sent.', $notSent));
98
+ } else {
99
+ $this->_getSession()->addError($this->__('No item(s) were sent successfully.'));
100
+ }
101
+ }
102
+ if ($sent) {
103
+ $this->_getSession()->addSuccess($this->__('%s item(s) have been sent successfully.', $sent));
104
+ }
105
+ $this->_redirect('adminhtml/catalog_product/index');
106
+ }
107
+
108
+ /**
109
+ * Mass send Order items (user actions) to SimpleRelevance
110
+ *
111
+ */
112
+ public function massOrderAction()
113
+ {
114
+ $orders = $this->getRequest()->getPost('order_ids', array());
115
+ $sent = 0;
116
+ $notSent = 0;
117
+
118
+ $api = Mage::getModel('simple_relevance/api', Mage::helper('simple_relevance')->config('apikey'));
119
+ $api->async = 1;
120
+
121
+ foreach ($orders as $orderId){
122
+ $order = Mage::getModel('sales/order')->load($orderId);
123
+
124
+ if(!$order->getId()){
125
+ continue;
126
+ }
127
+
128
+ $purchase = Mage::getModel('simple_relevance/purchase', $order);
129
+ $postData = $purchase->getPostData();
130
+
131
+ foreach($postData['items'] as $p){
132
+ $result = $api->postPurchases($p);
133
+ }
134
+
135
+ if (!$api->errorCode) {
136
+ $sent++;
137
+ } else {
138
+ $this->_getSession()->addError($this->__('Error on order #%s, - %s -', $order->getId(), $api->errorMessage));
139
+ $notSent++;
140
+ }
141
+ }
142
+ if ($notSent) {
143
+ if ($sent) {
144
+ $this->_getSession()->addError($this->__('%s order(s) were not sent.', $notSent));
145
+ } else {
146
+ $this->_getSession()->addError($this->__('No order(s) were sent successfully.'));
147
+ }
148
+ }
149
+ if ($sent) {
150
+ $this->_getSession()->addSuccess($this->__('%s order(s) have been sent successfully.', $sent));
151
+ }
152
+ $this->_redirect('adminhtml/sales_order/index');
153
+ }
154
+
155
+ }
app/code/community/SimpleRelevance/Integration/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <simple_relevance translate="title" module="simple_relevance">
12
+ <title>SimpleRelevance Configuration</title>
13
+ </simple_relevance>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/SimpleRelevance/Integration/etc/config.xml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SimpleRelevance_Integration>
5
+ <version>0.0.1</version>
6
+ </SimpleRelevance_Integration>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <simple_relevance>
11
+ <class>SimpleRelevance_Integration_Model</class>
12
+ </simple_relevance>
13
+ </models>
14
+ <blocks>
15
+ <simple_relevance>
16
+ <class>SimpleRelevance_Integration_Block</class>
17
+ </simple_relevance>
18
+ </blocks>
19
+ <helpers>
20
+ <simple_relevance>
21
+ <class>SimpleRelevance_Integration_Helper</class>
22
+ </simple_relevance>
23
+ </helpers>
24
+ </global>
25
+ <frontend>
26
+ <translate>
27
+ <modules>
28
+ <SimpleRelevance_Integration>
29
+ <files>
30
+ <default>SimpleRelevance_Integration.csv</default>
31
+ </files>
32
+ </SimpleRelevance_Integration>
33
+ </modules>
34
+ </translate>
35
+ <routers>
36
+ <simple_relevance>
37
+ <use>standard</use>
38
+ <args>
39
+ <module>SimpleRelevance_Integration</module>
40
+ <frontName>simple_relevance</frontName>
41
+ </args>
42
+ </simple_relevance>
43
+ </routers>
44
+ <events>
45
+ <checkout_onepage_controller_success_action>
46
+ <observers>
47
+ <simplerelevane_purchases>
48
+ <class>simple_relevance/observer</class>
49
+ <method>pushPurchase</method>
50
+ </simplerelevane_purchases>
51
+ </observers>
52
+ </checkout_onepage_controller_success_action>
53
+ </events>
54
+ </frontend>
55
+ <adminhtml>
56
+ <events>
57
+ <core_block_abstract_prepare_layout_before>
58
+ <observers>
59
+ <add_button>
60
+ <type>model</type>
61
+ <class>simple_relevance/observer</class>
62
+ <method>massaction</method>
63
+ </add_button>
64
+ </observers>
65
+ </core_block_abstract_prepare_layout_before>
66
+ </events>
67
+ <layout>
68
+ <updates>
69
+ <simple_relevance>
70
+ <file>simple_relevance.xml</file>
71
+ </simple_relevance>
72
+ </updates>
73
+ </layout>
74
+ <translate>
75
+ <modules>
76
+ <SimpleRelevance_Integration>
77
+ <files>
78
+ <default>SimpleRelevance_Integration.csv</default>
79
+ </files>
80
+ </SimpleRelevance_Integration>
81
+ </modules>
82
+ </translate>
83
+ </adminhtml>
84
+ <default>
85
+ <simple_relevance>
86
+ <general>
87
+ <active>0</active>
88
+ </general>
89
+ </simple_relevance>
90
+ </default>
91
+ </config>
app/code/community/SimpleRelevance/Integration/etc/system.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <simple_relevance translate="label" module="simple_relevance">
5
+ <class>simplerelevance-section</class>
6
+ <label>SimpleRelevance</label>
7
+ <header_css>simplerelevance-header</header_css>
8
+ <tab>customer</tab>
9
+ <sort_order>606</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <groups>
14
+ <general translate="label comment">
15
+ <label>SimpleRelevance integration</label>
16
+ <frontend_type>text</frontend_type>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <active translate="label">
22
+ <label>Enabled</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </active>
30
+ <apikey translate="label comment">
31
+ <label>API Key</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>0</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <comment><![CDATA[Your SimpleRelevance API Key.<br />You can find it on your SimpleRelevance admin panel under <i>Help and Support -> Your API Key</i>]]></comment>
38
+ </apikey>
39
+ </fields>
40
+ </general>
41
+ </groups>
42
+ </simple_relevance>
43
+ </sections>
44
+ </config>
app/design/adminhtml/default/default/layout/simple_relevance.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <adminhtml_system_config_edit>
5
+ <reference name="head">
6
+ <action method="addCss">
7
+ <stylesheet>simple_relevance/css.css</stylesheet>
8
+ </action>
9
+ <action method="addItem">
10
+ <type>skin_js</type>
11
+ <name>simple_relevance/js.js</name>
12
+ </action>
13
+ </reference>
14
+ </adminhtml_system_config_edit>
15
+
16
+ </layout>
app/etc/modules/SimpleRelevance_Integration.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SimpleRelevance_Integration>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Sales />
9
+ <Mage_Customer />
10
+ <Mage_Catalog />
11
+ </depends>
12
+ </SimpleRelevance_Integration>
13
+ </modules>
14
+ </config>
app/locale/en_US/SimpleRelevance_Integration.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "SimpleRelevance Configuration","SimpleRelevance Configuration"
2
+ "SimpleRelevance integration","SimpleRelevance integration"
3
+ "Your SimpleRelevance API Key.<br />You can find it on your SimpleRelevance admin panel under <i>Help and Support -> Your API Key</i>","Your SimpleRelevance API Key.<br />You can find it on your SimpleRelevance admin panel under <i>Help and Support -> Your API Key</i>"
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>SimpleRelevance_Integration</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>SimpleRelevance integration module</summary>
10
+ <description>Featuring customers, products and orders.</description>
11
+ <notes>-- version 0.0.1
12
+ First release</notes>
13
+ <authors><author><name>SimpleRelevance DEV team</name><user>auto-converted</user><email>info@simplerelevance.com</email></author></authors>
14
+ <date>2012-02-24</date>
15
+ <time>10:56:21</time>
16
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="simple_relevance.xml" hash="f0d73f30b7aeff70f63b295327ac906c"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="simple_relevance"><dir name="images"><file name="box-tab.png" hash="208977131fcbe078f10af53295ac686c"/><file name="simplerelevance-header.png" hash="c25099645618a32b8fdb8d4d7786cf2c"/></dir><file name="css.css" hash="c354dd9c0e48bdb99089b1756058efc1"/><file name="js.js" hash="5831e6e503ebd86f93e07230b56a6d2f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="SimpleRelevance_Integration.csv" hash="05e3ba1c882990c307dbe510bc0bea36"/></dir></target><target name="mageetc"><dir name="modules"><file name="SimpleRelevance_Integration.xml" hash="6ad0b704a9e62de159f09babfe2482d5"/></dir></target><target name="magecommunity"><dir name="SimpleRelevance"><dir name="Integration"><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="aebfe1b8317830ddbffae80f07848198"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="18e9829f6252920f6bf01a5340377b3a"/><file name="config.xml" hash="c441f6bae9a08e8e7e4aac3eb3253143"/><file name="system.xml" hash="9021a2bcf95bc2e79b548d529134af09"/></dir><dir name="Helper"><file name="Data.php" hash="9c0aaa6454c1e3d72b0b88e6933ed500"/></dir><dir name="Model"><file name="Api.php" hash="6bac0e7ca347318e814ec67c225f1235"/><file name="Observer.php" hash="191abba7ea01505797b61b0f3bd8ab24"/><file name="Purchase.php" hash="f073c1b379a0946a96ee5fcbfda6cc47"/></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies/>
19
+ </package>
skin/adminhtml/default/default/simple_relevance/css.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ ul.tabs a.simplerelevance-section:hover { background-color:#D8E6E6; }
2
+ ul.tabs a.simplerelevance-section,
3
+ ul.tabs a.simplerelevance-section:hover {border-bottom:none; padding:0.5em 0.5em 0 1.5em;}
4
+ ul.tabs a.simplerelevance-section span,
5
+ ul.tabs a.simplerelevance-section:hover span { background:url(images/box-tab.png) no-repeat 0 0; overflow:hidden; padding-left:35px; width:120px; height:22px;}
6
+ ul.tabs a.simplerelevance-section.active, ul.tabs a.simplerelevance-section.active:hover {background-color: white;border-bottom: 1px solid #BEBEBE;}
7
+
8
+ h3.simplerelevance-header { background:url(images/simplerelevance-header.png) no-repeat 0 0; height: 52px; overflow:hidden; padding:0; width:345px; text-indent:-9999px; }
skin/adminhtml/default/default/simple_relevance/images/box-tab.png ADDED
Binary file
skin/adminhtml/default/default/simple_relevance/images/simplerelevance-header.png ADDED
Binary file
skin/adminhtml/default/default/simple_relevance/js.js ADDED
@@ -0,0 +1 @@
 
1
+ //Place SimpleRelevance Integration scripts here