From 63f625b32908cacf3d35cd8d0f9958b39dc3b3eb Mon Sep 17 00:00:00 2001 From: Ivan Chaplygin Date: Mon, 3 Jul 2023 17:15:00 +0300 Subject: [PATCH 1/2] ref #73045 Changing the weight transfer when generating a catalog --- CHANGELOG.md | 3 ++ VERSION | 2 +- .../admin/model/extension/retailcrm/icml.php | 31 +++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1437e5c..507b5c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v4.1.11 +* Fixed the transfer of the weight of trade offers + ## v4.1.10 * Types of deliveries and payments are displayed only active status and available stores diff --git a/VERSION b/VERSION index 5d30083..152e452 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.10 +4.1.11 diff --git a/src/upload/admin/model/extension/retailcrm/icml.php b/src/upload/admin/model/extension/retailcrm/icml.php index 9aa970b..f668874 100644 --- a/src/upload/admin/model/extension/retailcrm/icml.php +++ b/src/upload/admin/model/extension/retailcrm/icml.php @@ -22,6 +22,7 @@ class ModelExtensionRetailcrmIcml extends Model { parent::__construct($registry); $this->load->library('retailcrm/retailcrm'); + $this->load->model('localisation/weight_class'); } public function generateICML() @@ -107,6 +108,12 @@ class ModelExtensionRetailcrmIcml extends Model $defaultCurrency = $this->getDefaultCurrency(); $settingLenght = $this->retailcrm->getLenghtForIcml(); $leghtsArray = $this->model_localisation_length_class->getLengthClasses(); + $weightClassesMas = $this->model_localisation_weight_class->getWeightClasses(); + $weightClasses = []; + + foreach ($weightClassesMas as $weightClass) { + $weightClasses[$weightClass['weight_class_id']]['value'] = $weightClass['value']; + } foreach ($leghtsArray as $lenght) { if ($lenght['value'] == 1) { @@ -309,17 +316,23 @@ class ModelExtensionRetailcrmIcml extends Model $e->appendChild($sku); } if ($product['weight'] != '') { - $weight = $this->dd->createElement('param'); - $weight->setAttribute('code', 'weight'); - $weight->setAttribute('name', $this->language->get('weight')); - if (!empty($optionsValues['weight'])) { - $weightValue = round($product['weight'] + $optionsValues['weight'], 3); - } else { - $weightValue = round($product['weight'], 3); + $weight = $this->dd->createElement('weight'); + $coeffWeight = 1; + + if ( + !empty($weightClasses[$product['weight_class_id']]['value']) + && $weightClasses[$product['weight_class_id']]['value'] !== 0 + ) { + $coeffWeight = $weightClasses[$product['weight_class_id']]['value']; } - if (isset($product['weight_class'])) { - $weightValue = $weightValue . ' ' . $product['weight_class']; + if (!empty($optionsValues['weight'])) { + $weightValue = round( + ($product['weight'] + $optionsValues['weight'])/$coeffWeight, + 6 + ); + } else { + $weightValue = round($product['weight']/$coeffWeight, 6); } $weight->appendChild($this->dd->createTextNode($weightValue)); From a2a4eca8c726d81874a9350e586360f4257cd60a Mon Sep 17 00:00:00 2001 From: Ivan Chaplygin Date: Tue, 4 Jul 2023 14:38:35 +0300 Subject: [PATCH 2/2] ref #73045 fix code --- CHANGELOG.md | 2 +- .../admin/model/extension/retailcrm/icml.php | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 507b5c6..fefe311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## v4.1.11 -* Fixed the transfer of the weight of trade offers +* Fixed the transfer of the weight offers ## v4.1.10 * Types of deliveries and payments are displayed only active status and available stores diff --git a/src/upload/admin/model/extension/retailcrm/icml.php b/src/upload/admin/model/extension/retailcrm/icml.php index f668874..4fd07ca 100644 --- a/src/upload/admin/model/extension/retailcrm/icml.php +++ b/src/upload/admin/model/extension/retailcrm/icml.php @@ -319,21 +319,15 @@ class ModelExtensionRetailcrmIcml extends Model $weight = $this->dd->createElement('weight'); $coeffWeight = 1; - if ( - !empty($weightClasses[$product['weight_class_id']]['value']) - && $weightClasses[$product['weight_class_id']]['value'] !== 0 - ) { + if (!empty($weightClasses[$product['weight_class_id']]['value'])) { $coeffWeight = $weightClasses[$product['weight_class_id']]['value']; } - if (!empty($optionsValues['weight'])) { - $weightValue = round( - ($product['weight'] + $optionsValues['weight'])/$coeffWeight, - 6 - ); - } else { - $weightValue = round($product['weight']/$coeffWeight, 6); - } + $weightValue = !empty($optionsValues['weight']) + ? $product['weight'] + $optionsValues['weight'] + : $product['weight'] + ; + $weightValue = round($weightValue / $coeffWeight, 6); $weight->appendChild($this->dd->createTextNode($weightValue)); $e->appendChild($weight);