From c893cf24fb2e3038163a68336c5a8ad106b77c58 Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Mon, 6 May 2024 09:07:38 +0300 Subject: [PATCH] ref #95381 Support for services in ICML (#265) --- CHANGELOG.md | 3 + VERSION | 2 +- .../controller/extension/module/retailcrm.php | 6 +- .../en-gb/extension/module/retailcrm.php | 8 ++- .../es-es/extension/module/retailcrm.php | 9 ++- .../ru-ru/extension/module/retailcrm.php | 8 ++- .../admin/model/extension/retailcrm/icml.php | 69 +++++++++++-------- .../admin/view/stylesheet/retailcrm.css | 8 ++- .../template/extension/module/retailcrm.tpl | 20 ++++-- .../template/extension/module/retailcrm.twig | 36 +++++++--- .../system/library/retailcrm/retailcrm.php | 9 +++ 11 files changed, 121 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f230e9a..27ae50c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v4.1.16 +* Support for services in ICML + ## v4.1.15 * Display module version diff --git a/VERSION b/VERSION index 796262d..1b94a07 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.15 +4.1.16 diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index b4d501c..d664c75 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -2,7 +2,7 @@ class ControllerExtensionModuleRetailcrm extends Controller { - const VERSION_MODULE = '4.1.15'; + const VERSION_MODULE = '4.1.16'; private $_error = []; protected $log, $statuses, $payments, $deliveryTypes, $retailcrmApiClient, $moduleTitle, $tokenTitle; @@ -301,7 +301,9 @@ class ControllerExtensionModuleRetailcrm extends Controller 'special_price', 'order_number', 'text_order_number', - 'text_currency', + 'icml_settings', + 'icml_service_enabled_label', + 'icml_service_description', 'text_currency_label', 'status_changes', 'text_status_changes', diff --git a/src/upload/admin/language/en-gb/extension/module/retailcrm.php b/src/upload/admin/language/en-gb/extension/module/retailcrm.php index 1f38053..aab7dd4 100644 --- a/src/upload/admin/language/en-gb/extension/module/retailcrm.php +++ b/src/upload/admin/language/en-gb/extension/module/retailcrm.php @@ -72,10 +72,12 @@ $_['retailcrm_missing_status'] = 'Status of lost orders'; $_['order_number'] = 'Order number'; $_['text_order_number'] = 'Upload the order number to RetailCRM'; -$_['text_currency'] = 'Currency setting'; -$_['text_currency_label'] = 'Currency in ICML'; +$_['icml_settings'] = 'ICML settings'; +$_['icml_service_enabled_label'] = 'Upload services in ICML'; +$_['icml_service_description'] = 'When the option is enabled, all products for which delivery is disabled will be considered as services and uploaded to CRM as services'; +$_['text_currency_label'] = 'Currency of goods'; $_['text_lenght'] = 'Setting of the unit of measurement'; -$_['text_lenght_label'] = 'Unit of measurement in ICML'; +$_['text_lenght_label'] = 'Unit of measurement of goods'; $_['status_changes'] = 'History of changes'; $_['text_status_changes'] = 'Record changes to the order history of Opencart'; diff --git a/src/upload/admin/language/es-es/extension/module/retailcrm.php b/src/upload/admin/language/es-es/extension/module/retailcrm.php index dbcaa03..9f88136 100644 --- a/src/upload/admin/language/es-es/extension/module/retailcrm.php +++ b/src/upload/admin/language/es-es/extension/module/retailcrm.php @@ -72,10 +72,13 @@ $_['retailcrm_missing_status'] = 'Estado de pedidos perdidos'; $_['order_number'] = 'Número de pedido'; $_['text_order_number'] = 'Transferir número de pedido a RetailCRM'; -$_['text_currency'] = 'Ajustes de moneda'; -$_['text_currency_label'] = 'Moneda en ICML'; +$_['icml_settings'] = 'Ajustes de ICML'; +$_['icml_service_enabled_label'] = 'Subir servicios de ICML'; +$_['icml_service_description'] = 'Si habilita la opción, todos los productos para los que la entrega está desactivada se tratarán como servicios y se cargarán en CRM como servicios'; + +$_['text_currency_label'] = 'Moneda de bienes'; $_['text_lenght'] = 'Ajustar unidad de medida'; -$_['text_lenght_label'] = 'Unidad de medida en ICML'; +$_['text_lenght_label'] = 'Unidad de medida de bienes'; $_['status_changes'] = 'Historial de cambios'; $_['text_status_changes'] = 'Registrar los cambios en el historial de pedidos de Opencart'; diff --git a/src/upload/admin/language/ru-ru/extension/module/retailcrm.php b/src/upload/admin/language/ru-ru/extension/module/retailcrm.php index 9b2d094..f7e0bd5 100644 --- a/src/upload/admin/language/ru-ru/extension/module/retailcrm.php +++ b/src/upload/admin/language/ru-ru/extension/module/retailcrm.php @@ -72,10 +72,12 @@ $_['retailcrm_missing_status'] = 'Статус пропавших заказо $_['order_number'] = 'Номер заказа'; $_['text_order_number'] = 'Передавать номер заказа в RetailCRM'; -$_['text_currency'] = 'Настройка валюты'; -$_['text_currency_label'] = 'Валюта в ICML'; +$_['icml_settings'] = 'Настройки ICML'; +$_['icml_service_enabled_label'] = 'Выгружать услуги в ICML'; +$_['icml_service_description'] = 'При включении опции все товары, для которых отключена доставка, будут рассматриваться как услуги и загружаться в CRM как услуги'; +$_['text_currency_label'] = 'Валюта товаров'; $_['text_lenght'] = 'Настройка единицы измерения'; -$_['text_lenght_label'] = 'Единица измерения в ICML'; +$_['text_lenght_label'] = 'Единица измерения товаров'; $_['status_changes'] = 'История изменений'; $_['text_status_changes'] = 'Фиксировать изменения в истории заказа Opencart'; diff --git a/src/upload/admin/model/extension/retailcrm/icml.php b/src/upload/admin/model/extension/retailcrm/icml.php index 4fd07ca..5656170 100644 --- a/src/upload/admin/model/extension/retailcrm/icml.php +++ b/src/upload/admin/model/extension/retailcrm/icml.php @@ -15,7 +15,7 @@ class ModelExtensionRetailcrmIcml extends Model /** * Constructor - * + * * @param Registry $registry */ public function __construct($registry) @@ -78,7 +78,7 @@ class ModelExtensionRetailcrmIcml extends Model */ private function addCategories() { - $categories = $this->model_catalog_category->getCategories(array()); + $categories = $this->model_catalog_category->getCategories([]); foreach ($categories as $category) { $category = $this->model_catalog_category->getCategory($category['category_id']); @@ -103,7 +103,8 @@ class ModelExtensionRetailcrmIcml extends Model } private function addOffers() { - $offerManufacturers = array(); + $offerManufacturers = []; + $servicesForIcml = $this->retailcrm->useServicesForIcml(); $currencyForIcml = $this->retailcrm->getCurrencyForIcml(); $defaultCurrency = $this->getDefaultCurrency(); $settingLenght = $this->retailcrm->getLenghtForIcml(); @@ -122,20 +123,20 @@ class ModelExtensionRetailcrmIcml extends Model } $manufacturers = $this->model_catalog_manufacturer - ->getManufacturers(array()); + ->getManufacturers([]); foreach ($manufacturers as $manufacturer) { $offerManufacturers[$manufacturer['manufacturer_id']] = $manufacturer['name']; } - $products = $this->model_catalog_product->getProducts(array()); + $products = $this->model_catalog_product->getProducts([]); foreach ($products as $product) { $offers = $this->retailcrm->getOffers($product); foreach ($offers as $optionsString => $optionsValues) { $optionsString = explode('_', $optionsString); - $options = array(); + $options = []; foreach($optionsString as $optionString) { $option = explode('-', $optionString); @@ -150,35 +151,43 @@ class ModelExtensionRetailcrmIcml extends Model 'value_id' => $option[1], 'option_id' => $optionIds[1] ); - } + } } } ksort($options); - $offerId = array(); + $offerId = []; foreach($options as $optionKey => $optionData) { $offerId[] = $optionKey.'-'.$optionData['value_id']; } $offerId = implode('_', $offerId); - $e = $this->eOffers->appendChild($this->dd->createElement('offer')); + $catalog = $this->eOffers->appendChild($this->dd->createElement('offer')); if (!empty($offerId)) { - $e->setAttribute('id', $product['product_id'] . '#' . $offerId); - $e->setAttribute('productId', $product['product_id']); - $e->setAttribute('quantity', $optionsValues['qty']); + $catalog->setAttribute('id', $product['product_id'] . '#' . $offerId); + $catalog->setAttribute('productId', $product['product_id']); + $catalog->setAttribute('quantity', $optionsValues['qty']); } else { - $e->setAttribute('id', $product['product_id']); - $e->setAttribute('productId', $product['product_id']); - $e->setAttribute('quantity', $product['quantity']); + $catalog->setAttribute('id', $product['product_id']); + $catalog->setAttribute('productId', $product['product_id']); + $catalog->setAttribute('quantity', $product['quantity']); } + + /** + * Set type for offers + */ + $useServices = $servicesForIcml && isset($product['shipping']) && $product['shipping'] == 0; + + $catalog->setAttribute('type', $useServices ? 'service' : 'product'); + /** * Offer activity */ $activity = $product['status'] == 1 ? 'Y' : 'N'; - $e->appendChild( + $catalog->appendChild( $this->dd->createElement('productActivity') )->appendChild( $this->dd->createTextNode($activity) @@ -190,7 +199,7 @@ class ModelExtensionRetailcrmIcml extends Model ->getProductCategories($product['product_id']); if (!empty($categories)) { foreach ($categories as $category) { - $e->appendChild($this->dd->createElement('categoryId')) + $catalog->appendChild($this->dd->createElement('categoryId')) ->appendChild( $this->dd->createTextNode($category) ); @@ -199,18 +208,18 @@ class ModelExtensionRetailcrmIcml extends Model /** * Name & price */ - $e->appendChild($this->dd->createElement('productName')) + $catalog->appendChild($this->dd->createElement('productName')) ->appendChild($this->dd->createTextNode($product['name'])); if (!empty($options)) { - $optionsString = array(); + $optionsString = []; foreach($options as $option) { $optionsString[] = $option['name'].': '.$option['value']; } $optionsString = ' ('.implode(', ', $optionsString).')'; - $e->appendChild($this->dd->createElement('name')) + $catalog->appendChild($this->dd->createElement('name')) ->appendChild($this->dd->createTextNode($product['name'].$optionsString)); } else { - $e->appendChild($this->dd->createElement('name')) + $catalog->appendChild($this->dd->createElement('name')) ->appendChild($this->dd->createTextNode($product['name'])); } @@ -224,13 +233,13 @@ class ModelExtensionRetailcrmIcml extends Model $price = $product['price'] + $optionsValues['price']; } - $e->appendChild($this->dd->createElement('price')) + $catalog->appendChild($this->dd->createElement('price')) ->appendChild($this->dd->createTextNode($price)); /** * Vendor */ if ($product['manufacturer_id'] != 0) { - $e->appendChild($this->dd->createElement('vendor')) + $catalog->appendChild($this->dd->createElement('vendor')) ->appendChild( $this->dd->createTextNode( $offerManufacturers[$product['manufacturer_id']] @@ -271,7 +280,7 @@ class ModelExtensionRetailcrmIcml extends Model $productHeight ); - $e->appendChild($this->dd->createElement('dimensions')) + $catalog->appendChild($this->dd->createElement('dimensions')) ->appendChild($this->dd->createTextNode($dimensions)); } @@ -280,14 +289,14 @@ class ModelExtensionRetailcrmIcml extends Model */ if ($product['image']) { $image = $this->generateImage($product['image']); - $e->appendChild($this->dd->createElement('picture')) + $catalog->appendChild($this->dd->createElement('picture')) ->appendChild($this->dd->createTextNode($image)); } /** * Url */ $this->url = new Url(HTTP_CATALOG, HTTPS_CATALOG); - $e->appendChild($this->dd->createElement('url')) + $catalog->appendChild($this->dd->createElement('url')) ->appendChild( $this->dd->createTextNode( $this->url->link( @@ -305,7 +314,7 @@ class ModelExtensionRetailcrmIcml extends Model $param->setAttribute('code', $optionData['option_id']); $param->setAttribute('name', $optionData['name']); $param->appendChild($this->dd->createTextNode($optionData['value'])); - $e->appendChild($param); + $catalog->appendChild($param); } } if ($product['sku']) { @@ -313,7 +322,7 @@ class ModelExtensionRetailcrmIcml extends Model $sku->setAttribute('code', 'article'); $sku->setAttribute('name', $this->language->get('article')); $sku->appendChild($this->dd->createTextNode($product['sku'])); - $e->appendChild($sku); + $catalog->appendChild($sku); } if ($product['weight'] != '') { $weight = $this->dd->createElement('weight'); @@ -330,7 +339,7 @@ class ModelExtensionRetailcrmIcml extends Model $weightValue = round($weightValue / $coeffWeight, 6); $weight->appendChild($this->dd->createTextNode($weightValue)); - $e->appendChild($weight); + $catalog->appendChild($weight); } } } @@ -343,7 +352,7 @@ class ModelExtensionRetailcrmIcml extends Model private function generateImage($image) { $this->load->model('tool/image'); - + $currentTheme = $this->config->get('config_theme'); $width = $this->config->get($currentTheme . '_image_related_width') ? $this->config->get($currentTheme . '_image_related_width') : 200; $height = $this->config->get($currentTheme . '_image_related_height') ? $this->config->get($currentTheme . '_image_related_height') : 200; diff --git a/src/upload/admin/view/stylesheet/retailcrm.css b/src/upload/admin/view/stylesheet/retailcrm.css index fba27ff..ea9adfa 100644 --- a/src/upload/admin/view/stylesheet/retailcrm.css +++ b/src/upload/admin/view/stylesheet/retailcrm.css @@ -1,5 +1,11 @@ .retailcrm_unit {margin-bottom: 10px;} +.retailcrm_disable_border {border: none !important;} .retailcrm_unit input {width: 30%;} .checkbox input{width: auto;} .retailcrm_unit input[type=checkbox] {width: 13px;} -.retailcrm_unit select {max-width: 500px;} \ No newline at end of file +.retailcrm_unit select {max-width: 500px;} + +.question-mark { + cursor: help; + position: relative; +} \ No newline at end of file diff --git a/src/upload/admin/view/template/extension/module/retailcrm.tpl b/src/upload/admin/view/template/extension/module/retailcrm.tpl index 0bf5580..d33e75c 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.tpl +++ b/src/upload/admin/view/template/extension/module/retailcrm.tpl @@ -97,7 +97,22 @@
- + +
+ +
+ + +
+
@@ -112,9 +127,6 @@
-
-
-
diff --git a/src/upload/admin/view/template/extension/module/retailcrm.twig b/src/upload/admin/view/template/extension/module/retailcrm.twig index 7ad02eb..a77a7a6 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.twig +++ b/src/upload/admin/view/template/extension/module/retailcrm.twig @@ -55,7 +55,7 @@
-
+
@@ -100,8 +100,27 @@
- {{ text_currency }} -
+ {{ icml_settings }} +
+ +
+ + +
+
+
-
-
- {{ text_lenght }} -
+
diff --git a/src/upload/system/library/retailcrm/retailcrm.php b/src/upload/system/library/retailcrm/retailcrm.php index 2442809..3f21c41 100644 --- a/src/upload/system/library/retailcrm/retailcrm.php +++ b/src/upload/system/library/retailcrm/retailcrm.php @@ -242,6 +242,15 @@ class Retailcrm { return false; } + public function useServicesForIcml() + { + $this->load->model('setting/setting'); + + $setting = $this->model_setting_setting->getSetting($this->getModuleTitle()); + + return $setting['module_retailcrm_icml_service_enabled'] ?? false; + } + /** * @return mixed */