Skip to content

Commit

Permalink
Merge pull request #159 from sergeygw1990/v3.1
Browse files Browse the repository at this point in the history
Добавление габаритов в генерации каталога
  • Loading branch information
gwinn authored Jun 13, 2019
2 parents 0b478bc + 5e6c308 commit 3e70e9b
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v.3.1.5
* Добавлена генерация габаритов в катало

## v.3.1.4
* Добавлено удаление типа цены для неустановленных акционных цен

Expand Down
8 changes: 6 additions & 2 deletions src/upload/admin/controller/extension/module/retailcrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function index()
$this->load->model('setting/setting');
$this->load->model('extension/retailcrm/references');
$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');
Expand Down Expand Up @@ -219,7 +220,9 @@ public function index()
'order_number',
'text_order_number',
'debug',
'text_debug'
'text_debug',
'text_lenght',
'text_lenght_label'
);

foreach ($text_strings as $text) {
Expand Down Expand Up @@ -250,8 +253,9 @@ public function index()
$_data['customFields'] = $this->model_extension_retailcrm_references
->getCustomFields($retailcrm_api_client);
$_data['priceTypes'] = $this->model_extension_retailcrm_references
->getPriceTypes();
->getPriceTypes($retailcrm_api_client);
$_data['customerGroups'] = $this->model_customer_customer_group->getCustomerGroups();
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
}

$config_data = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
$_['text_error_log'] = 'Log size is more than 2MB';
$_['text_error_delivery'] = 'Delivery types are not found';
$_['text_confirm_log'] = 'Are you sure that you want to clear the log?';
$_['text_lenght'] = 'Setting of the unit of measurement';
$_['text_lenght_label'] = 'Unit of measurement in ICML';

$_['retailcrm_dict_delivery'] = 'Delivery types';
$_['retailcrm_dict_status'] = 'Statuses';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
$_['text_error_log'] = 'El Tamaño del registro es más de 2MB';
$_['text_error_delivery'] = 'No se encontraron los métodos de envío';
$_['text_confirm_log'] = '¿Estás seguro de que quieres borrar el registro?';
$_['text_lenght_label'] = 'Ajustar unidad de medida';
$_['status_changes'] = 'Unidad de medida en ICML';

$_['retailcrm_dict_delivery'] = 'Métodos de envío';
$_['retailcrm_dict_status'] = 'Estados';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
$_['text_error_log'] = 'Размер лога более 2MB';
$_['text_error_delivery'] = 'Не найдены типы доставки';
$_['text_confirm_log'] = 'Вы уверены, что хотите очистить лог?';
$_['text_lenght'] = 'Единица измерения в ICML';
$_['text_lenght_label'] = 'История изменений';

$_['retailcrm_dict_delivery'] = 'Способы доставки';
$_['retailcrm_dict_status'] = 'Статусы';
Expand Down
48 changes: 48 additions & 0 deletions src/upload/admin/model/extension/retailcrm/icml.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function generateICML()
$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').'">
Expand Down Expand Up @@ -101,6 +102,15 @@ private function addOffers()

$manufacturers = $this->model_catalog_manufacturer
->getManufacturers(array());
$settingLenght = $this->retailcrm->getLenghtForIcml();
$leghtsArray = $this->model_localisation_length_class
->getLengthClasses();

foreach ($leghtsArray as $lenght) {
if ($lenght['value'] == 1) {
$defaultLenght = $lenght;
}
}

foreach ($manufacturers as $manufacturer) {
$offerManufacturers[
Expand Down Expand Up @@ -203,6 +213,44 @@ private function addOffers()
)
);
}

/**
* 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
*/
Expand Down
15 changes: 15 additions & 0 deletions src/upload/admin/view/template/extension/module/retailcrm.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,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 unit in lenghts %}
<option value="{{ unit.length_class_id }}" {% if saved_settings.module_retailcrm_lenght is defined and saved_settings.module_retailcrm_lenght == unit.length_class_id %} selected="selected" {% endif %}>
{{ unit.title }}
</option>
{% endfor %}
</select>
</div>
</div>
</fieldset>
{% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion != 'v3' %}
<fieldset>
<legend>{{ special_price_settings }}</legend>
Expand Down
15 changes: 15 additions & 0 deletions src/upload/system/library/retailcrm/retailcrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,19 @@ public static function filterRecursive($haystack)

return $haystack;
}

/**
* @return mixed
*/
public function getLenghtForIcml() {
$this->load->model('setting/setting');

$setting = $this->model_setting_setting->getSetting(self::MODULE);

if (isset($setting[self::MODULE . '_lenght'])) {
return $setting[self::MODULE . '_lenght'];
}

return false;
}
}

0 comments on commit 3e70e9b

Please sign in to comment.