From f8a5cd0f5ff7395babff5073dd57e6dd08c9c94f Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Wed, 22 Jul 2015 23:56:05 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=BA=D1=80=D1=8B=D1=82=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=81=D0=BE=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B2=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F,=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 65 +++++++++---------- .../model/retailcrm/dispatch.php | 10 +-- .../model/retailcrm/export.php | 2 +- .../model/retailcrm/history.php | 2 +- admin/model/retailcrm/icml.php | 12 ++-- admin/model/retailcrm/order.php | 2 +- 6 files changed, 42 insertions(+), 51 deletions(-) rename cli/cli_dispatch.php => admin/model/retailcrm/dispatch.php (94%) rename cli/cli_export.php => admin/model/retailcrm/export.php (56%) rename cli/cli_history.php => admin/model/retailcrm/history.php (58%) diff --git a/README.md b/README.md index a459d80..ebab93b 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,69 @@ Opencart module -============== +=============== -Opencart module for interaction with [RetailCRM](http://retailcrm.ru) through [REST API](http://www.retailcrm.ru/docs/). +Модуль интеграции CMS Openacrt c [RetailCRM](http://retailcrm.ru) -###Features +### Модуль позволяет: -* Send orders to RetailCRM -* Get changes from RetailCRM -* Configure relations between dictionaries of IntaroCRM and Opencart (statuses, payments, delivery types and etc) -* Generate catalog export file in [ICML](http://retailcrm.ru/docs/Разработчики/ФорматICML) format +* Экспортировать в CRM данные о заказах и клиентах и получать обратно изменения по этим данным +* Синхронизировать справочники (способы доставки и оплаты, статусы заказов и т.п.) +* Выгружать каталог товаров в формате [ICML](http://retailcrm.ru/docs/Разработчики/ФорматICML) (IntaroCRM Markup Language) -###Install +### Установка -#### Download module +#### Скачайте модуль ``` https://github.com/retailcrm/opencart-module/archive/master.zip ``` -#### Install module +#### Установите модуль скопировав необходимые файлы в корень сайта ``` unzip master.zip cp -r opencart-module/* /path/to/opecart/instance ``` -#### Activate via Admin interface. +#### Активируйте модуль -Go to Modules -> Intstall module. Before running exchange you must configure module. +В основном меню Extension -> Modules -> Intstall module. -#### Export +#### Настройка экспорта данных -Setup cron job for periodically catalog export +Для периодической выгрузки каталога добавьте в cron следующую запись: ``` -* */12 * * * /usr/bin/php /path/to/opencart/cli/cli_export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1 +* */4 * * * /usr/bin/php /path/to/opencart/admin/model/retailcrm/export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1 ``` -Into your CRM settings set path to exported file +В настройках CRM установите путь к файлу выгрузки ``` /download/retailcrm.xml ``` -#### Export new order from shop to CRM +#### Выгрузка новых заказов в CRM (для версии opencart 1.5.x.x, для версии 2.0 и старше не требуется) -Add this lines: +В файле: + +``` +/catalog/model/checkout/order.php +``` + +Добавьте следующие строки в метод addOrder непосредственно перед языковой конструкцией return: ``` $this->load->model('retailcrm/order'); $this->model_retailcrm_order->send($data, $order_id); ``` -into: +В файле: ``` -/catalog/model/checkout/order.php +/admin/model/sale/order.php ``` -script, into addOrder method before return statement - -Add this lines: +Добавьте следующие строки в методы addOrder и editOrder непосредственно перед языковой конструкцией return: ``` if (!isset($data['fromApi'])) { @@ -73,19 +76,11 @@ if (!isset($data['fromApi'])) { } ``` -into: +#### Получение измений из CRM + +Для получения изменений и новых данных добавьте в cron следующую запись: ``` -/admin/model/sale/order.php -``` - -script, into addOrder & editOrder methods at the end of these methods - -#### Export new order from CRM to shop - -Setup cron job for exchange between CRM & your shop - -``` -*/5 * * * * /usr/bin/php /path/to/opencart/cli/cli_history.php >> /path/to/opencart/system/logs/cronjob_history.log 2>&1 +*/5 * * * * /usr/bin/php /path/to/opencart/admin/model/retailcrm/history.php >> /path/to/opencart/system/logs/cronjob_history.log 2>&1 ``` diff --git a/cli/cli_dispatch.php b/admin/model/retailcrm/dispatch.php similarity index 94% rename from cli/cli_dispatch.php rename to admin/model/retailcrm/dispatch.php index 8baa5e4..22170b8 100644 --- a/cli/cli_dispatch.php +++ b/admin/model/retailcrm/dispatch.php @@ -1,12 +1,5 @@ write("ERROR: cli $cli_action call attempted by non-cli."); - http_response_code(400); - exit; -} - // Ensure $cli_action is set if (!isset($cli_action)) { echo 'ERROR: $cli_action must be set in calling script.'; @@ -19,7 +12,7 @@ if (!isset($cli_action)) { define('VERSION', '1.5.6'); // Configuration (note we're using the admin config) -require_once(__DIR__ . '/../admin/config.php'); +require_once(realpath(dirname(__FILE__)) . '/../../config.php'); // Configuration check if (!defined('DIR_APPLICATION')) { @@ -138,4 +131,3 @@ $controller->dispatch($action, new Action('error/not_found')); // Output $response->output(); -?> \ No newline at end of file diff --git a/cli/cli_export.php b/admin/model/retailcrm/export.php similarity index 56% rename from cli/cli_export.php rename to admin/model/retailcrm/export.php index c34100b..85d7d82 100644 --- a/cli/cli_export.php +++ b/admin/model/retailcrm/export.php @@ -1,3 +1,3 @@ eOffers = $this->dd ->getElementsByTagName('offers')->item(0); - $this->addCategories($categories); - $this->addOffers($offers); + $this->addCategories(); + $this->addOffers(); $this->dd->saveXML(); @@ -193,7 +193,11 @@ class ModelRetailcrmIcml extends Model { } } } - + + /** + * @param $image + * @return mixed + */ private function generateImage($image) { $this->load->model('tool/image'); @@ -202,6 +206,6 @@ class ModelRetailcrmIcml extends Model { $image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height') - ) + ); } } diff --git a/admin/model/retailcrm/order.php b/admin/model/retailcrm/order.php index 627808c..f1ae420 100644 --- a/admin/model/retailcrm/order.php +++ b/admin/model/retailcrm/order.php @@ -12,7 +12,7 @@ class ModelRetailcrmOrder extends Model { && !empty($settings['retailcrm_apikey']) ) { - require_once DIR_SYSTEM . 'library/retailcrm/Retailcrm.php'; + require_once DIR_SYSTEM . 'library/retailcrm.php'; $order['order_id'] = $order_id; $crm = new ApiHelper($settings); $crm->processOrder($order);