opencart-module/README.md

97 lines
2.2 KiB
Markdown
Raw Normal View History

2014-08-19 08:00:13 +04:00
Opencart module
2016-01-29 18:04:48 +03:00
===============
2014-08-15 13:35:22 +04:00
2016-03-14 23:00:43 +03:00
Module allows integrate CMS Opencart with [retailCRM](http://retailcrm.ru)
2014-08-15 13:35:22 +04:00
2016-03-14 23:00:43 +03:00
#### Features:
2014-08-15 13:35:22 +04:00
2016-03-10 02:07:25 +03:00
* Export orders to retailCRM & fetch changes back
* Export product catalog into [ICML](http://www.retailcrm.ru/docs/Developers/ICML) format
2014-08-15 13:35:22 +04:00
2016-03-10 02:07:25 +03:00
#### Install
2014-08-19 23:53:11 +04:00
2016-03-10 02:07:25 +03:00
Copy files to the site root
2016-01-29 18:04:48 +03:00
```
unzip master.zip
cp -r opencart-module/* /path/to/site/root
```
2016-03-10 02:07:25 +03:00
#### Setup
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
* Go to Admin -> Extensions -> Modules -> retailCRM
* Fill you api url & api key
* Specify directories matching
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
#### Export orders to retailCRM (for opencart 1.5.x, for version 2.x this step is unnecessary)
2016-01-29 18:04:48 +03:00
##### VQmod
2016-03-10 02:07:25 +03:00
Copy _retailcrm_create_order.xml_ into _/path/to/site/root/vqmod/xml_.
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
For VQmod cache renewal you may need to delete files _/path/to/site/root/vqmod/vqcache/vq2-admin_model_sale_order.php_ & _/path/to/site/root/vqmod/vqcache/vq2-catalog_model_checkout_order.php_
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
##### Manual setup
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
In the file:
2016-01-29 18:04:48 +03:00
```
/catalog/model/checkout/order.php
```
2016-03-10 02:07:25 +03:00
add theese lines into addOrder method right before return statement:
2016-01-29 18:04:48 +03:00
```php
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->sendToCrm($data, $order_id);
```
2016-03-10 02:07:25 +03:00
In the file:
2016-01-29 18:04:48 +03:00
```
/admin/model/sale/order.php
```
2016-03-10 02:07:25 +03:00
add theese lines into addOrder & editOrder methods right before return statement:
2016-01-29 18:04:48 +03:00
```php
if (!isset($data['fromApi'])) {
$this->load->model('setting/setting');
$status = $this->model_setting_setting->getSetting('retailcrm');
if (!empty($data['order_status_id'])) {
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
}
$this->load->model('retailcrm/order');
if (isset ($order_query)) {
$this->model_retailcrm_order->changeInCrm($data, $order_id);
} else {
$this->model_retailcrm_order->sendToCrm($data, $order_id);
}
}
```
2016-03-10 02:07:25 +03:00
#### Getting changes in orders
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
Add to cron:
2016-01-29 18:04:48 +03:00
```
2016-03-10 02:07:25 +03:00
*/5 * * * * /usr/bin/php /path/to/opencart/system/cron/history.php >> /path/to/opencart/system/logs/cronjob_history.log 2>&1
2016-01-29 18:04:48 +03:00
```
2016-03-10 02:07:25 +03:00
#### Setting product catalog export
2016-01-29 18:04:48 +03:00
2016-03-10 02:07:25 +03:00
Add to cron:
2016-01-29 18:04:48 +03:00
```
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1
```
2016-03-10 02:07:25 +03:00
Your export file will be available by following url
2016-01-29 18:04:48 +03:00
```
2016-03-10 02:07:25 +03:00
http://youropencartsite.com/retailcrm.xml
2016-01-29 18:04:48 +03:00
```