correios - Version 1.0.2

Version Notes

* Verificação da extensão PHP Soap
* Melhorada mensagem de prazo de entrega
* Adicionado link para wiki nas configurações

Download this release

Release Info

Developer Willian
Extension correios
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/Storm/Correios/Model/Adminhtml/Observer.php CHANGED
@@ -8,15 +8,6 @@
8
  */
9
  class Storm_Correios_Model_Adminhtml_Observer
10
  {
11
- protected $_message = array(
12
- 'configuration' => array(
13
- 'severity' => Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL,
14
- 'title' => 'You must configure the source address of delivery.',
15
- 'description' => 'The Correios module accepts deliveries only national, so the home country of delivery must be configured to Brazil. Do not forget to set the postcode too.',
16
- 'url' => null
17
- )
18
- );
19
-
20
  /**
21
  * Check if there are errors in the module configuration
22
  * and requirements for the delivery method
@@ -26,29 +17,41 @@ class Storm_Correios_Model_Adminhtml_Observer
26
  * @return boolean
27
  */
28
  public function checkConfiguration(Varien_Event_Observer $observer)
29
- {
30
- if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
31
- return false;
32
- }
33
-
34
- if(!Mage::helper('correios')->isEnabled()) {
35
- return false;
36
- }
37
-
38
- if(!Mage::helper('adminnotification')->isModuleEnabled()) {
39
- return false;
40
- }
41
 
42
- if (Mage::getStoreConfig('shipping/origin/country_id') != 'BR') {
43
- $data = $this->_message['configuration'];
44
- $data['title'] = Mage::helper('correios')->__($data['title']);
45
- $data['description'] = Mage::helper('correios')->__($data['description']);
46
- $data['date_added'] = date('Y-m-d H:i:s');
47
-
48
- $this->_getInbox()->getResource()->parse($this->_getInbox(), array($data));
 
 
 
 
 
 
 
 
49
  }
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- return true;
52
  }
53
 
54
  /**
8
  */
9
  class Storm_Correios_Model_Adminhtml_Observer
10
  {
 
 
 
 
 
 
 
 
 
11
  /**
12
  * Check if there are errors in the module configuration
13
  * and requirements for the delivery method
17
  * @return boolean
18
  */
19
  public function checkConfiguration(Varien_Event_Observer $observer)
20
+ {
21
+ try {
22
+ if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
23
+ return false;
24
+ }
 
 
 
 
 
 
 
25
 
26
+ if(!Mage::helper('adminnotification')->isModuleEnabled()) {
27
+ return false;
28
+ }
29
+
30
+ if(!extension_loaded('soap')) {
31
+ throw new Exception(Mage::helper('correios')->__('The extension of PHP Soap must be installed so that the module Correios to function properly.'));
32
+ }
33
+
34
+ if (Mage::getStoreConfig('shipping/origin/country_id') != 'BR') {
35
+ throw new Exception(Mage::helper('correios')->__('The Correios module accepts deliveries only national, so the home country of delivery must be configured to Brazil. Do not forget to set the postcode too.'));
36
+ }
37
+
38
+ return true;
39
+ } catch(Exception $e) {
40
+ $this->_addMessage($e->getMessage());
41
  }
42
+ }
43
+
44
+ protected function _addMessage($message)
45
+ {
46
+ $this->_getInbox()->getResource()->parse($this->_getInbox(), array(
47
+ array(
48
+ 'severity' => Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL,
49
+ 'title' => $message,
50
+ 'date_added' => date('Y-m-d H:i:s')
51
+ )
52
+ ));
53
 
54
+ return $this;
55
  }
56
 
57
  /**
app/code/community/Storm/Correios/Model/Carrier/Shipping.php CHANGED
@@ -116,6 +116,11 @@ class Storm_Correios_Model_Carrier_Shipping extends Mage_Shipping_Model_Carrier_
116
  */
117
  public function isValid(Mage_Shipping_Model_Rate_Request $request)
118
  {
 
 
 
 
 
119
  if (!$this->_getHelper()->isValidPostcode($request->getDestPostcode())) {
120
  throw new Mage_Shipping_Exception($this->_getHelper()->__('Please, enter the postcode correctly.'));
121
  return false;
@@ -279,7 +284,7 @@ class Storm_Correios_Model_Carrier_Shipping extends Mage_Shipping_Model_Carrier_
279
  $title = $this->_getHelper()->getMethodTitle($method->getCode());
280
 
281
  if ($includeDeliveryTime) {
282
- return $this->_getHelper()->__('%s - delivery time %d day(s)', $title, $method->getDeliveryTime());
283
  }
284
 
285
  return $title;
116
  */
117
  public function isValid(Mage_Shipping_Model_Rate_Request $request)
118
  {
119
+ if(!extension_loaded('soap')) {
120
+ throw new Mage_Shipping_Exception($this->_getHelper()->__('You must to install PHP Soap extension to use shipping method Correios.'));
121
+ return false;
122
+ }
123
+
124
  if (!$this->_getHelper()->isValidPostcode($request->getDestPostcode())) {
125
  throw new Mage_Shipping_Exception($this->_getHelper()->__('Please, enter the postcode correctly.'));
126
  return false;
284
  $title = $this->_getHelper()->getMethodTitle($method->getCode());
285
 
286
  if ($includeDeliveryTime) {
287
+ return $this->_getHelper()->__('%s - %d working day(s)', $title, $method->getDeliveryTime());
288
  }
289
 
290
  return $title;
app/code/community/Storm/Correios/Model/Carrier/Webservice.php CHANGED
@@ -18,17 +18,17 @@ class Storm_Correios_Model_Carrier_Webservice
18
  */
19
  public function __construct()
20
  {
21
- $this->_client = new SoapClient(self::WSDL_URL, array(
22
- 'trace' => true,
23
- 'exceptions' => true,
24
- 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
25
- 'connection_timeout' => ini_get('max_execution_timeout')
26
- ));
27
-
28
- $this->setParam('nCdEmpresa', $this->_getHelper()->getConfigData('account_code'))
29
- ->setParam('sDsSenha', $this->_getHelper()->getConfigData('account_password'))
30
- ->setParam('nCdServico', $this->_getHelper()->getConfigData('shipping_methods'))
31
- ->setParam('sCepOrigem', Mage::getStoreConfig('shipping/origin/postcode'));
32
  }
33
 
34
  /**
@@ -164,7 +164,7 @@ class Storm_Correios_Model_Carrier_Webservice
164
 
165
  /**
166
  * Converts the data returned from webservice to the object
167
- * Varien_Object using the parameter names in English
168
  *
169
  * @param stdClass $data
170
  * @return Varien_Object
18
  */
19
  public function __construct()
20
  {
21
+ $this->_client = new SoapClient(self::WSDL_URL, array(
22
+ 'trace' => true,
23
+ 'exceptions' => true,
24
+ 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
25
+ 'connection_timeout' => ini_get('max_execution_timeout')
26
+ ));
27
+
28
+ $this->setParam('nCdEmpresa', $this->_getHelper()->getConfigData('account_code'))
29
+ ->setParam('sDsSenha', $this->_getHelper()->getConfigData('account_password'))
30
+ ->setParam('nCdServico', $this->_getHelper()->getConfigData('shipping_methods'))
31
+ ->setParam('sCepOrigem', Mage::getStoreConfig('shipping/origin/postcode'));
32
  }
33
 
34
  /**
164
 
165
  /**
166
  * Converts the data returned from webservice to the object
167
+ * Varien_Object using the parameter names in English
168
  *
169
  * @param stdClass $data
170
  * @return Varien_Object
app/code/community/Storm/Correios/etc/config.xml CHANGED
@@ -11,7 +11,7 @@
11
  <config>
12
  <modules>
13
  <Storm_Correios>
14
- <version>1.0.0</version>
15
  </Storm_Correios>
16
  </modules>
17
 
@@ -94,6 +94,7 @@
94
  <name>Correios</name>
95
  <title>Correios</title>
96
  <debug_mode>0</debug_mode>
 
97
  <free_shipping_method>no-free-shipping</free_shipping_method>
98
  </correios>
99
  </carriers>
11
  <config>
12
  <modules>
13
  <Storm_Correios>
14
+ <version>1.0.2</version>
15
  </Storm_Correios>
16
  </modules>
17
 
94
  <name>Correios</name>
95
  <title>Correios</title>
96
  <debug_mode>0</debug_mode>
97
+ <showmethod>1</showmethod>
98
  <free_shipping_method>no-free-shipping</free_shipping_method>
99
  </correios>
100
  </carriers>
app/code/community/Storm/Correios/etc/system.xml CHANGED
@@ -12,8 +12,9 @@
12
  <sections>
13
  <carriers>
14
  <groups>
15
- <correios translate="label" module="correios">
16
  <label>Correios</label>
 
17
  <frontend_type>text</frontend_type>
18
  <sort_order>1</sort_order>
19
  <show_in_default>1</show_in_default>
12
  <sections>
13
  <carriers>
14
  <groups>
15
+ <correios translate="label comment" module="correios">
16
  <label>Correios</label>
17
+ <comment><![CDATA[Se você tem dúvidas de como configurar o módulo acesse a <a href="https://bitbucket.org/willcs/correios/wiki/" target="_blank">Wiki</a>.]]></comment>
18
  <frontend_type>text</frontend_type>
19
  <sort_order>1</sort_order>
20
  <show_in_default>1</show_in_default>
app/locale/pt_BR/Storm_Correios.csv CHANGED
@@ -6,7 +6,7 @@
6
  "Free shipping method","Método de entrega gratuíta"
7
  "With debug mode enabled you can get all the messages sent by the module. To analyze the log file located in the open var/log/correios.log. For this role you must have enabled the Log localizated in System> Configuration> Developer> Log","Com o modo de depuração habilitado é possível obter todas as mensagens enviadas pelo módulo. Para analisar o log abra o arquivo localizado em var/log/correios.log. Para esta função é necessário que você tenha habilitado a opção Log localizada em Sistema > Configuração > Desenvolvedor > Log."
8
  "You must configure the source address of delivery.","Você deve configurar a origem de entrega."
9
- "The Correios module accepts deliveries only national, so the home country of delivery must be configured to Brazil. Do not forget to set the postcode too.","O módulo dos Correios aceita apenas entregas nacionais, portanto o país de origem da entrega deve ser configurado para Brasil. Não se esqueça de configurar o cep também."
10
  "Choose by lowest price","Escolher pelo menor preço"
11
  "Choose shipping methods you want to show at checkout. If you select the methods you need to contract with the filling of your account information from Correios.","Escolha os métodos de entrega que você deseja mostrar no check-out. Se você selecionar os métodos que precisam de contrato é necessário o preenchimento das informações da sua conta do Correios."
12
  "Debug mode","Modo de depuração"
@@ -21,7 +21,7 @@
21
  "The heigth of the products is greater than %d cm","A altura dos produtos é maior do que %d cm"
22
  "The length of the products is greater than %d cm","O comprimento dos produtos é maior do que %d cm"
23
  "The dimensions of the products have passed the limit of of %d cm","As dimensões dos produtos passaram do limite de %d cm"
24
- "%s - delivery time %d day(s)","%s - prazo de entrega %d dia(s)"
25
  "Please, enter the postcode correctly.","Por favor, digite o código postal corretamente"
26
  "The package weight exceeds the weight limit.","O peso do pacote excede o peso limite."
27
  "Show method if not applicable","Mostrar método se não aplicável"
@@ -37,4 +37,6 @@
37
  "Enabled","Habilitado"
38
  "Yes","Sim"
39
  "No","Não"
40
- "This value will be added on final price of shipping","Este valor será adicionado no preço final do frete"
 
 
6
  "Free shipping method","Método de entrega gratuíta"
7
  "With debug mode enabled you can get all the messages sent by the module. To analyze the log file located in the open var/log/correios.log. For this role you must have enabled the Log localizated in System> Configuration> Developer> Log","Com o modo de depuração habilitado é possível obter todas as mensagens enviadas pelo módulo. Para analisar o log abra o arquivo localizado em var/log/correios.log. Para esta função é necessário que você tenha habilitado a opção Log localizada em Sistema > Configuração > Desenvolvedor > Log."
8
  "You must configure the source address of delivery.","Você deve configurar a origem de entrega."
9
+ "The Correios module accepts deliveries only national, so the home country of delivery must be configured to Brazil. Do not forget to set the postcode too.","O módulo dos Correios aceita apenas entregas nacionais, portanto o país de origem da entrega deve ser configurado para Brasil. Não se esqueça de configurar o CEP também."
10
  "Choose by lowest price","Escolher pelo menor preço"
11
  "Choose shipping methods you want to show at checkout. If you select the methods you need to contract with the filling of your account information from Correios.","Escolha os métodos de entrega que você deseja mostrar no check-out. Se você selecionar os métodos que precisam de contrato é necessário o preenchimento das informações da sua conta do Correios."
12
  "Debug mode","Modo de depuração"
21
  "The heigth of the products is greater than %d cm","A altura dos produtos é maior do que %d cm"
22
  "The length of the products is greater than %d cm","O comprimento dos produtos é maior do que %d cm"
23
  "The dimensions of the products have passed the limit of of %d cm","As dimensões dos produtos passaram do limite de %d cm"
24
+ "%s - %d working day(s)","%s - %d dia(s) útil(eis)"
25
  "Please, enter the postcode correctly.","Por favor, digite o código postal corretamente"
26
  "The package weight exceeds the weight limit.","O peso do pacote excede o peso limite."
27
  "Show method if not applicable","Mostrar método se não aplicável"
37
  "Enabled","Habilitado"
38
  "Yes","Sim"
39
  "No","Não"
40
+ "This value will be added on final price of shipping","Este valor será adicionado no preço final do frete"
41
+ "The extension of PHP Soap must be installed so that the module Correios to function properly.","A extensão do PHP Soap deve estar instalada para que o módulo dos Correios funcione corretamente."
42
+ "You must to install PHP Soap extension to use shipping method Correios.","Você deve instalar a extensão Soap do PHP para usar o método de entrega dos Correios."
package.xml CHANGED
@@ -1,42 +1,44 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>correios</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Module for calculating the value and estimated time of shipping using Webservice of Correios.</summary>
10
- <description>New Correios module developed for version 1.7 with good programming practices.&#xD;
11
- The module offers the following services to the calculation option without a contract to the Correios:&#xD;
12
  &#xD;
13
  - Sedex&#xD;
14
- - Sedex to charge&#xD;
15
  - Sedex 10&#xD;
16
- - Sedex today&#xD;
17
  - Pac&#xD;
18
  &#xD;
19
- The following delivery services are available with contract:&#xD;
20
  &#xD;
21
  - Sedex&#xD;
22
- - Sedex to charge&#xD;
23
  - Pac&#xD;
24
- - E-Sedex&#xD;
25
- - E-Sedex priority&#xD;
26
- - E-Sedex Express&#xD;
27
  &#xD;
28
- Functions of the module:&#xD;
29
  &#xD;
30
- * Tracker object in real time&#xD;
31
- * Choose the method of free shipping smart (following promotion rules)&#xD;
32
- * Possibility of adding days to the delivery time&#xD;
33
- * Easy translation of all messages&#xD;
34
- * Easy setup and intuitive</description>
35
- <notes>Fixed package configuration.</notes>
 
 
36
  <authors><author><name>Willian</name><user>willsouza</user><email>williancordeirodesouza@gmail.com</email></author></authors>
37
- <date>2013-04-22</date>
38
- <time>00:58:20</time>
39
- <contents><target name="magecommunity"><dir name="Storm"><dir name="Correios"><dir name="Helper"><file name="Data.php" hash="c0344a3cccf20787f115b24cacef68b7"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="de0eb1c320ea20a33a886f8604534df0"/></dir><dir name="Carrier"><dir name="Package"><file name="Dimension.php" hash="88d12d19a36e753c94f30c08431e9c45"/></dir><dir name="Shipping"><file name="Tracking.php" hash="6eb85dafb65d4d35bbf36a609905aae7"/></dir><file name="Shipping.php" hash="f37dd71f8c4c4e35fe74b37533dd4fa2"/><file name="Webservice.php" hash="ad74799301196fda9912c1b0da90b1be"/></dir><dir name="Catalog"><dir name="Resource"><file name="Setup.php" hash="833a10b8bc912d3df9818f3b0f86d442"/></dir></dir><dir name="Source"><file name="FreeMethods.php" hash="67646bf270c42fa6fa8b79de336236b3"/><file name="Methods.php" hash="d9118016fe15471f813682385c95a93b"/></dir></dir><dir name="etc"><file name="config.xml" hash="459c9d8eb169ee8f5491570f5d444cc1"/><file name="system.xml" hash="34f656f3890f57add112722e0cd93580"/></dir><dir name="sql"><dir name="correios_setup"><file name="mysql4-install-0.1.0.php" hash="dca339c0e46e4b9d116bc1eea9d09930"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Storm_Correios.csv" hash="028e3c6fd7e8192fde8ba836801de613"/></dir></target><target name="mageetc"><dir name="modules"><file name="Storm_Correios.xml" hash="93aa3a9938657131b77fa2a2e60abd71"/></dir></target></contents>
40
  <compatible/>
41
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Shipping</name><channel>magento-core</channel><min></min><max></max></package></required></dependencies>
42
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>correios</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>M&#xF3;dulo para o c&#xE1;lculo do valor e tempo estimado de transporte usando Webservice de Correios.</summary>
10
+ <description>Novo m&#xF3;dulo dos correios desenvolvido para a vers&#xE3;o 1.7 com boas pr&#xE1;ticas de programa&#xE7;&#xE3;o.&#xD;
11
+ O m&#xF3;dulo conta com os seguintes servi&#xE7;os para a op&#xE7;&#xE3;o de c&#xE1;lculo sem contrato com os Correios:&#xD;
12
  &#xD;
13
  - Sedex&#xD;
14
+ - Sedex a cobrar&#xD;
15
  - Sedex 10&#xD;
16
+ - Sedex hoje&#xD;
17
  - Pac&#xD;
18
  &#xD;
19
+ Os seguintes servi&#xE7;os de entrega est&#xE3;o dispon&#xED;veis com contrato:&#xD;
20
  &#xD;
21
  - Sedex&#xD;
22
+ - Sedex a cobrar&#xD;
23
  - Pac&#xD;
24
+ - e-Sedex&#xD;
25
+ - e-Sedex priorit&#xE1;rio&#xD;
26
+ - e-Sedex express&#xD;
27
  &#xD;
28
+ Fun&#xE7;&#xF5;es do m&#xF3;dulo:&#xD;
29
  &#xD;
30
+ * Rastreador de objeto em tempo real&#xD;
31
+ * Escolha do m&#xE9;todo de frete gr&#xE1;tis inteligente ( segue regras de promo&#xE7;&#xE3;o )&#xD;
32
+ * Possibilidade de adicionar dias ao prazo de entrega&#xD;
33
+ * F&#xE1;cil tradu&#xE7;&#xE3;o de todas as mensagens&#xD;
34
+ * Configura&#xE7;&#xE3;o f&#xE1;cil e intu&#xED;tiva</description>
35
+ <notes>* Verifica&#xE7;&#xE3;o da extens&#xE3;o PHP Soap&#xD;
36
+ * Melhorada mensagem de prazo de entrega&#xD;
37
+ * Adicionado link para wiki nas configura&#xE7;&#xF5;es</notes>
38
  <authors><author><name>Willian</name><user>willsouza</user><email>williancordeirodesouza@gmail.com</email></author></authors>
39
+ <date>2013-04-25</date>
40
+ <time>23:00:54</time>
41
+ <contents><target name="magecommunity"><dir name="Storm"><dir name="Correios"><dir name="Helper"><file name="Data.php" hash="c0344a3cccf20787f115b24cacef68b7"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="3e2d7ae7abb9dc2131f2a7868fd89d87"/></dir><dir name="Carrier"><dir name="Package"><file name="Dimension.php" hash="88d12d19a36e753c94f30c08431e9c45"/></dir><dir name="Shipping"><file name="Tracking.php" hash="6eb85dafb65d4d35bbf36a609905aae7"/></dir><file name="Shipping.php" hash="0e935cf432af23d09cec5223eea8e786"/><file name="Webservice.php" hash="79c7b0d57285e94b82b1c47521da3675"/></dir><dir name="Catalog"><dir name="Resource"><file name="Setup.php" hash="833a10b8bc912d3df9818f3b0f86d442"/></dir></dir><dir name="Source"><file name="FreeMethods.php" hash="67646bf270c42fa6fa8b79de336236b3"/><file name="Methods.php" hash="d9118016fe15471f813682385c95a93b"/></dir></dir><dir name="etc"><file name="config.xml" hash="98fa5dc22a115d1871a0ceef7c6b0c82"/><file name="system.xml" hash="18357e3ea97d3d5518e2e0b974037941"/></dir><dir name="sql"><dir name="correios_setup"><file name="mysql4-install-0.1.0.php" hash="dca339c0e46e4b9d116bc1eea9d09930"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Storm_Correios.csv" hash="2c9c04ccf7044d8f0ed9c93f314d47bc"/></dir></target><target name="mageetc"><dir name="modules"><file name="Storm_Correios.xml" hash="93aa3a9938657131b77fa2a2e60abd71"/></dir></target></contents>
42
  <compatible/>
43
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
44
  </package>