Skip to content

Commit

Permalink
Merge pull request #68 from pedro-teixeira/issue/68-preparar-v4.4.0
Browse files Browse the repository at this point in the history
Preparar para release da versão v4.4.0
  • Loading branch information
pedro-teixeira committed Mar 30, 2015
2 parents 03ed7c5 + bb4866d commit 1173743
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 153 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
# NEXT RELEASE
# v4.4.0

### Bugfix

- [#26](https://github.com/pedro-teixeira/correios/issues/26) Usar atributo para setar o carrier name e passar o encoding para htmlentities
- [#59](https://github.com/pedro-teixeira/correios/issues/59) Erro 99 Input string was not in a correct format
- [#42](https://github.com/pedro-teixeira/correios/issues/42) Peso Cúbico não Calculado no Backend
- [#40](https://github.com/pedro-teixeira/correios/issues/40) Corrige a leitura do valor de frete
- [#32](https://github.com/pedro-teixeira/correios/issues/32) Frete de mil reais exibido por 1 real
- [#21](https://github.com/pedro-teixeira/correios/issues/21) Problema com peso do eSEDEX

### Feature

- [#14](https://github.com/pedro-teixeira/correios/issues/14) Adiciona CONTRIBUTING.md
- [#7](https://github.com/pedro-teixeira/correios/issues/7) Adiciona badges
- [#5](https://github.com/pedro-teixeira/correios/issues/5) Integração com Travis
- [#50](https://github.com/pedro-teixeira/correios/issues/50) Testado em Magento 1.9.1.0
- [#47](https://github.com/pedro-teixeira/correios/issues/47) Serviços por Produto, Validação por Serviço, Grandes Formatos, Carta Registrada, Cache
- [#46](https://github.com/pedro-teixeira/correios/issues/46) Considerar Produtos Encaixados
- [#45](https://github.com/pedro-teixeira/correios/issues/45) Adicionar PAC Grandes Formatos aos Serviços de Postagem
- [#43](https://github.com/pedro-teixeira/correios/issues/43) Validação de Peso e Dimensões
- [#39](https://github.com/pedro-teixeira/correios/issues/39) Selecionar Serviços por Produto
- [#35](https://github.com/pedro-teixeira/correios/issues/35) Added support for modman installations
- [#17](https://github.com/pedro-teixeira/correios/issues/17) Integrar carta registrada
- [#16](https://github.com/pedro-teixeira/correios/issues/16) Implementar cache de respostas dos Coreios
- [#15](https://github.com/pedro-teixeira/correios/issues/15) Opção de dividir a entrega em mais de um pacote

# v4.3.0

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2010-2014 Pedro Teixeira <http://pedroteixeira.io>
Copyright (c) 2010-2015 Pedro Teixeira <http://pedroteixeira.io>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Caso você prefira fazer a instalação manual, basta baixar a última versão d
- <a href="#cache">Atualize o cache</a>
- Se você utiliza Flat Table, <a href="#flattable">atualize sua Flat Table</a>

## Instalando com [modman](https://github.com/colinmollenhour/modman):
## Instalando com [modman](https://github.com/colinmollenhour/modman)

$ cd /path/to/magento
$ modman init
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/PedroTeixeira/Correios/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @category PedroTeixeira
* @package PedroTeixeira_Correios
* @author Pedro Teixeira <hello@pedroteixeira.io>
* @copyright 2014 Pedro Teixeira (http://pedroteixeira.io)
* @copyright 2015 Pedro Teixeira (http://pedroteixeira.io)
* @license http://opensource.org/licenses/MIT MIT
* @link https://github.com/pedro-teixeira/correios
*/
Expand Down
88 changes: 44 additions & 44 deletions app/code/community/PedroTeixeira/Correios/Model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @category PedroTeixeira
* @package PedroTeixeira_Correios
* @author Pedro Teixeira <hello@pedroteixeira.io>
* @copyright 2014 Pedro Teixeira (http://pedroteixeira.io)
* @copyright 2015 Pedro Teixeira (http://pedroteixeira.io)
* @license http://opensource.org/licenses/MIT MIT
* @link https://github.com/pedro-teixeira/correios
*/
Expand All @@ -20,14 +20,14 @@ class PedroTeixeira_Correios_Model_Cache
* @var string
*/
protected $_code = 'pedroteixeira_correios';

/**
* Core cache instance
*
*
* @var Zend_Cache_Core
*/
private $_cache = null;

/**
* Retrieve cache instance.
*
Expand All @@ -50,43 +50,43 @@ protected function getZipTags()
{
$padLength = $this->getConfigData('cache_accuracy/zip');
$zipLength = $padLength - 1;
$tags = array();
$tags[] = "ZIP_".str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags[] = "ZIP_".str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags[] = "ZIP_".str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags[] = "ZIP_".str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags = array();
$tags[] = "ZIP_" . str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags[] = "ZIP_" . str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags[] = "ZIP_" . str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
$tags[] = "ZIP_" . str_pad(substr($this->getData('sCepDestino'), 0, $zipLength--), $padLength, '0');
return $tags;
}

/**
* Retrieve Weight Tags
*
* @return array
*/
protected function getWeightTags()
{
$tags = array();
$tags[] = "WEIGHT_".floor($this->getData('nVlPeso'));
$tags[] = "WEIGHT_".ceil($this->getData('nVlPeso'));
$tags = array();
$tags[] = "WEIGHT_" . floor($this->getData('nVlPeso'));
$tags[] = "WEIGHT_" . ceil($this->getData('nVlPeso'));
return $tags;
}

/**
* Retrieve Size Tags
*
* @return array
*/
protected function getSizeTags()
{
$tags = array();
$type = ($this->getData('nVlAltura') < 40) ? 'REAL' : 'UNDEFINED';
$tags = array();
$type = ($this->getData('nVlAltura') < 40) ? 'REAL' : 'UNDEFINED';
$tags[] = "SIZE_{$type}";
return $tags;
}

/**
* Retrieve Post Methods Tags
*
*
* @return array
*/
protected function getPostMethodsTags()
Expand Down Expand Up @@ -118,18 +118,18 @@ protected function getPostMethodsTags()
*/
protected function getCacheTags()
{
$tags = array();
$tags = array_merge($tags, $this->getPostMethodsTags());
$tags = array_merge($tags, $this->getZipTags());
$tags = array_merge($tags, $this->getWeightTags());
$tags = array_merge($tags, $this->getSizeTags());
$tags = array();
$tags = array_merge($tags, $this->getPostMethodsTags());
$tags = array_merge($tags, $this->getZipTags());
$tags = array_merge($tags, $this->getWeightTags());
$tags = array_merge($tags, $this->getSizeTags());
$tags[] = 'PEDROTEIXEIRA_CORREIOS';
return $tags;
}

/**
* Return example:
* 41068x40096x81019_10_16_51030240
* 41068x40096x81019_10_16_51030240
*
* @return string
*/
Expand All @@ -143,7 +143,7 @@ protected function _getId()
$cacheId = preg_replace("/[^[:alnum:]^_]/", "", $cacheId);
return $cacheId;
}

/**
* Retrieve the cache content.
*
Expand All @@ -152,7 +152,7 @@ protected function _getId()
public function load()
{
$data = $this->loadById();
if ( !$data ) {
if (!$data) {
$data = $this->loadByTags();
}
return $data;
Expand All @@ -165,32 +165,32 @@ public function load()
*/
public function loadById()
{
$id = $this->_getId();
$id = $this->_getId();
$data = $this->getCache()->load($id);
if ( $data ) {
if ($data) {
Mage::log("{$this->_code} [cache]: mode={$this->getConfigData('cache_mode')} status=hit");
}
return $data;
}

/**
* Iterates over the ZIP codes, and returns the closest match.
*
* @return string
*/
public function loadByTags()
{
$data = false;
$data = false;
$padLength = $this->getConfigData('cache_accuracy/zip');
for ($i=1; $i<5; $i++) {
$zipTag = str_pad(substr($this->getData('sCepDestino'), 0, $padLength-$i), $padLength, '0');
$tags = array();
$tags = array_merge($tags, $this->getPostMethodsTags());
$tags = array_merge($tags, $this->getWeightTags());
$tags = array_merge($tags, $this->getSizeTags());
for ($i = 1; $i < 5; $i++) {
$zipTag = str_pad(substr($this->getData('sCepDestino'), 0, $padLength - $i), $padLength, '0');
$tags = array();
$tags = array_merge($tags, $this->getPostMethodsTags());
$tags = array_merge($tags, $this->getWeightTags());
$tags = array_merge($tags, $this->getSizeTags());
$tags[] = 'PEDROTEIXEIRA_CORREIOS';
$tags[] = "ZIP_{$zipTag}";
$keys = $this->getCache()->getIdsMatchingTags($tags);
$keys = $this->getCache()->getIdsMatchingTags($tags);
if (count($keys)) {
Mage::log("{$this->_code} [cache]: mode={$this->getConfigData('cache_mode')} status=hit tag=zip");
$data = $this->getCache()->load($keys[0]);
Expand All @@ -210,8 +210,8 @@ public function loadByTags()
protected function _isValidCache($data)
{
$response = Zend_Http_Response::fromString($data);
$content = $response->getBody();
$pattern = $this->getConfigData('pattern_nocache');
$content = $response->getBody();
$pattern = $this->getConfigData('pattern_nocache');
if ($pattern != '' && preg_match($pattern, $content, $matches)) {
return false;
}
Expand All @@ -225,7 +225,7 @@ protected function _isValidCache($data)
}
return true;
}

/**
* Save Correios content, tags and expiration period.
*
Expand All @@ -240,27 +240,27 @@ public function save($data)
if (!$this->_isValidCache($data)) {
return false; // Invalid for the Cache only
}
$id = $this->_getId();
$id = $this->_getId();
$tags = $this->getCacheTags();
if ($this->getCache()->save($data, $id, $tags)) {
Mage::log("{$this->_code} [cache]: mode={$this->getConfigData('cache_mode')} status=write key={$id}");
}
return $this;
}

/**
* Retrieve information from carrier configuration
*
* @param string $field Field
*
*
* @return mixed
*/
public function getConfigData($field)
{
if (empty($this->_code)) {
return false;
}
$path = 'carriers/'.$this->_code.'/'.$field;
$path = 'carriers/' . $this->_code . '/' . $field;
return Mage::getStoreConfig($path);
}
}
Loading

0 comments on commit 1173743

Please sign in to comment.