diff --git a/CHANGELOG.md b/CHANGELOG.md index f230e9ad..27ae50cc 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 796262d5..1b94a070 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 b4d501cb..d664c75b 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 @@ public function index() '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 1f38053a..aab7dd4b 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 @@ $_['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 dbcaa035..9f88136e 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 @@ $_['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 9b2d0942..f7e0bd51 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 @@ $_['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 4fd07caa..5656170b 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 @@ public function generateICML() */ 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 @@ private function addCategories() } 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 @@ private function addOffers() { } $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 @@ private function addOffers() { '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 @@ private function addOffers() { ->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 @@ private function addOffers() { /** * 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 @@ private function addOffers() { $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 @@ private function addOffers() { $productHeight ); - $e->appendChild($this->dd->createElement('dimensions')) + $catalog->appendChild($this->dd->createElement('dimensions')) ->appendChild($this->dd->createTextNode($dimensions)); } @@ -280,14 +289,14 @@ private function addOffers() { */ 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 @@ private function addOffers() { $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 @@ private function addOffers() { $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 @@ private function addOffers() { $weightValue = round($weightValue / $coeffWeight, 6); $weight->appendChild($this->dd->createTextNode($weightValue)); - $e->appendChild($weight); + $catalog->appendChild($weight); } } } @@ -343,7 +352,7 @@ private function addOffers() { 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 fba27ff6..ea9adfa4 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 0bf55808..d33e75c8 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 7ad02eb3..a77a7a6d 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 2442809e..3f21c411 100644 --- a/src/upload/system/library/retailcrm/retailcrm.php +++ b/src/upload/system/library/retailcrm/retailcrm.php @@ -242,6 +242,15 @@ public function getCurrencyForIcml() { 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 */