Shipjunction_Util - Version 1.2.0

Version Notes

For more information contact us at info@shipjunction.com

Download this release

Release Info

Developer ShipJunction
Extension Shipjunction_Util
Version 1.2.0
Comparing to
See all releases


Code changes from version 1.1.1 to 1.2.0

app/code/local/Shipjunction/Utilities/Model/Objectmodel/Api.php CHANGED
@@ -1,334 +1,338 @@
1
- <?php
2
- class productLocationZone
3
- {
4
- public $productId = "";
5
- public $location = "";
6
- public $zone = "";
7
- }
8
- class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resource_Abstract
9
- {
10
- /**
11
- * sendShipmentEmail
12
- *
13
- * @param string $shipmentIncrementId
14
- * @return string 1 = sucess, 0 = failure
15
- */
16
-
17
- public function sendShipmentEmail( $shipmentIncrementId )
18
- {
19
- $return = 1;
20
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: sendShipmentEmail called");
21
- $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);
22
- if($shipment)
23
- {
24
- $shipment->sendEmail(true);
25
- $shipment->setEmailSent(true);
26
- $shipment->save();
27
- }
28
- else {
29
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: shipment NOT found : ". $shipmentIncrementId);
30
- $result = 0;
31
- }
32
- return $return;
33
- }
34
-
35
- /**
36
- * getClearpathOrderNumber
37
- *
38
- * @param string $_orderIncrementId
39
- * @return string clearpathOrderNumber, boolean false
40
- */
41
- public function getClearpathOrderNumber( $_orderIncrementId )
42
- {
43
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getClearpathOrderNumber called");
44
-
45
- $_clearpath_tablename = Mage::getStoreConfig('clearpath/general/clearpath_tablename');
46
- $_db = Mage::getSingleton('core/resource')->getConnection('core_read');
47
- $_db_query = "SELECT cp_order_number FROM {$_clearpath_tablename} WHERE mage_order_number = '{$_orderIncrementId}'";
48
- $_db_result = $_db->fetchAll($_db_query);
49
-
50
- if ($_db_result) {
51
- return $_db_result[0]['cp_order_number'];
52
- } else {
53
- return false;
54
- }
55
- }
56
-
57
- /**
58
- * getEmbeddedErpFullStockOrders
59
- *
60
- * @return string comma delimited list of increment_ids which are fully stocked
61
- */
62
- public function getEmbeddedErpFullStockOrders()
63
- {
64
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getEmbeddedErpFullStockOrders called");
65
- $result = "";
66
- $resource = Mage::getSingleton('core/resource');
67
- $readConnection = $resource->getConnection('core_read');
68
- $sales_order_table = $resource->getTableName('sales/order');
69
-
70
- $completeOrders = Mage::getModel('Orderpreparation/ordertoprepare')->getFullStockOrdersFromCache();
71
- foreach($completeOrders as $completeOrder)
72
- {
73
- $completeOrderIds[] = $completeOrder->getopp_order_id();
74
- }
75
-
76
- $sql = "SELECT `increment_id` FROM `". $sales_order_table ."` WHERE `entity_id` in ('". implode("', '", $completeOrderIds) ."')";
77
- $db_result = $readConnection->fetchAll($sql);
78
- if ($db_result) {
79
- foreach($db_result as $row){
80
- $result = $result.$row['increment_id'].",";
81
- }
82
- }
83
-
84
- return $result;
85
- }
86
-
87
- /**
88
- * getEmbeddedErpZonesAndBins
89
- *
90
- * @param string $_productIdList comma delimited list of productIds to retrieve zone & bin information
91
- * @return string pipe delimited set of productId|binLocation|zone for $_productIdList
92
- */
93
- public function getEmbeddedErpZonesAndBins($_productIdList)
94
- {
95
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getEmbeddedErpZonesAndBins called");
96
-
97
- $productToBin = array();
98
- $binToZone = array();
99
- $locationList = "";
100
- $result = "";
101
-
102
- $warehouse = Mage::getModel('AdvancedStock/Warehouse')->load(1);
103
- $productIds = explode(",",$_productIdList);
104
-
105
- // Map each productId to a bin_num
106
- foreach($productIds as $productId) {
107
- $location = $warehouse->getProductLocation($productId);
108
- $productToBin[$productId] = $location;
109
- $locationList = $locationList."'".$location."',";
110
- }
111
-
112
- $resource = Mage::getSingleton('core/resource');
113
- $readConnection = $resource->getConnection('core_read');
114
- // Map each bin_num to a zone
115
- $sql = "SELECT `bin_num`,`zone` FROM `bin_list` WHERE `bin_num` in (". rtrim($locationList, ',') .");";
116
- /*Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getEmbeddedErpZonesAndBins sql : ".$sql);*/
117
-
118
- $db_result = $readConnection->fetchAll($sql);
119
- if ($db_result) {
120
- foreach($db_result as $row){
121
- if (strlen($row['bin_num']) > 0) {
122
- $binToZone[strtoupper($row['bin_num'])] = $row['zone'];
123
- }
124
- }
125
- }
126
- // put the results together
127
- foreach(array_keys($productToBin) as $productId) {
128
- $location = $productToBin[$productId];
129
- $zone = $binToZone[strtoupper($location)];
130
- $result = $result."|".$productId."|".$location."|".$zone;
131
- }
132
- // remove starting pipe
133
- $result = ltrim($result, '|');
134
-
135
- return $result;
136
- }
137
-
138
- /**
139
- * Create new invoice for order
140
- *
141
- * @param string $invoiceIncrementId
142
- * @param array $itemsQty
143
- * @param string $comment
144
- * @param bool $email
145
- * @param bool $includeComment
146
- * @param bool $capture
147
- * @return string
148
- */
149
- public function createInvoice($orderIncrementId,
150
- $itemsQty,
151
- $comment = null,
152
- $email = false,
153
- $includeComment = false,
154
- $capture = false)
155
- {
156
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createInvoice called with id:".$orderIncrementId.",email=".$email.",capture=".$capture.",itemsQty=".var_dump($itemsQty));
157
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
158
- /**
159
- * Check order existing
160
- */
161
- if (!$order->getId()) {
162
- return "Invalid order incrementId";
163
- }
164
-
165
- if ($order->getBaseTotalDue() == 0) {
166
- return "Invoiced";
167
- }
168
- /**
169
- * Check invoice create availability
170
- */
171
- if (!$order->canInvoice()) {
172
- return "Cannot do invoice for order.";
173
- }
174
-
175
- $invoice = $order->prepareInvoice(); // removing $itemsQty for now
176
-
177
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
178
-
179
- $invoice->register();
180
-
181
- if ($capture && $invoice->canCapture()) {
182
- $invoice->capture();
183
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createInvoice attempted to capture invoice");
184
- }
185
-
186
- if ($comment !== null) {
187
- $invoice->addComment($comment, $email);
188
- }
189
-
190
- if ($email) {
191
- $invoice->setEmailSent(true);
192
- }
193
-
194
- $invoice->getOrder()->setIsInProcess(true);
195
-
196
- $retries = 0;
197
- do {
198
- $shouldRetry = false;
199
- try {
200
- Mage::getModel('core/resource_transaction')
201
- ->addObject($invoice)
202
- ->addObject($invoice->getOrder())
203
- ->save();
204
- $invoice->sendEmail($email, ($includeComment ? $comment : ''));
205
- } catch (Exception $e) {
206
- $errmsg = $e->getMessage();
207
- if ($retries < 10 and strpos($errmsg, "try restarting transaction") > -1) {
208
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: retrying due to error $errmsg");
209
- $shouldRetry = true;
210
- } else {
211
- return $errmsg;
212
- }
213
- $retries++;
214
- usleep(50000 * $retries); // wait
215
- }
216
- } while ($shouldRetry);
217
-
218
- return $invoice->getIncrementId();
219
- }
220
- /**
221
- * Create new shipment for order
222
- *
223
- * @param string $orderIncrementId
224
- * @param array $itemsQty
225
- * @param string $carrierName
226
- * @param string $title
227
- * @param string $trackingNumbers
228
- * @return string
229
- */
230
- public function createShipment($orderIncrementId,
231
- $itemsQty,
232
- $carrierName,
233
- $title,
234
- $trackingNumbers)
235
- {
236
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createShipment called with id:".$orderIncrementId.",carrierName=".$carrierName.",title=".$title.",itemsQty=".var_dump($itemsQty));
237
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
238
-
239
- if (!$order->getId()) {
240
- return "Invalid order incrementId";
241
- }
242
-
243
- $shipment = null;
244
-
245
- if ($order->hasShipments()) {
246
- $shipment = $order->getShipmentsCollection()->getFirstItem();
247
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: has Shipments");
248
- }
249
- else {
250
- /**
251
- * Check shipment create availability
252
- */
253
- if (!$order->canShip()) {
254
- return "Cannot do shipment for order.";
255
- }
256
-
257
- $shipment = $order->prepareShipment();
258
- if ($shipment) {
259
- $shipment->register();
260
- //$shipment->addComment($comment, $email && $includeComment);
261
- $shipment->getOrder()->setIsInProcess(true);
262
- $retries = 0;
263
- do {
264
- $shouldRetry = false;
265
- try {
266
- $transactionSave = Mage::getModel('core/resource_transaction')
267
- ->addObject($shipment)
268
- ->addObject($shipment->getOrder())
269
- ->save();
270
- } catch (Exception $e) {
271
- $errmsg = $e->getMessage();
272
- if ($retries < 10 and strpos($errmsg, "try restarting transaction") > -1) {
273
- Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: retrying due to error $errmsg");
274
- $shouldRetry = true;
275
- } else {
276
- return $errmsg;
277
- }
278
- $retries++;
279
- usleep(50000 * $retries); // wait
280
- }
281
- } while ($shouldRetry);
282
- }
283
- }
284
-
285
- if (!$shipment) {
286
- return "Unable to find or create a shipment.";
287
- }
288
-
289
- $trackingNumbersOnShipment = array();
290
- foreach($shipment->getAllTracks() as $trackingNumberOnShipment) {
291
- $trackingNumbersOnShipment[]=$trackingNumberOnShipment->getNumber();
292
- }
293
- $numbersToUpdate = array_diff($trackingNumbers, $trackingNumbersOnShipment);
294
- foreach($numbersToUpdate as $trackingNumberToUpdate)
295
- {
296
- $trackId = Mage::getModel('sales/order_shipment_api')->addTrack($shipment->increment_id, $carrierName, $title, $trackingNumberToUpdate);
297
- }
298
-
299
- $order->save();
300
-
301
- return $shipment->increment_id;
302
- }
303
- /**
304
- * Create new invoice for order
305
- *
306
- * @param string $orderIncrementId
307
- * @param array $itemsQty
308
- * @param string $comment
309
- * @param bool $email
310
- * @param bool $includeComment
311
- * @param bool $capture
312
- * @param string $carrierName
313
- * @param string $title
314
- * @param string $trackingNumbers
315
- * @return string
316
- */
317
- public function createInvoiceAndShipment($orderIncrementId,
318
- $itemsQty,
319
- $comment = null,
320
- $email = false,
321
- $includeComment = false,
322
- $capture = false,
323
- $carrierName,
324
- $title,
325
- $trackingNumbers) {
326
- $invoiceResult = $this->createInvoice($orderIncrementId, $itemsQty, $comment, $email, $includeComment, $capture);
327
- if (is_numeric($invoiceResult) || $invoiceResult == "Invoiced") {
328
- $shipmentResult = $this->createShipment($orderIncrementId, $itemsQty, $carrierName, $title, $trackingNumbers);
329
- return $shipmentResult;
330
- }
331
- return $invoiceResult;
332
- }
333
- }
334
- ?>
 
 
 
 
1
+ <?php
2
+ class productLocationZone
3
+ {
4
+ public $productId = "";
5
+ public $location = "";
6
+ public $zone = "";
7
+ }
8
+ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resource_Abstract
9
+ {
10
+ /**
11
+ * sendShipmentEmail
12
+ *
13
+ * @param string $shipmentIncrementId
14
+ * @return string 1 = sucess, 0 = failure
15
+ */
16
+
17
+ public function sendShipmentEmail( $shipmentIncrementId )
18
+ {
19
+ $return = 1;
20
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: sendShipmentEmail called on Shipment IncrementId $shipmentIncrementId");
21
+ $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);
22
+ if($shipment)
23
+ {
24
+ $shipment->sendEmail(true);
25
+ $shipment->setEmailSent(true);
26
+ $shipment->save();
27
+ }
28
+ else {
29
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: shipment NOT found : ". $shipmentIncrementId);
30
+ $result = 0;
31
+ }
32
+ return $return;
33
+ }
34
+
35
+ /**
36
+ * getClearpathOrderNumber
37
+ *
38
+ * @param string $_orderIncrementId
39
+ * @return string clearpathOrderNumber, boolean false
40
+ */
41
+ public function getClearpathOrderNumber( $_orderIncrementId )
42
+ {
43
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getClearpathOrderNumber called");
44
+
45
+ $_clearpath_tablename = Mage::getStoreConfig('clearpath/general/clearpath_tablename');
46
+ $_db = Mage::getSingleton('core/resource')->getConnection('core_read');
47
+ $_db_query = "SELECT cp_order_number FROM {$_clearpath_tablename} WHERE mage_order_number = '{$_orderIncrementId}'";
48
+ $_db_result = $_db->fetchAll($_db_query);
49
+
50
+ if ($_db_result) {
51
+ return $_db_result[0]['cp_order_number'];
52
+ } else {
53
+ return false;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * getEmbeddedErpFullStockOrders
59
+ *
60
+ * @return string comma delimited list of increment_ids which are fully stocked
61
+ */
62
+ public function getEmbeddedErpFullStockOrders()
63
+ {
64
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getEmbeddedErpFullStockOrders called");
65
+ $result = "";
66
+ $resource = Mage::getSingleton('core/resource');
67
+ $readConnection = $resource->getConnection('core_read');
68
+ $sales_order_table = $resource->getTableName('sales/order');
69
+
70
+ $completeOrders = Mage::getModel('Orderpreparation/ordertoprepare')->getFullStockOrdersFromCache();
71
+ foreach($completeOrders as $completeOrder)
72
+ {
73
+ $completeOrderIds[] = $completeOrder->getopp_order_id();
74
+ }
75
+
76
+ $sql = "SELECT `increment_id` FROM `". $sales_order_table ."` WHERE `entity_id` in ('". implode("', '", $completeOrderIds) ."')";
77
+ $db_result = $readConnection->fetchAll($sql);
78
+ if ($db_result) {
79
+ foreach($db_result as $row){
80
+ $result = $result.$row['increment_id'].",";
81
+ }
82
+ }
83
+
84
+ return $result;
85
+ }
86
+
87
+ /**
88
+ * getEmbeddedErpZonesAndBins
89
+ *
90
+ * @param string $_productIdList comma delimited list of productIds to retrieve zone & bin information
91
+ * @return string pipe delimited set of productId|binLocation|zone for $_productIdList
92
+ */
93
+ public function getEmbeddedErpZonesAndBins($_productIdList)
94
+ {
95
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getEmbeddedErpZonesAndBins called");
96
+
97
+ $productToBin = array();
98
+ $binToZone = array();
99
+ $locationList = "";
100
+ $result = "";
101
+
102
+ $warehouse = Mage::getModel('AdvancedStock/Warehouse')->load(1);
103
+ $productIds = explode(",",$_productIdList);
104
+
105
+ // Map each productId to a bin_num
106
+ foreach($productIds as $productId) {
107
+ $location = $warehouse->getProductLocation($productId);
108
+ $productToBin[$productId] = $location;
109
+ $locationList = $locationList."'".$location."',";
110
+ }
111
+
112
+ $resource = Mage::getSingleton('core/resource');
113
+ $readConnection = $resource->getConnection('core_read');
114
+ // Map each bin_num to a zone
115
+ $sql = "SELECT `bin_num`,`zone` FROM `bin_list` WHERE `bin_num` in (". rtrim($locationList, ',') .");";
116
+ /*Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: getEmbeddedErpZonesAndBins sql : ".$sql);*/
117
+
118
+ $db_result = $readConnection->fetchAll($sql);
119
+ if ($db_result) {
120
+ foreach($db_result as $row){
121
+ if (strlen($row['bin_num']) > 0) {
122
+ $binToZone[strtoupper($row['bin_num'])] = $row['zone'];
123
+ }
124
+ }
125
+ }
126
+ // put the results together
127
+ foreach(array_keys($productToBin) as $productId) {
128
+ $location = $productToBin[$productId];
129
+ $zone = $binToZone[strtoupper($location)];
130
+ $result = $result."|".$productId."|".$location."|".$zone;
131
+ }
132
+ // remove starting pipe
133
+ $result = ltrim($result, '|');
134
+
135
+ return $result;
136
+ }
137
+
138
+ /**
139
+ * Create new invoice for order
140
+ *
141
+ * @param string $invoiceIncrementId
142
+ * @param array $itemsQty
143
+ * @param string $comment
144
+ * @param bool $email
145
+ * @param bool $includeComment
146
+ * @param bool $capture
147
+ * @return string
148
+ */
149
+ public function createInvoice($orderIncrementId,
150
+ $itemsQty,
151
+ $comment = null,
152
+ $email = false,
153
+ $includeComment = false,
154
+ $capture = false)
155
+ {
156
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createInvoice called with id:".$orderIncrementId.",email=".$email.",capture=".$capture.",itemsQty=".var_dump($itemsQty));
157
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
158
+ /**
159
+ * Check order existing
160
+ */
161
+ if (!$order->getId()) {
162
+ return "Invalid order incrementId";
163
+ }
164
+
165
+ if ($order->getBaseTotalDue() == 0) {
166
+ return "Invoiced";
167
+ }
168
+ /**
169
+ * Check invoice create availability
170
+ */
171
+ if (!$order->canInvoice()) {
172
+ return "Cannot do invoice for order.";
173
+ }
174
+
175
+ $invoice = $order->prepareInvoice(); // removing $itemsQty for now
176
+
177
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
178
+
179
+ $invoice->register();
180
+
181
+ if ($capture && $invoice->canCapture()) {
182
+ $invoice->capture();
183
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createInvoice attempted to capture invoice");
184
+ }
185
+
186
+ if ($comment !== null) {
187
+ $invoice->addComment($comment, $email);
188
+ }
189
+
190
+ if ($email) {
191
+ $invoice->setEmailSent(true);
192
+ }
193
+
194
+ $invoice->getOrder()->setIsInProcess(true);
195
+
196
+ $retries = 0;
197
+ do {
198
+ $shouldRetry = false;
199
+ try {
200
+ Mage::getModel('core/resource_transaction')
201
+ ->addObject($invoice)
202
+ ->addObject($invoice->getOrder())
203
+ ->save();
204
+ $invoice->sendEmail($email, ($includeComment ? $comment : ''));
205
+ } catch (Exception $e) {
206
+ $errmsg = $e->getMessage();
207
+ if ($retries < 10 and strpos($errmsg, "try restarting transaction") > -1) {
208
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: retrying due to error $errmsg");
209
+ $shouldRetry = true;
210
+ } else {
211
+ return $errmsg;
212
+ }
213
+ $retries++;
214
+ usleep(50000 * $retries); // wait
215
+ }
216
+ } while ($shouldRetry);
217
+
218
+ return $invoice->getIncrementId();
219
+ }
220
+ /**
221
+ * Create new shipment for order
222
+ *
223
+ * @param string $orderIncrementId
224
+ * @param array $itemsQty
225
+ * @param string $carrierName
226
+ * @param string $title
227
+ * @param string $trackingNumbers
228
+ * @return string
229
+ */
230
+ public function createShipment($orderIncrementId,
231
+ $itemsQty,
232
+ $carrierName,
233
+ $title,
234
+ $trackingNumbers)
235
+ {
236
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createShipment called with id:".$orderIncrementId.",carrierName=".$carrierName.",title=".$title.",itemsQty=".var_dump($itemsQty));
237
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
238
+
239
+ if (!$order->getId()) {
240
+ return "Invalid order incrementId $orderIncrementId";
241
+ }
242
+
243
+ $shipment = null;
244
+
245
+ if ($order->hasShipments()) {
246
+ $shipment = $order->getShipmentsCollection()->getFirstItem();
247
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: $orderIncrementId has Shipments");
248
+ }
249
+ else {
250
+ /**
251
+ * Check shipment create availability
252
+ */
253
+ if (!$order->canShip()) {
254
+ return "Cannot do shipment for order.";
255
+ }
256
+
257
+ $shipment = $order->prepareShipment();
258
+ if ($shipment) {
259
+ $shipment->register();
260
+ //$shipment->addComment($comment, $email && $includeComment);
261
+ $shipment->getOrder()->setIsInProcess(true);
262
+ $retries = 0;
263
+ do {
264
+ $shouldRetry = false;
265
+ try {
266
+ $transactionSave = Mage::getModel('core/resource_transaction')
267
+ ->addObject($shipment)
268
+ ->addObject($shipment->getOrder())
269
+ ->save();
270
+ } catch (Exception $e) {
271
+ $errmsg = $e->getMessage();
272
+ if ($retries < 10 and strpos($errmsg, "try restarting transaction") > -1) {
273
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: retrying due to error $errmsg");
274
+ $shouldRetry = true;
275
+ } else {
276
+ return $errmsg;
277
+ }
278
+ $retries++;
279
+ usleep(50000 * $retries); // wait
280
+ }
281
+ } while ($shouldRetry);
282
+ }
283
+ else {
284
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: shipment not valid $orderIncrementId");
285
+ }
286
+ }
287
+
288
+ if (!$shipment) {
289
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: shipment not valid $orderIncrementId");
290
+ return "Unable to find or create a shipment.";
291
+ }
292
+
293
+ $trackingNumbersOnShipment = array();
294
+ foreach($shipment->getAllTracks() as $trackingNumberOnShipment) {
295
+ $trackingNumbersOnShipment[]=$trackingNumberOnShipment->getNumber();
296
+ }
297
+ $numbersToUpdate = array_diff($trackingNumbers, $trackingNumbersOnShipment);
298
+ foreach($numbersToUpdate as $trackingNumberToUpdate)
299
+ {
300
+ $trackId = Mage::getModel('sales/order_shipment_api')->addTrack($shipment->increment_id, $carrierName, $title, $trackingNumberToUpdate);
301
+ }
302
+
303
+ $order->save();
304
+
305
+ return $shipment->increment_id;
306
+ }
307
+ /**
308
+ * Create new invoice for order
309
+ *
310
+ * @param string $orderIncrementId
311
+ * @param array $itemsQty
312
+ * @param string $comment
313
+ * @param bool $email
314
+ * @param bool $includeComment
315
+ * @param bool $capture
316
+ * @param string $carrierName
317
+ * @param string $title
318
+ * @param string $trackingNumbers
319
+ * @return string
320
+ */
321
+ public function createInvoiceAndShipment($orderIncrementId,
322
+ $itemsQty,
323
+ $comment = null,
324
+ $email = false,
325
+ $includeComment = false,
326
+ $capture = false,
327
+ $carrierName,
328
+ $title,
329
+ $trackingNumbers) {
330
+ $invoiceResult = $this->createInvoice($orderIncrementId, $itemsQty, $comment, $email, $includeComment, $capture);
331
+ if (is_numeric($invoiceResult) || $invoiceResult == "Invoiced") {
332
+ $shipmentResult = $this->createShipment($orderIncrementId, $itemsQty, $carrierName, $title, $trackingNumbers);
333
+ return $shipmentResult;
334
+ }
335
+ return $invoiceResult;
336
+ }
337
+ }
338
+ ?>
app/code/local/Shipjunction/Utilities/Model/Objectmodel/Api/v2.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ //class Shipjunction_Utilites_Model_Objectmodel_Api_V2 extends Shipjunction_Utilites_Model_Objectmodel_Api
3
+ class Shipjunction_Utilities_Model_Objectmodel_Api_V2 extends Shipjunction_Utilities_Model_Objectmodel_Api
4
+ {
5
+ }
6
+ ?>
app/code/local/Shipjunction/Utilities/etc/config.xml CHANGED
@@ -2,14 +2,16 @@
2
  <config>
3
  <modules>
4
  <Shipjunction_Utilities>
5
- <version>1.0.2</version>
6
  </Shipjunction_Utilities>
7
  </modules>
8
  <global>
9
  <models>
10
  <shipjunction_utilities>
 
11
  <class>Shipjunction_Utilities_Model</class>
12
  </shipjunction_utilities>
 
13
  </models>
14
  </global>
15
  <default>
2
  <config>
3
  <modules>
4
  <Shipjunction_Utilities>
5
+ <version>0.1.0</version>
6
  </Shipjunction_Utilities>
7
  </modules>
8
  <global>
9
  <models>
10
  <shipjunction_utilities>
11
+ <!-- <modulename>-->
12
  <class>Shipjunction_Utilities_Model</class>
13
  </shipjunction_utilities>
14
+ <!-- </modulename>-->
15
  </models>
16
  </global>
17
  <default>
app/etc/modules/Shipjunction_Utilities.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Shipjunction_Utilities>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- </Shipjunction_Utilities>
8
- </modules>
9
- </config>
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shipjunction_Util</name>
4
- <version>1.1.1</version>
5
  <stability>stable</stability>
6
  <license>Massachusetts Institute of Technology License (MITL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Shipjunction Utilities enables tight integration between the Magento and Shipjunction platforms</summary>
10
- <description>ShipJunction is a multi-carrier shipping platform that helps reduce carrier expenses and improve warehouse efficiency.</description>
 
11
  <notes>For more information contact us at info@shipjunction.com</notes>
12
  <authors><author><name>ShipJunction</name><user>shipjunction</user><email>dev@shipjunction.com</email></author></authors>
13
- <date>2014-12-10</date>
14
- <time>02:19:18</time>
15
- <contents><target name="magelocal"><dir name="Shipjunction"><dir name="Utilities"><dir name="Model"><dir name="Objectmodel"><dir name="Api"><file name="V2.php" hash="c72849bd552b06b397854eb0327cab1a"/></dir><file name="Api.php" hash="bf49cf010489f2801d65184af742627f"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8bd8b8559228898482f0350c88abbf2c"/><file name="api.xml" hash="e06219c93f542e947a5aef6216962ad1"/><file name="config.xml" hash="7a9465f4a3f25c3e9363d716fdac622a"/><file name="system.xml" hash="9a1e37f245ae223621bdaede1ac2e329"/><file name="wsdl.xml" hash="a030c34a59a1c5e25502f0b947b168b8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shipjunction_Utilities.xml" hash="0252203c4538e847e3a753c5fdb9a1f3"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shipjunction_Util</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license>Massachusetts Institute of Technology License (MITL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Shipjunction Utilities enables tight integration between the Magento and Shipjunction platforms</summary>
10
+ <description>ShipJunction is a multi-carrier shipping platform that provides unparalleled efficiency and optimization in the management of backend fulfillment processes and carrier expenses.&#xD;
11
+ </description>
12
  <notes>For more information contact us at info@shipjunction.com</notes>
13
  <authors><author><name>ShipJunction</name><user>shipjunction</user><email>dev@shipjunction.com</email></author></authors>
14
+ <date>2015-12-14</date>
15
+ <time>13:01:13</time>
16
+ <contents><target name="magelocal"><dir name="Shipjunction"><dir name="Utilities"><dir name="Model"><dir name="Objectmodel"><dir name="Api"><file name="V2.php" hash="c72849bd552b06b397854eb0327cab1a"/><file name="v2.php" hash="c72849bd552b06b397854eb0327cab1a"/></dir><file name="Api.php" hash="e2e69bdd87250aaada81c6a82dc354bd"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8bd8b8559228898482f0350c88abbf2c"/><file name="api.xml" hash="e06219c93f542e947a5aef6216962ad1"/><file name="config.xml" hash="61dbf18db5f93e7c2f0d233db70d0cfa"/><file name="system.xml" hash="9a1e37f245ae223621bdaede1ac2e329"/><file name="wsdl.xml" hash="a030c34a59a1c5e25502f0b947b168b8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shipjunction_Utilities" hash=""/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>