RetentionHero - Version 1.0.0

Version Notes

Initial release.

Download this release

Release Info

Developer Retention Hero
Extension RetentionHero
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/RetentionHero/Core/Helper/Data.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Copyright (c) 2014 Retention Hero
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ class RetentionHero_Core_Helper_Data extends Mage_Core_Helper_Abstract
26
+ {
27
+
28
+ }
app/code/community/RetentionHero/Core/Model/Dispatcher.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Copyright (c) 2014 Retention Hero
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ class RetentionHero_Core_Model_Dispatcher extends Mage_Core_Model_Abstract
26
+ {
27
+
28
+ protected $_apiKey;
29
+
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_apiKey = Mage::getStoreConfig('retentionhero_options/general/rest_api_key');
34
+ }
35
+
36
+ public function getApiKey()
37
+ {
38
+ return $this->_apiKey;
39
+ }
40
+ public function dispatch($event)
41
+ {
42
+ Mage::log('[RH] Dispatching event');
43
+
44
+ $events = $this->getPendingEvents();
45
+ $events[] = $event;
46
+ $this->setPendingEvents($events);
47
+ return true;
48
+ }
49
+
50
+ public function fireEvent($event)
51
+ {
52
+ if ( Mage::getStoreConfig('retentionhero_options/general/enable') != true ) {
53
+ Mage::log('[RH_WARNING] Retention Hero is disabled. Not firing events');
54
+ return false;
55
+ }
56
+
57
+ $eventData = $event->getEventData();
58
+ Mage::log( '[RH] Firing event data:' . var_export($eventData,TRUE) );
59
+ $this->fireCurl( $eventData );
60
+ }
61
+
62
+ public function fireAll()
63
+ {
64
+ $events = $this->getPendingEvents();
65
+ // Mage::log( '[RH] Pending events: ' . var_export($events, TRUE) );
66
+ if( empty($events) ) { return false; }
67
+ foreach ($events as $event) {
68
+ $this->fireEvent( $event );
69
+ }
70
+
71
+ $this->setPendingEvents( array() );
72
+
73
+ return true;
74
+ }
75
+
76
+ protected function fireCurl($data)
77
+ {
78
+ $data_string = json_encode($data);
79
+ $api_key = $this->getApiKey();
80
+
81
+ $ch = curl_init('https://app.retentionhero.com/api/v1/orders/');
82
+
83
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
84
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
85
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); // 2-second timeout
86
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
87
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
88
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
89
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
90
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
91
+ 'Authorization: Token ' . $api_key,
92
+ 'Content-Type: application/json',
93
+ 'Content-Length: ' . strlen($data_string))
94
+ );
95
+
96
+ $result = curl_exec($ch);
97
+ Mage::log( '[RH] Curl response: ' . var_export(json_decode($result), TRUE) );
98
+ }
99
+ }
app/code/community/RetentionHero/Core/Model/Event/Abstract.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Copyright (c) 2014 Retention Hero
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ abstract class RetentionHero_Core_Model_Event_Abstract extends Mage_Core_Model_Abstract
26
+ {
27
+ abstract protected function getEventData();
28
+
29
+ protected $_dispatched = false;
30
+
31
+ protected $_apiKey;
32
+
33
+ public function _construct()
34
+ {
35
+ parent::_construct();
36
+ $this->_apiKey = Mage::getStoreConfig('retentionhero_options/general/rest_api_key');
37
+ }
38
+ public function dispatch()
39
+ {
40
+ $dispatcher = Mage::getSingleton('retentionhero_core/dispatcher');
41
+ $this->_dispatched = $dispatcher->dispatch($this);
42
+ }
43
+
44
+ public function isDispatched()
45
+ {
46
+ return $this->_dispatched ? true : false;
47
+ }
48
+
49
+ protected function _parseAddress($address)
50
+ {
51
+ $rhAddress = array();
52
+
53
+ $rhAddress['firstname'] = $address->getFirstname();
54
+ $rhAddress['middlename'] = $address->getMiddlename();
55
+ $rhAddress['lastname'] = $address->getLastname();
56
+ $rhAddress['telephone'] = $address->getTelephone();
57
+ $rhAddress['company'] = $address->getCompany();
58
+
59
+ $streets = $address->getStreet();
60
+ $rhAddress['address1'] = $streets[0];
61
+ if ( sizeof( $streets ) > 1 ) {
62
+ $rhAddress['address2'] = $streets[1];
63
+ }
64
+
65
+ $rhAddress['city'] = $address->getCity();
66
+ $rhAddress['region'] = $address->getRegion();
67
+ $rhAddress['country'] = $address->getCountry();
68
+ $rhAddress['postcode'] = $address->getPostcode();
69
+ $rhAddress['country_id'] = $address->getCountry();
70
+
71
+ return $rhAddress;
72
+ }
73
+ }
app/code/community/RetentionHero/Core/Model/Event/CreateOrder.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Copyright (c) 2014 Retention Hero
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ class RetentionHero_Core_Model_Event_CreateOrder extends RetentionHero_Core_Model_Event_Abstract
26
+ {
27
+ public function setOrder($order)
28
+ {
29
+ $this->_order = $order;
30
+ }
31
+ public function getEventData()
32
+ {
33
+ return $this->setUpData($this->_order);
34
+ }
35
+
36
+ public function getApiKey()
37
+ {
38
+ return $this->_apiKey;
39
+ }
40
+
41
+ protected function setUpData($order)
42
+ {
43
+ $data = array();
44
+
45
+ $data['store_id'] = Mage::app()->getStore()->getStoreId();
46
+ $data['increment_id'] = $order->getIncrementId();
47
+ $data['created_at'] = $order->getCreatedAt();
48
+
49
+ if ( Mage::getSingleton('customer/session')->isLoggedIn() ) {
50
+ $data['customer_id'] = Mage::getSingleton('customer/session')->getCustomer()->getId();
51
+ }
52
+ if ($order->getCustomerIsGuest()) {
53
+ $data['customer_firstname'] = $order->getBillingAddress()->getFirstname();
54
+ $data['customer_lastname'] = $order->getBillingAddress()->getLastname();
55
+ } else {
56
+ $data['customer_firstname'] = $order->getCustomerFirstname();
57
+ $data['customer_lastname'] = $order->getCustomerLastname();
58
+ }
59
+ $data['customer_email'] = $order->getCustomerEmail();
60
+ $data['base_grand_total'] = $order->getBaseGrandTotal();
61
+ $data['base_subtotal'] = $order->getBaseSubtotal();
62
+ $data['discount_amount'] = $order->getDiscountAmount();
63
+ $data['order_currency_code'] = $order->getOrderCurrencyCode();
64
+
65
+ $billing_address = $order->getBillingAddress();
66
+ if ( !empty( $billing_address ) ) {
67
+ $data['billing_address'] = $this->_parseAddress( $billing_address );
68
+ }
69
+
70
+ $shipping_address = $order->getShippingAddress();
71
+ if( !empty( $shipping_address ) ) {
72
+ $data['shipping_address'] = $this->_parseAddress( $shipping_address );
73
+ }
74
+
75
+ $data['items'] = array();
76
+
77
+ $items = $order->getAllVisibleItems();
78
+ foreach ($items as $item) {
79
+ $data['items'][] = $this->_parseItem( $item );
80
+ }
81
+
82
+ return $data;
83
+ }
84
+
85
+ private function _parseItem($item)
86
+ {
87
+ $rhItem = array();
88
+ $rhItem['item_id'] = $item->getId();
89
+ $rhItem['product_id'] = $item->getProductId();
90
+ $rhItem['base_price'] = $item->getBasePrice();
91
+ $rhItem['name'] = $item->getName();
92
+ $rhItem['sku'] = $item->getSku();
93
+ $rhItem['qty_ordered'] = $item->getQtyOrdered();
94
+ return $rhItem;
95
+ }
96
+ }
app/code/community/RetentionHero/Core/Model/Observer.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Copyright (c) 2014 Retention Hero
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ *
25
+ * Extending Model_Abstract is not necessary, but helpful for testing.
26
+ */
27
+
28
+ class RetentionHero_Core_Model_Observer extends Mage_Core_Model_Abstract
29
+ {
30
+
31
+ public function front_after_hook($observer)
32
+ {
33
+ $dispatcher = Mage::getSingleton('retentionhero_core/dispatcher');
34
+ $dispatcher->fireAll();
35
+ return $observer;
36
+ }
37
+
38
+ /**
39
+ * Triggers the RetentionHero Event_CreateOrder model to fire.
40
+ * @param array $observer array( 'order'=>$order, 'quote'=>$quote )
41
+ * @return array $observer
42
+ */
43
+ public function order_success_hook($observer)
44
+ {
45
+ $order = $observer->getEvent()->getOrder();
46
+
47
+ // $order->setRetentionhero_customerid($user_id);
48
+
49
+ // Fire event after updating user id
50
+ Mage::log( '[RH] order_success_hook firing');
51
+ $createOrderEvent = Mage::getSingleton('retentionhero_core/event_createOrder');
52
+ $createOrderEvent->setOrder($order);
53
+ $createOrderEvent->dispatch();
54
+
55
+ // $order->save();
56
+
57
+ return $observer;
58
+ }
59
+ }
app/code/community/RetentionHero/Core/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ Copyright (c) 2014 Retention Hero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ -->
23
+
24
+ <config>
25
+ <modules>
26
+ <RetentionHero_Core>
27
+ <version>1.0.0</version>
28
+ </RetentionHero_Core>
29
+ </modules>
30
+
31
+ <!--
32
+ <stores>
33
+ <admin>
34
+ <design>
35
+ <theme>
36
+ <template>retentionheroadmin</template>
37
+ </theme>
38
+ </design>
39
+ </admin>
40
+ </stores>
41
+ -->
42
+
43
+ <global>
44
+
45
+ <models>
46
+ <retentionhero_core>
47
+ <class>RetentionHero_Core_Model</class>
48
+ </retentionhero_core>
49
+ </models>
50
+
51
+ <events>
52
+ <controller_action_postdispatch>
53
+ <observers>
54
+ <retentionhero_core_observer>
55
+ <type>singleton</type>
56
+ <class>retentionhero_core/observer</class>
57
+ <method>front_after_hook</method>
58
+ </retentionhero_core_observer>
59
+ </observers>
60
+ </controller_action_postdispatch>
61
+ <sales_model_service_quote_submit_success>
62
+ <observers>
63
+ <retentionhero_core_observer>
64
+ <type>singleton</type>
65
+ <class>retentionhero_core/observer</class>
66
+ <method>order_success_hook</method>
67
+ </retentionhero_core_observer>
68
+ </observers>
69
+ </sales_model_service_quote_submit_success>
70
+
71
+ </events>
72
+
73
+ <resources>
74
+ <retentionhero_setup>
75
+ <setup>
76
+ <module>RetentionHero_Core</module>
77
+ <class>Mage_Sales_Model_Mysql4_Setup</class>
78
+ </setup>
79
+ <connection>
80
+ <use>core_setup</use>
81
+ </connection>
82
+ </retentionhero_setup>
83
+ <retentionhero_write>
84
+ <connection>
85
+ <use>core_write</use>
86
+ </connection>
87
+ </retentionhero_write>
88
+ <retentionhero_read>
89
+ <connection>
90
+ <use>core_read</use>
91
+ </connection>
92
+ </retentionhero_read>
93
+ </resources>
94
+
95
+ <helpers>
96
+ <retentionhero_core>
97
+ <class>RetentionHero_Core_Helper</class>
98
+ </retentionhero_core>
99
+ </helpers>
100
+
101
+ </global>
102
+
103
+ <adminhtml>
104
+ <acl>
105
+ <resources>
106
+ <admin>
107
+ <children>
108
+ <system>
109
+ <children>
110
+ <config>
111
+ <children>
112
+ <retentionhero_options>
113
+ <title>Retention Hero Options</title>
114
+ </retentionhero_options>
115
+ </children>
116
+ </config>
117
+ </children>
118
+ </system>
119
+ </children>
120
+ </admin>
121
+ </resources>
122
+ </acl>
123
+ </adminhtml>
124
+
125
+
126
+ </config>
app/code/community/RetentionHero/Core/etc/system.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ Copyright (c) 2014 Retention Hero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ -->
23
+
24
+ <!--
25
+ Variables:
26
+ * REST API Key
27
+ -->
28
+ <config>
29
+ <tabs>
30
+ <retentionhero_core_tab translate="label" module="retentionhero_core">
31
+ <label>Retention Hero</label>
32
+ <sort_order>100</sort_order>
33
+ </retentionhero_core_tab>
34
+ </tabs>
35
+
36
+ <sections>
37
+ <retentionhero_options translate="label" module="retentionhero_core">
38
+ <label>Extension Configuration</label>
39
+ <tab>retentionhero_core_tab</tab>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>1000</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <groups>
46
+ <general translate="label">
47
+ <label>Retention Hero Extension Configuration</label>
48
+
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>1</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+
55
+ <fields>
56
+ <enable>
57
+ <label>Enable</label>
58
+ <comment>Enable Retention Hero Extension</comment>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>1</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </enable>
66
+
67
+ <rest_api_key>
68
+ <label>API Key</label>
69
+ <comment><![CDATA[Visit <a href="https://app.retentionhero.com/#/settings/api-keys" target="_blank">https://app.retentionhero.com/#/settings/api-keys</a> to see your API Keys.]]></comment>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>2</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </rest_api_key>
76
+ </fields>
77
+
78
+ </general>
79
+ </groups>
80
+ </retentionhero_options>
81
+ </sections>
82
+
83
+ </config>
app/code/community/RetentionHero/Core/sql/retentionhero_setup/mysql4-install-0.3.0.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Copyright (c) 2014 Retention Hero
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ *
25
+ * Modifies the flat order table to add a column for retentionhero_customerid, so that we
26
+ * may retrieve it via Magento's order attribute.
27
+ */
28
+ $this->startSetup();
29
+ $this->addAttribute('order', 'retentionhero_customerid', array(
30
+ 'type' => 'varchar',
31
+ 'label' => 'Retention Hero CustomerID',
32
+ 'visible' => false,
33
+ 'required' => false,
34
+ 'visible_on_front' => false,
35
+ 'user_defined' => false
36
+ ));
37
+
38
+ $this->endSetup();
app/etc/modules/RetentionHero_Core.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ Copyright (c) 2014 Retention Hero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ -->
23
+
24
+ <config>
25
+ <modules>
26
+ <RetentionHero_Core>
27
+ <active>true</active>
28
+ <codePool>community</codePool>
29
+ </RetentionHero_Core>
30
+ </modules>
31
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>RetentionHero</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>MIT License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Identify valuable customers early on and keep them coming back with targeted lifecycle marketing.</summary>
10
+ <description>Predictive marketing for Magento. Retention Hero analyzes customers' buying behavior and highlights potential stars early. More at http://www.retentionhero.com.</description>
11
+ <notes>Initial release.</notes>
12
+ <authors><author><name>Retention Hero</name><user>retentionhero</user><email>support@retentionhero.com</email></author></authors>
13
+ <date>2014-11-25</date>
14
+ <time>04:57:35</time>
15
+ <contents><target name="magecommunity"><dir name="RetentionHero"><dir name="Core"><dir name="Helper"><file name="Data.php" hash="7a6f5dbd9b8c57dda3a0482b91534736"/></dir><dir name="Model"><file name="Dispatcher.php" hash="7fe0dbcd2709525ab27eb570bd6ab15c"/><dir name="Event"><file name="Abstract.php" hash="39e187db54ed13a8cf2afd1deac7c14c"/><file name="CreateOrder.php" hash="2634dd6631eeb2154f3b58375170113d"/></dir><file name="Observer.php" hash="4761e8229ecde31e405042c370f23c3a"/></dir><dir name="etc"><file name="config.xml" hash="a8c02c4f213466716645db1b4b9a0ae6"/><file name="system.xml" hash="1721810417084d8c601550a32ecd754a"/></dir><dir name="sql"><dir name="retentionhero_setup"><file name="mysql4-install-0.3.0.php" hash="a9a52928c3a7aabd6328ec676ae6462e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RetentionHero_Core.xml" hash="d2904bd8da646346bdf68295ded49469"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>