mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 05:06:07 +03:00
commit
ee36226b31
@ -1,3 +1,7 @@
|
||||
## v.3.2.0
|
||||
* Добавлена выгрузка картинок для категорий в ICML
|
||||
* Добавлена настройка для выбора валюты, в которой будет выгружаться цена в ICML
|
||||
|
||||
## v.3.1.6
|
||||
* Исправлено получение событий из БД для OC 3.0
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -68,6 +68,8 @@ $_['retailcrm_missing_status'] = 'Статус пропавших заказо
|
||||
|
||||
$_['order_number'] = 'Номер заказа';
|
||||
$_['text_order_number'] = 'Передавать номер заказа в retailCRM';
|
||||
$_['text_currency'] = 'Настройка валюты';
|
||||
$_['text_currency_label'] = 'Валюта в ICML';
|
||||
|
||||
$_['column_total'] = 'Итого';
|
||||
$_['product_summ'] = 'Сумма';
|
||||
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?php echo $text_currency; ?></legend>
|
||||
<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">
|
||||
<select id="retailcrm_currency" name="retailcrm_currency" class="form-control">
|
||||
<?php foreach ($currencies as $currency) :?>
|
||||
<?php if ($currency['status']) :?>
|
||||
<option value="<?php echo $currency['code']; ?>" <?php if(isset($saved_settings['retailcrm_currency']) && $saved_settings['retailcrm_currency'] == $currency['code']):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $currency['title']; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||
<?php if (!empty($retailcrm_errors)) : ?>
|
||||
<?php foreach($retailcrm_errors as $retailcrm_error): ?>
|
||||
|
@ -91,6 +91,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ text_currency }}</legend>
|
||||
<div class="form-group retailcrm_unit">
|
||||
<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">
|
||||
{% for currency in currencies %}
|
||||
{% if currency.status == 1 %}
|
||||
<option value="{{ currency.code }}" {% if saved_settings.module_retailcrm_currency is defined and saved_settings.module_retailcrm_currency == currency.code %} selected="selected" {% endif %}>
|
||||
{{ currency.title }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
{% 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' %}
|
||||
<div class="form-group retailcrm_unit">
|
||||
<div class="col-lg-4 col-md-6 col-sm-6">
|
||||
<select id="retailcrm_delivery_{{ val.code }}" name="module_retailcrm_delivery[{{ val.code }}]" >
|
||||
<select id="retailcrm_delivery_{{ val.code }}" name="module_retailcrm_delivery[{{ val.code }}]" class="form-control">
|
||||
{% for k, v in delivery.retailcrm %}
|
||||
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_delivery[key] is defined and v.code == saved_settings.module_retailcrm_delivery[key] %} selected="selected" {% endif %}>
|
||||
{{ v.name }}
|
||||
@ -179,7 +196,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 col-sm-6">
|
||||
<label class="col-sm-2 control-label" for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label>
|
||||
<label class="control-label" for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user