Shipjunction_Util - Version 0.2.0

Version Notes

For more information contact us at info@shipjunction.com

Download this release

Release Info

Developer ShipJunction
Extension Shipjunction_Util
Version 0.2.0
Comparing to
See all releases


Code changes from version 0.1.0 to 0.2.0

app/code/local/Shipjunction/Utilities/Model/Objectmodel/.Api.php.swo ADDED
Binary file
app/code/local/Shipjunction/Utilities/Model/Objectmodel/.Api.php.swp ADDED
Binary file
app/code/local/Shipjunction/Utilities/Model/Objectmodel/Api.php CHANGED
@@ -32,26 +32,26 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
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
  /**
@@ -113,19 +113,20 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
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
 
117
  $db_result = $readConnection->fetchAll($sql);
118
  if ($db_result) {
119
  foreach($db_result as $row){
120
  if (strlen($row['bin_num']) > 0) {
121
- $binToZone[$row['bin_num']] = $row['zone'];
122
  }
123
  }
124
  }
125
  // put the results together
126
  foreach(array_keys($productToBin) as $productId) {
127
  $location = $productToBin[$productId];
128
- $zone = $binToZone[$location];
129
  $result = $result."|".$productId."|".$location."|".$zone;
130
  }
131
  // remove starting pipe
@@ -154,8 +155,6 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
154
  {
155
  Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createInvoice called with id:".$orderIncrementId.",email=".$email.",capture=".$capture.",itemsQty=".var_dump($itemsQty));
156
  $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
157
- //$itemsQty = $this->_prepareItemQtyData($itemsQty);
158
- /* @var $order Mage_Sales_Model_Order */
159
  /**
160
  * Check order existing
161
  */
@@ -163,6 +162,9 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
163
  return "Invalid order incrementId";
164
  }
165
 
 
 
 
166
  /**
167
  * Check invoice create availability
168
  */
@@ -202,6 +204,106 @@ class Shipjunction_Utilities_Model_Objectmodel_Api extends Mage_Api_Model_Resour
202
  }
203
 
204
  return $invoice->getIncrementId();
205
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
  ?>
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
  /**
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
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
  */
162
  return "Invalid order incrementId";
163
  }
164
 
165
+ if ($order->getBaseTotalDue() == 0) {
166
+ return "Invoiced";
167
+ }
168
  /**
169
  * Check invoice create availability
170
  */
204
  }
205
 
206
  return $invoice->getIncrementId();
207
+ }
208
+ /**
209
+ * Create new shipment for order
210
+ *
211
+ * @param string $orderIncrementId
212
+ * @param array $itemsQty
213
+ * @param string $carrierName
214
+ * @param string $title
215
+ * @param string $trackingNumbers
216
+ * @return string
217
+ */
218
+ public function createShipment($orderIncrementId,
219
+ $itemsQty,
220
+ $carrierName,
221
+ $title,
222
+ $trackingNumbers)
223
+ {
224
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: createShipment called with id:".$orderIncrementId.",carrierName=".$carrierName.",title=".$title.",itemsQty=".var_dump($itemsQty));
225
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
226
+
227
+ if (!$order->getId()) {
228
+ return "Invalid order incrementId";
229
+ }
230
+
231
+ $shipment = null;
232
+
233
+ if ($order->hasShipments()) {
234
+ $shipment = $order->getShipmentsCollection()->getFirstItem();
235
+ Mage::log("Shipjunction_Utilites_Model_Objectmodel_Api: has Shipments");
236
+ }
237
+ else {
238
+ /**
239
+ * Check shipment create availability
240
+ */
241
+ if (!$order->canShip()) {
242
+ return "Cannot do shipment for order.";
243
+ }
244
+
245
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
246
+ $shipment = $order->prepareShipment($itemsQty);
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
+
262
+ if (!$shipment) {
263
+ return "Unable to find or create a shipment.";
264
+ }
265
+
266
+ $trackingNumbersOnShipment = array();
267
+ foreach($shipment->getAllTracks() as $trackingNumberOnShipment) {
268
+ $trackingNumbersOnShipment[]=$trackingNumberOnShipment->getNumber();
269
+ }
270
+ $numbersToUpdate = array_diff($trackingNumbers, $trackingNumbersOnShipment);
271
+ foreach($numbersToUpdate as $trackingNumberToUpdate)
272
+ {
273
+ $trackId = Mage::getModel('sales/order_shipment_api')->addTrack($shipment->increment_id, $carrierName, $title, $trackingNumberToUpdate);
274
+ }
275
+
276
+ return $shipment->increment_id;
277
+ }
278
+ /**
279
+ * Create new invoice for order
280
+ *
281
+ * @param string $orderIncrementId
282
+ * @param array $itemsQty
283
+ * @param string $comment
284
+ * @param bool $email
285
+ * @param bool $includeComment
286
+ * @param bool $capture
287
+ * @param string $carrierName
288
+ * @param string $title
289
+ * @param string $trackingNumbers
290
+ * @return string
291
+ */
292
+ public function createInvoiceAndShipment($orderIncrementId,
293
+ $itemsQty,
294
+ $comment = null,
295
+ $email = false,
296
+ $includeComment = false,
297
+ $capture = false,
298
+ $carrierName,
299
+ $title,
300
+ $trackingNumbers) {
301
+ $invoiceResult = $this->createInvoice($orderIncrementId, $itemsQty, $comment, $email, $includeComment, $capture);
302
+ if (is_numeric($invoiceResult) || $invoiceResult == "Invoiced") {
303
+ $shipmentResult = $this->createShipment($orderIncrementId, $itemsQty, $carrierName, $title, $trackingNumbers);
304
+ return $shipmentResult;
305
+ }
306
+ return $invoiceResult;
307
+ }
308
  }
309
  ?>
app/code/local/Shipjunction/Utilities/etc/api.xml CHANGED
@@ -26,6 +26,14 @@
26
  <title>Create Invoice</title>
27
  <method>createInvoice</method>
28
  </createInvoice>
 
 
 
 
 
 
 
 
29
  </methods>
30
  </shipjunction_utilities>
31
  </resources>
26
  <title>Create Invoice</title>
27
  <method>createInvoice</method>
28
  </createInvoice>
29
+ <createShipment translate="title" module="shipjunction_utilities">
30
+ <title>Create Shipment</title>
31
+ <method>createShipment</method>
32
+ </createShipment>
33
+ <createInvoiceAndShipment translate="title" module="shipjunction_utilities">
34
+ <title>Create Invoice and Shipment</title>
35
+ <method>createInvoiceAndShipment</method>
36
+ </createInvoiceAndShipment>
37
  </methods>
38
  </shipjunction_utilities>
39
  </resources>
app/code/local/Shipjunction/Utilities/etc/wsdl.xml CHANGED
@@ -66,9 +66,35 @@
66
  <part name="email" type="xsd:string"></part>
67
  <part name="includeComment" type="xsd:string"></part>
68
  <part name="capture" type="xsd:string"></part>
69
- </message>
70
  <message name="shipjunctionUtilitiesCreateInvoiceResponse">
71
  <part name="invoiceIncrementId" type="xsd:string"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  </message>
73
  <portType name="{{var wsdl.handler}}PortType">
74
  <operation name="shipjunctionUtilitiesSendShipmentEmail">
@@ -96,6 +122,16 @@
96
  <input message="typens:shipjunctionUtilitiesCreateInvoiceRequest"></input>
97
  <output message="typens:shipjunctionUtilitiesCreateInvoiceResponse"></output>
98
  </operation>
 
 
 
 
 
 
 
 
 
 
99
  </portType>
100
  <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
101
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
@@ -144,6 +180,24 @@
144
  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:{{var wsdl.name}}" use="encoded"/>
145
  </output>
146
  </operation>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  </binding>
148
  <service name="{{var wsdl.name}}Service">
149
  <port binding="typens:{{var wsdl.handler}}Binding" name="{{var wsdl.handler}}Port">
66
  <part name="email" type="xsd:string"></part>
67
  <part name="includeComment" type="xsd:string"></part>
68
  <part name="capture" type="xsd:string"></part>
69
+ </message>
70
  <message name="shipjunctionUtilitiesCreateInvoiceResponse">
71
  <part name="invoiceIncrementId" type="xsd:string"/>
72
+ </message>
73
+ <message name="shipjunctionUtilitiesCreateShipmentRequest">
74
+ <part name="sessionId" type="xsd:string"></part>
75
+ <part name="orderIncrementId" type="xsd:string"></part>
76
+ <part name="itemsQty" type="typens:orderItemIdQtyArray"></part>
77
+ <part name="carrierName" type="xsd:string"></part>
78
+ <part name="title" type="xsd:string"></part>
79
+ <part name="trackingNumbers" type="typens:ArrayOfString"></part>
80
+ </message>
81
+ <message name="shipjunctionUtilitiesCreateShipmentResponse">
82
+ <part name="shipmentIncrementId" type="xsd:string"/>
83
+ </message>
84
+ <message name="shipjunctionUtilitiesCreateInvoiceAndShipmentRequest">
85
+ <part name="sessionId" type="xsd:string"></part>
86
+ <part name="orderIncrementId" type="xsd:string"></part>
87
+ <part name="itemsQty" type="typens:orderItemIdQtyArray"></part>
88
+ <part name="comment" type="xsd:string"></part>
89
+ <part name="email" type="xsd:string"></part>
90
+ <part name="includeComment" type="xsd:string"></part>
91
+ <part name="capture" type="xsd:string"></part>
92
+ <part name="carrierName" type="xsd:string"></part>
93
+ <part name="title" type="xsd:string"></part>
94
+ <part name="trackingNumbers" type="typens:ArrayOfString"></part>
95
+ </message>
96
+ <message name="shipjunctionUtilitiesCreateInvoiceAndShipmentResponse">
97
+ <part name="shipmentIncrementId" type="xsd:string"/>
98
  </message>
99
  <portType name="{{var wsdl.handler}}PortType">
100
  <operation name="shipjunctionUtilitiesSendShipmentEmail">
122
  <input message="typens:shipjunctionUtilitiesCreateInvoiceRequest"></input>
123
  <output message="typens:shipjunctionUtilitiesCreateInvoiceResponse"></output>
124
  </operation>
125
+ <operation name="shipjunctionUtilitiesCreateShipment">
126
+ <documentation>Create or update Shipment for order</documentation>
127
+ <input message="typens:shipjunctionUtilitiesCreateShipmentRequest"></input>
128
+ <output message="typens:shipjunctionUtilitiesCreateShipmentResponse"></output>
129
+ </operation>
130
+ <operation name="shipjunctionUtilitiesCreateInvoiceAndShipment">
131
+ <documentation>Create new Invoice and create new or update Shipment for order</documentation>
132
+ <input message="typens:shipjunctionUtilitiesCreateInvoiceAndShipmentRequest"></input>
133
+ <output message="typens:shipjunctionUtilitiesCreateInvoiceAndShipmentResponse"></output>
134
+ </operation>
135
  </portType>
136
  <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
137
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
180
  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:{{var wsdl.name}}" use="encoded"/>
181
  </output>
182
  </operation>
183
+ <operation name="shipjunctionUtilitiesCreateShipment">
184
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action"/>
185
+ <input>
186
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:{{var wsdl.name}}" use="encoded"/>
187
+ </input>
188
+ <output>
189
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:{{var wsdl.name}}" use="encoded"/>
190
+ </output>
191
+ </operation>
192
+ <operation name="shipjunctionUtilitiesCreateInvoiceAndShipment">
193
+ <soap:operation soapAction="urn:{{var wsdl.handler}}Action"/>
194
+ <input>
195
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:{{var wsdl.name}}" use="encoded"/>
196
+ </input>
197
+ <output>
198
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:{{var wsdl.name}}" use="encoded"/>
199
+ </output>
200
+ </operation>
201
  </binding>
202
  <service name="{{var wsdl.name}}Service">
203
  <port binding="typens:{{var wsdl.handler}}Binding" name="{{var wsdl.handler}}Port">
package.xml CHANGED
@@ -1,21 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shipjunction_Util</name>
4
- <version>0.1.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
- &#xD;
12
  Supported Releases 1.5.0.0 &amp; later&#xD;
13
  </description>
14
  <notes>For more information contact us at info@shipjunction.com</notes>
15
  <authors><author><name> ShipJunction</name><user>shipjunction</user><email>dev@shipjunction.com</email></author></authors>
16
- <date>2014-02-14</date>
17
- <time>00:01:11</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="70f1f62424a3f8b489e5a8f223d5e60c"/><file name="test.php" hash="3540a784ed1d7718ac71de641a5ebed6"/><file name="test_ordinc_id.php" hash="f57e53a52e00a157413aaa9ecf575462"/><file name="xmlreturned.xml" hash="e59322fac4773ec2b62db3b88a792676"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8bd8b8559228898482f0350c88abbf2c"/><file name="api.xml" hash="0b54268c9e7a49ad5b2a980facf67ea8"/><file name="config.xml" hash="61dbf18db5f93e7c2f0d233db70d0cfa"/><file name="system.xml" hash="9a1e37f245ae223621bdaede1ac2e329"/><file name="wsdl.xml" hash="3e61b422ba97b24b96172f1265bef8e1"/></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>0.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 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>For more information contact us at info@shipjunction.com</notes>
15
  <authors><author><name> ShipJunction</name><user>shipjunction</user><email>dev@shipjunction.com</email></author></authors>
16
+ <date>2014-04-02</date>
17
+ <time>05:23:45</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="570ea43ff729f1fd517db74c8abfb10e"/><file name="test.php" hash="3540a784ed1d7718ac71de641a5ebed6"/><file name="test_ordinc_id.php" hash="f57e53a52e00a157413aaa9ecf575462"/><file name="xmlreturned.xml" hash="e59322fac4773ec2b62db3b88a792676"/><file name=".Api.php.swo" hash="f982acba7d2d66453c371db447b1d1de"/><file name=".Api.php.swp" hash="a5b46996819b40c7aafae0363380cf43"/></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>