Infoplus_Connector - Version 4.0.0

Version Notes

No Notes

Download this release

Release Info

Developer Infoplus
Extension Infoplus_Connector
Version 4.0.0
Comparing to
See all releases


Version 4.0.0

app/code/community/Infoplus/Connector/Block/Adminhtml/Catalog/Product/Edit/Tab/Infoplusitem.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Block_Adminhtml_Catalog_Product_Edit_Tab_Infoplusitem extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
9
+ {
10
+
11
+ /*********************************************
12
+ ** _construct **
13
+ ** **
14
+ ** constructor, set the template **
15
+ ** **
16
+ ** @return void **
17
+ *********************************************/
18
+ protected function _construct()
19
+ {
20
+ parent::_construct();
21
+ $this->setTemplate('infoplus_connector/catalog/product/edit/tab/infoplus_item.phtml');
22
+ }
23
+
24
+
25
+
26
+ /*********************************************
27
+ ** getTabLabel **
28
+ ** **
29
+ ** specifies tab label for template **
30
+ ** **
31
+ ** @return string **
32
+ *********************************************/
33
+ public function getTabLabel()
34
+ {
35
+ return $this->__('Infoplus Product Info');
36
+ }
37
+
38
+
39
+
40
+ /*********************************************
41
+ ** getTabTitle **
42
+ ** **
43
+ ** specifies tab title for template **
44
+ ** **
45
+ ** @return string **
46
+ *********************************************/
47
+ public function getTabTitle()
48
+ {
49
+ return $this->__('Infoplus Product Info');
50
+ }
51
+
52
+
53
+
54
+ /*********************************************
55
+ ** canShowTab **
56
+ ** **
57
+ ** Determinies if tab can be shown **
58
+ ** **
59
+ ** @return boolean **
60
+ *********************************************/
61
+ public function canShowTab()
62
+ {
63
+ return true;
64
+ }
65
+
66
+
67
+
68
+ /*********************************************
69
+ ** isHidden **
70
+ ** **
71
+ ** Determinies if tab is hidden **
72
+ ** **
73
+ ** @return boolean **
74
+ *********************************************/
75
+ public function isHidden()
76
+ {
77
+ return false;
78
+ }
79
+
80
+
81
+ /*********************************************
82
+ ** getProduct **
83
+ ** **
84
+ ** Fetches current product from registry **
85
+ ** **
86
+ ** @return boolean **
87
+ *********************************************/
88
+ public function getProduct()
89
+ {
90
+ return Mage::registry('product');
91
+ }
92
+
93
+ }
app/code/community/Infoplus/Connector/Catalog/Model/Product/Api.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Catalog_Model_Product_Api extends Mage_Catalog_Model_Product_Api
9
+ {
10
+
11
+ /***************************************
12
+ ** Retrieve product info **
13
+ ** **
14
+ ** @param int|string $productId **
15
+ ** @param string|int $store **
16
+ ** @param stdClass $attributes **
17
+ ** @return array **
18
+ ***************************************/
19
+ public function info($productId, $store = null, $attributes = null, $identifierType = null)
20
+ {
21
+ ###################################
22
+ ## get array from call to parent ##
23
+ ###################################
24
+ $productInfo = parent::info($productId, $store, $attributes, $identifierType);
25
+
26
+ ####################################################
27
+ ## look for existing infoplus_record for this sku ##
28
+ ####################################################
29
+ $collection = Mage::getModel('infoplus/infoplus_product')->getCollection()->addFieldToFilter('magento_sku', $productInfo["sku"]);
30
+ if(count($collection) > 0)
31
+ {
32
+ ######################################
33
+ ## get infoplus product information ##
34
+ ######################################
35
+ $infoplusProduct = $collection->getFirstItem();
36
+ $wmsSku = $infoplusProduct->getWmsSku();
37
+
38
+ ############################################################
39
+ ## if value is set for sku add to the product information ##
40
+ ############################################################
41
+ if(isset($wmsSku) && $wmsSku != "")
42
+ {
43
+ $productInfo["fulfilled_by_infoplus"] = $infoplusProduct->getWmsSku();
44
+ }
45
+ }
46
+
47
+ return $productInfo;
48
+ }
49
+
50
+
51
+
52
+ /**********************************************
53
+ ** Retrieve product info for given wms sku **
54
+ ** **
55
+ ** @param string $wmsSku **
56
+ ** @param stdClass $attributes **
57
+ ** @return array **
58
+ **********************************************/
59
+ public function getProductInfoByWmsSku($wmsSku)
60
+ {
61
+ $result = array();
62
+
63
+ ###############################################
64
+ ## look for infoplus_record for this wms sku ##
65
+ ###############################################
66
+ $infoplusProductCollection = Mage::getModel('infoplus/infoplus_product')->getCollection()->addFieldToFilter('wms_sku', $wmsSku);
67
+
68
+ #####################################################################
69
+ ## if any found, iterate over here, adding product data to results ##
70
+ #####################################################################
71
+ foreach($infoplusProductCollection as $infoplusProduct)
72
+ {
73
+ #############################
74
+ ## load product from model ##
75
+ #############################
76
+ $productCollection = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('sku', $infoplusProduct->getMagentoSku());
77
+
78
+ ##############################
79
+ ## add to our results array ##
80
+ ##############################
81
+ foreach($productCollection as $product)
82
+ {
83
+ $result[] = array
84
+ (
85
+ 'product_id' => $product->getId(),
86
+ 'sku' => $product->getSku(),
87
+ 'name' => $product->getName(),
88
+ 'set' => $product->getAttributeSetId(),
89
+ 'type' => $product->getTypeId(),
90
+ 'category_ids' => $product->getCategoryIds(),
91
+ 'website_ids' => $product->getWebsiteIds()
92
+ );
93
+ }
94
+ }
95
+
96
+ return $result;
97
+ }
98
+
99
+ }
app/code/community/Infoplus/Connector/Helper/Data.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+
11
+ }
app/code/community/Infoplus/Connector/Model/Infoplus/Product.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Model_Infoplus_Product extends Mage_Core_Model_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('infoplus/infoplus_product');
15
+ }
16
+
17
+ }
app/code/community/Infoplus/Connector/Model/Mysql4/Infoplus/Product.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Model_Mysql4_Infoplus_Product extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ $this->_init('infoplus/infoplus_product', 'id');
14
+ }
15
+
16
+ }
app/code/community/Infoplus/Connector/Model/Mysql4/Infoplus/Product/Collection.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Model_Mysql4_Infoplus_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('infoplus/infoplus_product');
15
+ }
16
+
17
+ }
app/code/community/Infoplus/Connector/Model/Observer.php ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Model_Observer
9
+ {
10
+
11
+ public function on_eav_load_before($observer)
12
+ {
13
+ Mage::log('Inside Infoplus_Connector_Model_Observer:on_eav_load_before($event)');
14
+
15
+ $collection = $observer->getCollection();
16
+ if (!isset($collection)) return;
17
+
18
+ if (is_a($collection, 'Mage_Catalog_Model_Resource_Product_Collection'))
19
+ {
20
+ $infoplusTable = Mage::getSingleton('core/resource')->getTableName('infoplus_product');
21
+ $collection->getSelect()->join(array("ip" => $infoplusTable), "e.sku=ip.magento_sku", array("wms_sku as fulfilled_by_infoplus"));
22
+ }
23
+ }
24
+
25
+
26
+
27
+ public function admin_html_block_html_before($observer)
28
+ {
29
+ Mage::log('Inside Infoplusor_Connector_Model_Observer:admin_html_block_html_before($event)');
30
+
31
+ $block = $observer->getEvent()->getBlock();
32
+ if (!isset($block)) return;
33
+
34
+ switch ($block->getType())
35
+ {
36
+ case 'adminhtml/catalog_product_grid':
37
+ /* @var $block Mage_Adminhtml_Block_Catalog_Product_Grid */
38
+ $block->addColumnAfter('fulfilled_by_infoplus', array(
39
+ 'header' => Mage::helper('catalog')->__('Fulfilled By Infoplus'),
40
+ 'type' => 'text',
41
+ 'width' => '20px',
42
+ 'filter' => false,
43
+ 'index' => 'fulfilled_by_infoplus',
44
+ ),"status")->sortColumnsByOrder();
45
+ break;
46
+ }
47
+ }
48
+
49
+
50
+
51
+ public function admin_html_widget_container_html_before($observer)
52
+ {
53
+ Mage::log('Inside Infoplus_Connector_Model_Observer:admin_html_widget_container_html_before($event)');
54
+
55
+ $block = $observer->getEvent()->getBlock();
56
+
57
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View)
58
+ {
59
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
60
+ $order = Mage::getModel('sales/order')->load($orderId);
61
+ $incrementId = $order->getIncrementId();
62
+
63
+ $message = Mage::helper('sales')->__('Are you sure you want to resend order ' . $incrementId . ' to Infoplus?');
64
+
65
+ $resendURL = Mage::getStoreConfig('infoplus_options/infoplus_options_general/infoplus_url');
66
+ $resendURL .= "/infoplus-wms/api/magento/repost";
67
+ $resendURL .= "?order_id=" . $incrementId;
68
+ $resendURL .= "&store_url=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
69
+
70
+ $viewURL = Mage::getStoreConfig('infoplus_options/infoplus_options_general/infoplus_url');
71
+ $viewURL .= "/infoplus-wms/order/req/query/";
72
+ $viewURL .= "{%22criteriaFields%22:[{%22fieldName%22:%22customerOrderNo%22,%22values%22:[%22" . $incrementId . "%22],%22operator%22:%22EQUALS%22},{%22fieldName%22:%22reqLoadProgramId%22,%22operator%22:%22IN%22,%22values%22:[{%22id%22:4,%22text%22:%22magento (4)%22,%22idValue%22:4}],%22isAdvancedPVS%22:false}],%22orderByFields%22:[{%22fieldName%22:%22reqNo%22,%22direction%22:%22DESC%22}],%22startAt%22:null,%22limit%22:null}";
73
+
74
+ $block->addButton('resend_to_infoplus', array(
75
+ 'label' => Mage::helper('sales')->__('Resend To Infoplus'),
76
+ 'onclick' => "if(confirm('{$message}')){window.open('{$resendURL}','_blank','width=350,height=250');}",
77
+ 'class' => 'go'
78
+ ));
79
+
80
+ $block->addButton('view_in_infoplus', array(
81
+ 'label' => Mage::helper('sales')->__('View In Infoplus'),
82
+ 'onclick' => "window.open('". ${viewURL} . "')",
83
+ 'class' => 'go'
84
+ ));
85
+ }
86
+ }
87
+
88
+
89
+ /*********************************************
90
+ ** save_product_tab_data **
91
+ ** **
92
+ ** called when product is saved **
93
+ ** **
94
+ ** @param class $observer **
95
+ ** @return void **
96
+ *********************************************/
97
+ public function save_product_tab_data($observer)
98
+ {
99
+ Mage::log('Inside Infoplus_Connector_Model_Observer:save_product_tab_data()...');
100
+
101
+ #################################
102
+ ## get the product being saved ##
103
+ #################################
104
+ $product = $observer->getEvent()->getProduct();
105
+
106
+ ####################################
107
+ ## get the field values passed in ##
108
+ ####################################
109
+ $request = Mage::app()->getRequest();
110
+
111
+ #######################################################################################
112
+ ## if the save is not coming from a form (ie the api), then dont worry about wms_sku ##
113
+ #######################################################################################
114
+ $formKey = $request->getPost('form_key');
115
+ if(! $formKey)
116
+ {
117
+ Mage::log('No form key present on POST, not considering infoplus_product data...');
118
+ return;
119
+ }
120
+
121
+ $wmsSku = $request->getPost('infoplus_wms_sku');
122
+ if(! $wmsSku)
123
+ {
124
+ $wmsSku = "off";
125
+ }
126
+
127
+ ####################################################
128
+ ## look for existing infoplus_record for this sku ##
129
+ ####################################################
130
+ $collection = Mage::getModel('infoplus/infoplus_product')->getCollection()->addFieldToFilter('magento_sku', $product->getSku());
131
+
132
+ ######################################
133
+ ## if any records found, do updates ##
134
+ ######################################
135
+ if(count($collection) > 0)
136
+ {
137
+ foreach($collection as $infoplusProduct)
138
+ {
139
+ #############################
140
+ ## load product from model ##
141
+ #############################
142
+ $_product = Mage::getModel('infoplus/infoplus_product')->load($infoplusProduct->getId());
143
+ $_product->setWmsSku ($wmsSku);
144
+ $_product->setUpdateTime (now());
145
+ $_product->save();
146
+ }
147
+ }
148
+ else
149
+ {
150
+ ###############################################
151
+ ## if no records found, and we were provided ##
152
+ ## a value to store, insert a record ##
153
+ ###############################################
154
+ if(isset($wmsSku) && $wmsSku != "")
155
+ {
156
+ $infoplusProduct = Mage::getModel('infoplus/infoplus_product');
157
+ $infoplusProduct->setMagentoSku ($product->getSku());
158
+ $infoplusProduct->setWmsSku ($wmsSku);
159
+ $infoplusProduct->setCreatedTime (now());
160
+ $infoplusProduct->setUpdateTime (now());
161
+ $infoplusProduct->save();
162
+ }
163
+ }
164
+
165
+ Mage::app()->getCacheInstance()->cleanType('block_html');
166
+ }
167
+
168
+
169
+
170
+ /*********************************************
171
+ ** post_new_order_queue_message **
172
+ ** **
173
+ ** called when new order event occurs **
174
+ ** **
175
+ ** @param class $observer **
176
+ ** @return void **
177
+ *********************************************/
178
+ public function post_new_order_queue_message($observer)
179
+ {
180
+ Mage::log('Inside Infoplus_Connector_Model_Observer:post_new_order_queue_message()...');
181
+ $orderId = $observer->getEvent()->getOrder()->getIncrementId();
182
+ $this->post_event("order-created", $orderId);
183
+ }
184
+
185
+
186
+
187
+ /*********************************************
188
+ ** post_cancel_order_queue_message **
189
+ ** **
190
+ ** called when order cancelled event occurs **
191
+ ** **
192
+ ** @param class $observer **
193
+ ** @return void **
194
+ *********************************************/
195
+ public function post_cancel_order_queue_message($observer)
196
+ {
197
+ Mage::log('Inside Infoplus_Connector_Model_Observer:post_cancel_order_queue_message()...');
198
+ $orderId = $observer->getEvent()->getOrder()->getIncrementId();
199
+ $this->post_event("order-cancelled", $orderId);
200
+ }
201
+
202
+
203
+
204
+ /*********************************************
205
+ ** post_queue_message **
206
+ ** **
207
+ ** Posts message to given queue name **
208
+ ** **
209
+ ** @param string $event **
210
+ ** @param string $orderId **
211
+ ** @return void **
212
+ *********************************************/
213
+ private function post_event($event, $orderId)
214
+ {
215
+ Mage::log('Inside Infoplus_Connector_Model_Observer:post_event("' . $event . '","' . $orderId . '")...');
216
+
217
+ #################################
218
+ ## get the URL from the config ##
219
+ #################################
220
+ $url = Mage::getStoreConfig('infoplus_options/infoplus_options_general/infoplus_url');
221
+ if(! $url)
222
+ {
223
+ Mage::log('Store Configuration Infoplus URL was not set, not posting webhook event...');
224
+ return;
225
+ }
226
+ $url .= "/infoplus-wms/api/magento/orders";
227
+
228
+ $data = array("event" => $event, "increment_id" => $orderId, "store_url" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB));
229
+ $jsonData = Mage::helper('core')->jsonEncode($data);
230
+
231
+ Mage::log('Attempting to post event=['.$event.'] for order=['.$orderId.'] to url=['.$url.'].');
232
+ $curlHandle = curl_init();
233
+ curl_setopt($curlHandle, CURLOPT_URL, $url);
234
+ curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, "POST");
235
+ curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $jsonData);
236
+ curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
237
+ ## curl_setopt($curlHandle, CURLOPT_SSL_VERIFYHOST, 0);
238
+ ## curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, 0);
239
+ curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array(
240
+ 'Content-Type: application/json',
241
+ 'Content-Length: ' . strlen($jsonData))
242
+ );
243
+
244
+ $output = curl_exec($curlHandle);
245
+ Mage::log('Post complete!');
246
+
247
+ #################################
248
+ ## check if any error occurred ##
249
+ #################################
250
+ if(curl_errno($curlHandle))
251
+ {
252
+ ##############################################
253
+ ## send message with error and close handle ##
254
+ ##############################################
255
+ $this->send_error_email('Curl error: ['.curl_error($curlHandle).'] when posting message=['.$message.'] to url=['.$url.'], received output=['.$output.']');
256
+ curl_close($curlHandle);
257
+ return;
258
+ }
259
+ else
260
+ {
261
+ ####################################
262
+ ## retrieve info and close handle ##
263
+ ####################################
264
+ $curlInfo = curl_getinfo($curlHandle);
265
+ curl_close($curlHandle);
266
+
267
+ #######################################
268
+ ## get the http code for the request ##
269
+ #######################################
270
+ $httpCode = $curlInfo['http_code'];
271
+
272
+ ###########################################################
273
+ ## if none returned send email, or if not 200 send email ##
274
+ ###########################################################
275
+ if(empty($httpCode))
276
+ {
277
+ $this->send_error_email('No HTTP code was returned when posting message=['.$message.'] to url=['.$url.'], received output=['.$output.']');
278
+ return;
279
+ }
280
+ else if($httpCode != "200")
281
+ {
282
+ $this->send_error_email('Unexpected HTTP code=['.$httpCode.'] was returned when posting message=['.$message.'] to url=['.$url.'], received output=['.$output.']');
283
+ return;
284
+ }
285
+
286
+ #############################################################
287
+ ## ensure we received the expected response text from call ##
288
+ #############################################################
289
+ if(strpos($output, 'SUCCESS') === false)
290
+ {
291
+ $this->send_error_email('Did not receive expected output when posting message=['.$message.'] to url=['.$url.'], received output=['.$output.']');
292
+ return;
293
+ }
294
+ }
295
+ }
296
+
297
+
298
+
299
+ /*********************************************
300
+ ** send_error_email **
301
+ ** **
302
+ ** Sends an error message **
303
+ ** **
304
+ ** @param string $errorMessage **
305
+ ** @return void **
306
+ *********************************************/
307
+ private function send_error_email($errorMessage)
308
+ {
309
+ Mage::log('ERROR: ' . $errorMessage);
310
+
311
+ /*
312
+ $errorEmailFromAddress = Mage::getStoreConfig('infoplus/connector/error_email_from_address');
313
+ $errorEmailToAddress = Mage::getStoreConfig('infoplus/connector/error_email_to_address');
314
+
315
+ if($errorEmailFromAddress && $errorEmailToAddress)
316
+ {
317
+ $mail = new Zend_Mail();
318
+ $mail->setBodyText ($errorMessage);
319
+ $mail->setFrom ($errorEmailFromAddress);
320
+ $mail->addTo ($errorEmailToAddress);
321
+ $mail->setSubject ('Magento Module Exception : Infoplus_Connector_Model_Observer');
322
+ $mail->send();
323
+ }
324
+ */
325
+ }
326
+
327
+ }
app/code/community/Infoplus/Connector/Sales/Model/Order.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Sales_Model_Order extends Mage_Sales_Model_Order
9
+ {
10
+
11
+ /*********************************************
12
+ ** cancel **
13
+ ** **
14
+ ** Calls parent cancel method, and if ok **
15
+ ** dispatches a custom event which our **
16
+ ** Observer class can handle **
17
+ ** **
18
+ ** @return $this **
19
+ *********************************************/
20
+ public function cancel()
21
+ {
22
+ ###################################
23
+ ## call parent to attempt cancel ##
24
+ ###################################
25
+ parent::cancel();
26
+
27
+ #################################################
28
+ ## if cancel successful, dispatch custom event ##
29
+ #################################################
30
+ if($this->getState() === self::STATE_CANCELED)
31
+ {
32
+ Mage::dispatchEvent('sales_order_cancel', array('order'=>$this));
33
+ }
34
+
35
+ return $this;
36
+ }
37
+
38
+ }
app/code/community/Infoplus/Connector/Sales/Model/Order/Invoice/Api.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Sales_Model_Order_Invoice_Api extends Mage_Sales_Model_Order_Invoice_Api
9
+ {
10
+
11
+ /*********************************************
12
+ ** create **
13
+ ** **
14
+ ** creates a new invoice for an order **
15
+ ** **
16
+ ** @param string $orderIncrementId **
17
+ ** @param array $itemsQty **
18
+ ** @param string $comment **
19
+ ** @param booleam $email **
20
+ ** @param boolean $includeComment **
21
+ ** @param boolean $capturedOffline **
22
+ ** @return string **
23
+ *********************************************/
24
+ public function create($orderIncrementId, $itemsQty, $comment = null, $email = false, $includeComment = false, $capturedOffline = false)
25
+ {
26
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
27
+
28
+ ################################
29
+ ## make sure the order exists ##
30
+ ################################
31
+ if (!$order->getId())
32
+ {
33
+ $this->_fault('order_not_exists');
34
+ }
35
+
36
+ #######################################
37
+ ## ensure the invoice can be created ##
38
+ #######################################
39
+ if (!$order->canInvoice())
40
+ {
41
+ $this->_fault('data_invalid', Mage::helper('sales')->__('Can not do invoice for order.'));
42
+ }
43
+
44
+ $invoice = $order->prepareInvoice($itemsQty);
45
+
46
+ if($capturedOffline)
47
+ {
48
+ $invoice->setRequestedCaptureCase("offline");
49
+ }
50
+
51
+ $invoice->register();
52
+
53
+ if ($comment !== null)
54
+ {
55
+ $invoice->addComment($comment, $email);
56
+ }
57
+
58
+ if ($email)
59
+ {
60
+ $invoice->setEmailSent(true);
61
+ }
62
+
63
+ $invoice->getOrder()->setIsInProcess(true);
64
+
65
+ try
66
+ {
67
+ $transactionSave = Mage::getModel('core/resource_transaction')
68
+ ->addObject($invoice)
69
+ ->addObject($invoice->getOrder())
70
+ ->save();
71
+
72
+ $invoice->sendEmail($email, ($includeComment ? $comment : ''));
73
+ }
74
+ catch (Mage_Core_Exception $e)
75
+ {
76
+ $this->_fault('data_invalid', $e->getMessage());
77
+ }
78
+
79
+ return $invoice->getIncrementId();
80
+ }
81
+
82
+ }
app/code/community/Infoplus/Connector/Sales/Model/Order/Shipment/Api.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category Infoplus
6
+ * @package Infoplus_Connector
7
+ */
8
+ class Infoplus_Connector_Sales_Model_Order_Shipment_Api extends Mage_Sales_Model_Order_Shipment_Api
9
+ {
10
+
11
+ /*********************************************
12
+ ** sendEmailToCustomer **
13
+ ** **
14
+ ** Override of validate method to allow **
15
+ ** optional address validation by ML **
16
+ ** **
17
+ ** @param string $shipmentIncrementId **
18
+ ** @return boolean **
19
+ *********************************************/
20
+ public function sendEmailToCustomer($shipmentIncrementId)
21
+ {
22
+ $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);
23
+
24
+ ###################################
25
+ ## make sure the shipment exists ##
26
+ ###################################
27
+ if (!$shipment->getId())
28
+ {
29
+ $this->_fault('not_exists');
30
+ }
31
+
32
+ $shipment->sendEmail(true, '');
33
+
34
+ return null;
35
+ }
36
+
37
+ }
app/code/community/Infoplus/Connector/etc/api.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * @category Infoplus
7
+ * @package Infoplus_Connector
8
+ */
9
+ -->
10
+ <config>
11
+ <api>
12
+ <resources>
13
+ <sales_order_shipment>
14
+ <methods>
15
+ <sendEmailToCustomer>
16
+ <title>Send a Shipment email to the customer on an order</title>
17
+ </sendEmailToCustomer>
18
+ </methods>
19
+ </sales_order_shipment>
20
+ <catalog_product>
21
+ <methods>
22
+ <getProductInfoByWmsSku>
23
+ <title>Get product information based on wms sku</title>
24
+ </getProductInfoByWmsSku>
25
+ </methods>
26
+ </catalog_product>
27
+ </resources>
28
+ </api>
29
+ </config>
app/code/community/Infoplus/Connector/etc/config.xml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * @category Infoplus
7
+ * @package Infoplus_Connector
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Infoplus_Connector>
13
+ <version>4.0.0</version>
14
+ </Infoplus_Connector>
15
+ </modules>
16
+ <global>
17
+ <models>
18
+ <infoplus>
19
+ <class>Infoplus_Connector_Model</class>
20
+ <resourceModel>infoplus_mysql4</resourceModel>
21
+ </infoplus>
22
+ <infoplus_mysql4>
23
+ <class>Infoplus_Connector_Model_Mysql4</class>
24
+ <entities>
25
+ <infoplus_product>
26
+ <table>infoplus_product</table>
27
+ </infoplus_product>
28
+ </entities>
29
+ </infoplus_mysql4>
30
+ </models>
31
+ <helpers>
32
+ <infoplus>
33
+ <class>Infoplus_Connector_Helper</class>
34
+ </infoplus>
35
+ </helpers>
36
+ <resources>
37
+ <infoplus_setup>
38
+ <setup>
39
+ <module>Infoplus_Connector</module>
40
+ </setup>
41
+ <connection>
42
+ <use>core_setup</use>
43
+ </connection>
44
+ </infoplus_setup>
45
+ <infoplus_read>
46
+ <connection>
47
+ <use>core_read</use>
48
+ </connection>
49
+ </infoplus_read>
50
+ <infoplus_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </infoplus_write>
55
+ </resources>
56
+ <blocks>
57
+ <infoplus>
58
+ <class>Infoplus_Connector_Block</class>
59
+ </infoplus>
60
+ </blocks>
61
+ <events>
62
+ <sales_order_place_after>
63
+ <observers>
64
+ <infoplus_observer>
65
+ <type>singleton</type>
66
+ <class>Infoplus_Connector_Model_Observer</class>
67
+ <method>post_new_order_queue_message</method>
68
+ </infoplus_observer>
69
+ </observers>
70
+ </sales_order_place_after>
71
+ <sales_order_cancel>
72
+ <observers>
73
+ <infoplus_observer>
74
+ <type>singleton</type>
75
+ <class>Infoplus_Connector_Model_Observer</class>
76
+ <method>post_cancel_order_queue_message</method>
77
+ </infoplus_observer>
78
+ </observers>
79
+ </sales_order_cancel>
80
+ <catalog_product_save_after>
81
+ <observers>
82
+ <infoplus_observer>
83
+ <type>singleton</type>
84
+ <class>Infoplus_Connector_Model_Observer</class>
85
+ <method>save_product_tab_data</method>
86
+ </infoplus_observer>
87
+ </observers>
88
+ </catalog_product_save_after>
89
+ </events>
90
+ <models>
91
+ <sales>
92
+ <rewrite>
93
+ <order>Infoplus_Connector_Sales_Model_Order</order>
94
+ <order_invoice_api>Infoplus_Connector_Sales_Model_Order_Invoice_Api</order_invoice_api>
95
+ <order_shipment_api>Infoplus_Connector_Sales_Model_Order_Shipment_Api</order_shipment_api>
96
+ </rewrite>
97
+ </sales>
98
+ <catalog>
99
+ <rewrite>
100
+ <product_api>Infoplus_Connector_Catalog_Model_Product_Api</product_api>
101
+ </rewrite>
102
+ </catalog>
103
+ </models>
104
+ </global>
105
+ <adminhtml>
106
+ <acl>
107
+ <resources>
108
+ <admin>
109
+ <children>
110
+ <system>
111
+ <children>
112
+ <config>
113
+ <children>
114
+ <infoplus_options>
115
+ <title>Infoplus Section</title>
116
+ </infoplus_options>
117
+ </children>
118
+ </config>
119
+ </children>
120
+ </system>
121
+ </children>
122
+ </admin>
123
+ </resources>
124
+ </acl>
125
+ <layout>
126
+ <updates>
127
+ <infoplus>
128
+ <file>infoplus_connector.xml</file>
129
+ </infoplus>
130
+ </updates>
131
+ </layout>
132
+ <events>
133
+ <adminhtml_widget_container_html_before>
134
+ <observers>
135
+ <infoplus_connector>
136
+ <class>Infoplus_Connector_Model_Observer</class>
137
+ <type>model</type>
138
+ <method>admin_html_widget_container_html_before</method>
139
+ </infoplus_connector>
140
+ </observers>
141
+ </adminhtml_widget_container_html_before>
142
+ <adminhtml_block_html_before>
143
+ <observers>
144
+ <infoplus_connector>
145
+ <class>Infoplus_Connector_Model_Observer</class>
146
+ <type>model</type>
147
+ <method>admin_html_block_html_before</method>
148
+ </infoplus_connector>
149
+ </observers>
150
+ </adminhtml_block_html_before>
151
+ <eav_collection_abstract_load_before>
152
+ <observers>
153
+ <infoplus_connector>
154
+ <class>Infoplus_Connector_Model_Observer</class>
155
+ <type>model</type>
156
+ <method>on_eav_load_before</method>
157
+ </infoplus_connector>
158
+ </observers>
159
+ </eav_collection_abstract_load_before>
160
+ </events>
161
+ </adminhtml>
162
+ <default>
163
+ <infoplus_options>
164
+ <infoplus_options_general>
165
+ <infoplus_deployment_identifier>ecom9999gatewayinsurance</infoplus_deployment_identifier>
166
+ <infoplus_test_mode>1</infoplus_test_mode>
167
+ <infoplus_enable_address_validation>1</infoplus_enable_address_validation>
168
+ </infoplus_options_general>
169
+ </infoplus_options>
170
+ <infoplus>
171
+ <connector>
172
+ <error_email_from_address>noreply@infopluscommerce.com</error_email_from_address>
173
+ <error_email_to_address>tchamberlain@infopluscommerce.com</error_email_to_address>
174
+ </connector>
175
+ </infoplus>
176
+ </default>
177
+ </config>
app/code/community/Infoplus/Connector/etc/system.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * @category Infoplus
7
+ * @package Infoplus_Connector
8
+ */
9
+ -->
10
+ <config>
11
+ <tabs>
12
+ <infoplus_config translate="label" module="infoplus">
13
+ <label>Infoplus</label>
14
+ <sort_order>99999</sort_order>
15
+ </infoplus_config>
16
+ </tabs>
17
+ <sections>
18
+ <infoplus_options translate="label" module="infoplus">
19
+ <label>Settings</label>
20
+ <tab>infoplus_config</tab>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1000</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <groups>
27
+ <infoplus_options_general translate="label">
28
+ <label>General</label>
29
+ <expanded>1</expanded>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <infoplus_url>
37
+ <label>Infoplus URL</label>
38
+ <comment>Base URL for your Infoplus website. Example: https://yourcompany.infopluswms.com</comment>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </infoplus_url>
45
+ </fields>
46
+ </infoplus_options_general>
47
+ </groups>
48
+ </infoplus_options>
49
+ </sections>
50
+ </config>
app/code/community/Infoplus/Connector/sql/infoplus_setup/install-2.0.0.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ ###################################
3
+ ## file mysql4-install-2.0.0.php ##
4
+ ###################################
5
+
6
+ $installer = $this;
7
+ $installer->startSetup();
8
+
9
+ $installer->run
10
+ ("
11
+ DROP TABLE IF EXISTS {$this->getTable('infoplus_product')};
12
+ CREATE TABLE {$this->getTable('infoplus_product')}
13
+ (
14
+ `id` int(11) unsigned NOT NULL auto_increment,
15
+ `magento_sku` varchar(64) NOT NULL default '',
16
+ `wms_sku` varchar(20) NOT NULL default '',
17
+ `created_time` datetime NULL,
18
+ `update_time` datetime NULL,
19
+ PRIMARY KEY (`id`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
+ ");
22
+
23
+ $installer->endSetup();
24
+
25
+ ?>
app/design/adminhtml/default/default/layout/infoplus_connector.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * @category design
7
+ * @package default_default
8
+ */
9
+ -->
10
+ <layout>
11
+ <adminhtml_catalog_product_edit>
12
+ <reference name="product_tabs">
13
+ <action method="addTab">
14
+ <name>infoplus_product_tab</name>
15
+ <block>infoplus/adminhtml_catalog_product_edit_tab_infoplusitem</block>
16
+ </action>
17
+ </reference>
18
+ </adminhtml_catalog_product_edit>
19
+ </layout>
app/design/adminhtml/default/default/template/infoplus_connector/catalog/product/edit/tab/infoplus_item.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category design
6
+ * @package default_default
7
+ */
8
+ ?>
9
+
10
+ <?php
11
+
12
+ $isChecked = "";
13
+
14
+ ####################################################
15
+ ## look for existing infoplus_record for this sku ##
16
+ ####################################################
17
+ $collection = Mage::getModel('infoplus/infoplus_product')->getCollection()->addFieldToFilter('magento_sku', $this->getProduct()->getSku());
18
+
19
+ ######################################
20
+ ## if any records found, do updates ##
21
+ ######################################
22
+ if(count($collection) > 0)
23
+ {
24
+ foreach($collection as $infoplusProduct)
25
+ {
26
+ $existingValue = $infoplusProduct->getWmsSku();
27
+ if($existingValue == "on")
28
+ {
29
+ $isChecked = "checked";
30
+ break;
31
+ }
32
+ }
33
+ }
34
+ ?>
35
+
36
+
37
+ <div class="entry-edit">
38
+ <div class="entry-edit-head">
39
+ <h4><?php echo $this->__('Infoplus Product Info'); ?></h4>
40
+ </div>
41
+ <div class="fieldset fieldset-wide">
42
+ <label for="infoplus_wms_sku">Fulfilled By Infoplus:&nbsp;</label>
43
+ <input type="checkbox" class="input-text" name="infoplus_wms_sku" id="infoplus_wms_sku" <?php echo $isChecked ?> />
44
+ </div>
45
+ </div>
app/etc/modules/Infoplus_Connector.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * @category Infoplus
7
+ * @package Infoplus_Connector
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Infoplus_Connector>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Infoplus_Connector>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Infoplus_Connector</name>
4
+ <version>4.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Apache License, Version 2.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Module to integrate Magento with Infoplus</summary>
10
+ <description>Module to integrate Magento with Infoplus</description>
11
+ <notes>No Notes</notes>
12
+ <authors><author><name>Infoplus</name><user>infoplus</user><email>infoplusconnect@infopluscommerce.com</email></author></authors>
13
+ <date>2016-05-17</date>
14
+ <time>20:57:36</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Infoplus_Connector.xml" hash=""/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="infoplus_connector.xml" hash=""/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>100.9.99</max></php></required></dependencies>
18
+ </package>
19
+