From 6790cf7b0ef9aa2ee5eaddfc6d4ec0664f9a7948 Mon Sep 17 00:00:00 2001 From: Vlad <48670792+Mozgito@users.noreply.github.com> Date: Fri, 1 Apr 2022 13:14:34 +0300 Subject: [PATCH] Minor improvements * Fix country iso code * Fix ICML weight generation * Update phpcs rules to php >= 7.3 --- Makefile | 2 +- src/upload/admin/model/extension/retailcrm/icml.php | 6 +++++- src/upload/catalog/controller/api/retailcrm.php | 4 ++-- .../system/library/retailcrm/lib/api/OpencartApiClient.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 664aa44..e0147d5 100644 --- a/Makefile +++ b/Makefile @@ -46,4 +46,4 @@ phpcs-config: bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility phpcomp: phpcs-config - @bin/phpcs -s -p ./src --standard=PHPCompatibility --runtime-set testVersion 5.4-7.3 + @bin/phpcs -s -p ./src --standard=PHPCompatibility --runtime-set testVersion 7.3-7.4 diff --git a/src/upload/admin/model/extension/retailcrm/icml.php b/src/upload/admin/model/extension/retailcrm/icml.php index bcae0e8..9aa970b 100644 --- a/src/upload/admin/model/extension/retailcrm/icml.php +++ b/src/upload/admin/model/extension/retailcrm/icml.php @@ -312,7 +312,11 @@ class ModelExtensionRetailcrmIcml extends Model $weight = $this->dd->createElement('param'); $weight->setAttribute('code', 'weight'); $weight->setAttribute('name', $this->language->get('weight')); - $weightValue = round($product['weight'] + $optionsValues['weight'], 3); + if (!empty($optionsValues['weight'])) { + $weightValue = round($product['weight'] + $optionsValues['weight'], 3); + } else { + $weightValue = round($product['weight'], 3); + } if (isset($product['weight_class'])) { $weightValue = $weightValue . ' ' . $product['weight_class']; diff --git a/src/upload/catalog/controller/api/retailcrm.php b/src/upload/catalog/controller/api/retailcrm.php index 35fb491..0d88cc6 100644 --- a/src/upload/catalog/controller/api/retailcrm.php +++ b/src/upload/catalog/controller/api/retailcrm.php @@ -77,8 +77,8 @@ class ControllerApiRetailcrm extends Controller $address = array( 'country_id' => $country_id, 'zone_id' => $zone['zone_id'], - 'iso_code_2' => $country['iso_code_2'], - 'iso_code_3' => $country['iso_code_3'], + 'iso_code_2' => $country['iso_code_2'] ?? '', + 'iso_code_3' => $country['iso_code_3'] ?? '', 'zone_code' => $zone['code'], 'postcode' => '', 'city' => '' diff --git a/src/upload/system/library/retailcrm/lib/api/OpencartApiClient.php b/src/upload/system/library/retailcrm/lib/api/OpencartApiClient.php index 8f92be2..adec79a 100644 --- a/src/upload/system/library/retailcrm/lib/api/OpencartApiClient.php +++ b/src/upload/system/library/retailcrm/lib/api/OpencartApiClient.php @@ -31,7 +31,7 @@ class OpencartApiClient { $cookies = array(); foreach ($cookieFile as $line) { - if (empty($line) OR $line{0} == '#') { + if (empty($line) OR $line[0] == '#') { continue; }