Closes: #157 Генерация габаритов товара

This commit is contained in:
Sergey 2019-06-07 08:59:57 +03:00
parent 93bacf9b7b
commit f71002f4d6
10 changed files with 108 additions and 2 deletions

View File

@ -1,3 +1,6 @@
## v.3.3.5
* Добавлена генерация габаритов в каталоге
## v.3.3.4
* Исправлен баг с некорректной выгрузкой акционных цен для товаров с характеристиками

View File

@ -1 +1 @@
3.3.4
3.3.5

View File

@ -120,6 +120,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
$this->load->model('extension/retailcrm/references');
$this->load->model('localisation/currency');
$this->load->model('customer/customer_group');
$this->load->model('localisation/length_class');
$this->load->language('extension/module/retailcrm');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
@ -306,7 +307,9 @@ class ControllerExtensionModuleRetailcrm extends Controller
'text_currency',
'text_currency_label',
'status_changes',
'text_status_changes'
'text_status_changes',
'text_lenght',
'text_lenght_label'
);
$_data = &$data;
@ -344,6 +347,8 @@ class ControllerExtensionModuleRetailcrm extends Controller
->getCustomFields();
}
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
if ($apiVersion != 'v3') {
$_data['priceTypes'] = $this->model_extension_retailcrm_references
->getPriceTypes();

View File

@ -70,6 +70,8 @@ $_['order_number'] = 'Order number';
$_['text_order_number'] = 'Upload the order number to retailCRM';
$_['text_currency'] = 'Currency setting';
$_['text_currency_label'] = 'Currency in ICML';
$_['text_lenght'] = 'Setting of the unit of measurement';
$_['text_lenght_label'] = 'Unit of measurement in ICML';
$_['status_changes'] = 'History of changes';
$_['text_status_changes'] = 'Record changes to the order history of Opencart';

View File

@ -70,6 +70,8 @@ $_['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';
$_['text_lenght'] = 'Ajustar unidad de medida';
$_['text_lenght_label'] = 'Unidad de medida en ICML';
$_['status_changes'] = 'Historial de cambios';
$_['text_status_changes'] = 'Registrar los cambios en el historial de pedidos de Opencart';

View File

@ -70,6 +70,8 @@ $_['order_number'] = 'Номер заказа';
$_['text_order_number'] = 'Передавать номер заказа в retailCRM';
$_['text_currency'] = 'Настройка валюты';
$_['text_currency_label'] = 'Валюта в ICML';
$_['text_lenght'] = 'Настройка единицы измерения';
$_['text_lenght_label'] = 'Единица измерения в ICML';
$_['status_changes'] = 'История изменений';
$_['text_status_changes'] = 'Фиксировать изменения в истории заказа Opencart';

View File

@ -31,6 +31,7 @@ class ModelExtensionRetailcrmIcml extends Model
$this->load->model('catalog/product');
$this->load->model('catalog/option');
$this->load->model('catalog/manufacturer');
$this->load->model('localisation/length_class');
$string = '<?xml version="1.0" encoding="UTF-8"?>
<yml_catalog date="'.date('Y-m-d H:i:s').'">
@ -104,6 +105,14 @@ class ModelExtensionRetailcrmIcml extends Model
$offerManufacturers = array();
$currencyForIcml = $this->retailcrm->getCurrencyForIcml();
$defaultCurrency = $this->getDefaultCurrency();
$settingLenght = $this->retailcrm->getLenghtForIcml();
$leghtsArray = $this->model_localisation_length_class->getLengthClasses();
foreach ($leghtsArray as $lenght) {
if ($lenght['value'] == 1) {
$defaultLenght = $lenght;
}
}
$manufacturers = $this->model_catalog_manufacturer
->getManufacturers(array());
@ -218,6 +227,44 @@ class ModelExtensionRetailcrmIcml extends Model
)
);
}
/**
* Dimensions
*/
if ((!empty($product['length']) && $product['length'] > 0) &&
(!empty($product['width'] && $product['width'] > 0))
&& !empty($product['height']))
{
$lenghtArray = $this->model_localisation_length_class->getLengthClass($product['length_class_id']);
if ($defaultLenght['length_class_id'] != $lenghtArray['length_class_id']) {
$productLength = $product['length'] / $lenghtArray['value'];
$productWidth = $product['width'] / $lenghtArray['value'];
$productHeight = $product['height'] / $lenghtArray['value'];
} else {
$productLength = $product['length'];
$productWidth = $product['width'];
$productHeight = $product['height'];
}
if ($defaultLenght['length_class_id'] != $settingLenght) {
$unit = $this->model_localisation_length_class->getLengthClass($settingLenght);
$productLength = $productLength * $unit['value'];
$productWidth = $productWidth * $unit['value'];
$productHeight = $productHeight * $unit['value'];
}
$dimensions = sprintf(
'%01.3f/%01.3f/%01.3f',
$productLength,
$productWidth,
$productHeight
);
$e->appendChild($this->dd->createElement('dimensions'))
->appendChild($this->dd->createTextNode($dimensions));
}
/**
* Image
*/

View File

@ -109,6 +109,21 @@
</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">
<select id="retailcrm_lenght" name="retailcrm_lenght" class="form-control">
<?php foreach ($lenghts as $lenght) :?>
<option value="<?php echo $lenght['length_class_id']; ?>" <?php if(isset($saved_settings['retailcrm_lenght']) && $saved_settings['retailcrm_lenght'] == $lenght['length_class_id']):?>selected="selected"<?php endif;?>>
<?php echo $lenght['title']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</fieldset>
<fieldset>
<legend><?php echo $status_changes; ?></legend>
<div class="form-group">

View File

@ -108,6 +108,21 @@
</div>
</div>
</fieldset>
<fieldset>
<legend>{{ text_lenght }}</legend>
<div class="form-group retailcrm_unit">
<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>
{% endfor %}
</select>
</div>
</div>
</fieldset>
<fieldset>
<legend>{{ status_changes }}</legend>
<div class="form-group">

View File

@ -179,4 +179,19 @@ class Retailcrm {
return false;
}
/**
* @return mixed
*/
public function getLenghtForIcml() {
$this->load->model('setting/setting');
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
if (isset($setting[$this->getModuleTitle() . '_lenght'])) {
return $setting[$this->getModuleTitle() . '_lenght'];
}
return false;
}
}