diff --git a/CHANGELOG.md b/CHANGELOG.md index b11d392..48c8ff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v.3.2.0 +* Добавлена выгрузка картинок для категорий в ICML +* Добавлена настройка для выбора валюты, в которой будет выгружаться цена в ICML + ## v.3.1.6 * Исправлено получение событий из БД для OC 3.0 diff --git a/VERSION b/VERSION index 9cec716..944880f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.6 +3.2.0 diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index 0bf0f00..f1725e9 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -118,6 +118,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->load->model('localisation/country'); $this->load->model('setting/setting'); $this->load->model('extension/retailcrm/references'); + $this->load->model('localisation/currency'); $this->load->language('extension/module/retailcrm'); $this->document->setTitle($this->language->get('heading_title')); $this->document->addStyle('/admin/view/stylesheet/retailcrm.css'); @@ -300,7 +301,9 @@ class ControllerExtensionModuleRetailcrm extends Controller 'special_price_settings', 'special_price', 'order_number', - 'text_order_number' + 'text_order_number', + 'text_currency', + 'text_currency_label' ); $_data = &$data; @@ -309,6 +312,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $_data[$text] = $this->language->get($text); } + $_data['currencies'] = $this->model_localisation_currency->getCurrencies(0); $_data['retailcrm_errors'] = array(); $_data['saved_settings'] = $this->model_setting_setting ->getSetting($this->moduleTitle); 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 35d0ba7..579cce8 100644 --- a/src/upload/admin/language/en-gb/extension/module/retailcrm.php +++ b/src/upload/admin/language/en-gb/extension/module/retailcrm.php @@ -68,6 +68,8 @@ $_['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'; $_['column_total'] = 'Total'; $_['product_summ'] = 'Sum'; 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 929a9bc..041fba5 100644 --- a/src/upload/admin/language/es-es/extension/module/retailcrm.php +++ b/src/upload/admin/language/es-es/extension/module/retailcrm.php @@ -68,6 +68,8 @@ $_['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'; $_['column_total'] = 'Total'; $_['product_summ'] = 'Importe'; 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 cbfd9ee..6f3ebe7 100644 --- a/src/upload/admin/language/ru-ru/extension/module/retailcrm.php +++ b/src/upload/admin/language/ru-ru/extension/module/retailcrm.php @@ -68,6 +68,8 @@ $_['retailcrm_missing_status'] = 'Статус пропавших заказо $_['order_number'] = 'Номер заказа'; $_['text_order_number'] = 'Передавать номер заказа в retailCRM'; +$_['text_currency'] = 'Настройка валюты'; +$_['text_currency_label'] = 'Валюта в ICML'; $_['column_total'] = 'Итого'; $_['product_summ'] = 'Сумма'; diff --git a/src/upload/admin/model/extension/retailcrm/icml.php b/src/upload/admin/model/extension/retailcrm/icml.php index d0afb5c..d5030a5 100644 --- a/src/upload/admin/model/extension/retailcrm/icml.php +++ b/src/upload/admin/model/extension/retailcrm/icml.php @@ -77,14 +77,19 @@ class ModelExtensionRetailcrmIcml extends Model private function addCategories() { $categories = $this->model_catalog_category->getCategories(array()); - foreach($categories as $category) { + foreach ($categories as $category) { $category = $this->model_catalog_category->getCategory($category['category_id']); - $e = $this->eCategories->appendChild( - $this->dd->createElement( - 'category', $category['name'] - ) - ); + $c = $this->dd->createElement('category'); + + if ($category['image']) { + $c->appendChild( + $this->dd->createElement('picture', $this->generateImage($category['image'])) + ); + } + + $c->appendChild($this->dd->createElement('name', $category['name'])); + $e = $this->eCategories->appendChild($c); $e->setAttribute('id', $category['category_id']); @@ -95,17 +100,16 @@ class ModelExtensionRetailcrmIcml extends Model } - private function addOffers() - { + private function addOffers() { $offerManufacturers = array(); + $currencyForIcml = $this->retailcrm->getCurrencyForIcml(); + $defaultCurrency = $this->getDefaultCurrency(); $manufacturers = $this->model_catalog_manufacturer ->getManufacturers(array()); foreach ($manufacturers as $manufacturer) { - $offerManufacturers[ - $manufacturer['manufacturer_id'] - ] = $manufacturer['name']; + $offerManufacturers[$manufacturer['manufacturer_id']] = $manufacturer['name']; } $products = $this->model_catalog_product->getProducts(array()); @@ -178,7 +182,7 @@ class ModelExtensionRetailcrmIcml extends Model */ $e->appendChild($this->dd->createElement('productName')) ->appendChild($this->dd->createTextNode($product['name'])); - if(!empty($options)) { + if (!empty($options)) { $optionsString = array(); foreach($options as $option) { $optionsString[] = $option['name'].': '.$option['value']; @@ -190,8 +194,19 @@ class ModelExtensionRetailcrmIcml extends Model $e->appendChild($this->dd->createElement('name')) ->appendChild($this->dd->createTextNode($product['name'])); } + + if ($currencyForIcml && $currencyForIcml != $defaultCurrency) { + $price = $this->currency->convert( + $product['price'] + $optionsValues['price'], + $this->getDefaultCurrency(), + $this->retailcrm->getCurrencyForIcml() + ); + } else { + $price = $product['price'] + $optionsValues['price']; + } + $e->appendChild($this->dd->createElement('price')) - ->appendChild($this->dd->createTextNode($product['price'] + $optionsValues['price'])); + ->appendChild($this->dd->createTextNode($price)); /** * Vendor */ @@ -229,7 +244,7 @@ class ModelExtensionRetailcrmIcml extends Model ) ); // Options - if(!empty($options)) { + if (!empty($options)) { foreach($options as $optionKey => $optionData) { $param = $this->dd->createElement('param'); $param->setAttribute('code', $optionKey); @@ -299,4 +314,16 @@ class ModelExtensionRetailcrmIcml extends Model 'optionValue' => $optionValue['name'] ); } + + private function getDefaultCurrency() { + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency"); + + foreach ($query->rows as $currency) { + if ($currency['value'] == 1) { + return $currency['code']; + } + } + + return $query->rows[0]['code']; + } } diff --git a/src/upload/admin/view/template/extension/module/retailcrm.tpl b/src/upload/admin/view/template/extension/module/retailcrm.tpl index 5adffdf..9ff2d27 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.tpl +++ b/src/upload/admin/view/template/extension/module/retailcrm.tpl @@ -91,7 +91,24 @@ - + +
+ +
+ +
+ +
+
+
diff --git a/src/upload/admin/view/template/extension/module/retailcrm.twig b/src/upload/admin/view/template/extension/module/retailcrm.twig index 25062be..6b7ba84 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.twig +++ b/src/upload/admin/view/template/extension/module/retailcrm.twig @@ -91,6 +91,23 @@ +
+ {{ text_currency }} +
+ +
+ +
+
+
{% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %} {% if retailcrm_errors|length %} {% for retailcrm_error in retailcrm_errors %} @@ -170,7 +187,7 @@ {% if key != 'title' %}
- {% for k, v in delivery.retailcrm %}
- +
{% endif %} diff --git a/src/upload/system/library/retailcrm/retailcrm.php b/src/upload/system/library/retailcrm/retailcrm.php index 525a43b..d6e81cf 100644 --- a/src/upload/system/library/retailcrm/retailcrm.php +++ b/src/upload/system/library/retailcrm/retailcrm.php @@ -8,8 +8,7 @@ class Retailcrm { protected $apiClient; protected $registry; - public function __construct($registry) - { + public function __construct($registry) { $this->registry = $registry; } @@ -26,8 +25,7 @@ class Retailcrm { * * @return mixed object | boolean */ - public function getApiClient($apiUrl = null, $apiKey = null, $apiVersion = null) - { + public function getApiClient($apiUrl = null, $apiKey = null, $apiVersion = null) { $this->load->model('setting/setting'); $setting = $this->model_setting_setting->getSetting($this->getModuleTitle()); @@ -55,8 +53,7 @@ class Retailcrm { * * @return \OpencartApiClient */ - public function getOcApiClient($registry) - { + public function getOcApiClient($registry) { return new \OpencartApiClient($registry); } @@ -65,8 +62,7 @@ class Retailcrm { * * @return string $title */ - public function getModuleTitle() - { + public function getModuleTitle() { if (version_compare(VERSION, '3.0', '<')) { $title = 'retailcrm'; } else { @@ -81,8 +77,7 @@ class Retailcrm { * * @return string $token */ - public function getTokenTitle() - { + public function getTokenTitle() { if (version_compare(VERSION, '3.0', '<')) { $token = 'token'; } else { @@ -92,8 +87,7 @@ class Retailcrm { return $token; } - public function getOffers($product) - { + public function getOffers($product) { // Формируем офферы отнсительно доступных опций $options = $this->model_catalog_product->getProductOptions($product['product_id']); $offerOptions = array('select', 'radio'); @@ -165,4 +159,21 @@ class Retailcrm { return $offers; } + + /** + * @return mixed + */ + public function getCurrencyForIcml() { + $this->load->model('setting/setting'); + + $setting = $this->model_setting_setting->getSetting($this->getModuleTitle()); + + if (isset($setting[$this->getModuleTitle() . '_currency']) + && $this->currency->has($setting[$this->getModuleTitle() . '_currency']) + ) { + return $setting[$this->getModuleTitle() . '_currency']; + } + + return false; + } }