customersintosugarcrm - Version 1.0.0

Version Notes

First version of "Customers into SugarCRM" extension.

Download this release

Release Info

Developer Magento Core Team
Extension customersintosugarcrm
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/OlegKoval/CustomersIntoSugarCrm/Helper/Data.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CustomersIntoSugarCrm Data Helper
4
+ *
5
+ * @category OlegKoval
6
+ * @package OlegKoval_CustomersIntoSugarCrm
7
+ * @copyright Copyright (c) 2013 Oleg Koval
8
+ * @author Oleg Koval <oleh.koval@gmail.com>
9
+ */
10
+ class OlegKoval_CustomersIntoSugarCrm_Helper_Data extends Mage_Core_Helper_Abstract {
11
+ const XML_PATH_ENABLED = 'customersintosugarcrm/extension/enabled';
12
+ const XML_PATH_SUGAR_URL = 'customersintosugarcrm/sugarcrm/url';
13
+ const XML_PATH_SUGAR_LOGIN = 'customersintosugarcrm/sugarcrm/login';
14
+ const XML_PATH_SUGAR_PASSWD = 'customersintosugarcrm/sugarcrm/password';
15
+
16
+ private $sessionId = '';
17
+
18
+ /**
19
+ * Synchronize customer with SugarCRM
20
+ * @param Mage_Customer_Model_Customer $customer
21
+ * @return OlegKoval_CustomersIntoSugarCrm_Helper_Data
22
+ */
23
+ public function synchronizeCustomer($customer) {
24
+ $this->init();
25
+
26
+ if (strlen($this->sessionId) > 0) {
27
+ $contactId = $this->getContactID($customer->getData('email'));
28
+
29
+ $sugarId = Mage::getModel('customersintosugarcrm/sugarcrm')->syncSugarcrm(
30
+ $customer,
31
+ array(
32
+ 'sessionId' => $this->sessionId,
33
+ 'contactId' => $contactId
34
+ )
35
+ );
36
+
37
+ //show messages only for admin
38
+ if (Mage::getSingleton('admin/session')->isLoggedIn() && $sugarId !== false && strlen($sugarId) == 36) {
39
+ if ($contactId == false) {
40
+ Mage::getSingleton('adminhtml/session')->addSuccess(
41
+ $this->__('New Contact was created in SugarCRM')
42
+ );
43
+ }
44
+ else {
45
+ Mage::getSingleton('adminhtml/session')->addSuccess(
46
+ $this->__('The Contact info was updated in SugarCRM')
47
+ );
48
+ }
49
+ }
50
+ }
51
+
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Delete customer from SugarCRM
57
+ * @param string $email
58
+ * @return OlegKoval_CustomersIntoSugarCrm_Helper_Data
59
+ */
60
+ public function deleteCustomer($email) {
61
+ $this->init();
62
+
63
+ if (strlen($this->sessionId) > 0) {
64
+ $contactId = $this->getContactID($email);
65
+
66
+ if ($contactId !== false) {
67
+ $sugarId = Mage::getModel('customersintosugarcrm/sugarcrm')->deleteFromSugarcrm(
68
+ array(
69
+ 'sessionId' => $this->sessionId,
70
+ 'contactId' => $contactId
71
+ )
72
+ );
73
+
74
+ if (Mage::getSingleton('admin/session')->isLoggedIn() && $sugarId !== false && strlen($sugarId) == 36) {
75
+ Mage::getSingleton('adminhtml/session')->addSuccess(
76
+ $this->__('The Contact was deleted in SugarCRM')
77
+ );
78
+ }
79
+ }
80
+ else if(Mage::getSingleton('admin/session')->isLoggedIn()) {
81
+ Mage::getSingleton('adminhtml/session')->addSuccess(
82
+ $this->__('The Contact with this email not exists in SugarCRM')
83
+ );
84
+ }
85
+ }
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Send request to SugarCRM REST API
92
+ * @param string $method
93
+ * @param array $params
94
+ * @return mixed
95
+ */
96
+ public function sendRequest($method, $params) {
97
+ $result = false;
98
+
99
+ $postParams = http_build_query(
100
+ array(
101
+ 'method' => $method,
102
+ 'input_type' => 'JSON',
103
+ 'response_type' => 'JSON',
104
+ 'rest_data' => json_encode($params)
105
+ )
106
+ );
107
+
108
+ $curl = curl_init($this->getSugarUrl());
109
+ curl_setopt($curl, CURLOPT_POST, true);
110
+ curl_setopt($curl, CURLOPT_HEADER, false);
111
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
112
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $postParams);
113
+ $response = curl_exec($curl);
114
+
115
+ $jsonObj = json_decode($response);
116
+ if (is_object($jsonObj) && get_class($jsonObj) == 'stdClass') {
117
+ $result = $jsonObj;
118
+ }
119
+
120
+ return $result;
121
+ }
122
+
123
+ /**
124
+ * Check if contact with this email exists in SugarCRM and return Contact id or false
125
+ * @param string $email
126
+ * @return mixed
127
+ */
128
+ private function getContactID($email) {
129
+ $result = false;
130
+
131
+ $query = sprintf('contacts.id in (select eab.bean_id from email_addresses ea, email_addr_bean_rel eab where ea.email_address LIKE \'%s\' and eab.primary_address=1 and eab.email_address_id=ea.id and eab.bean_module=\'Contacts\' and ea.opt_out=0 and ea.deleted=0 and eab.deleted=0) and contacts.deleted=0', $email);
132
+ $params = array($this->sessionId, 'Contacts', $query, '', '', '', '', '');
133
+ $entries = $this->sendRequest('get_entry_list', $params);
134
+
135
+ //if contact exist - get Id
136
+ if ($entries !== false && isset($entries->entry_list) && count($entries->entry_list) == 1 && isset($entries->entry_list[0])) {
137
+ $result = $entries->entry_list[0]->id;
138
+ }
139
+
140
+ return $result;
141
+ }
142
+
143
+ /**
144
+ * Init function: login into Sugar, etc.
145
+ * @return [type] [description]
146
+ */
147
+ private function init() {
148
+ if (strlen($this->sessionId) == 0) {
149
+ $params = array(
150
+ 'user_auth' => array(
151
+ 'user_name' => $this->getSugarLogin(),
152
+ 'password' => md5($this->getSugarPassword()),
153
+ ),
154
+ );
155
+
156
+ $result = $this->sendRequest('login', $params);
157
+
158
+ if ($result !== false && isset($result->id)) {
159
+ $this->sessionId = $result->id;
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Get URl of SugarCRM from config
166
+ * @return string
167
+ */
168
+ private function getSugarUrl() {
169
+ return Mage::getStoreConfig(self::XML_PATH_SUGAR_URL);
170
+ }
171
+
172
+ /**
173
+ * Get login of SugarCRM user from config
174
+ * @return string
175
+ */
176
+ private function getSugarLogin() {
177
+ return Mage::getStoreConfig(self::XML_PATH_SUGAR_LOGIN);
178
+ }
179
+
180
+ /**
181
+ * Get password of SugarCRM user from config
182
+ * @return string
183
+ */
184
+ private function getSugarPassword() {
185
+ return Mage::getStoreConfig(self::XML_PATH_SUGAR_PASSWD);
186
+ }
187
+ }
app/code/community/OlegKoval/CustomersIntoSugarCrm/Model/Observer.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Observer for customer save/delete actions
4
+ *
5
+ * @category OlegKoval
6
+ * @package OlegKoval_CustomersIntoSugarCrm
7
+ * @copyright Copyright (c) 2013 Oleg Koval
8
+ * @author Oleg Koval <oleh.koval@gmail.com>
9
+ */
10
+ class OlegKoval_CustomersIntoSugarCrm_Model_Observer {
11
+ const XML_PATH_ENABLED = 'customersintosugarcrm/extension/enabled';
12
+
13
+ /**
14
+ * Initialization of our custom model
15
+ */
16
+ protected function _construct() {
17
+ $this->_init('customersintosugarcrm/observer');
18
+ parent::_construct();
19
+ }
20
+
21
+ /**
22
+ * Customer save handler
23
+ * @param Varien_Object $observer
24
+ * @return OlegKoval_CustomersIntoSugarCrm_Model_Observer
25
+ */
26
+ public function customerSaved($observer) {
27
+ if (Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
28
+ $customer = $observer->getEvent()->getCustomer();
29
+ if (($customer instanceof Mage_Customer_Model_Customer)) {
30
+ Mage::helper('customersintosugarcrm')->synchronizeCustomer($customer);
31
+ }
32
+ }
33
+
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * Customer delete handler
39
+ * @param Varien_Object $observer
40
+ * @return OlegKoval_CustomersIntoSugarCrm_Model_Observer
41
+ */
42
+ public function customerDeleted($observer) {
43
+ if (Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
44
+ Mage::helper('customersintosugarcrm')->deleteCustomer($observer->getEvent()->getCustomer()->getEmail());
45
+ }
46
+
47
+ return $this;
48
+ }
49
+ }
app/code/community/OlegKoval/CustomersIntoSugarCrm/Model/Sugarcrm.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Model for SugarCRM data manipulations.
4
+ *
5
+ * @category OlegKoval
6
+ * @package OlegKoval_CustomersIntoSugarCrm
7
+ * @copyright Copyright (c) 2013 Oleg Koval
8
+ * @author Oleg Koval <oleh.koval@gmail.com>
9
+ */
10
+ class OlegKoval_CustomersIntoSugarCrm_Model_Sugarcrm extends Mage_Core_Model_Abstract {
11
+ /**
12
+ * Initialization of our custom model
13
+ */
14
+ protected function _construct() {
15
+ $this->_init('customersintosugarcrm/sugarcrm');
16
+ parent::_construct();
17
+ }
18
+
19
+ /**
20
+ * Synchronize Magento Customer data with SugarCRM Contact object
21
+ * @param Mage_Customer_Model_Customer $customer
22
+ * @param array $params
23
+ * @return OlegKoval_CustomersIntoSugarCrm_Model_Sugarcrm
24
+ */
25
+ public function syncSugarcrm($customer, $params) {
26
+ $contactId = $this->syncContact($customer, $params);
27
+
28
+ return $contactId;
29
+ }
30
+
31
+ /**
32
+ * Delete Contact object from SugarCRM
33
+ * @param array $params
34
+ * @return OlegKoval_CustomersIntoSugarCrm_Model_Sugarcrm
35
+ */
36
+ public function deleteFromSugarcrm($params) {
37
+ $result = false;
38
+
39
+ if ($params['contactId'] !== false) {
40
+ //set Contact properties
41
+ $contactParams = array(
42
+ 'session' => $params['sessionId'],
43
+ 'module' => 'Contacts',
44
+ 'name_value_list' => array(
45
+ 0 => array(
46
+ array('name' => 'id', 'value' => $params['contactId']),
47
+ array('name' => 'deleted', 'value' => '1')
48
+ )
49
+ ),
50
+ );
51
+
52
+ $requestResult = Mage::helper('customersintosugarcrm')->sendRequest('set_entries', $contactParams);
53
+
54
+ if (isset($requestResult->ids) && isset($requestResult->ids[0])) {
55
+ $result = $requestResult->ids[0];
56
+ }
57
+ }
58
+
59
+ return $result;
60
+ }
61
+
62
+ /**
63
+ * Update or create new Contact in SugarCRM
64
+ * @param Mage_Customer_Model_Customer $customer
65
+ * @param array $params
66
+ * @return mixed
67
+ */
68
+ private function syncContact($customer, $params) {
69
+ $result = false;
70
+
71
+ //set Contact properties
72
+ $contactParams = array(
73
+ 'session' => $params['sessionId'],
74
+ 'module' => 'Contacts',
75
+ 'name_value_list' => array(
76
+ 0 => array(
77
+ array('name' => 'title', 'value' => $customer->getData('prefix')),
78
+ array('name' => 'first_name', 'value' => $customer->getData('firstname')),
79
+ array('name' => 'last_name', 'value' => $customer->getData('lastname')),
80
+ array('name' => 'email1', 'value' => $customer->getData('email')),
81
+ array('name' => 'birthdate', 'value' => $customer->getData('dob')),
82
+ array('name' => 'lead_source', 'value' => 'Other')
83
+ )
84
+ ),
85
+ );
86
+
87
+ //get all addresses of current customer
88
+ $addressList = $customer->getAddresses();
89
+
90
+ //add Primary Address of Contact
91
+ if (($address = $customer->getPrimaryAddress('default_billing')) != false || count($addressList) > 0) {
92
+ //we do not have default billing BUT we have "some" address in address book - we use it
93
+ if ($address == false) {
94
+ $address = $addressList[0];
95
+ }
96
+
97
+ $contactParams['name_value_list'][0] = array_merge(
98
+ $contactParams['name_value_list'][0],
99
+ $this->prepareAddressArray($address)
100
+ );
101
+ }
102
+ //set address as empty
103
+ else {
104
+ $contactParams['name_value_list'][0][] = array('name' => 'primary_address_country', 'value' => '');
105
+ $contactParams['name_value_list'][0][] = array('name' => 'primary_address_postalcode', 'value' => '');
106
+ $contactParams['name_value_list'][0][] = array('name' => 'primary_address_state', 'value' => '');
107
+ $contactParams['name_value_list'][0][] = array('name' => 'primary_address_city', 'value' => '');
108
+ $contactParams['name_value_list'][0][] = array('name' => 'primary_address_street', 'value' => '');
109
+ }
110
+
111
+ //add Other Address of Contact
112
+ if (($address = $customer->getPrimaryAddress('default_shipping')) != false) {
113
+ $contactParams['name_value_list'][0] = array_merge(
114
+ $contactParams['name_value_list'][0],
115
+ $this->prepareAddressArray($address, 'alt')
116
+ );
117
+ }
118
+ //set address as empty
119
+ else {
120
+ $contactParams['name_value_list'][0][] = array('name' => 'alt_address_country', 'value' => '');
121
+ $contactParams['name_value_list'][0][] = array('name' => 'alt_address_postalcode', 'value' => '');
122
+ $contactParams['name_value_list'][0][] = array('name' => 'alt_address_state', 'value' => '');
123
+ $contactParams['name_value_list'][0][] = array('name' => 'alt_address_city', 'value' => '');
124
+ $contactParams['name_value_list'][0][] = array('name' => 'alt_address_street', 'value' => '');
125
+ }
126
+
127
+ //if Contact exists - we add Id into params to update info instead of creating new contact
128
+ if ($params['contactId'] !== false) {
129
+ $contactParams['name_value_list'][0][] = array('name' => 'id', 'value' => $params['contactId']);
130
+ }
131
+
132
+ $requestResult = Mage::helper('customersintosugarcrm')->sendRequest('set_entries', $contactParams);
133
+
134
+ if (isset($requestResult->ids) && isset($requestResult->ids[0])) {
135
+ $result = $requestResult->ids[0];
136
+ }
137
+
138
+ return $result;
139
+ }
140
+
141
+ /**
142
+ * Prepare array of Contact Address properties
143
+ * @param Mage_Customer_Model_Address $address
144
+ * @param string $prefix
145
+ * @return array
146
+ */
147
+ private function prepareAddressArray($address, $prefix = 'primary') {
148
+ $result = array();
149
+
150
+ //Country
151
+ $result[] = array(
152
+ 'name' => $prefix . '_address_country',
153
+ 'value' => Mage::app()->getLocale()->getCountryTranslation($address->getData('country_id'))
154
+ );
155
+ //Postal Code
156
+ $result[] = array(
157
+ 'name' => $prefix . '_address_postalcode',
158
+ 'value' => $address->getData('postcode')
159
+ );
160
+ //State/Region
161
+ $result[] = array(
162
+ 'name' => $prefix . '_address_state',
163
+ 'value' => (
164
+ $address->getData('region_id') > 0 ?
165
+ Mage::getModel('directory/region')->load($address->getData('region_id'))->getName() :
166
+ $address->getData('region')
167
+ )
168
+ );
169
+ //City
170
+ $result[] = array(
171
+ 'name' => $prefix . '_address_city',
172
+ 'value' => $address->getData('city')
173
+ );
174
+ //Address
175
+ $result[] = array(
176
+ 'name' => $prefix . '_address_street',
177
+ 'value' => $address->getData('street')
178
+ );
179
+
180
+ return $result;
181
+ }
182
+ }
app/code/community/OlegKoval/CustomersIntoSugarCrm/etc/config.xml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Customers into SugarCRM
5
+ *
6
+ * @category OlegKoval
7
+ * @package OlegKoval_CustomersIntoSugarCrm
8
+ * @copyright Copyright (c) 2013 Oleg Koval
9
+ * @author Oleg Koval <oleh.koval@gmail.com>
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <OlegKoval_CustomersIntoSugarCrm>
15
+ <version>1.0.0</version>
16
+ <depends>
17
+ <Mage_Customer/>
18
+ </depends>
19
+ </OlegKoval_CustomersIntoSugarCrm>
20
+ </modules>
21
+
22
+ <global>
23
+ <helpers>
24
+ <customersintosugarcrm>
25
+ <class>OlegKoval_CustomersIntoSugarCrm_Helper</class>
26
+ </customersintosugarcrm>
27
+ </helpers>
28
+
29
+ <models>
30
+ <customersintosugarcrm>
31
+ <class>OlegKoval_CustomersIntoSugarCrm_Model</class>
32
+ </customersintosugarcrm>
33
+ </models>
34
+ </global>
35
+
36
+ <frontend>
37
+ <events>
38
+ <customer_save_after>
39
+ <observers>
40
+ <customersintosugarcrm_observer>
41
+ <class>customersintosugarcrm/observer</class>
42
+ <method>customerSaved</method>
43
+ </customersintosugarcrm_observer>
44
+ </observers>
45
+ </customer_save_after>
46
+ <customer_delete_after>
47
+ <observers>
48
+ <customersintosugarcrm_observer>
49
+ <class>customersintosugarcrm/observer</class>
50
+ <method>customerDeleted</method>
51
+ </customersintosugarcrm_observer>
52
+ </observers>
53
+ </customer_delete_after>
54
+ </events>
55
+
56
+ <translate>
57
+ <modules>
58
+ <OlegKoval_CustomersIntoSugarCrm>
59
+ <files>
60
+ <default>OlegKoval_CustomersIntoSugarCrm.csv</default>
61
+ </files>
62
+ </OlegKoval_CustomersIntoSugarCrm>
63
+ </modules>
64
+ </translate>
65
+ </frontend>
66
+
67
+ <adminhtml>
68
+ <events>
69
+ <customer_save_after>
70
+ <observers>
71
+ <customersintosugarcrm_observer>
72
+ <class>customersintosugarcrm/observer</class>
73
+ <method>customerSaved</method>
74
+ </customersintosugarcrm_observer>
75
+ </observers>
76
+ </customer_save_after>
77
+ <customer_delete_after>
78
+ <observers>
79
+ <customersintosugarcrm_observer>
80
+ <class>customersintosugarcrm/observer</class>
81
+ <method>customerDeleted</method>
82
+ </customersintosugarcrm_observer>
83
+ </observers>
84
+ </customer_delete_after>
85
+ </events>
86
+
87
+ <translate>
88
+ <modules>
89
+ <OlegKoval_CustomersIntoSugarCrm>
90
+ <files>
91
+ <default>OlegKoval_CustomersIntoSugarCrm.csv</default>
92
+ </files>
93
+ </OlegKoval_CustomersIntoSugarCrm>
94
+ </modules>
95
+ </translate>
96
+
97
+ <acl>
98
+ <resources>
99
+ <admin>
100
+ <children>
101
+ <system>
102
+ <children>
103
+ <config>
104
+ <children>
105
+ <customersintosugarcrm translate="title" module="customersintosugarcrm">
106
+ <title>Customers into SugarCRM</title>
107
+ </customersintosugarcrm>
108
+ </children>
109
+ </config>
110
+ </children>
111
+ </system>
112
+ </children>
113
+ </admin>
114
+ </resources>
115
+ </acl>
116
+ </adminhtml>
117
+ </config>
app/code/community/OlegKoval/CustomersIntoSugarCrm/etc/system.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Customers into SugarCRM
5
+ *
6
+ * @category OlegKoval
7
+ * @package OlegKoval_CustomersIntoSugarCrm
8
+ * @copyright Copyright (c) 2013 Oleg Koval
9
+ * @author Oleg Koval <oleh.koval@gmail.com>
10
+ */
11
+ -->
12
+ <config>
13
+ <sections>
14
+ <customersintosugarcrm translate="label" module="customersintosugarcrm">
15
+ <label>Customers into SugarCRM</label>
16
+ <tab>customer</tab>
17
+ <frontend_type>text</frontend_type>
18
+ <sort_order>300</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ <groups>
23
+ <extension translate="label">
24
+ <label>Extension Options</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>110</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <fields>
31
+ <enabled translate="label">
32
+ <label>Enable synchronization of Customers into SugarCRM</label>
33
+ <frontend_type>select</frontend_type>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ <sort_order>110</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </enabled>
40
+ </fields>
41
+ </extension>
42
+ <sugarcrm translate="label">
43
+ <label>SugarCRM Options</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>120</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <fields>
50
+ <url translate="label">
51
+ <label>URL to SugarCRM REST API</label>
52
+ <comment>For example: http://{sugar_url}/service/v4/rest.php</comment>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>110</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </url>
59
+ <login translate="label">
60
+ <label>Username</label>
61
+ <comment>Username of SugarCRM user which have admin rights</comment>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>120</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </login>
68
+ <password translate="label">
69
+ <label>Password</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>130</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
+ </password>
76
+ </fields>
77
+ </sugarcrm>
78
+ </groups>
79
+ </customersintosugarcrm>
80
+ </sections>
81
+ </config>
app/etc/modules/OlegKoval_CustomersIntoSugarCrm.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Customers into SugarCRM
5
+ *
6
+ * @category OlegKoval
7
+ * @package OlegKoval_CustomersIntoSugarCrm
8
+ * @copyright Copyright (c) 2013 Oleg Koval
9
+ * @author Oleg Koval <oleh.koval@gmail.com>
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <OlegKoval_CustomersIntoSugarCrm>
15
+ <active>true</active>
16
+ <codePool>community</codePool>
17
+ </OlegKoval_CustomersIntoSugarCrm>
18
+ </modules>
19
+ </config>
app/locale/en_US/OlegKoval_CustomersIntoSugarCrm.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Customers into SugarCRM","Customers into SugarCRM"
2
+ "SugarCRM Options","SugarCRM Options"
3
+ "URL to SugarCRM REST API","URL to SugarCRM REST API"
4
+ "For example: http://{sugar_url}/service/v4/rest.php","For example: http://{sugar_url}/service/v4/rest.php"
5
+ "Username","Username"
6
+ "Username of SugarCRM user which have admin rights","Username of SugarCRM user which have admin rights"
7
+ "Password","Password"
8
+ "Extension Options","Extension Options"
9
+ "Enable synchronization of Customers into SugarCRM","Enable synchronization of Customers into SugarCRM"
10
+ "New Contact was created in SugarCRM","New Contact was created in SugarCRM"
11
+ "The Contact info was updated in SugarCRM", "The Contact info was updated in SugarCRM"
12
+ "The Contact with this email not exists in SugarCRM","The Contact with this email not exists in SugarCRM"
13
+ "The Contact was deleted in SugarCRM","The Contact was deleted in SugarCRM"
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>customersintosugarcrm</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/OSL-3.0">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Synchronization Magento Customers data with SugarCRM Contacts.</summary>
10
+ <description>This extension allow you automaticaly synchronize Magento Customers data with SugarCRM Contacts:&#xD;
11
+ - will automaticaly create new if Contact with this Customer email not exists;&#xD;
12
+ - will atomaticaly update information if Contact exists;&#xD;
13
+ &#xD;
14
+ This extension will synchronize this Magento Customer info:&#xD;
15
+ - Prefix;&#xD;
16
+ - First Name;&#xD;
17
+ - Last Name;&#xD;
18
+ - Email;&#xD;
19
+ - Birthdate;&#xD;
20
+ - Customer Addresses (primary Billing/Shipping);</description>
21
+ <notes>First version of "Customers into SugarCRM" extension.</notes>
22
+ <authors><author><name>Oleg Koval</name><user>auto-converted</user><email>oleh.koval@gmail.com</email></author></authors>
23
+ <date>2013-05-11</date>
24
+ <time>17:09:33</time>
25
+ <contents><target name="magecommunity"><dir name="OlegKoval"><dir name="CustomersIntoSugarCrm"><dir name="Helper"><file name="Data.php" hash="6d49c57ec023005d5590f39221c04891"/></dir><dir name="Model"><file name="Observer.php" hash="a16c2847b5886dc73e10a5ff5eb8db14"/><file name="Sugarcrm.php" hash="ee93e4183e491bf6ac58d3ca5e7b2c76"/></dir><dir name="etc"><file name="config.xml" hash="79b898093973ab4d5acc1380bcf07075"/><file name="system.xml" hash="2ed29bd461b6245a939be086ccbcb457"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="OlegKoval_CustomersIntoSugarCrm.xml" hash="3a070329709b0ff6c3c83db148753980"/></dir></target><target name="magelocale"><dir name="en_US"><file name="OlegKoval_CustomersIntoSugarCrm.csv" hash="53fa303aebc72e1efed88857c475e6a1"/></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies/>
28
+ </package>