Version Notes
Bug Fix:
- Multiple volumes
Features:
- Tracking
Download this release
Release Info
Developer | Frenet |
Extension | LithiumSoftware_Akhilleus |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
app/code/community/LithiumSoftware/Akhilleus/Model/Carrier/Akhilleus.php
CHANGED
@@ -27,6 +27,7 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
27 |
protected $_title = NULL; // Título do método de envio
|
28 |
protected $_from = NULL; // CEP de origem
|
29 |
protected $_to = NULL; // CEP de destino
|
|
|
30 |
protected $_packageWeight = NULL; // valor ajustado do pacote
|
31 |
protected $_showDelivery = NULL; // Determina exibição de prazo de entrega
|
32 |
protected $_addDeliveryDays = NULL; // Adiciona n dias ao prazo de entrega
|
@@ -45,6 +46,7 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
45 |
|
46 |
return $this->_result;
|
47 |
}
|
|
|
48 |
/**
|
49 |
* Get shipping quote
|
50 |
*
|
@@ -53,19 +55,19 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
53 |
protected function _getQuotes(Mage_Shipping_Model_Rate_Request $request)
|
54 |
{
|
55 |
// Call Webservices
|
56 |
-
$wsReturn = $this->
|
57 |
|
58 |
if ($wsReturn !== false) {
|
59 |
|
60 |
-
$this->_log("Qtd serviços: " . count($wsReturn->
|
61 |
|
62 |
// Check if exist return from Webservices
|
63 |
$existReturn = false;
|
64 |
|
65 |
-
if(count($wsReturn->
|
66 |
-
$servicosArray[0] = $wsReturn->
|
67 |
else
|
68 |
-
$servicosArray = $wsReturn->
|
69 |
|
70 |
foreach($servicosArray as $servicos){
|
71 |
|
@@ -73,7 +75,7 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
73 |
|
74 |
$this->_log("Percorrendo os serviços retornados");
|
75 |
|
76 |
-
if ($servicos->ServiceCode . '' == '') {
|
77 |
continue;
|
78 |
}
|
79 |
|
@@ -82,6 +84,7 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
82 |
$shipping_method = $servicos->ServiceCode;
|
83 |
$shipping_method_name = $servicos->ServiceDescription;
|
84 |
|
|
|
85 |
|
86 |
// Append shipping methods
|
87 |
$this->_appendShippingMethod($shipping_method, $shippingPrice, $delivery, $shipping_method_name, $request);
|
@@ -108,13 +111,12 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
108 |
*
|
109 |
* @return bool|SimpleXMLElement[]
|
110 |
*/
|
111 |
-
protected function
|
112 |
{
|
113 |
$url = $this->getConfigData('url_ws');
|
|
|
114 |
|
115 |
try {
|
116 |
-
|
117 |
-
$client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
|
118 |
if ($this->getConfigFlag('use_default'))
|
119 |
{
|
120 |
$this->_length = $this->getConfigData('default_length'); //16
|
@@ -135,39 +137,85 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
135 |
$this->_length = $item->getProduct()->getData('volume_comprimento');
|
136 |
|
137 |
if($item->getProduct()->getData('volume_largura') > $this->_width)
|
138 |
-
|
139 |
|
140 |
if($item->getProduct()->getData('volume_altura') > $this->_height)
|
141 |
$this->_height = $item->getProduct()->getData('volume_altura');
|
142 |
|
143 |
$this->_diameter = 0;
|
144 |
}
|
145 |
-
|
146 |
}
|
147 |
|
148 |
-
|
149 |
-
$
|
150 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
$service_param = array (
|
153 |
-
'
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
'shipmentDiameter' => $this->_diameter
|
163 |
);
|
164 |
|
165 |
-
$
|
166 |
-
'Origem: ' .$this->_from . 'Destino: ' .$this->_to . 'Peso: ' . $this->_weight . 'ValorDeclarado: ' . $this->_value .
|
167 |
-
'Tamanho: ' .$this->_length . 'Altura: ' . $this->_height . 'Largura: ' . $this->_width . 'Diametro: ' . $this->_diameter);
|
168 |
-
|
169 |
-
$content = $client->__soapCall("Rate", array($service_param));
|
170 |
|
|
|
|
|
171 |
|
172 |
if ($content == "") {
|
173 |
throw new Exception("No XML returned [" . __LINE__ . "]");
|
@@ -177,7 +225,7 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
177 |
|
178 |
} catch (Exception $e) {
|
179 |
//URL Error
|
180 |
-
$this->_throwError('urlerror', 'URL Error - ' . $e->getMessage(), __LINE__);
|
181 |
return false;
|
182 |
};
|
183 |
}
|
@@ -226,7 +274,7 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
226 |
|
227 |
$this->_log('Leadtime: ' . $cartLeadTime);
|
228 |
|
229 |
-
if ($this->_showDelivery && $delivery > 0){
|
230 |
$this->_log('Delivery: ' . $delivery);
|
231 |
$this->_log('Show Delivery: ' . $this->_showDelivery);
|
232 |
|
@@ -248,7 +296,6 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
248 |
return false;
|
249 |
}
|
250 |
|
251 |
-
//if (!$this->_checkCountry($request)) return false;
|
252 |
if (!$this->_checkZipCode($request)) return false;
|
253 |
|
254 |
$this->_title = $this->getConfigData('title');
|
@@ -262,6 +309,9 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
262 |
$this->_updatePackageWeight($request);
|
263 |
|
264 |
$this->_weight = $this->_fixWeight($request->getPackageWeight());
|
|
|
|
|
|
|
265 |
}
|
266 |
|
267 |
protected function _updatePackageWeight(Mage_Shipping_Model_Rate_Request $request)
|
@@ -416,4 +466,143 @@ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
|
|
416 |
{
|
417 |
return array($this->_code => $this->getConfigData('name'));
|
418 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
}
|
27 |
protected $_title = NULL; // Título do método de envio
|
28 |
protected $_from = NULL; // CEP de origem
|
29 |
protected $_to = NULL; // CEP de destino
|
30 |
+
protected $_recipientDocument = NULL; // CPF / CNPJ do destinatario
|
31 |
protected $_packageWeight = NULL; // valor ajustado do pacote
|
32 |
protected $_showDelivery = NULL; // Determina exibição de prazo de entrega
|
33 |
protected $_addDeliveryDays = NULL; // Adiciona n dias ao prazo de entrega
|
46 |
|
47 |
return $this->_result;
|
48 |
}
|
49 |
+
|
50 |
/**
|
51 |
* Get shipping quote
|
52 |
*
|
55 |
protected function _getQuotes(Mage_Shipping_Model_Rate_Request $request)
|
56 |
{
|
57 |
// Call Webservices
|
58 |
+
$wsReturn = $this->_getWebServicesQuoteReturn($request);
|
59 |
|
60 |
if ($wsReturn !== false) {
|
61 |
|
62 |
+
$this->_log("Qtd serviços: " . count($wsReturn->GetShippingQuoteResult->ShippingSevicesArray->ShippingSevices));
|
63 |
|
64 |
// Check if exist return from Webservices
|
65 |
$existReturn = false;
|
66 |
|
67 |
+
if(count($wsReturn->GetShippingQuoteResult->ShippingSevicesArray->ShippingSevices)==1)
|
68 |
+
$servicosArray[0] = $wsReturn->GetShippingQuoteResult->ShippingSevicesArray->ShippingSevices;
|
69 |
else
|
70 |
+
$servicosArray = $wsReturn->GetShippingQuoteResult->ShippingSevicesArray->ShippingSevices;
|
71 |
|
72 |
foreach($servicosArray as $servicos){
|
73 |
|
75 |
|
76 |
$this->_log("Percorrendo os serviços retornados");
|
77 |
|
78 |
+
if (!isset($servicos->ServiceCode) || $servicos->ServiceCode . '' == '' || !isset($servicos->ShippingPrice)) {
|
79 |
continue;
|
80 |
}
|
81 |
|
84 |
$shipping_method = $servicos->ServiceCode;
|
85 |
$shipping_method_name = $servicos->ServiceDescription;
|
86 |
|
87 |
+
$this->_log("Preço " . $shippingPrice);
|
88 |
|
89 |
// Append shipping methods
|
90 |
$this->_appendShippingMethod($shipping_method, $shippingPrice, $delivery, $shipping_method_name, $request);
|
111 |
*
|
112 |
* @return bool|SimpleXMLElement[]
|
113 |
*/
|
114 |
+
protected function _getWebServicesQuoteReturn(Mage_Shipping_Model_Rate_Request $request)
|
115 |
{
|
116 |
$url = $this->getConfigData('url_ws');
|
117 |
+
$client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
|
118 |
|
119 |
try {
|
|
|
|
|
120 |
if ($this->getConfigFlag('use_default'))
|
121 |
{
|
122 |
$this->_length = $this->getConfigData('default_length'); //16
|
137 |
$this->_length = $item->getProduct()->getData('volume_comprimento');
|
138 |
|
139 |
if($item->getProduct()->getData('volume_largura') > $this->_width)
|
140 |
+
$this->_width = $item->getProduct()->getData('volume_largura');
|
141 |
|
142 |
if($item->getProduct()->getData('volume_altura') > $this->_height)
|
143 |
$this->_height = $item->getProduct()->getData('volume_altura');
|
144 |
|
145 |
$this->_diameter = 0;
|
146 |
}
|
|
|
147 |
}
|
148 |
|
149 |
+
// gerar o array de produtos
|
150 |
+
$shippingItemArray = array();
|
151 |
+
$count = 0;
|
152 |
+
foreach($request->getAllItems() as $item){
|
153 |
+
$product_id = $item->getProductId();
|
154 |
+
$productObj = Mage::getModel('catalog/product')->load($product_id);
|
155 |
+
|
156 |
+
$shippingItem = new stdClass();
|
157 |
+
$shippingItem->Weight = $productObj->getWeight() * $item->getQty();
|
158 |
+
if ($this->getConfigFlag('use_default'))
|
159 |
+
{
|
160 |
+
$shippingItem->Length = $this->getConfigData('default_length'); //16
|
161 |
+
$shippingItem->Width = $this->getConfigData('default_width'); //11
|
162 |
+
$shippingItem->Height = $this->getConfigData('default_height'); //2
|
163 |
+
}
|
164 |
+
else{
|
165 |
+
$shippingItem->Length = ($productObj->getVolume_comprimento() > 0 ? $productObj->getVolume_comprimento() : $this->getConfigData('default_length') );
|
166 |
+
$shippingItem->Height = ($productObj->getVolume_altura() > 0 ? $productObj->getVolume_altura() : $this->getConfigData('default_height'));
|
167 |
+
$shippingItem->Width = ($productObj->getVolume_largura()>0 ? $productObj->getVolume_largura() : $this->getConfigData('default_width'));
|
168 |
+
}
|
169 |
+
$shippingItem->Diameter = 0;
|
170 |
+
$shippingItem->SKU = $productObj->getSku();
|
171 |
+
|
172 |
+
$categoryIds = $productObj->getCategoryIds();
|
173 |
+
$result = '';
|
174 |
+
|
175 |
+
foreach ($categoryIds as $catId) {
|
176 |
+
$category = Mage::getModel('catalog/category')->load($catId);
|
177 |
+
|
178 |
+
if($category)
|
179 |
+
{
|
180 |
+
$coll = $category->getResourceCollection();
|
181 |
+
$pathIds = $category->getPathIds();
|
182 |
+
$coll->addAttributeToSelect('name');
|
183 |
+
$coll->addAttributeToFilter('entity_id', array('in' => $pathIds));
|
184 |
+
|
185 |
+
foreach ($coll as $cat) {
|
186 |
+
if(strpos($result, $cat->getName())=== false)
|
187 |
+
$result .= $cat->getName().'|';
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
$shippingItem->Category = $result;
|
193 |
+
|
194 |
+
if($item->getProduct()->getData('fragile'))
|
195 |
+
$shippingItem->isFragile = $item->getProduct()->getData('fragile');
|
196 |
+
else
|
197 |
+
$shippingItem->isFragile=false;
|
198 |
+
|
199 |
+
$shippingItemArray[$count] = $shippingItem;
|
200 |
+
$count++;
|
201 |
+
}
|
202 |
|
203 |
$service_param = array (
|
204 |
+
'quoteRequest' => array(
|
205 |
+
'Username' => $this->getConfigData('login'),
|
206 |
+
'Password' => $this->getConfigData('password'),
|
207 |
+
'SellerCEP' => $this->_from,
|
208 |
+
'RecipientCEP' => $this->_to,
|
209 |
+
'RecipientDocument' => $this->_recipientDocument,
|
210 |
+
'ShipmentInvoiceValue' => $this->_value,
|
211 |
+
'ShippingItemArray' => $shippingItemArray
|
212 |
+
)
|
|
|
213 |
);
|
214 |
|
215 |
+
$content = $client->__soapCall("GetShippingQuote", array($service_param));
|
|
|
|
|
|
|
|
|
216 |
|
217 |
+
$this->_log($client->__getLastRequest());
|
218 |
+
$this->_log($client->__getLastResponse());
|
219 |
|
220 |
if ($content == "") {
|
221 |
throw new Exception("No XML returned [" . __LINE__ . "]");
|
225 |
|
226 |
} catch (Exception $e) {
|
227 |
//URL Error
|
228 |
+
$this->_throwError('urlerror', 'URL Error - ' . $e->getMessage() . ' request ' . $client->__getLastRequest(), __LINE__);
|
229 |
return false;
|
230 |
};
|
231 |
}
|
274 |
|
275 |
$this->_log('Leadtime: ' . $cartLeadTime);
|
276 |
|
277 |
+
if ($this->_showDelivery && ((int)($delivery + $this->_addDeliveryDays + $cartLeadTime) > 0)){
|
278 |
$this->_log('Delivery: ' . $delivery);
|
279 |
$this->_log('Show Delivery: ' . $this->_showDelivery);
|
280 |
|
296 |
return false;
|
297 |
}
|
298 |
|
|
|
299 |
if (!$this->_checkZipCode($request)) return false;
|
300 |
|
301 |
$this->_title = $this->getConfigData('title');
|
309 |
$this->_updatePackageWeight($request);
|
310 |
|
311 |
$this->_weight = $this->_fixWeight($request->getPackageWeight());
|
312 |
+
|
313 |
+
// obter o documento do destinatário - algumas transportadoras exigem
|
314 |
+
$this->_recipientDocument = '';
|
315 |
}
|
316 |
|
317 |
protected function _updatePackageWeight(Mage_Shipping_Model_Rate_Request $request)
|
466 |
{
|
467 |
return array($this->_code => $this->getConfigData('name'));
|
468 |
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Check if current carrier offer support to tracking
|
472 |
+
*
|
473 |
+
* @return bool true
|
474 |
+
*/
|
475 |
+
public function isTrackingAvailable()
|
476 |
+
{
|
477 |
+
return true;
|
478 |
+
}
|
479 |
+
|
480 |
+
public function getTrackingInfo($tracking)
|
481 |
+
{
|
482 |
+
$result = $this->getTracking($tracking);
|
483 |
+
if ($result instanceof Mage_Shipping_Model_Tracking_Result) {
|
484 |
+
if ($trackings = $result->getAllTrackings()) {
|
485 |
+
return $trackings[0];
|
486 |
+
}
|
487 |
+
} elseif (is_string($result) && !empty($result)) {
|
488 |
+
return $result;
|
489 |
+
}
|
490 |
+
|
491 |
+
return false;
|
492 |
+
}
|
493 |
+
|
494 |
+
public function getTracking($trackings)
|
495 |
+
{
|
496 |
+
$this->_result = Mage::getModel('shipping/tracking_result');
|
497 |
+
foreach ((array) $trackings as $code) {
|
498 |
+
$this->_getTrackingFromWS($code);
|
499 |
+
}
|
500 |
+
return $this->_result;
|
501 |
+
}
|
502 |
+
|
503 |
+
protected function _getTrackingFromWS($tracking)
|
504 |
+
{
|
505 |
+
$sales_flat_shipment_track = Mage::getSingleton('core/resource')->getTableName('sales_flat_shipment_track');
|
506 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
507 |
+
$sql = 'SELECT order_id FROM ' . $sales_flat_shipment_track . ' WHERE track_number = ?';
|
508 |
+
$tracking_table = $connection->fetchAll($sql, $tracking);
|
509 |
+
$orderId='';
|
510 |
+
foreach ($tracking_table as $track){
|
511 |
+
$orderId = $track['order_id'];
|
512 |
+
break;
|
513 |
+
}
|
514 |
+
|
515 |
+
$url = $this->getConfigData('url_ws');
|
516 |
+
$client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
|
517 |
+
//$orderId = Mage::getModel("sales/order")->getCollection()->getLastItem()->getIncrementId();
|
518 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
519 |
+
|
520 |
+
$shippingServiceCode = str_replace($this->_code . '_','', $order->getShippingMethod());
|
521 |
+
|
522 |
+
$invoiceNumber='';
|
523 |
+
if ($order->hasInvoices()) {
|
524 |
+
foreach ($order->getInvoiceCollection() as $inv) {
|
525 |
+
$invoiceNumber += $inv->getIncrementId() . '|';
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
$customer_id = $order->getCustomerId();
|
530 |
+
$customer = Mage::getModel('customer/customer')->load($customer_id);
|
531 |
+
$recipientDocument = $customer->getData('taxvat');
|
532 |
+
|
533 |
+
$this->_log('Shipping Service Code: ' . $shippingServiceCode);
|
534 |
+
$this->_log('CPF: ' . $recipientDocument);
|
535 |
+
|
536 |
+
$service_param = array (
|
537 |
+
'trackingRequest' => array(
|
538 |
+
'Username' => $this->getConfigData('login'),
|
539 |
+
'Password' => $this->getConfigData('password'),
|
540 |
+
'TrackingNumber' => $tracking,
|
541 |
+
'InvoiceNumber' => $invoiceNumber,
|
542 |
+
'RecipientDocument' => $recipientDocument,
|
543 |
+
'OrderNumber' => $order->getIncrementId(),
|
544 |
+
'ShippingServiceCode' => $shippingServiceCode
|
545 |
+
)
|
546 |
+
);
|
547 |
+
$this->_log(json_encode($service_param));
|
548 |
+
$wsReturn = $client->__soapCall("GetTrackingInfo", array($service_param));
|
549 |
+
|
550 |
+
$this->_log($client->__getLastRequest());
|
551 |
+
$this->_log($client->__getLastResponse());
|
552 |
+
|
553 |
+
if ($wsReturn == "") {
|
554 |
+
throw new Exception("No XML returned [" . __LINE__ . "]");
|
555 |
+
}
|
556 |
+
|
557 |
+
if ($wsReturn !== false) {
|
558 |
+
if(isset($wsReturn->GetTrackingInfoResult->TrackingEvents))
|
559 |
+
{
|
560 |
+
if(count($wsReturn->GetTrackingInfoResult->TrackingEvents->TrackingEvent)==1)
|
561 |
+
$trackingEventArray[0] = $wsReturn->GetTrackingInfoResult->TrackingEvents->TrackingEvent;
|
562 |
+
else
|
563 |
+
$trackingEventArray = $wsReturn->GetTrackingInfoResult->TrackingEvents->TrackingEvent;
|
564 |
+
|
565 |
+
|
566 |
+
$progress = array();
|
567 |
+
foreach($trackingEventArray as $trackingEvent){
|
568 |
+
$this->_log("Percorrendo os eventos");
|
569 |
+
|
570 |
+
$datetime = explode(' ',$trackingEvent->EventDateTime);
|
571 |
+
$locale = new Zend_Locale('pt_BR');
|
572 |
+
$date = '';
|
573 |
+
$date = new Zend_Date($datetime[0], 'dd/MM/YYYY', $locale);
|
574 |
+
|
575 |
+
$trackingProgress = array(
|
576 |
+
'deliverydate' => $date->toString('YYYY-MM-dd'),
|
577 |
+
'deliverytime' => $datetime[1],
|
578 |
+
'deliverylocation' => $trackingEvent->EventLocation,
|
579 |
+
'activity' => $trackingEvent->EventDescription
|
580 |
+
);
|
581 |
+
$progress[] = $trackingProgress;
|
582 |
+
}
|
583 |
+
|
584 |
+
$trackData = $progress[0];
|
585 |
+
$trackData['progressdetail'] = $progress;
|
586 |
+
|
587 |
+
$carrierTitle='';
|
588 |
+
if(isset($wsReturn->GetTrackingInfoResult->ServiceDescrition))
|
589 |
+
$carrierTitle = $wsReturn->GetTrackingInfoResult->ServiceDescrition;
|
590 |
+
|
591 |
+
$track = Mage::getModel('shipping/tracking_result_status');
|
592 |
+
$track->setTracking($tracking)
|
593 |
+
->setCarrierTitle($carrierTitle)
|
594 |
+
->addData($trackData);
|
595 |
+
|
596 |
+
$this->_result->append($track);
|
597 |
+
return true;
|
598 |
+
}
|
599 |
+
else{
|
600 |
+
$error = Mage::getModel('shipping/tracking_result_error');
|
601 |
+
$this->_result->append($error);
|
602 |
+
return false;
|
603 |
+
}
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
|
608 |
}
|
app/code/community/LithiumSoftware/Akhilleus/Model/Observer.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This source file is subject to the MIT License.
|
4 |
+
* It is also available through http://opensource.org/licenses/MIT
|
5 |
+
*
|
6 |
+
* @category Akhilleus
|
7 |
+
* @package LithiumSoftware_Akhilleus
|
8 |
+
* @author LithiumSoftware <contato@lithiumsoftware.com.br>
|
9 |
+
* @copyright 2015 Lithium Software
|
10 |
+
* @license http://opensource.org/licenses/MIT MIT
|
11 |
+
*/
|
12 |
+
|
13 |
+
class LithiumSoftware_Akhilleus_Model_Observer extends Mage_Core_Model_Abstract {
|
14 |
+
|
15 |
+
public function SaveShippingResultLog($observer){
|
16 |
+
try
|
17 |
+
{
|
18 |
+
$shipment = $observer->getEvent()->getShipment();
|
19 |
+
if ($shipment) {
|
20 |
+
$order = $shipment->getOrder();
|
21 |
+
if ($order) {
|
22 |
+
|
23 |
+
$this->_log('SaveShippingResultLog - ShippingMethod: ' . $order->getShippingMethod());
|
24 |
+
$this->_log('SaveShippingResultLog - ShippingDescription: ' . $order->getShippingDescription());
|
25 |
+
|
26 |
+
$orderID = $order->getIncrementId();
|
27 |
+
$sellerCEP = Mage::getStoreConfig('shipping/origin/postcode');
|
28 |
+
$recipientCEP = $order->getShippingAddress()->getPostcode();
|
29 |
+
$shipmentInvoiceValue = $order->getSubtotal();
|
30 |
+
$shippingAmount = $order->getShippingAmount();
|
31 |
+
$shipmentWeight = $order->getWeight();
|
32 |
+
$deliveryTime = preg_replace("/[^0-9]/","",$order->getShippingDescription());
|
33 |
+
$shippingMethod = str_replace("akhilleus_", "",$order->getShippingMethod());
|
34 |
+
|
35 |
+
// Call Webservices
|
36 |
+
$this->saveShippingResult($orderID, $sellerCEP,
|
37 |
+
$recipientCEP, $shipmentInvoiceValue, $shippingAmount, $deliveryTime, $shipmentWeight, $shippingMethod);
|
38 |
+
|
39 |
+
}
|
40 |
+
}
|
41 |
+
} catch (Exception $e) {
|
42 |
+
$this->_log('SaveShippingResultLog - Error: ' . $e->getMessage(), __LINE__);
|
43 |
+
}
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _log($msg) {
|
49 |
+
Mage::log('Akhilleus: ' . $msg);
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function saveShippingResult($orderID, $sellerCEP, $recipientCEP, $shipmentInvoiceValue, $shippingAmount, $deliveryTime, $shipmentWeight, $shippingMethod)
|
53 |
+
{
|
54 |
+
$url = Mage::getStoreConfig('carriers/akhilleus/url_ws');
|
55 |
+
|
56 |
+
try {
|
57 |
+
$client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
|
58 |
+
|
59 |
+
$login = Mage::getStoreConfig('carriers/akhilleus/login');
|
60 |
+
$password = Mage::getStoreConfig('carriers/akhilleus/password');
|
61 |
+
|
62 |
+
$service_param = array (
|
63 |
+
'saveRequest' => array(
|
64 |
+
'Username' => $login,
|
65 |
+
'Password' => $password,
|
66 |
+
'OrderID' => $orderID,
|
67 |
+
'SellerCEP' => $sellerCEP,
|
68 |
+
'RecipientCEP' => $recipientCEP,
|
69 |
+
'ShipmentInvoiceValue' => $shipmentInvoiceValue,
|
70 |
+
'ShippingPrice' => $shippingAmount,
|
71 |
+
'DeliveryTime' => $deliveryTime,
|
72 |
+
'ShipmentWeight' => $shipmentWeight,
|
73 |
+
'ShippingMethod' => $shippingMethod
|
74 |
+
)
|
75 |
+
);
|
76 |
+
|
77 |
+
$content = $client->__soapCall("SaveShippingResultLog", array($service_param));
|
78 |
+
|
79 |
+
$this->_log($client->__getLastRequest());
|
80 |
+
$this->_log($client->__getLastResponse());
|
81 |
+
|
82 |
+
if ($content == "") {
|
83 |
+
throw new Exception("No XML returned [" . __LINE__ . "]");
|
84 |
+
}
|
85 |
+
return $content;
|
86 |
+
|
87 |
+
} catch (Exception $e) {
|
88 |
+
$this->_log('_getWebServicesReturn - Error: ' . $e->getMessage(), __LINE__);
|
89 |
+
|
90 |
+
//URL Error
|
91 |
+
$this->_throwError('urlerror', 'URL Error - ' . $e->getMessage(), __LINE__);
|
92 |
+
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
}
|
app/code/community/LithiumSoftware/Akhilleus/etc/config.xml
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
<config>
|
15 |
<modules>
|
16 |
<LithiumSoftware_Akhilleus>
|
17 |
-
<version>1.0.
|
18 |
<depends>
|
19 |
<Mage_Shipping/>
|
20 |
</depends>
|
@@ -53,6 +53,17 @@
|
|
53 |
</connection>
|
54 |
</akhilleus_setup>
|
55 |
</resources>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
</global>
|
57 |
<default>
|
58 |
<carriers>
|
14 |
<config>
|
15 |
<modules>
|
16 |
<LithiumSoftware_Akhilleus>
|
17 |
+
<version>1.0.2</version>
|
18 |
<depends>
|
19 |
<Mage_Shipping/>
|
20 |
</depends>
|
53 |
</connection>
|
54 |
</akhilleus_setup>
|
55 |
</resources>
|
56 |
+
<events>
|
57 |
+
<sales_order_shipment_save_after>
|
58 |
+
<observers>
|
59 |
+
<send_statistics>
|
60 |
+
<type>singleton</type>
|
61 |
+
<class>LithiumSoftware_Akhilleus_Model_Observer</class>
|
62 |
+
<method>SaveShippingResultLog</method>
|
63 |
+
</send_statistics>
|
64 |
+
</observers>
|
65 |
+
</sales_order_shipment_save_after>
|
66 |
+
</events>
|
67 |
</global>
|
68 |
<default>
|
69 |
<carriers>
|
package.xml
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LithiumSoftware_Akhilleus</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/MIT">MIT</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Frenet allows merchants to display freight options from multiple carriers, including brazilian Correios.</summary>
|
10 |
<description>The Frenet freight gateway is able to integrate and process tables of freight carriers and brazilian Correios. The freight calculation for the brazilian Correios services is done on-line (via Correios webservice) or in case of unavailability, uses database in the cloud highly available and regularly updated automatically, with the values of quotations. 
|
11 |
-
It provides to the store owners, major carriers in Brazil to transport large volumes as well as JadLog, ASAP Log, JAMEF among others.</description>
|
12 |
-
<notes>
|
|
|
|
|
|
|
|
|
13 |
<authors><author><name>Frenet</name><user>MAG002970201</user><email>contato@frenet.com.br</email></author></authors>
|
14 |
-
<date>
|
15 |
-
<time>19:
|
16 |
-
<contents><target name="magecommunity"><dir name="LithiumSoftware"><dir name="Akhilleus"><dir name="Helper"><file name="Data.php" hash="fae99f78422836771d71873f253e8471"/></dir><dir name="Model"><dir name="Carrier"><file name="Akhilleus.php" hash="
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.2.1</min><max>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LithiumSoftware_Akhilleus</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/MIT">MIT</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Frenet allows merchants to display freight options from multiple carriers, including brazilian Correios.</summary>
|
10 |
<description>The Frenet freight gateway is able to integrate and process tables of freight carriers and brazilian Correios. The freight calculation for the brazilian Correios services is done on-line (via Correios webservice) or in case of unavailability, uses database in the cloud highly available and regularly updated automatically, with the values of quotations. 
|
11 |
+
It provides to the store owners, major carriers in Brazil to transport large volumes as well as JadLog, ASAP Log, TNT, Direct, Total Express, JAMEF among others.</description>
|
12 |
+
<notes>Bug Fix:
|
13 |
+
- Multiple volumes
|
14 |
+

|
15 |
+
Features:
|
16 |
+
- Tracking</notes>
|
17 |
<authors><author><name>Frenet</name><user>MAG002970201</user><email>contato@frenet.com.br</email></author></authors>
|
18 |
+
<date>2016-03-11</date>
|
19 |
+
<time>19:30:43</time>
|
20 |
+
<contents><target name="magecommunity"><dir name="LithiumSoftware"><dir name="Akhilleus"><dir name="Helper"><file name="Data.php" hash="fae99f78422836771d71873f253e8471"/></dir><dir name="Model"><dir name="Carrier"><file name="Akhilleus.php" hash="6ec067e8919777395a6b2f5634f01649"/></dir><file name="Observer.php" hash="927d49b0b02ecfe36aa708a7f186422a"/><dir name="Source"><file name="WeightType.php" hash="90bd2253381d2c2094aa0183e3129eb7"/></dir></dir><dir name="etc"><file name="config.xml" hash="ab30a6169d9c8adbc8c9581d122745d9"/><file name="system.xml" hash="162638242c34a75a65091ec10b971741"/></dir><dir name="sql"><dir name="akhilleus_setup"><file name="install-1.0.0.php" hash="17104e4cf30a39bd0980837310ae940a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LithiumSoftware_Akhilleus.xml" hash="ad180127bc24251a43a18818f2a30c21"/></dir></target></contents>
|
21 |
<compatible/>
|
22 |
+
<dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
|
23 |
</package>
|