mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-21 20:56:07 +03:00
parent
d5f29dc5fe
commit
c893cf24fb
@ -1,3 +1,6 @@
|
||||
## v4.1.16
|
||||
* Support for services in ICML
|
||||
|
||||
## v4.1.15
|
||||
* Display module version
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;}
|
||||
.retailcrm_unit select {max-width: 500px;}
|
||||
|
||||
.question-mark {
|
||||
cursor: help;
|
||||
position: relative;
|
||||
}
|
@ -97,7 +97,22 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?php echo $text_currency; ?></legend>
|
||||
<legend><?php echo $icml_settings; ?></legend>
|
||||
<div class="form-group retailcrm_unit">
|
||||
<label class="col-sm-2 control-label question-mark" for="retailcrm_icml_service_enabled" title="When the option is enabled, all products for which delivery is disabled will be considered as services and uploaded to CRM as services"><?php echo $icml_service_enabled_label; ?></label>
|
||||
<div class="col-sm-10">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_icml_service_enabled value="1"
|
||||
<?php if(isset($saved_settings['retailcrm_icml_service_enabled']) && $saved_settings['retailcrm_icml_service_enabled'] == 1): echo 'checked'; endif;?>/>
|
||||
<?php echo $text_yes; ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_icml_service_enabled" value="0"
|
||||
<?php if(!isset($saved_settings['retailcrm_icml_service_enabled']) || $saved_settings['retailcrm_icml_service_enabled'] == 0): echo 'checked'; endif;?>/>
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div
|
||||
<div class="form-group retailcrm_unit">
|
||||
<label class="col-sm-2 control-label"><?php echo $text_currency; ?></label>
|
||||
<div class="col-md-4 col-sm-10">
|
||||
@ -112,9 +127,6 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?php echo $text_lenght; ?></legend>
|
||||
<div class="form-group retailcrm_unit">
|
||||
<label class="col-sm-2 control-label"><?php echo $text_lenght_label; ?></label>
|
||||
<div class="col-md-4 col-sm-10">
|
||||
|
@ -55,7 +55,7 @@
|
||||
<input class="form-control" id="retailcrm_url" type="text" name="module_retailcrm_url" value="{% if saved_settings.module_retailcrm_url is defined %}{{ saved_settings.module_retailcrm_url }}{% endif %}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group retailcrm_unit">
|
||||
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||
<label class="col-sm-2 control-label" for="retailcrm_apikey">{{ retailcrm_apikey }}</label>
|
||||
<div class="col-lg-4 col-md-6 col-sm-10">
|
||||
<input class="form-control" id="retailcrm_apikey" type="text" name="module_retailcrm_apikey" value="{% if saved_settings.module_retailcrm_apikey is defined %}{{ saved_settings.module_retailcrm_apikey }}{% endif %}">
|
||||
@ -100,8 +100,27 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ text_currency }}</legend>
|
||||
<div class="form-group retailcrm_unit">
|
||||
<legend>{{ icml_settings }}</legend>
|
||||
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||
<label class="col-sm-2 control-label question-mark" for="module_retailcrm_icml_service_enabled" title="{{ icml_service_description }}">{{ icml_service_enabled_label }}</label>
|
||||
<div class="col-sm-10">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_icml_service_enabled" value="1"
|
||||
{% if saved_settings.module_retailcrm_icml_service_enabled is defined and saved_settings.module_retailcrm_icml_service_enabled == 1 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{{ text_yes }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_icml_service_enabled" value="0"
|
||||
{% if saved_settings.module_retailcrm_icml_service_enabled is not defined or saved_settings.module_retailcrm_icml_service_enabled == 0 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{{ text_no }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||
<label class="col-sm-2 control-label">{{ text_currency_label }}</label>
|
||||
<div class="col-md-4 col-sm-10">
|
||||
<select id="module_retailcrm_currency" name="module_retailcrm_currency" class="form-control">
|
||||
@ -115,17 +134,14 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ text_lenght }}</legend>
|
||||
<div class="form-group retailcrm_unit">
|
||||
<div class="form-group retailcrm_unit retailcrm_disable_border">
|
||||
<label class="col-sm-2 control-label">{{ text_lenght_label }}</label>
|
||||
<div class="col-md-4 col-sm-10">
|
||||
<select id="module_retailcrm_lenght" name="module_retailcrm_lenght" class="form-control">
|
||||
{% for lenght in lenghts %}
|
||||
<option value="{{ lenght.length_class_id }}" {% if saved_settings.module_retailcrm_lenght is defined and saved_settings.module_retailcrm_lenght == lenght.length_class_id %} selected="selected" {% endif %}>
|
||||
{{ lenght.title }}
|
||||
</option>
|
||||
<option value="{{ lenght.length_class_id }}" {% if saved_settings.module_retailcrm_lenght is defined and saved_settings.module_retailcrm_lenght == lenght.length_class_id %} selected="selected" {% endif %}>
|
||||
{{ lenght.title }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user