Skip to content

Commit

Permalink
Merge pull request #32 from logeecom/dev
Browse files Browse the repository at this point in the history
Release v3.1.1
  • Loading branch information
logeecom authored Dec 22, 2020
2 parents 1bf9d72 + b5dd71c commit 6871d32
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 3 deletions.
Binary file modified PluginInstallation/3.1.0/packlink.zip
Binary file not shown.
Binary file added PluginInstallation/3.1.1/packlink.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions PluginInstallation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [3.1.1](https://github.com/packlink-dev/prestashop_module/compare/v3.1.0...v3.1.1)
### Added
- Added a migration script that converts all string values within the default parcel to number.

## [3.1.0](https://github.com/packlink-dev/prestashop_module/compare/v3.0.4...v3.1.0)
### Added
- Added compatibility with PrestaShop version 1.7.7.
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Utility/PacklinkInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ private function addHooks()
*
* @return array
*/
private function getAdditionalHooks() {
private function getAdditionalHooks()
{
return array(
'actionAdminControllerSetMedia',
'actionOrderGridDefinitionModifier',
Expand Down
2 changes: 1 addition & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "packlink/prestashop",
"description": "Packlink Shipping PrestaShop plugin",
"type": "library",
"version": "3.1.0",
"version": "3.1.1",
"repositories": [
{
"type": "vcs",
Expand Down
2 changes: 1 addition & 1 deletion src/packlink.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct()
$this->module_key = 'a7a3a395043ca3a09d703f7d1c74a107';
$this->name = 'packlink';
$this->tab = 'shipping_logistics';
$this->version = '3.1.0';
$this->version = '3.1.1';
$this->author = $this->l('Packlink Shipping S.L.');
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.6.0.14', 'max' => _PS_VERSION_);
Expand Down
52 changes: 52 additions & 0 deletions src/upgrade/upgrade-3.1.1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

if (!defined('_PS_VERSION_')) {
exit;
}

/**
* Updates module to version 3.1.1.
*
* @return boolean
*
* @noinspection PhpUnused
*/
function upgrade_module_3_1_1()
{
$query = new \DbQuery();
$query->select('id, data')
->from(bqSQL('packlink_entity'))
->where('index_1="defaultParcel"');

$records = \Db::getInstance()->executeS($query);
foreach ($records as $record) {
if (empty($record)) {
continue;
}

$data = json_decode($record['data'], true);
if (!empty($data['value']['weight'])) {
$weight = (float)$data['value']['weight'];
$data['value']['weight'] = !empty($weight) ? $weight : 1;
}

foreach (array('length', 'height', 'width') as $field) {
if (!empty($data['value'][$field])) {
$fieldValue = (int)$data['value'][$field];
$data['value'][$field] = !empty($fieldValue) ? $fieldValue : 10;
}
}

if (!empty($record['id'])) {
\Db::getInstance()->update(
'packlink_entity',
array(
'data' => pSQL(json_encode($data), true)
),
'`id` = ' . $record['id']
);
}
}

return true;
}

0 comments on commit 6871d32

Please sign in to comment.