LithiumSoftware_Akhilleus - Version 1.0.0

Version Notes

First Magento Connect version

Download this release

Release Info

Developer Frenet
Extension LithiumSoftware_Akhilleus
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/LithiumSoftware/Akhilleus/Helper/Data.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ class LithiumSoftware_Akhilleus_Helper_Data extends Mage_Core_Helper_Abstract
13
+ {
14
+ }
15
+
app/code/community/LithiumSoftware/Akhilleus/Model/Carrier/Akhilleus.php ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ class LithiumSoftware_Akhilleus_Model_Carrier_Akhilleus
13
+ extends Mage_Shipping_Model_Carrier_Abstract
14
+ implements Mage_Shipping_Model_Carrier_Interface
15
+ {
16
+ protected $_code = 'akhilleus';
17
+
18
+ protected $_result = null;
19
+
20
+ protected $_value = NULL; // Valor do pedido
21
+ protected $_weightType = NULL; // Unidade de medida
22
+ protected $_weight = NULL; // Peso total do pedido
23
+ protected $_length = NULL; // Tamanho
24
+ protected $_height = NULL; // Altura
25
+ protected $_width = NULL; // Largura
26
+ protected $_diameter = NULL; // Diametro
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
33
+
34
+
35
+ /**
36
+ * Collect rates for this shipping method based on information in $request
37
+ *
38
+ * @param Mage_Shipping_Model_Rate_Request $data
39
+ * @return Mage_Shipping_Model_Rate_Result
40
+ */
41
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request){
42
+ $this->_init($request);
43
+
44
+ $this->_getQuotes($request);
45
+
46
+ return $this->_result;
47
+ }
48
+ /**
49
+ * Get shipping quote
50
+ *
51
+ * @return Mage_Shipping_Model_Rate_Result|Mage_Shipping_Model_Tracking_Result
52
+ */
53
+ protected function _getQuotes(Mage_Shipping_Model_Rate_Request $request)
54
+ {
55
+ // Call Webservices
56
+ $wsReturn = $this->_getWebServicesReturn($request);
57
+
58
+ if ($wsReturn !== false) {
59
+
60
+ $this->_log("Qtd serviços: " . count($wsReturn->RateResult->ShippingSevicesArray->ShippingSevices));
61
+
62
+ // Check if exist return from Webservices
63
+ $existReturn = false;
64
+
65
+ if(count($wsReturn->RateResult->ShippingSevicesArray->ShippingSevices)==1)
66
+ $servicosArray[0] = $wsReturn->RateResult->ShippingSevicesArray->ShippingSevices;
67
+ else
68
+ $servicosArray = $wsReturn->RateResult->ShippingSevicesArray->ShippingSevices;
69
+
70
+ foreach($servicosArray as $servicos){
71
+
72
+ // Get Webservices error
73
+
74
+ $this->_log("Percorrendo os serviços retornados");
75
+
76
+ if ($servicos->ServiceCode . '' == '') {
77
+ continue;
78
+ }
79
+
80
+ $shippingPrice = floatval(str_replace(",", ".", (string) $servicos->ShippingPrice));
81
+ $delivery = (int) $servicos->DeliveryTime;
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);
88
+
89
+ $existReturn = true;
90
+ }
91
+
92
+ // All services are ignored
93
+ if ($existReturn === false) {
94
+ $this->_throwError('urlerror', 'URL Error, all services return with error', __LINE__);
95
+ return $this->_result;
96
+ }
97
+ } else {
98
+ // Error on HTTP Webservices
99
+ return $this->_result;
100
+ }
101
+
102
+ // Success
103
+ return $this->_result;
104
+ }
105
+
106
+ /**
107
+ * Get Webservices return
108
+ *
109
+ * @return bool|SimpleXMLElement[]
110
+ */
111
+ protected function _getWebServicesReturn(Mage_Shipping_Model_Rate_Request $request)
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
121
+ $this->_width = $this->getConfigData('default_width'); //11
122
+ $this->_height = $this->getConfigData('default_height'); //2
123
+ $this->_diameter = 0;
124
+ }
125
+ else
126
+ {
127
+ $this->_length = 0;
128
+ $this->_width = 0;
129
+ $this->_height = 0;
130
+ $this->_diameter = 0;
131
+
132
+ // Pega as maiores dimensões dos produtos do carrinho
133
+ foreach($request->getAllItems() as $item){
134
+ if($item->getProduct()->getData('volume_comprimento') > $this->_length)
135
+ $this->_length = $item->getProduct()->getData('volume_comprimento');
136
+
137
+ if($item->getProduct()->getData('volume_largura') > $this->_width)
138
+ $this->_width = $item->getProduct()->getData('volume_largura');
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
+ $this->_log('altura ' . $this->_height);
149
+ $this->_log('largura ' . $this->_width);
150
+ $this->_log('comprimento ' . $this->_length);
151
+
152
+ $service_param = array (
153
+ 'userName' => $this->getConfigData('login'),
154
+ 'password' => $this->getConfigData('password'),
155
+ 'sellerCEP' => $this->_from,
156
+ 'recipientCEP' => $this->_to,
157
+ 'shipmentInvoiceValue' => $this->_value,
158
+ 'shipmentWeight' => $this->_weight,
159
+ 'shipmentLength' => $this->_length,
160
+ 'shipmentHeight' => $this->_height,
161
+ 'shipmentWidth' => $this->_width,
162
+ 'shipmentDiameter' => $this->_diameter
163
+ );
164
+
165
+ $this->_log('Chamada do webservices - ' .
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__ . "]");
174
+ }
175
+
176
+ return $content;
177
+
178
+ } catch (Exception $e) {
179
+ //URL Error
180
+ $this->_throwError('urlerror', 'URL Error - ' . $e->getMessage(), __LINE__);
181
+ return false;
182
+ };
183
+ }
184
+
185
+ protected function _appendShippingMethod($shipping_method, $shippingPrice = 0, $delivery = 0, $shipping_method_name, Mage_Shipping_Model_Rate_Request $request){
186
+ $method = Mage::getModel('shipping/rate_result_method');
187
+ $method->setCarrier($this->_code);
188
+ $method->setCarrierTitle($this->_title);
189
+
190
+ $method->setMethod($shipping_method);
191
+
192
+
193
+ //Obter o maior LEADTIME dos produtos do request
194
+ $cartLeadTime = 0;
195
+ $productLeadTime=0;
196
+ if ($request->getAllItems()) {
197
+ foreach ($request->getAllItems() as $item) {
198
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
199
+ continue;
200
+ }
201
+
202
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
203
+ foreach ($item->getChildren() as $child) {
204
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
205
+ $product_id = $child->getProductId();
206
+ $productObj = Mage::getModel('catalog/product')->load($product_id);
207
+
208
+ //verificar se a propriedade Leadtime existe
209
+ if($productObj->offsetExists('leadtime'))
210
+ $productLeadTime = $productObj->getleadtime();
211
+ }
212
+ }
213
+ } else {
214
+ $productId = $item->getProductId();
215
+ $productObj = Mage::getModel('catalog/product')->load($productId);
216
+
217
+ //verificar se a propriedade Leadtime existe
218
+ if($productObj->offsetExists('leadtime'))
219
+ $productLeadTime = $productObj->getleadtime();
220
+ }
221
+
222
+ if($cartLeadTime < $productLeadTime)
223
+ $cartLeadTime=$productLeadTime;
224
+ }
225
+ }
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
+
233
+ $method->setMethodTitle(sprintf($this->getConfigData('msgprazo'), $shipping_method_name, (int)($delivery + $this->_addDeliveryDays + $cartLeadTime)));
234
+ }
235
+ else {
236
+ $method->setMethodTitle($shipping_method_name);
237
+ }
238
+
239
+ $method->setPrice($shippingPrice);
240
+ $method->setCost($shippingPrice);
241
+
242
+ $this->_result->append($method);
243
+ }
244
+
245
+ protected function _init(Mage_Shipping_Model_Rate_Request $request){
246
+ if (!$this->isActive()) {
247
+ $this->_log('Módulo Desabilitado');
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');
255
+ $this->_weightType = $this->getConfigData('weight_type');
256
+ $this->_result = Mage::getModel('shipping/rate_result');
257
+ $this->_showDelivery = $this->getConfigData('show_delivery');
258
+ $this->_addDeliveryDays = $this->getConfigData('add_delivery_days');
259
+
260
+ $this->_value = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
261
+
262
+ $this->_updatePackageWeight($request);
263
+
264
+ $this->_weight = $this->_fixWeight($request->getPackageWeight());
265
+ }
266
+
267
+ protected function _updatePackageWeight(Mage_Shipping_Model_Rate_Request $request)
268
+ {
269
+ $this->_packageWeight = 0;
270
+
271
+ if ($request->getAllItems()) {
272
+ foreach ($request->getAllItems() as $item) {
273
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
274
+ continue;
275
+ }
276
+
277
+ if ($item->getHasChildren()) {
278
+ foreach ($item->getChildren() as $child) {
279
+ $product_id = $child->getProductId();
280
+ $productObj = Mage::getModel('catalog/product')->load($product_id);
281
+
282
+ $this->_packageWeight += $productObj->getWeight();
283
+ }
284
+ } else {
285
+ $this->_packageWeight += $item->getRowWeight();
286
+ }
287
+ }
288
+
289
+ if($request->getPackageWeight() > $this->_packageWeight)
290
+ $this->_packageWeight = $request->getPackageWeight();
291
+
292
+ }
293
+ $request->setPackageWeight($this->_packageWeight);
294
+ }
295
+
296
+ /**
297
+ * Retorna mensagem de erro
298
+ *
299
+ * @param $message string
300
+ * @param $log string
301
+ * @param $line int
302
+ * @param $custom string
303
+ */
304
+ protected function _throwError($message, $log = null, $line = 'NO LINE', $custom = null){
305
+
306
+ $this->_result = null;
307
+ $this->_result = Mage::getModel('shipping/rate_result');
308
+
309
+ // Get error model
310
+ $error = Mage::getModel('shipping/rate_result_error');
311
+ $error->setCarrier($this->_code);
312
+ $error->setCarrierTitle($this->getConfigData('title'));
313
+
314
+ if(is_null($custom)){
315
+ //Log error
316
+ Mage::log($this->_code . ' [' . $line . ']: ' . $log);
317
+ $error->setErrorMessage($this->getConfigData($message));
318
+ }else{
319
+ //Log error
320
+ Mage::log($this->_code . ' [' . $line . ']: ' . $log);
321
+ $error->setErrorMessage(sprintf($this->getConfigData($message), $custom));
322
+ }
323
+
324
+ // Apend error
325
+ $this->_result->append($error);
326
+ }
327
+
328
+ /**
329
+ * Registra as mensagens do módulo no padrão estabelecido
330
+ *
331
+ * @param string $msg
332
+ */
333
+ protected function _log($msg) {
334
+ Mage::log('Akhilleus: ' . $msg);
335
+ }
336
+
337
+ /**
338
+ * Formata um CEP informado
339
+ *
340
+ * @param string $zipcode
341
+ * @return boolean|Ambigous <string, mixed>
342
+ */
343
+ protected function _formatZip($zipcode) {
344
+ $new = trim($zipcode);
345
+ $new = preg_replace('/[^0-9\s]/', '', $new);
346
+
347
+ if(!preg_match("/^[0-9]{8}$/", $new)){
348
+ return false;
349
+ }
350
+
351
+ return $new;
352
+ }
353
+
354
+ /**
355
+ * Recupera, formata e verifica se os CEPs de origem e destino estão
356
+ * dentro do padrão correto
357
+ *
358
+ * @param Mage_Shipping_Model_Rate_Request $request
359
+ * @return boolean
360
+ */
361
+ protected function _checkZipCode(Mage_Shipping_Model_Rate_Request $request) {
362
+ $this->_from = $this->_formatZip(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()));
363
+ $this->_to = $this->_formatZip($request->getDestPostcode());
364
+
365
+ if(!$this->_from){
366
+ $this->_log('Erro com CEP de origem');
367
+ return false;
368
+ }
369
+
370
+ if(!$this->_to){
371
+ $this->_log('Erro com CEP de destino');
372
+ $this->_throwError('zipcodeerror', 'CEP Inválido', __LINE__);
373
+ return false;
374
+ }
375
+
376
+ return true;
377
+ }
378
+
379
+ /**
380
+ * Verifica se o país está dentro da área atendida
381
+ *
382
+ * @param Mage_Shipping_Model_Rate_Request $request
383
+ * @return boolean
384
+ */
385
+ protected function _checkCountry(Mage_Shipping_Model_Rate_Request $request) {
386
+ $from = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
387
+ $to = $request->getDestCountryId();
388
+ if ($from != "BR" || $to != "BR"){
389
+ $this->_log('Fora da área de atendimento');
390
+ return false;
391
+ }
392
+
393
+ return true;
394
+ }
395
+
396
+ /**
397
+ * Corrige o peso informado com base na medida de peso configurada
398
+ * @param string|int|float $weight
399
+ * @return double
400
+ */
401
+ protected function _fixWeight($weight) {
402
+ $result = $weight;
403
+ if ($this->_weightType == 'gr') {
404
+ $result = number_format($weight/1000, 2, '.', '');
405
+ }
406
+
407
+ return $result;
408
+ }
409
+
410
+ /**
411
+ * Returns the allowed carrier methods
412
+ *
413
+ * @return array
414
+ */
415
+ public function getAllowedMethods()
416
+ {
417
+ return array($this->_code => $this->getConfigData('name'));
418
+ }
419
+ }
app/code/community/LithiumSoftware/Akhilleus/Model/Source/WeightType.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ class LithiumSoftware_Akhilleus_Model_Source_WeightType
13
+ {
14
+ /**
15
+ * Constants for weight
16
+ */
17
+ const WEIGHT_GR = 'gr';
18
+ const WEIGHT_KG = 'kg';
19
+
20
+ /**
21
+ * Get options for weight
22
+ *
23
+ * @return array
24
+ */
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array('value' => self::WEIGHT_GR, 'label' => Mage::helper('adminhtml')->__('Gramas')),
29
+ array('value' => self::WEIGHT_KG, 'label' => Mage::helper('adminhtml')->__('Kilos')),
30
+ );
31
+ }
32
+ }
app/code/community/LithiumSoftware/Akhilleus/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * This source file is subject to the MIT License.
5
+ * It is also available through http://opensource.org/licenses/MIT
6
+ *
7
+ * @category Akhilleus
8
+ * @package LithiumSoftware_Akhilleus
9
+ * @author LithiumSoftware <contato@lithiumsoftware.com.br>
10
+ * @copyright 2015 Lithium Software
11
+ * @license http://opensource.org/licenses/MIT MIT
12
+ */
13
+ -->
14
+ <config>
15
+ <modules>
16
+ <LithiumSoftware_Akhilleus>
17
+ <version>1.0.0</version>
18
+ <depends>
19
+ <Mage_Shipping/>
20
+ </depends>
21
+ </LithiumSoftware_Akhilleus>
22
+ </modules>
23
+ <global>
24
+ <sales>
25
+ <quote>
26
+ <item>
27
+ <product_attributes>
28
+ <volume_altura/>
29
+ <volume_comprimento/>
30
+ <volume_largura/>
31
+ </product_attributes>
32
+ </item>
33
+ </quote>
34
+ </sales>
35
+ <helpers>
36
+ <akhilleus>
37
+ <class>LithiumSoftware_Akhilleus_Helper</class>
38
+ </akhilleus>
39
+ </helpers>
40
+ <models>
41
+ <akhilleus>
42
+ <class>LithiumSoftware_Akhilleus_Model</class>
43
+ <resourceModel>akhilleus_mysql4</resourceModel>
44
+ </akhilleus>
45
+ </models>
46
+ <resources>
47
+ <akhilleus_setup>
48
+ <setup>
49
+ <module>LithiumSoftware_Akhilleus</module>
50
+ </setup>
51
+ <connection>
52
+ <use>directory_setup</use>
53
+ </connection>
54
+ </akhilleus_setup>
55
+ </resources>
56
+ </global>
57
+ <default>
58
+ <carriers>
59
+ <akhilleus>
60
+ <active>1</active>
61
+ <model>akhilleus/carrier_akhilleus</model>
62
+ <title>Serviços de Entrega</title>
63
+ <msgprazo>%s - Em média %d dia(s)</msgprazo>
64
+ <!-- VOLUME -->
65
+ <use_default>1</use_default>
66
+ <altura_padrao>2</altura_padrao>
67
+ <comprimento_padrao>16</comprimento_padrao>
68
+ <largura_padrao>11</largura_padrao>
69
+ <altura_sent>2</altura_sent>
70
+ <comprimento_sent>16</comprimento_sent>
71
+ <largura_sent>11</largura_sent>
72
+
73
+ <sort_order>0</sort_order>
74
+ <sallowspecific>0</sallowspecific>
75
+ <specificcountry>BR</specificcountry>
76
+
77
+ <weight_type>kg</weight_type>
78
+
79
+ <url_ws>http://services.lithiumsoftware.com.br/logistics/ShippingQuoteWS.asmx?wsdl</url_ws>
80
+ </akhilleus>
81
+ </carriers>
82
+ </default>
83
+ </config>
app/code/community/LithiumSoftware/Akhilleus/etc/system.xml ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * This source file is subject to the MIT License.
5
+ * It is also available through http://opensource.org/licenses/MIT
6
+ *
7
+ * @category Akhilleus
8
+ * @package LithiumSoftware_Akhilleus
9
+ * @author LithiumSoftware <contato@lithiumsoftware.com.br>
10
+ * @copyright 2015 Lithium Software
11
+ * @license http://opensource.org/licenses/MIT MIT
12
+ */
13
+ -->
14
+ <config>
15
+ <sections>
16
+ <carriers translate="label" module="akhilleus">
17
+ <groups>
18
+ <akhilleus translate="label">
19
+ <label>Frenet - Gateway de fretes</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>0</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <comment>
26
+ <![CDATA[ <div style="background: #FFF; border: 1px solid #0091DB;">
27
+ <div style="padding:10px;float: left;text-align: left; vertical-align:bottom;">
28
+ <a href="http://www.frenet.com.br" target="_blank">
29
+ <img src="https://painel.frenet.com.br/Content/images/Frenet_logo_painel.png" style="float: left;" />
30
+ </a>
31
+ <b>
32
+ Para configurar as transportadoras as quais deseja obter cotações de frete, obter usuário e senha de acesso,
33
+ cadastrar regras de frete, acesse o <a href="https://painel.frenet.com.br" target="_blank">painel administrativo Frenet</a>
34
+ </div>
35
+ </b>
36
+ <div class="clear"></div>
37
+ </div> ]]>
38
+ </comment>
39
+ <model>akhilleus/carrier_akhilleus</model>
40
+ <fields>
41
+ <active translate="label">
42
+ <label>Enabled</label>
43
+ <frontend_type>select</frontend_type>
44
+ <source_model>adminhtml/system_config_source_yesno</source_model>
45
+ <sort_order>1</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </active>
50
+ <title translate="label">
51
+ <label>Title</label>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>2</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ </title>
58
+ <login translate="label">
59
+ <label>Usuário</label>
60
+ <frontend_type>text</frontend_type>
61
+ <sort_order>4</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </login>
66
+ <password translate="label">
67
+ <label>Password</label>
68
+ <frontend_type>password</frontend_type>
69
+ <sort_order>5</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </password>
74
+ <use_default translate="label">
75
+ <label>Utilizar dimensões padrão</label>
76
+ <frontend_type>select</frontend_type>
77
+ <sort_order>6</sort_order>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ <comment>O frete será calculado com as dimensões padrão preenchidas a seguir</comment>
83
+ </use_default>
84
+ <default_height translate="label">
85
+ <label>Altura Padrão (cm)</label>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>7</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ <comment><![CDATA[Mínimo de 2 cm.]]></comment>
92
+ </default_height>
93
+ <default_length translate="label">
94
+ <label>Comprimento Padrão (cm)</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>8</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <comment><![CDATA[Mínimo de 16 cm.]]></comment>
101
+ </default_length>
102
+ <default_width translate="label">
103
+ <label>Largura Padrão (cm)</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>9</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ <comment><![CDATA[Mínimo de 11 cm.]]></comment>
110
+ </default_width>
111
+ <weight_type translate="label">
112
+ <label>Formato do Peso</label>
113
+ <frontend_type>select</frontend_type>
114
+ <source_model>LithiumSoftware_Akhilleus_Model_Source_WeightType</source_model>
115
+ <sort_order>20</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ <comment>Formato do peso dos produtos.</comment>
120
+ <tooltip>O formato do peso irá implicar na maneira como o mesmo é cadastrado no produto, por
121
+ exemplo, 1 Kg no formato "Kilo" será "1.000", já em "Gramas" será "1000.000".
122
+ </tooltip>
123
+ </weight_type>
124
+ <show_delivery translate="label">
125
+ <label>Exibir Prazo de Entrega</label>
126
+ <frontend_type>select</frontend_type>
127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
128
+ <sort_order>10</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ </show_delivery>
133
+ <msgprazo translate="label">
134
+ <label>Mensagem que exibe o prazo de entrega</label>
135
+ <frontend_type>text</frontend_type>
136
+ <sort_order>11</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ </msgprazo>
141
+ <add_delivery_days translate="label">
142
+ <label>Adicionar ao prazo de entrega (dias)</label>
143
+ <frontend_type>text</frontend_type>
144
+ <sort_order>12</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ <comment>Adicionará mais dias aos prazos de entrega fornecidos.</comment>
149
+ </add_delivery_days>
150
+ <sort_order translate="label">
151
+ <label>Sort Order</label>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>100</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ <sort_order>100</sort_order>
158
+ </sort_order>
159
+ </fields>
160
+ </akhilleus>
161
+ </groups>
162
+ </carriers>
163
+ </sections>
164
+ </config>
app/code/community/LithiumSoftware/Akhilleus/sql/akhilleus_setup/install-1.0.0.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /** @var $installer Mage_Core_Model_Resource_Setup */
14
+ $installer = $this;
15
+ $installer->startSetup();
16
+
17
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
18
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
19
+
20
+ // Add volume to product attribute set
21
+ $codigo = 'volume_comprimento';
22
+ $config = array(
23
+ 'position' => 1,
24
+ 'required' => 1,
25
+ 'label' => 'Comprimento (cm)',
26
+ 'type' => 'int',
27
+ 'input' => 'text',
28
+ 'apply_to' => 'simple,bundle,grouped,configurable',
29
+ 'default' => 16,
30
+ 'note' => 'Comprimento da embalagem do produto (Para cálculo de frete, mínimo de 16cm)'
31
+ );
32
+
33
+ $setup->addAttribute('catalog_product', $codigo, $config);
34
+
35
+ // Add volume to product attribute set
36
+ $codigo = 'volume_altura';
37
+ $config = array(
38
+ 'position' => 1,
39
+ 'required' => 1,
40
+ 'label' => 'Altura (cm)',
41
+ 'type' => 'int',
42
+ 'input' => 'text',
43
+ 'apply_to' => 'simple,bundle,grouped,configurable',
44
+ 'default' => 2,
45
+ 'note' => 'Altura da embalagem do produto (Para cálculo de frete, mínimo de 2cm)'
46
+ );
47
+
48
+ $setup->addAttribute('catalog_product', $codigo, $config);
49
+
50
+ // Add volume to product attribute set
51
+ $codigo = 'volume_largura';
52
+ $config = array(
53
+ 'position' => 1,
54
+ 'required' => 1,
55
+ 'label' => 'Largura (cm)',
56
+ 'type' => 'int',
57
+ 'input' => 'text',
58
+ 'apply_to' => 'simple,bundle,grouped,configurable',
59
+ 'default' => 11,
60
+ 'note' => 'Largura da embalagem do produto (Para cálculo de frete, mínimo de 11cm)'
61
+ );
62
+
63
+ $setup->addAttribute('catalog_product', $codigo, $config);
64
+
65
+ // Add leadtime to product attribute set
66
+ $codigo = 'leadtime';
67
+ $config = array(
68
+ 'position' => 1,
69
+ 'required' => 1,
70
+ 'label' => 'Lead time (dias)',
71
+ 'type' => 'int',
72
+ 'input' => 'text',
73
+ 'apply_to' => 'simple,bundle,grouped,configurable',
74
+ 'default' => 0,
75
+ 'note' => 'Tempo de fabricação do produto (Para cálculo de frete)'
76
+ );
77
+
78
+ $setup->addAttribute('catalog_product', $codigo, $config);
79
+
80
+ // Add fragile to product attribute set
81
+ $codigo = 'fragile';
82
+ $config = array(
83
+ 'position' => 1,
84
+ 'label' => 'Produto frágil?',
85
+ 'type' => 'int',
86
+ 'input' => 'boolean',
87
+ 'apply_to' => 'simple,bundle,grouped,configurable',
88
+ 'default' => 0,
89
+ 'required' => 1,
90
+ 'note' => 'Produto contém vidro ou outros materiais frágeis? (Para cálculo de frete)'
91
+ );
92
+
93
+ $setup->addAttribute('catalog_product', $codigo, $config);
94
+
95
+ $installer->endSetup();
app/etc/modules/LithiumSoftware_Akhilleus.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * This source file is subject to the MIT License.
5
+ * It is also available through http://opensource.org/licenses/MIT
6
+ *
7
+ * @category Akhilleus
8
+ * @package LithiumSoftware_Akhilleus
9
+ * @author LithiumSoftware <contato@lithiumsoftware.com.br>
10
+ * @copyright 2015 Lithium Software
11
+ * @license http://opensource.org/licenses/MIT MIT
12
+ */
13
+ -->
14
+ <config>
15
+ <modules>
16
+ <LithiumSoftware_Akhilleus>
17
+ <active>true</active>
18
+ <codePool>community</codePool>
19
+ </LithiumSoftware_Akhilleus>
20
+ </modules>
21
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>LithiumSoftware_Akhilleus</name>
4
+ <version>1.0.0</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. &#xD;
11
+ It provides to the store owners, major carriers in Brazil to transport large volumes as well as JadLog, JAMEF among others.</description>
12
+ <notes>First Magento Connect version</notes>
13
+ <authors><author><name>Frenet</name><user>Frenet</user><email>contato@frenet.com.br</email></author></authors>
14
+ <date>2015-05-20</date>
15
+ <time>21:08:52</time>
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="c5721e139ff641857dbde5a70db9527d"/></dir><dir name="Source"><file name="WeightType.php" hash="b5d8a6a8b530a540f64be4626beeedff"/></dir></dir><dir name="etc"><file name="config.xml" hash="e70400ff4978b0b1fac14c44dae0ba0e"/><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>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>