Ventata_Connector - Version 1.3.0.0

Version Notes

.

Download this release

Release Info

Developer Magento Core Team
Extension Ventata_Connector
Version 1.3.0.0
Comparing to
See all releases


Code changes from version 1.1.0.0 to 1.3.0.0

app/code/local/Ventata/Connector/Model/.DS_Store DELETED
Binary file
app/code/local/Ventata/Connector/Model/Config/Observer.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ error_reporting(E_ALL);
3
+ ini_set('display_errors', '1');
4
+ class Ventata_Connector_Model_Config_Observer extends Varien_Event_Observer
5
+ {
6
+ public function __construct()
7
+ {
8
+
9
+ }
10
+
11
+ public function get_all_stores_api_key($observer)
12
+ {
13
+ $allStores = Mage::app()->getStores();
14
+
15
+ if(Mage::getStoreConfig('ventata/orderhook_group/apipassword') == null) {
16
+ $magentoApiKey = $this->createVentataApiUser();
17
+ Mage::getModel('core/config')->saveConfig('ventata/orderhook_group/apipassword', $magentoApiKey);
18
+ } else {
19
+ $magentoApiKey = Mage::getStoreConfig('ventata/orderhook_group/apipassword');
20
+ }
21
+
22
+ foreach ($allStores as $_eachStoreId => $val) {
23
+ $_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
24
+ $_storeName = Mage::app()->getStore($_eachStoreId)->getName();
25
+ $_storeId = Mage::app()->getStore($_eachStoreId)->getId();
26
+ $storeUrl = Mage::app()->getStore($_storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
27
+
28
+ if(Mage::getStoreConfig('ventata/orderhook_group/storeapikey', Mage::app()->getStore($_eachStoreId)) == null) {
29
+ $data = array();
30
+
31
+ $data["Name"] = $_storeName;
32
+ $data["URL"] = $storeUrl;
33
+
34
+ $storeType = array();
35
+ $storeType["Id"] = 1004;
36
+ $storeType["Name"] = "Magento";
37
+ $data["StoreType"] = $storeType;
38
+
39
+
40
+ $data_string = json_encode($data);
41
+ $ventataCompanyAPIKey = Mage::getStoreConfig('ventata/orderhook_group/apikey');
42
+
43
+ $result = $this->_processRequest("https://api.ventata.com/stores?ApiKey=", $ventataCompanyAPIKey, $data_string);
44
+
45
+ //Mage::setStoreConfig('ventata/orderhook_group/storeapikey', $res["ApiKey"], Mage::app()->getStore());
46
+ Mage::getModel('core/config')->saveConfig('ventata/orderhook_group/storeapikey', $result['ApiKey'], 'stores', $_storeId);
47
+ //Mage::app()->getStore($_storeCode)->setConfig('ventata/orderhook_group/storeapikey', $res['ApiKey']);
48
+
49
+ $storeSetting = array();
50
+ $storeSetting["Key"] = "ApiPassword";
51
+ $storeSetting["Value"] = $magentoApiKey;
52
+ //Note we are now using the $ventataStoreApiKey
53
+ //4a. Use CURL to POST $storeSetting to https://api.ventata.com/store/setting?ApiKey=$ventataStoreAPIKey
54
+
55
+ $settingsResult = $this->_processRequest("https://api.ventata.com/store/setting?ApiKey=", $result['ApiKey'], json_encode($storeSetting));
56
+
57
+ $storeSetting = array();
58
+ $storeSetting["Key"] = "StoreUrl";
59
+ $storeSetting["Value"] = $storeUrl;
60
+
61
+ $settingsResult = $this->_processRequest("https://api.ventata.com/store/setting?ApiKey=", $result['ApiKey'], json_encode($storeSetting));
62
+
63
+ $storeSetting = array();
64
+ $storeSetting["Key"] = "StoreViewId";
65
+ $storeSetting["Value"] = $_storeId;
66
+
67
+ $settingsResult = $this->_processRequest("https://api.ventata.com/store/setting?ApiKey=", $result['ApiKey'], json_encode($storeSetting));
68
+
69
+ }
70
+ }
71
+
72
+ return $this;
73
+ }
74
+
75
+ public function _processRequest($url, $apiKey, $data_string)
76
+ {
77
+ $ch = curl_init();
78
+
79
+ $url = $url . $apiKey;
80
+
81
+ curl_setopt($ch, CURLOPT_URL, $url);
82
+ curl_setopt($ch, CURLOPT_POST, true);
83
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
84
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
85
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
86
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
87
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
88
+
89
+ $result = curl_exec($ch);
90
+
91
+ curl_close($ch);
92
+
93
+ return json_decode($result, true);
94
+ }
95
+
96
+ public function createVentataApiUser()
97
+ {
98
+ $user = Mage::getModel('api/user')->loadByUsername('VentataConnector');
99
+ if(!$user || !$user->getId()) {
100
+ $role = Mage::getModel('api/roles')
101
+ ->setName('Ventata')
102
+ ->setPid(false)
103
+ ->setRoleType('G')
104
+ ->save();
105
+
106
+
107
+ Mage::getModel('api/rules')
108
+ ->setRoleId($role->getId())
109
+ ->setResources(array('all'))
110
+ ->saveRel();
111
+
112
+ $magentoApiKey = $this->getRandomString(24);
113
+ $user = Mage::getModel('api/user');
114
+ $user->setData($this->generateUserData($role->getId(), $magentoApiKey));
115
+
116
+ $user->save()->load($user->getId());
117
+
118
+ $user->setRoleIds(array($role->getId()))
119
+ ->setRoleUserId($user->getUserId())
120
+ ->saveRelations();
121
+
122
+ $rules = Mage::getModel('api/rules')->getCollection()
123
+ ->addFieldToFilter('role_id', $role->getId());
124
+
125
+ foreach($rules as $rule) {
126
+ $rule->setApiPermission('allow');
127
+ }
128
+
129
+ $rules->save();
130
+ }
131
+
132
+ return $magentoApiKey;
133
+ }
134
+
135
+ public function generateUserData($roleId, $magentoApiKey)
136
+ {
137
+ $data = array(
138
+ 'username' => 'VentataConnector',
139
+ 'firstname' => 'Ventata',
140
+ 'lastname' => 'Connector',
141
+ 'email' => 'magento@ventata.com',
142
+ 'api_key' => $magentoApiKey,
143
+ 'api_key_confirmation' => $magentoApiKey,
144
+ 'is_active' => 1,
145
+ 'user_roles' => '',
146
+ 'assigned_user_role' => '',
147
+ 'role_name' => '',
148
+ 'roles' => array($roleId)
149
+ );
150
+
151
+ return $data;
152
+ }
153
+
154
+ public function getRandomString($length, $charset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
155
+ {
156
+ $str = '';
157
+ $count = strlen($charset);
158
+ while ($length--) {
159
+ $str .= $charset[mt_rand(0, $count-1)];
160
+ }
161
+ return $str;
162
+ }
163
+ }
164
+ ?>
app/code/local/Ventata/Connector/Model/Order/Observer.php CHANGED
@@ -6,53 +6,53 @@ class Ventata_Connector_Model_Order_Observer extends Varien_Event_Observer
6
  }
7
 
8
  public function upload_order_to_ventata($observer)
9
- {
10
- $order = $observer->getOrder();
11
-
12
- $data = array();
13
- $data['DateCreated'] = "/Date(" . strtotime($order->getCreatedAt()) . ")/";
14
- $data['ExternalOrderId'] = $order->getIncrementId();
15
- $data['ShippingCost'] = $order->getShippingAmount();
16
- $data['SubTotal'] = $order->getSubtotal();
17
- $data['Taxes'] = $order->getTaxAmount();
18
- $data['TotalPrice'] = $order->getGrandTotal();
19
- $data['OrderDetails'] = array();
20
- $items = $order->getAllItems();
21
-
22
- if ($items) {
23
- foreach ($items as $item) {
24
- $product = $item->getProduct();
25
- $store = Mage::getModel('core/store')->load($item->getStoreId());
26
- $tempData = array(
27
- 'CostPerItem' => $product->getPrice(),
28
- 'ManuCode' => $item->getSku(),
29
- 'Quantity' => $item->getQtyOrdered(),
30
- 'PricePaid' => $item->getPrice(),
31
- 'StoreCode' => $store->getCode(),
32
- );
33
- array_push($data['OrderDetails'], $tempData);
34
- }
35
- }
36
-
37
- $data_string = json_encode($data);
38
- $ch = curl_init();
39
-
40
- $APIKey = Mage::getStoreConfig('ventata/orderhook_group/apikey', Mage::app()->getStore());;
41
 
42
- $url = "https://api.ventata.com/orders?ApiKey=" . $APIKey;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- curl_setopt($ch, CURLOPT_URL, $url);
45
- curl_setopt($ch, CURLOPT_POST, true);
46
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
47
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
49
- curl_setopt($ch, CURLOPT_VERBOSE, true);
50
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
51
-
52
- $result = curl_exec($ch);
53
- curl_close($ch);
54
-
55
- return $this;
56
  }
57
  }
58
  ?>
6
  }
7
 
8
  public function upload_order_to_ventata($observer)
9
+ {
10
+ $order = $observer->getOrder();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ $data = array();
13
+ $data['DateCreated'] = '/Date(' . date('U', strtotime($order->getCreatedAt())) . '000)/';
14
+ $data['ExternalOrderId'] = $order->getIncrementId();
15
+ $data['ShippingCost'] = $order->getShippingAmount();
16
+ $data['SubTotal'] = $order->getSubtotal();
17
+ $data['Taxes'] = $order->getTaxAmount();
18
+ $data['TotalPrice'] = $order->getGrandTotal();
19
+ $data['OrderDetails'] = array();
20
+ $items = $order->getAllItems();
21
+
22
+ if ($items) {
23
+ foreach ($items as $item) {
24
+ $product = $item->getProduct();
25
+ $store = Mage::getModel('core/store')->load($item->getStoreId());
26
+ $tempData = array(
27
+ 'CostPerItem' => $product->getPrice(),
28
+ 'ManuCode' => $item->getSku(),
29
+ 'Quantity' => $item->getQtyOrdered(),
30
+ 'PricePaid' => $item->getPrice(),
31
+ 'StoreCode' => $store->getCode(),
32
+ );
33
+ array_push($data['OrderDetails'], $tempData);
34
+ }
35
+ }
36
+
37
+ $data_string = json_encode($data);
38
+ $ch = curl_init();
39
+
40
+ $storeApiKey = Mage::getStoreConfig('ventata/orderhook_group/storeapikey', Mage::app()->getStore());;
41
+
42
+ $url = "https://api.ventata.com/orders?ApiKey=" . $storeApiKey;
43
+
44
+ curl_setopt($ch, CURLOPT_URL, $url);
45
+ curl_setopt($ch, CURLOPT_POST, true);
46
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
47
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
48
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
49
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
50
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
51
+
52
+ $result = curl_exec($ch);
53
+ curl_close($ch);
54
 
55
+ return $this;
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
  }
58
  ?>
app/code/local/Ventata/Connector/Model/Product/Observer.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ error_reporting(E_ALL);
3
+ ini_set('display_errors', '1');
4
+ class Ventata_Connector_Model_Product_Observer extends Varien_Event_Observer
5
+ {
6
+ public function __construct()
7
+ {
8
+
9
+ }
10
+
11
+ public function product_save_after($observer)
12
+ {
13
+ $product = $observer->getProduct();
14
+ $websiteIds = $product->getWebsiteIds();
15
+
16
+ if(Mage::app()->getRequest()->getParam('id') != null) {
17
+ $action = 'edit';
18
+ } else {
19
+ $action = 'new';
20
+ }
21
+
22
+ switch($action) {
23
+ case 'new':
24
+ $data = $this->_prepareProductForVentata($product);
25
+ $this->sendProductToVentata($data, 'new', $websiteIds);
26
+ break;
27
+
28
+ case 'edit':
29
+ $data = $this->prepareProductForVentata($product);
30
+ $this->sendProductToVentata($data, 'update', $websiteIds);
31
+ break;
32
+
33
+ }
34
+
35
+ return $this;
36
+ }
37
+
38
+
39
+ public function _prepareProductForVentata($product)
40
+ {
41
+ $data = array(
42
+ 'Cost' => ($product->getCost()) ? $product->getCost() : 0,
43
+ 'DateCreated' => '/Date(' . date('U', strtotime($product->getCreatedAt())) . '+0000)/',
44
+ 'Description' => $product->getDescription(),
45
+ //'MANUCODE' => $product['model'],
46
+ 'Name' => $product->getName(),
47
+ 'Price' => $product->getPrice(),
48
+ 'SKU' => $product->getSku(),
49
+ 'StoreCode' => $product->getId(),
50
+ 'Strategy' => 'Unlimited Supply',
51
+ );
52
+
53
+ return $data;
54
+ }
55
+
56
+ public function sendProductToVentata($data, $action, $websiteIds)
57
+ {
58
+ $data_string = json_encode($data);
59
+
60
+ $stores = Mage::app()->getStores();
61
+ foreach ($stores as $_eachStoreId => $val) {
62
+ $store = Mage::app()->getStore($_eachStoreId);
63
+ $_storeCode = $store->getCode();
64
+ $_storeName = $store->getName();
65
+ $_storeId = $store->getId();
66
+ $websiteId = $store->getWebsiteId();
67
+
68
+ //echo $store->getWebsiteId() . ": $_storeCode";
69
+
70
+ if(!in_array($websiteId, $websiteIds)) {
71
+ // echo $store->getWebsiteId() . ": $_storeCode break here\n";
72
+ break;
73
+ }
74
+
75
+ $storeApiKey = Mage::getStoreConfig('ventata/orderhook_group/storeapikey', Mage::app()->getStore($_eachStoreId));
76
+ $this->_processRequest($data_string, $action, $storeApiKey);
77
+ }
78
+
79
+ //exit;
80
+ }
81
+
82
+ public function _processRequest($data_string, $action, $storeApiKey)
83
+ {
84
+ $ch = curl_init();
85
+
86
+ if($storeApiKey == null) {
87
+ return;
88
+ }
89
+
90
+ $url = "https://api.ventata.com/product?ApiKey=" . $storeApiKey;
91
+ curl_setopt($ch, CURLOPT_URL, $url);
92
+
93
+ switch($action)
94
+ {
95
+ case 'new':
96
+ curl_setopt($ch, CURLOPT_POST, true);
97
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
98
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
99
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
100
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
101
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
102
+ break;
103
+
104
+ case 'update':
105
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
106
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
107
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
108
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
109
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
110
+ break;
111
+ }
112
+
113
+ $result = curl_exec($ch);
114
+ //print_r(json_decode($result, true));
115
+ curl_close($ch);
116
+
117
+ return $result;
118
+ }
119
+
120
+ }
121
+ ?>
app/code/local/Ventata/Connector/etc/config.xml CHANGED
@@ -20,7 +20,26 @@
20
  <method>upload_order_to_ventata</method>
21
  </ventata_connector_order_observer>
22
  </observers>
23
- </checkout_type_onepage_save_order_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  </events>
25
  <helpers>
26
  <connector>
20
  <method>upload_order_to_ventata</method>
21
  </ventata_connector_order_observer>
22
  </observers>
23
+ </checkout_type_onepage_save_order_after>
24
+ <admin_system_config_changed_section_ventata>
25
+ <observers>
26
+ <ventata_connector_config_observer>
27
+ <type>singleton</type>
28
+ <class>Ventata_Connector_Model_Config_Observer</class>
29
+ <method>get_all_stores_api_key</method>
30
+ </ventata_connector_config_observer>
31
+ </observers>
32
+ </admin_system_config_changed_section_ventata>
33
+ <catalog_product_save_after>
34
+ <observers>
35
+ <ventata_connector_product_observer>
36
+ <type>singleton</type>
37
+ <class>Ventata_Connector_Model_Product_Observer</class>
38
+ <method>product_save_after</method>
39
+ </ventata_connector_product_observer>
40
+ </observers>
41
+ </catalog_product_save_after>
42
+
43
  </events>
44
  <helpers>
45
  <connector>
app/code/local/Ventata/Connector/etc/system.xml CHANGED
@@ -19,16 +19,32 @@
19
  <show_in_store>1</show_in_store>
20
  <fields>
21
  <apikey translate="label">
22
- <label>API key: </label>
23
  <frontend_type>text</frontend_type>
24
  <sort_order>20</sort_order>
25
  <show_in_default>1</show_in_default>
26
- <show_in_website>1</show_in_website>
27
- <show_in_store>1</show_in_store>
28
  </apikey>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  </fields>
30
  </orderhook_group>
31
  </groups>
32
  </ventata>
33
  </sections>
34
- </config>
19
  <show_in_store>1</show_in_store>
20
  <fields>
21
  <apikey translate="label">
22
+ <label>Company API key: </label>
23
  <frontend_type>text</frontend_type>
24
  <sort_order>20</sort_order>
25
  <show_in_default>1</show_in_default>
26
+ <show_in_website>0</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
  </apikey>
29
+ <storeapikey translate="label">
30
+ <label>Store API key: </label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>30</sort_order>
33
+ <show_in_default>0</show_in_default>
34
+ <show_in_website>0</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </storeapikey>
37
+ <apipassword translate="label">
38
+ <label>API password: </label>
39
+ <frontend_type>hidden</frontend_type>
40
+ <sort_order>30</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>0</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ </apipassword>
45
  </fields>
46
  </orderhook_group>
47
  </groups>
48
  </ventata>
49
  </sections>
50
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Ventata_Connector</name>
4
- <version>1.1.0.0</version>
5
  <stability>stable</stability>
6
  <license>MIT</license>
7
  <channel>community</channel>
@@ -9,10 +9,10 @@
9
  <summary>Ventata Dynamic Pricing Software</summary>
10
  <description>Ventata Dynamic Pricing Software</description>
11
  <notes>.</notes>
12
- <authors><author><name>Luke Davis</name><user>ventata</user><email>ldavis@ventata.com</email></author></authors>
13
- <date>2012-06-04</date>
14
- <time>01:41:07</time>
15
- <contents><target name="magelocal"><dir name="Ventata"><dir name="Connector"><dir name="Helper"><file name="Data.php" hash="d2838df85bb8d15047db074dd6712ee1"/></dir><dir name="Model"><dir name="Order"><file name="Observer.php" hash="05db5bdf96dbdb9b2d341b8d63a46f5c"/></dir><file name=".DS_Store" hash="4fd0cefc93be2b011f8fe45626f49faf"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f8096b19be11130aebca410143f113b8"/><file name="config.xml" hash="aaf8535f1531ebca1c67f32c3bc1dbea"/><file name="system.xml" hash="ff3404073be3003636259b4bba99ebf6"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ventata_Connector.xml" hash="b88dfd737477ad81895d153fd3a41106"/></dir></target><target name="mage"><dir name="."><file name="ventata.php" hash="06b4891d1e854fb66a5b39b46c3ef124"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.4.0.0</min><max>1.7</max></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Ventata_Connector</name>
4
+ <version>1.3.0.0</version>
5
  <stability>stable</stability>
6
  <license>MIT</license>
7
  <channel>community</channel>
9
  <summary>Ventata Dynamic Pricing Software</summary>
10
  <description>Ventata Dynamic Pricing Software</description>
11
  <notes>.</notes>
12
+ <authors><author><name>Luke Davis</name><user>auto-converted</user><email>ldavis@ventata.com</email></author></authors>
13
+ <date>2012-08-20</date>
14
+ <time>04:01:35</time>
15
+ <contents><target name="magelocal"><dir name="Ventata"><dir name="Connector"><dir name="Helper"><file name="Data.php" hash="d2838df85bb8d15047db074dd6712ee1"/></dir><dir name="Model"><dir name="Config"><file name="Observer.php" hash="c257d43455aa428b56f2ff34821d33ef"/></dir><dir name="Order"><file name="Observer.php" hash="6ae624e95fdd364bf8485dd73c536aa2"/></dir><dir name="Product"><file name="Observer.php" hash="657bf7705338e5060ca673fecdac24b7"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f8096b19be11130aebca410143f113b8"/><file name="config.xml" hash="06c29828c412a609f925d3b33156999a"/><file name="system.xml" hash="a6b331bac6316b066d800c6ed1117bc4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ventata_Connector.xml" hash="b88dfd737477ad81895d153fd3a41106"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.4.0.0</min><max>1.7</max></package></required></dependencies>
18
  </package>
ventata.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
-
3
- require 'app/Mage.php';
4
- umask(0);
5
- try {
6
- $app = Mage::app('default');
7
- $ventataApiKey = $_GET['APIKey'];
8
- $magentoApiKey = $_GET['MagentoKey'];
9
-
10
- Mage::getModel('core/config')->saveConfig('ventata/orderhook_group/apikey', $ventataApiKey );
11
-
12
- $user = Mage::getModel('api/user')->loadByUsername('VentataConnector');
13
- if(!$user || !$user->getId()) {
14
- $role = Mage::getModel('api/roles')
15
- ->setName('Ventata')
16
- ->setPid(false)
17
- ->setRoleType('G')
18
- ->save();
19
-
20
-
21
- Mage::getModel('api/rules')
22
- ->setRoleId($role->getId())
23
- ->setResources(array('all'))
24
- ->saveRel();
25
-
26
-
27
- $user = Mage::getModel('api/user');
28
- $user->setData(array(
29
- 'username' => 'VentataConnector',
30
- 'firstname' => 'Ventata',
31
- 'lastname' => 'Connector',
32
- 'email' => 'magento@ventata.com',
33
- 'api_key' => $magentoApiKey,
34
- 'api_key_confirmation' => $magentoApiKey,
35
- 'is_active' => 1,
36
- 'user_roles' => '',
37
- 'assigned_user_role' => '',
38
- 'role_name' => '',
39
- 'roles' => array($role->getId())
40
- ));
41
-
42
- $user->save()->load($user->getId());
43
-
44
- $user->setRoleIds(array($role->getId()))
45
- ->setRoleUserId($user->getUserId())
46
- ->saveRelations();
47
-
48
- $rules = Mage::getModel('api/rules')->getCollection()
49
- ->addFieldToFilter('role_id', $role->getId());
50
-
51
- foreach($rules as $rule) {
52
- $rule->setApiPermission('allow');
53
- }
54
- $rules->save();
55
- }
56
-
57
- echo "Successfull";
58
-
59
- } catch (Exception $e) {
60
- Mage::printException($e);
61
- }