Shipjunction_Util - Version 1.0.0

Version Notes

For more information contact us at info@shipjunction.com

Download this release

Release Info

Developer ShipJunction
Extension Shipjunction_Util
Version 1.0.0
Comparing to
See all releases


Code changes from version 0.3.0 to 1.0.0

app/code/local/Shipjunction/Utilities/Model/Objectmodel/Api.php CHANGED
@@ -193,15 +193,27 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
193
 
194
  $invoice->getOrder()->setIsInProcess(true);
195
 
196
- try {
197
- Mage::getModel('core/resource_transaction')
198
- ->addObject($invoice)
199
- ->addObject($invoice->getOrder())
200
- ->save();
201
- $invoice->sendEmail($email, ($includeComment ? $comment : ''));
202
- } catch (Mage_Core_Exception $e) {
203
- return "Data invalid : ".$e->getMessage();
204
- }
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
  return $invoice->getIncrementId();
207
  }
@@ -242,20 +254,31 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
242
  return "Cannot do shipment for order.";
243
  }
244
 
245
- /* @var $shipment Mage_Sales_Model_Order_Shipment */
246
- $shipment = $order->prepareShipment(); // removing $itemsQty for now
247
  if ($shipment) {
248
  $shipment->register();
249
  //$shipment->addComment($comment, $email && $includeComment);
250
  $shipment->getOrder()->setIsInProcess(true);
251
- try {
252
- $transactionSave = Mage::getModel('core/resource_transaction')
253
- ->addObject($shipment)
254
- ->addObject($shipment->getOrder())
255
- ->save();
256
- } catch (Mage_Core_Exception $e) {
257
- return $e->getMessage();
258
- }
 
 
 
 
 
 
 
 
 
 
 
 
259
  }
260
  }
261
 
@@ -273,6 +296,8 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
273
  $trackId = Mage::getModel('sales/order_shipment_api')->addTrack($shipment->increment_id, $carrierName, $title, $trackingNumberToUpdate);
274
  }
275
 
 
 
276
  return $shipment->increment_id;
277
  }
278
  /**
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
  }
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
 
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
  /**
package.xml CHANGED
@@ -1,21 +1,23 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shipjunction_Util</name>
4
- <version>0.3.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 helps reduce carrier expenses and improve warehouse efficiency.&#xD;
 
11
  ShipJunction is a multi-carrier shipping platform that provides unparalleled efficiency and optimization in the management of backend fulfillment processes and carrier expenses.&#xD;
 
12
  Supported Releases 1.5.0.0 &amp; later&#xD;
13
  </description>
14
- <notes>Bug fixes - tracking update</notes>
15
- <authors><author><name> ShipJunction</name><user>shipjunction</user><email>dev@shipjunction.com</email></author></authors>
16
- <date>2014-04-07</date>
17
- <time>16:58:05</time>
18
- <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="7ec411e6f771c70a5370a39e4766fb9b"/></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></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shipjunction_Util</name>
4
+ <version>1.0.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 helps reduce carrier expenses and improve warehouse efficiency.&#xD;
11
+ &#xD;
12
  ShipJunction is a multi-carrier shipping platform that provides unparalleled efficiency and optimization in the management of backend fulfillment processes and carrier expenses.&#xD;
13
+ &#xD;
14
  Supported Releases 1.5.0.0 &amp; later&#xD;
15
  </description>
16
+ <notes>For more information contact us at info@shipjunction.com</notes>
17
+ <authors><author><name>ShipJunction</name><user>shipjunction</user><email>dev@shipjunction.com</email></author></authors>
18
+ <date>2014-07-31</date>
19
+ <time>16:51:13</time>
20
+ <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="61dbf18db5f93e7c2f0d233db70d0cfa"/><file name="system.xml" hash="9a1e37f245ae223621bdaede1ac2e329"/><file name="wsdl.xml" hash="a030c34a59a1c5e25502f0b947b168b8"/></dir></dir></dir></target></contents>
21
  <compatible/>
22
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
23
  </package>