Update to v2.3 (#22)

* restruct for 2.3
* new files for 2.3
This commit is contained in:
iyzoer 2017-03-22 12:12:54 +03:00 committed by Alex Lushpai
parent 10459281f7
commit 3be4ac76a9
22 changed files with 166 additions and 234 deletions

View File

@ -1,39 +0,0 @@
Changelog
=========
####v0.3.0
* Расширена библиотека клиента
* Добавлена возможность кастомизации моделей заказа через vqmod
* Устранены мелкие баги, проведен рефакторинг кода.
####v0.2.0
Общие изменения
* Код приведен в состоянии совместимости с PHP 5.2
* Убрана необходимость собирать пакет через composer
* Библиотека api-client-php обновлена до последней версии и добавлена в стандартную поставку
* Переименованы методы, пути и значения ключей конфигурации в связи с ребрендингом
* Временая метка последнего запуска получения истории перенесена в таблицу конфигурации БД
Выгрузка каталога (ICML)
* Генерация обновлена в соответствии с последними измениями формата файла выгрузки
* Генерация вынесена в отдельный класс
* Добавлена возможность добавлять подкатегории
* Скорректировано указание активности офера
* Убрана генерация размера офера вследствие кастомизации этого параметра в разных магазинах
####v0.1.1
* Устранена ошибка редактирования, при которой терялась часть данных при получении истории из CRM
* Оптимизирован код получения и обработки истории заказов
* Актуализированы переводы
####v.0.1
* Реализован интерфейс настроек модуля
* Реализована отправка данных о заказе/клиенте в CRM
* Реализована выгрузка каталога (cron only)
* Реализовано получение данных о заказах, сделанных на стороне CRM (cron only)

View File

@ -1,7 +1,13 @@
Opencart module
===============
Module allows integrate CMS Opencart 2.x with [retailCRM](http://retailcrm.pro)
Module allows integrate CMS Opencart >= 2.3 with [retailCRM](http://retailcrm.pro)
### Previous versions:
[v1.x](https://github.com/retailcrm/opencart-module/tree/v1.x)
[v2.x (2.0, 2.1, 2.2)](https://github.com/retailcrm/opencart-module/tree/v2.2)
#### Features:

View File

@ -1,7 +1,13 @@
Opencart module
===============
Модуль интеграции CMS Openacart 2.x c [RetailCRM](http://retailcrm.ru)
Модуль интеграции CMS Opencart >= 2.3 c [RetailCRM](http://retailcrm.ru)
### Предыдущие версии:
[v1.x](https://github.com/retailcrm/opencart-module/tree/v1.x)
[v2.x (2.0, 2.1, 2.2)](https://github.com/retailcrm/opencart-module/tree/v2.2)
#### Модуль позволяет:

View File

@ -11,7 +11,7 @@ require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
*/
class ControllerModuleRetailcrm extends Controller
class ControllerExtensionModuleRetailcrm extends Controller
{
private $_error = array();
protected $log, $statuses, $payments, $deliveryTypes, $retailcrm;
@ -33,22 +33,29 @@ class ControllerModuleRetailcrm extends Controller
$this->model_extension_event
->addEvent(
'retailcrm',
version_compare(VERSION, '2.2', '>=') ? 'catalog/model/checkout/order/addOrder/after' : 'post.order.add',
'module/retailcrm/order_create'
'catalog/model/checkout/order/addOrder/after',
'extension/module/retailcrm/order_create'
);
$this->model_extension_event
->addEvent(
'retailcrm',
version_compare(VERSION, '2.2', '>=') ? 'catalog/model/checkout/order/addOrderHistory/after' : 'post.order.history.add',
'module/retailcrm/order_edit'
'catalog/model/checkout/order/addOrderHistory/after',
'extension/module/retailcrm/order_edit'
);
$this->model_extension_event
->addEvent(
'retailcrm',
version_compare(VERSION, '2.2', '>=') ? 'catalog/model/account/customer/addCustomer/after' : 'post.customer.add',
'module/retailcrm/customer_create'
'catalog/model/account/customer/addCustomer/after',
'extension/module/retailcrm/customer_create'
);
$this->model_extension_event
->addEvent(
'retailcrm',
'catalog/model/checkout/order/editOrder/after',
'extension/module/retailcrm/order_edit'
);
}
@ -77,12 +84,16 @@ class ControllerModuleRetailcrm extends Controller
$this->load->model('setting/setting');
$this->load->model('extension/module');
$this->load->model('retailcrm/references');
$this->load->language('module/retailcrm');
$this->load->model('extension/retailcrm/references');
$this->load->language('extension/module/retailcrm');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
if (parse_url($this->request->post['retailcrm_url'])){
$crm_url = parse_url($this->request->post['retailcrm_url'], PHP_URL_HOST);
$this->request->post['retailcrm_url'] = 'https://'.$crm_url;
}
$this->model_setting_setting->editSetting(
'retailcrm',
$this->request->post
@ -90,7 +101,7 @@ class ControllerModuleRetailcrm extends Controller
$this->session->data['success'] = $this->language->get('text_success');
$redirect = $this->url->link(
'module/retailcrm', 'token=' . $this->session->data['token'],
'extension/module/retailcrm', 'token=' . $this->session->data['token'],
'SSL'
);
@ -137,14 +148,14 @@ class ControllerModuleRetailcrm extends Controller
$this->retailcrm = new RetailcrmProxy(
$url,
$key,
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$_data['delivery'] = $this->model_retailcrm_references
$_data['delivery'] = $this->model_extension_retailcrm_references
->getDeliveryTypes();
$_data['statuses'] = $this->model_retailcrm_references
$_data['statuses'] = $this->model_extension_retailcrm_references
->getOrderStatuses();
$_data['payments'] = $this->model_retailcrm_references
$_data['payments'] = $this->model_extension_retailcrm_references
->getPaymentTypes();
}
@ -181,7 +192,7 @@ class ControllerModuleRetailcrm extends Controller
$_data['breadcrumbs'][] = array(
'text' => $this->language->get('text_module'),
'href' => $this->url->link(
'extension/module',
'extension/extension/module',
'token=' . $this->session->data['token'], 'SSL'
),
'separator' => ' :: '
@ -190,19 +201,19 @@ class ControllerModuleRetailcrm extends Controller
$_data['breadcrumbs'][] = array(
'text' => $this->language->get('retailcrm_title'),
'href' => $this->url->link(
'module/retailcrm',
'extension/module/retailcrm',
'token=' . $this->session->data['token'], 'SSL'
),
'separator' => ' :: '
);
$_data['action'] = $this->url->link(
'module/retailcrm',
'extension/module/retailcrm',
'token=' . $this->session->data['token'], 'SSL'
);
$_data['cancel'] = $this->url->link(
'extension/module',
'extension/extension',
'token=' . $this->session->data['token'], 'SSL'
);
@ -222,7 +233,7 @@ class ControllerModuleRetailcrm extends Controller
$_data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput(
$this->load->view('module/retailcrm.tpl', $_data)
$this->load->view('extension/module/retailcrm.tpl', $_data)
);
}
@ -233,12 +244,12 @@ class ControllerModuleRetailcrm extends Controller
*/
public function history()
{
if (file_exists(DIR_APPLICATION . 'model/retailcrm/custom/history.php')) {
$this->load->model('retailcrm/custom/history');
$this->model_retailcrm_custom_history->request();
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/history.php')) {
$this->load->model('extension/retailcrm/custom/history');
$this->model_extension_retailcrm_custom_history->request();
} else {
$this->load->model('retailcrm/history');
$this->model_retailcrm_history->request();
$this->load->model('extension/retailcrm/history');
$this->model_extension_retailcrm_history->request();
}
}
@ -249,12 +260,12 @@ class ControllerModuleRetailcrm extends Controller
*/
public function icml()
{
if (file_exists(DIR_APPLICATION . 'model/retailcrm/custom/icml.php')) {
$this->load->model('retailcrm/custom/icml');
$this->model_retailcrm_custom_icml->generateICML();
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/icml.php')) {
$this->load->model('extension/retailcrm/custom/icml');
$this->model_extension_retailcrm_custom_icml->generateICML();
} else {
$this->load->model('retailcrm/icml');
$this->model_retailcrm_icml->generateICML();
$this->load->model('extension/retailcrm/icml');
$this->model_extension_retailcrm_icml->generateICML();
}
}
@ -278,8 +289,8 @@ class ControllerModuleRetailcrm extends Controller
$status = $this->model_setting_setting->getSetting('retailcrm');
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
$this->load->model('extension/retailcrm/order');
$this->model_extension_retailcrm_order->sendToCrm($data, $data['order_id']);
}
}
@ -289,16 +300,12 @@ class ControllerModuleRetailcrm extends Controller
*
*/
public function export() {
if(version_compare(VERSION, '2.1', '<')) {
$this->load->model('sale/customer');
$customers = $this->model_sale_customer->getCustomers();
} else {
$this->load->model('customer/customer');
$customers = $this->model_customer_customer->getCustomers();
}
$this->load->model('retailcrm/customer');
$this->model_retailcrm_customer->uploadToCrm($customers);
$this->load->model('extension/retailcrm/customer');
$this->model_extension_retailcrm_customer->uploadToCrm($customers);
$this->load->model('sale/order');
$orders = $this->model_sale_order->getOrders();
@ -317,8 +324,8 @@ class ControllerModuleRetailcrm extends Controller
$fullOrders[] = $fullOrder;
}
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->uploadToCrm($fullOrders);
$this->load->model('extension/retailcrm/order');
$this->model_extension_retailcrm_order->uploadToCrm($fullOrders);
}
/**
@ -328,7 +335,7 @@ class ControllerModuleRetailcrm extends Controller
*/
private function validate()
{
if (!$this->user->hasPermission('modify', 'module/retailcrm')) {
if (!$this->user->hasPermission('modify', 'extension/module/retailcrm')) {
$this->_error['warning'] = $this->language->get('error_permission');
}

View File

@ -1,6 +1,6 @@
<?php
class ModelRetailcrmCustomer extends Model {
class ModelExtensionRetailcrmCustomer extends Model {
public function uploadToCrm($customers) {
$this->load->model('setting/setting');
@ -16,7 +16,7 @@ class ModelRetailcrmCustomer extends Model {
$this->retailcrmApi = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$customersToCrm = array();

View File

@ -1,6 +1,6 @@
<?php
class ModelRetailcrmHistory extends Model
class ModelExtensionRetailcrmHistory extends Model
{
protected $createResult;
@ -12,17 +12,13 @@ class ModelRetailcrmHistory extends Model
$this->load->model('setting/store');
$this->load->model('user/api');
$this->load->model('sale/order');
if (version_compare(VERSION, '2.1.0.0', '>=')) {
$this->load->model('customer/customer');
} else {
$this->load->model('sale/customer');
}
$this->load->model('retailcrm/references');
$this->load->model('extension/retailcrm/references');
$this->load->model('catalog/product');
$this->load->model('catalog/option');
$this->load->model('localisation/zone');
$this->load->language('module/retailcrm');
$this->load->language('extension/module/retailcrm');
$settings = $this->model_setting_setting->getSetting('retailcrm');
$history = $this->model_setting_setting->getSetting('retailcrm_history');
@ -41,7 +37,7 @@ class ModelRetailcrmHistory extends Model
$crm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$lastRun = !empty($history['retailcrm_history'])
@ -65,10 +61,10 @@ class ModelRetailcrmHistory extends Model
$this->payment = array_flip($settings['retailcrm_payment']);
$this->status = array_flip($settings['retailcrm_status']);
$this->ocPayment = $this->model_retailcrm_references
$this->ocPayment = $this->model_extension_retailcrm_references
->getOpercartPaymentTypes();
$this->ocDelivery = $this->model_retailcrm_references
$this->ocDelivery = $this->model_extension_retailcrm_references
->getOpercartDeliveryTypes();
$this->zones = $this->model_localisation_zone->getZones();
@ -314,25 +310,14 @@ class ModelRetailcrmHistory extends Model
),
);
if (version_compare(VERSION, '2.1.0.0', '>=')) {
$this->model_customer_customer->addCustomer($cData);
} else {
$this->model_sale_customer->addCustomer($cData);
}
if (!empty($order['email'])) {
if (version_compare(VERSION, '2.1.0.0', '>=')) {
$tryToFind = $this->model_customer_customer->getCustomerByEmail($order['email']);
} else {
$tryToFind = $this->model_sale_customer->getCustomerByEmail($order['email']);
}
$customer_id = $tryToFind['customer_id'];
} else {
if (version_compare(VERSION, '2.1.0.0', '>=')) {
$last = $this->model_customer_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1));
} else {
$last = $this->model_sale_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1));
}
$customer_id = $last[0]['customer_id'];
}

View File

@ -1,6 +1,6 @@
<?php
class ModelRetailcrmIcml extends Model
class ModelExtensionRetailcrmIcml extends Model
{
protected $shop;
protected $file;
@ -15,7 +15,7 @@ class ModelRetailcrmIcml extends Model
public function generateICML()
{
$this->load->language('module/retailcrm');
$this->load->language('extension/module/retailcrm');
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->load->model('catalog/option');
@ -297,7 +297,6 @@ class ModelRetailcrmIcml extends Model
{
$this->load->model('tool/image');
if (version_compare(VERSION, '2.2', '>=')) {
$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;
@ -307,7 +306,7 @@ class ModelRetailcrmIcml extends Model
$width,
$height
);
}
return $this->model_tool_image->resize(
$image,

View File

@ -1,6 +1,6 @@
<?php
class ModelRetailcrmOrder extends Model {
class ModelExtensionRetailcrmOrder extends Model {
public function uploadToCrm($orders) {
$this->load->model('catalog/product');

View File

@ -2,7 +2,7 @@
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
class ModelRetailcrmReferences extends Model
class ModelExtensionRetailcrmReferences extends Model
{
protected $retailcrm;
@ -33,13 +33,13 @@ class ModelRetailcrmReferences extends Model
public function getOpercartDeliveryTypes()
{
$deliveryMethods = array();
$files = glob(DIR_APPLICATION . 'controller/shipping/*.php');
$files = glob(DIR_APPLICATION . 'controller/extension/shipping/*.php');
if ($files) {
foreach ($files as $file) {
$extension = basename($file, '.php');
$this->load->language('shipping/' . $extension);
$this->load->language('extension/shipping/' . $extension);
if ($this->config->get($extension . '_status')) {
$deliveryMethods[$extension.'.'.$extension] = strip_tags(
@ -63,13 +63,13 @@ class ModelRetailcrmReferences extends Model
public function getOpercartPaymentTypes()
{
$paymentTypes = array();
$files = glob(DIR_APPLICATION . 'controller/payment/*.php');
$files = glob(DIR_APPLICATION . 'controller/extension/payment/*.php');
if ($files) {
foreach ($files as $file) {
$extension = basename($file, '.php');
$this->load->language('payment/' . $extension);
$this->load->language('extension/payment/' . $extension);
if ($this->config->get($extension . '_status')) {
$paymentTypes[$extension] = strip_tags(
@ -91,7 +91,7 @@ class ModelRetailcrmReferences extends Model
$this->retailcrm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$response = $this->retailcrm->deliveryTypesList();
@ -109,7 +109,7 @@ class ModelRetailcrmReferences extends Model
$this->retailcrm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$response = $this->retailcrm->statusesList();
@ -127,7 +127,7 @@ class ModelRetailcrmReferences extends Model
$this->retailcrm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$response = $this->retailcrm->paymentTypesList();

View File

@ -9,7 +9,7 @@
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
*/
class ControllerModuleRetailcrm extends Controller
class ControllerExtensionModuleRetailcrm extends Controller
{
/**
* Create order on event
@ -18,15 +18,12 @@ class ControllerModuleRetailcrm extends Controller
*
* @return void
*/
public function order_create($parameter1, $parameter2 = null)
public function order_create($parameter1, $parameter2 = null, $parameter3 = null)
{
$this->load->model('checkout/order');
$this->load->model('account/order');
if($parameter2 != null)
$order_id = $parameter2;
else
$order_id = $parameter1;
$order_id = $parameter3;
$data = $this->model_checkout_order->getOrder($order_id);
@ -50,16 +47,13 @@ class ControllerModuleRetailcrm extends Controller
'value' => $this->session->data['shipping_method']['cost']
);
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
$this->load->model('extension/retailcrm/order');
$this->model_extension_retailcrm_order->sendToCrm($data, $data['order_id']);
}
}
public function order_edit($parameter1, $parameter2 = null, $parameter3 = null, $parameter4 = null) {
if($parameter4 != null)
$order_id = $parameter3;
else
$order_id = $parameter1;
public function order_edit($parameter1, $parameter2 = null) {
$order_id = $parameter2[0];
$this->load->model('checkout/order');
$this->load->model('account/order');
@ -90,8 +84,8 @@ class ControllerModuleRetailcrm extends Controller
'value' => isset($this->session->data['shipping_method']) ? $this->session->data['shipping_method']['cost'] : ''
);
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->changeInCrm($data, $data['order_id']);
$this->load->model('extension/retailcrm/order');
$this->model_extension_retailcrm_order->changeInCrm($data, $data['order_id']);
}
}
@ -102,16 +96,13 @@ class ControllerModuleRetailcrm extends Controller
*
* @return void
*/
public function customer_create($parameter1, $parameter2 = null) {
if($parameter2 != null)
$customerId = $parameter2;
else
$customerId = $parameter1;
public function customer_create($parameter1, $parameter2 = null, $parameter3 = null) {
$customerId = $parameter3;
$this->load->model('account/customer');
$customer = $this->model_account_customer->getCustomer($customerId);
$this->load->model('retailcrm/customer');
$this->model_retailcrm_customer->sendToCrm($customer);
$this->load->model('extension/retailcrm/customer');
$this->model_extension_retailcrm_customer->sendToCrm($customer);
}
}

View File

@ -1,6 +1,6 @@
<?php
class ModelRetailcrmCustomer extends Model {
class ModelExtensionRetailcrmCustomer extends Model {
public function sendToCrm($customer) {
$this->load->model('setting/setting');
$settings = $this->model_setting_setting->getSetting('retailcrm');
@ -15,7 +15,7 @@ class ModelRetailcrmCustomer extends Model {
$this->retailcrmApi = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$customerToCrm = $this->process($customer);

View File

@ -1,6 +1,6 @@
<?php
class ModelRetailcrmOrder extends Model {
class ModelExtensionRetailcrmOrder extends Model {
public function sendToCrm($order_data, $order_id)
{
@ -17,7 +17,7 @@ class ModelRetailcrmOrder extends Model {
$this->retailcrm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$order = array();
@ -157,7 +157,7 @@ class ModelRetailcrmOrder extends Model {
$this->retailcrm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
DIR_SYSTEM . 'storage/logs/retailcrm.log'
);
$order = array();
@ -191,7 +191,6 @@ class ModelRetailcrmOrder extends Model {
$order['delivery'] = array(
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
'cost' => $deliveryCost,
'address' => array(
'index' => $order_data['shipping_postcode'],
'city' => $order_data['shipping_city'],
@ -206,6 +205,9 @@ class ModelRetailcrmOrder extends Model {
))
)
);
if(!empty($deliveryCost)){
$order['delivery']['cost'] = $deliveryCost;
}
$orderProducts = isset($order_data['products']) ? $order_data['products'] : $order_data['order_product'];
$offerOptions = array('select', 'radio');

View File

@ -34,17 +34,12 @@ if (!defined('DIR_APPLICATION')) {
require_once(DIR_SYSTEM . 'startup.php');
// Application Classes
if (version_compare(VERSION, '2.2', '>=')) {
require_once(DIR_SYSTEM . 'library/cart/currency.php');
require_once(DIR_SYSTEM . 'library/cart/user.php');
require_once(DIR_SYSTEM . 'library/cart/weight.php');
require_once(DIR_SYSTEM . 'library/cart/length.php');
} else {
require_once(DIR_SYSTEM . 'library/currency.php');
require_once(DIR_SYSTEM . 'library/user.php');
require_once(DIR_SYSTEM . 'library/weight.php');
require_once(DIR_SYSTEM . 'library/length.php');
}
// Registry
$registry = new Registry();
@ -68,10 +63,7 @@ foreach ($query->rows as $setting) {
if (!$setting['serialized']) {
$config->set($setting['key'], $setting['value']);
} else {
if (version_compare(VERSION, '2.1', '>='))
$config->set($setting['key'], json_decode($setting['value']), true);
else
$config->set($setting['key'], unserialize($setting['value']));
}
}
@ -85,10 +77,9 @@ $registry->set('log', $log);
// Event
if (version_compare(VERSION, '2.2', '>=')) {
$event = new Event($registry);
$registry->set('event', $event);
}
function error_handler($errno, $errstr, $errfile, $errline) {
global $log, $config;
@ -153,17 +144,12 @@ $registry->set('language', $language);
$document = new Document();
$registry->set('document', $document);
if (version_compare(VERSION, '2.2', '>=')) {
$registry->set('currency', new Cart\Currency($registry));
$registry->set('weight', new Cart\Weight($registry));
$registry->set('length', new Cart\Length($registry));
$registry->set('user', new Cart\User($registry));
} else {
$registry->set('currency', new Currency($registry));
$registry->set('weight', new Weight($registry));
$registry->set('length', new Length($registry));
$registry->set('user', new User($registry));
}
$controller = new Front($registry);
$action = new Action($cli_action);

View File

@ -1,3 +1,3 @@
<?php
$cli_action = 'module/retailcrm/export';
$cli_action = 'extension/module/retailcrm/export';
require_once('dispatch.php');

View File

@ -1,3 +1,3 @@
<?php
$cli_action = 'module/retailcrm/history';
$cli_action = 'extension/module/retailcrm/history';
require_once('dispatch.php');

View File

@ -1,3 +1,3 @@
<?php
$cli_action = 'module/retailcrm/icml';
$cli_action = 'extension/module/retailcrm/icml';
require_once('dispatch.php');

View File

@ -43,7 +43,7 @@ class OpencartApiClient {
public function request($method, $getParams, $postParams) {
$opencartStoreInfo = $this->model_setting_store->getStore($this->opencartStoreId);
if(version_compare(VERSION, '2.1.0', '>=') && !empty($this->apiToken)) {
if(!empty($this->apiToken)) {
$getParams['token'] = $this->apiToken;
}
@ -89,19 +89,10 @@ class OpencartApiClient {
$api = array();
foreach ($apiUsers as $apiUser) {
if($apiUser['status'] == 1) {
if(version_compare(VERSION, '2.1.0', '>=')) {
$api = array(
'api_id' => $apiUser['api_id'],
'key' => $apiUser['key']
);
} else {
$api = array(
'api_id' => $apiUser['api_id'],
'username' => $apiUser['username'],
'password' => $apiUser['password']
);
}
break;
}
}
@ -109,7 +100,7 @@ class OpencartApiClient {
if(!isset($api['api_id']))
return false;
if(version_compare(VERSION, '2.1.0', '>=')) {
$alreadyBinded = false;
$innerIp = $this->getInnerIpAddr();
@ -122,13 +113,11 @@ class OpencartApiClient {
if(!$alreadyBinded) {
$this->model_user_api->addApiIp($api['api_id'], $innerIp);
}
}
$apiAnswer = $this->request('login', array(), $apiUser);
if(version_compare(VERSION, '2.1.0', '>=')) {
$this->apiToken = $apiAnswer['token'];
}
return $apiAnswer;
}

View File

@ -12,7 +12,7 @@ class RetailcrmHistoryHelper {
$orders = array();
foreach ($orderHistory as $change) {
$change['order'] = self::removeEmpty($change['order']);
if($change['order']['items']) {
if(isset($change['order']['items']) && $change['order']['items']) {
$items = array();
foreach($change['order']['items'] as $item) {
if(isset($change['created'])) {
@ -23,18 +23,18 @@ class RetailcrmHistoryHelper {
$change['order']['items'] = $items;
}
if($change['order']['contragent']['contragentType']) {
if(isset($change['order']['contragent']['contragentType']) && $change['order']['contragent']['contragentType']) {
$change['order']['contragentType'] = $change['order']['contragent']['contragentType'];
unset($change['order']['contragent']);
}
if($orders[$change['order']['id']]) {
if(!empty($orders) && $orders[$change['order']['id']]) {
$orders[$change['order']['id']] = array_merge($orders[$change['order']['id']], $change['order']);
} else {
$orders[$change['order']['id']] = $change['order'];
}
if($change['item']) {
if(isset($change['item']) && $change['item']) {
if($orders[$change['order']['id']]['items'][$change['item']['id']]) {
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']);
} else {
@ -51,15 +51,15 @@ class RetailcrmHistoryHelper {
$orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue'];
}
} else {
if($fields['delivery'][$change['field']] == 'service') {
if(isset($fields['delivery'][$change['field']]) && $fields['delivery'][$change['field']] == 'service'){
$orders[$change['order']['id']]['delivery']['service']['code'] = self::newValue($change['newValue']);
} elseif($fields['delivery'][$change['field']]) {
} elseif(isset($fields['delivery'][$change['field']]) && $fields['delivery'][$change['field']]) {
$orders[$change['order']['id']]['delivery'][$fields['delivery'][$change['field']]] = self::newValue($change['newValue']);
} elseif($fields['orderAddress'][$change['field']]) {
} elseif(isset($fields['orderAddress'][$change['field']]) && $fields['orderAddress'][$change['field']]){
$orders[$change['order']['id']]['delivery']['address'][$fields['orderAddress'][$change['field']]] = $change['newValue'];
} elseif($fields['integrationDelivery'][$change['field']]) {
} elseif(isset($fields['integrationDelivery'][$change['field']]) && $fields['integrationDelivery'][$change['field']]) {
$orders[$change['order']['id']]['delivery']['service'][$fields['integrationDelivery'][$change['field']]] = self::newValue($change['newValue']);
} elseif($fields['customerContragent'][$change['field']]) {
} elseif(isset($fields['customerContragent'][$change['field']]) && $fields['customerContragent'][$change['field']]) {
$orders[$change['order']['id']][$fields['customerContragent'][$change['field']]] = self::newValue($change['newValue']);
} elseif(strripos($change['field'], 'custom_') !== false) {
$orders[$change['order']['id']]['customFields'][str_replace('custom_', '', $change['field'])] = self::newValue($change['newValue']);