mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-29 08:36:05 +03:00
Merge pull request #12 from DmitryKorol/version2
module for opencart v2.x
This commit is contained in:
commit
74993334c5
@ -86,7 +86,7 @@ Add to cron:
|
|||||||
Add to cron:
|
Add to cron:
|
||||||
|
|
||||||
```
|
```
|
||||||
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1
|
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/icml.php >> /path/to/opencart/system/logs/cronjob_icml.log 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
Your export file will be available by following url
|
Your export file will be available by following url
|
||||||
|
@ -89,7 +89,7 @@ if (!isset($data['fromApi'])) {
|
|||||||
Для периодической выгрузки каталога добавьте в cron следующую запись:
|
Для периодической выгрузки каталога добавьте в cron следующую запись:
|
||||||
|
|
||||||
```
|
```
|
||||||
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1
|
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/icml.php >> /path/to/opencart/system/logs/cronjob_icml.log 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
В настройках CRM установите путь к файлу выгрузки
|
В настройках CRM установите путь к файлу выгрузки
|
||||||
|
75
admin/controller/module/retailcrm.php
Executable file → Normal file
75
admin/controller/module/retailcrm.php
Executable file → Normal file
@ -28,23 +28,21 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
$this->model_setting_setting
|
$this->model_setting_setting
|
||||||
->editSetting('retailcrm', array('retailcrm_status' => 1));
|
->editSetting('retailcrm', array('retailcrm_status' => 1));
|
||||||
|
|
||||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
$this->load->model('extension/event');
|
||||||
$this->load->model('extension/event');
|
|
||||||
|
|
||||||
$this->model_extension_event
|
$this->model_extension_event
|
||||||
->addEvent(
|
->addEvent(
|
||||||
'retailcrm',
|
'retailcrm',
|
||||||
'post.order.add',
|
version_compare(VERSION, '2.2', '>=') ? 'catalog/model/checkout/order/addOrder/after' : 'post.order.add',
|
||||||
'module/retailcrm/order_create'
|
'module/retailcrm/order_create'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->model_extension_event
|
$this->model_extension_event
|
||||||
->addEvent(
|
->addEvent(
|
||||||
'retailcrm',
|
'retailcrm',
|
||||||
'post.order.history.add',
|
version_compare(VERSION, '2.2', '>=') ? 'catalog/model/checkout/order/addOrderHistory/after' : 'post.order.history.add',
|
||||||
'module/retailcrm/order_edit'
|
'module/retailcrm/order_edit'
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,10 +56,8 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
$this->model_setting_setting
|
$this->model_setting_setting
|
||||||
->editSetting('retailcrm', array('retailcrm_status' => 0));
|
->editSetting('retailcrm', array('retailcrm_status' => 0));
|
||||||
|
|
||||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
$this->load->model('extension/event');
|
||||||
$this->load->model('extension/event');
|
$this->model_extension_event->deleteEvent('retailcrm');
|
||||||
$this->model_extension_event->deleteEvent('retailcrm');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,9 +69,7 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
$this->load->model('extension/module');
|
||||||
$this->load->model('extension/module');
|
|
||||||
}
|
|
||||||
$this->load->model('retailcrm/references');
|
$this->load->model('retailcrm/references');
|
||||||
$this->load->language('module/retailcrm');
|
$this->load->language('module/retailcrm');
|
||||||
$this->document->setTitle($this->language->get('heading_title'));
|
$this->document->setTitle($this->language->get('heading_title'));
|
||||||
@ -93,11 +87,7 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
'SSL'
|
'SSL'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
$this->response->redirect($redirect);
|
||||||
$this->redirect($redirect);
|
|
||||||
} else {
|
|
||||||
$this->response->redirect($redirect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$text_strings = array(
|
$text_strings = array(
|
||||||
@ -117,13 +107,8 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
'retailcrm_dict_payment',
|
'retailcrm_dict_payment',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
$this->load->model('extension/extension');
|
||||||
$_data = &$this->data;
|
$_data = &$data;
|
||||||
$this->load->model('setting/extension');
|
|
||||||
} else {
|
|
||||||
$this->load->model('extension/extension');
|
|
||||||
$_data = &$data;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($text_strings as $text) {
|
foreach ($text_strings as $text) {
|
||||||
$_data[$text] = $this->language->get($text);
|
$_data[$text] = $this->language->get($text);
|
||||||
@ -225,23 +210,13 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
$this->load->model('design/layout');
|
$this->load->model('design/layout');
|
||||||
$_data['layouts'] = $this->model_design_layout->getLayouts();
|
$_data['layouts'] = $this->model_design_layout->getLayouts();
|
||||||
|
|
||||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
$_data['header'] = $this->load->controller('common/header');
|
||||||
$this->template = 'module/retailcrm.1.x.tpl';
|
$_data['column_left'] = $this->load->controller('common/column_left');
|
||||||
$this->children = array(
|
$_data['footer'] = $this->load->controller('common/footer');
|
||||||
'common/header',
|
|
||||||
'common/footer',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->response->setOutput($this->render());
|
$this->response->setOutput(
|
||||||
} else {
|
$this->load->view('module/retailcrm.tpl', $_data)
|
||||||
$_data['header'] = $this->load->controller('common/header');
|
);
|
||||||
$_data['column_left'] = $this->load->controller('common/column_left');
|
|
||||||
$_data['footer'] = $this->load->controller('common/footer');
|
|
||||||
|
|
||||||
$this->response->setOutput(
|
|
||||||
$this->load->view('module/retailcrm.2.x.tpl', $_data)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
62
admin/model/retailcrm/history.php
Executable file → Normal file
62
admin/model/retailcrm/history.php
Executable file → Normal file
@ -10,9 +10,7 @@ class ModelRetailcrmHistory extends Model
|
|||||||
{
|
{
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$this->load->model('setting/store');
|
$this->load->model('setting/store');
|
||||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
$this->load->model('user/api');
|
||||||
$this->load->model('user/api');
|
|
||||||
}
|
|
||||||
$this->load->model('sale/order');
|
$this->load->model('sale/order');
|
||||||
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
||||||
$this->load->model('customer/customer');
|
$this->load->model('customer/customer');
|
||||||
@ -21,6 +19,7 @@ class ModelRetailcrmHistory extends Model
|
|||||||
}
|
}
|
||||||
$this->load->model('retailcrm/references');
|
$this->load->model('retailcrm/references');
|
||||||
$this->load->model('catalog/product');
|
$this->load->model('catalog/product');
|
||||||
|
$this->load->model('catalog/option');
|
||||||
$this->load->model('localisation/zone');
|
$this->load->model('localisation/zone');
|
||||||
|
|
||||||
$this->load->language('module/retailcrm');
|
$this->load->language('module/retailcrm');
|
||||||
@ -37,9 +36,7 @@ class ModelRetailcrmHistory extends Model
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
$this->opencartApiClient = new OpencartApiClient($this->registry);
|
||||||
$this->opencartApiClient = new OpencartApiClient($this->registry);
|
|
||||||
}
|
|
||||||
|
|
||||||
$crm = new RetailcrmProxy(
|
$crm = new RetailcrmProxy(
|
||||||
$settings['retailcrm_url'],
|
$settings['retailcrm_url'],
|
||||||
@ -193,19 +190,36 @@ class ModelRetailcrmHistory extends Model
|
|||||||
$data['order_product'] = array();
|
$data['order_product'] = array();
|
||||||
|
|
||||||
foreach ($order['items'] as $item) {
|
foreach ($order['items'] as $item) {
|
||||||
$product = $this->model_catalog_product->getProduct($item['offer']['externalId']);
|
//$product = $this->model_catalog_product->getProduct($item['offer']['externalId']);
|
||||||
$data['order_product'][] = array(
|
$productId = $item['offer']['externalId'];
|
||||||
'product_id' => $item['offer']['externalId'],
|
$options = array();
|
||||||
'name' => $item['offer']['name'],
|
if(mb_strpos($item['offer']['externalId'], '#') > 1) {
|
||||||
'quantity' => $item['quantity'],
|
$offer = explode('#', $item['offer']['externalId']);
|
||||||
'price' => $item['initialPrice'],
|
$productId = $offer[0];
|
||||||
'total' => $item['initialPrice'] * $item['quantity'],
|
$optionsFromCRM = explode('_', $offer[1]);
|
||||||
'model' => $product['model'],
|
|
||||||
|
|
||||||
// this data will not retrive from crm
|
foreach($optionsFromCRM as $optionFromCRM) {
|
||||||
'order_product_id' => '',
|
$optionData = explode('-', $optionFromCRM);
|
||||||
'tax' => 0,
|
$productOptionId = $optionData[0];
|
||||||
'reward' => 0
|
$optionValueId = $optionData[1];
|
||||||
|
|
||||||
|
$productOptions = $this->model_catalog_product->getProductOptions($productId);
|
||||||
|
|
||||||
|
foreach($productOptions as $productOption) {
|
||||||
|
if($productOptionId == $productOption['product_option_id']) {
|
||||||
|
foreach($productOption['product_option_value'] as $productOptionValue) {
|
||||||
|
if($productOptionValue['option_value_id'] == $optionValueId) {
|
||||||
|
$options[$productOptionId] = $productOptionValue['product_option_value_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['order_product'][] = array(
|
||||||
|
'product_id' => $productId,
|
||||||
|
'quantity' => $item['quantity'],
|
||||||
|
'option' => $options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,11 +261,7 @@ class ModelRetailcrmHistory extends Model
|
|||||||
$data['order_status_id'] = $tmpOrder['order_status_id'];
|
$data['order_status_id'] = $tmpOrder['order_status_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
$this->opencartApiClient->editOrder($order['externalId'], $data);
|
||||||
$this->opencartApiClient->editOrder($order['externalId'], $data);
|
|
||||||
} else {
|
|
||||||
$this->model_sale_order->editOrder($order['externalId'], $data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,11 +452,7 @@ class ModelRetailcrmHistory extends Model
|
|||||||
$data['fromApi'] = true;
|
$data['fromApi'] = true;
|
||||||
$data['order_status_id'] = 1;
|
$data['order_status_id'] = 1;
|
||||||
|
|
||||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
$this->opencartApiClient->addOrder($data);
|
||||||
$this->opencartApiClient->addOrder($data);
|
|
||||||
} else {
|
|
||||||
$this->model_sale_order->addOrder($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$last = $this->model_sale_order->getOrders($data = array('order' => 'DESC', 'limit' => 1, 'start' => 0));
|
$last = $this->model_sale_order->getOrders($data = array('order' => 'DESC', 'limit' => 1, 'start' => 0));
|
||||||
|
|
||||||
|
308
admin/model/retailcrm/icml.php
Executable file → Normal file
308
admin/model/retailcrm/icml.php
Executable file → Normal file
@ -10,11 +10,15 @@ class ModelRetailcrmIcml extends Model
|
|||||||
protected $eCategories;
|
protected $eCategories;
|
||||||
protected $eOffers;
|
protected $eOffers;
|
||||||
|
|
||||||
|
private $options;
|
||||||
|
private $optionValues;
|
||||||
|
|
||||||
public function generateICML()
|
public function generateICML()
|
||||||
{
|
{
|
||||||
$this->load->language('module/retailcrm');
|
$this->load->language('module/retailcrm');
|
||||||
$this->load->model('catalog/category');
|
$this->load->model('catalog/category');
|
||||||
$this->load->model('catalog/product');
|
$this->load->model('catalog/product');
|
||||||
|
$this->load->model('catalog/option');
|
||||||
$this->load->model('catalog/manufacturer');
|
$this->load->model('catalog/manufacturer');
|
||||||
|
|
||||||
$string = '<?xml version="1.0" encoding="UTF-8"?>
|
$string = '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
@ -95,107 +99,192 @@ class ModelRetailcrmIcml extends Model
|
|||||||
|
|
||||||
$products = $this->model_catalog_product->getProducts(array());
|
$products = $this->model_catalog_product->getProducts(array());
|
||||||
|
|
||||||
foreach ($products as $offer) {
|
foreach ($products as $product) {
|
||||||
|
// Формируем офферы отнсительно доступных опций
|
||||||
$e = $this->eOffers->appendChild($this->dd->createElement('offer'));
|
$options = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||||
$e->setAttribute('id', $offer['product_id']);
|
$offerOptions = array('select', 'radio');
|
||||||
$e->setAttribute('productId', $offer['product_id']);
|
$requiredOptions = array();
|
||||||
$e->setAttribute('quantity', $offer['quantity']);
|
$notRequiredOptions = array();
|
||||||
|
// Оставляем опции связанные с вариациями товаров, сортируем по параметру обязательный или нет
|
||||||
/**
|
foreach($options as $option) {
|
||||||
* Offer activity
|
if(in_array($option['type'], $offerOptions)) {
|
||||||
*/
|
if($option['required']) {
|
||||||
$activity = $offer['status'] == 1 ? 'Y' : 'N';
|
$requiredOptions[] = $option;
|
||||||
$e->appendChild(
|
} else {
|
||||||
$this->dd->createElement('productActivity')
|
$notRequiredOptions[] = $option;
|
||||||
)->appendChild(
|
}
|
||||||
$this->dd->createTextNode($activity)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Offer categories
|
|
||||||
*/
|
|
||||||
$categories = $this->model_catalog_product
|
|
||||||
->getProductCategories($offer['product_id']);
|
|
||||||
|
|
||||||
if (!empty($categories)) {
|
|
||||||
foreach ($categories as $category) {
|
|
||||||
$e->appendChild($this->dd->createElement('categoryId'))
|
|
||||||
->appendChild(
|
|
||||||
$this->dd->createTextNode($category)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$offers = array();
|
||||||
|
// Сначала совмещаем все обязательные опции
|
||||||
|
foreach($requiredOptions as $requiredOption) {
|
||||||
|
// Если первая итерация
|
||||||
|
if(empty($offers)) {
|
||||||
|
foreach($requiredOption['product_option_value'] as $optionValue) {
|
||||||
|
$offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = (float)$optionValue['price'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach($offers as $optionKey => $optionCost) {
|
||||||
|
unset($offers[$optionKey]); // Работая в контексте обязательных опций не забываем удалять прошлые обязательные опции, т.к. они должны быть скомбинированы с другими обязательными опциями
|
||||||
|
foreach($requiredOption['product_option_value'] as $optionValue) {
|
||||||
|
$offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = $optionCost + (float)$optionValue['price'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Совмещаем или добавляем необязательные опции, учитывая тот факт что обязательных опций может и не быть.
|
||||||
|
foreach($notRequiredOptions as $notRequiredOption) {
|
||||||
|
// Если обязательных опцией не оказалось и первая итерация
|
||||||
|
if(empty($offers)) {
|
||||||
|
$offers['0:0-0'] = 0; // В случае работы с необязательными опциями мы должны учитывать товарное предложение без опций, поэтому создадим "пустую" опцию
|
||||||
|
foreach($notRequiredOption['product_option_value'] as $optionValue) {
|
||||||
|
$offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = (float)$optionValue['price'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach($offers as $optionKey => $optionCost) {
|
||||||
|
foreach($notRequiredOption['product_option_value'] as $optionValue) {
|
||||||
|
$offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = $optionCost + (float)$optionValue['price'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(empty($offers)) {
|
||||||
|
$offers = array('0:0-0' => '0');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
foreach($offers as $optionsString => $optionsTotalCost) {
|
||||||
* Name & price
|
$optionsString = explode('_', $optionsString);
|
||||||
*/
|
$options = array();
|
||||||
$e->appendChild($this->dd->createElement('name'))
|
foreach($optionsString as $optionString) {
|
||||||
->appendChild($this->dd->createTextNode($offer['name']));
|
$option = explode('-', $optionString);
|
||||||
$e->appendChild($this->dd->createElement('productName'))
|
$optionIds = explode(':', $option[0]);
|
||||||
->appendChild($this->dd->createTextNode($offer['name']));
|
if($optionString != '0:0-0') {
|
||||||
$e->appendChild($this->dd->createElement('price'))
|
$optionData = $this->getOptionData($optionIds[1], $option[1]);
|
||||||
->appendChild($this->dd->createTextNode($offer['price']));
|
$options[$optionIds[0]] = array(
|
||||||
|
'name' => $optionData['optionName'],
|
||||||
/**
|
'value' => $optionData['optionValue'],
|
||||||
* Vendor
|
'value_id' => $option[1]
|
||||||
*/
|
);
|
||||||
if ($offer['manufacturer_id'] != 0) {
|
}
|
||||||
$e->appendChild($this->dd->createElement('vendor'))
|
}
|
||||||
|
ksort($options);
|
||||||
|
$offerId = array();
|
||||||
|
foreach($options as $optionKey => $optionData) {
|
||||||
|
$offerId[] = $optionKey.'-'.$optionData['value_id'];
|
||||||
|
}
|
||||||
|
$offerId = implode('_', $offerId);
|
||||||
|
$e = $this->eOffers->appendChild($this->dd->createElement('offer'));
|
||||||
|
if(!empty($offerId))
|
||||||
|
$e->setAttribute('id', $product['product_id'].'#'.$offerId);
|
||||||
|
else
|
||||||
|
$e->setAttribute('id', $product['product_id']);
|
||||||
|
$e->setAttribute('productId', $product['product_id']);
|
||||||
|
$e->setAttribute('quantity', $product['quantity']);
|
||||||
|
/**
|
||||||
|
* Offer activity
|
||||||
|
*/
|
||||||
|
$activity = $product['status'] == 1 ? 'Y' : 'N';
|
||||||
|
$e->appendChild(
|
||||||
|
$this->dd->createElement('productActivity')
|
||||||
|
)->appendChild(
|
||||||
|
$this->dd->createTextNode($activity)
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* Offer categories
|
||||||
|
*/
|
||||||
|
$categories = $this->model_catalog_product
|
||||||
|
->getProductCategories($product['product_id']);
|
||||||
|
if (!empty($categories)) {
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$e->appendChild($this->dd->createElement('categoryId'))
|
||||||
|
->appendChild(
|
||||||
|
$this->dd->createTextNode($category)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Name & price
|
||||||
|
*/
|
||||||
|
$e->appendChild($this->dd->createElement('productName'))
|
||||||
|
->appendChild($this->dd->createTextNode($product['name']));
|
||||||
|
if(!empty($options)) {
|
||||||
|
$optionsString = array();
|
||||||
|
foreach($options as $option) {
|
||||||
|
$optionsString[] = $option['name'].': '.$option['value'];
|
||||||
|
}
|
||||||
|
$optionsString = ' ('.implode(', ', $optionsString).')';
|
||||||
|
$e->appendChild($this->dd->createElement('name'))
|
||||||
|
->appendChild($this->dd->createTextNode($product['name'].$optionsString));
|
||||||
|
} else {
|
||||||
|
$e->appendChild($this->dd->createElement('name'))
|
||||||
|
->appendChild($this->dd->createTextNode($product['name']));
|
||||||
|
}
|
||||||
|
$e->appendChild($this->dd->createElement('price'))
|
||||||
|
->appendChild($this->dd->createTextNode($product['price'] + $optionsTotalCost));
|
||||||
|
/**
|
||||||
|
* Vendor
|
||||||
|
*/
|
||||||
|
if ($product['manufacturer_id'] != 0) {
|
||||||
|
$e->appendChild($this->dd->createElement('vendor'))
|
||||||
|
->appendChild(
|
||||||
|
$this->dd->createTextNode(
|
||||||
|
$offerManufacturers[$product['manufacturer_id']]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Image
|
||||||
|
*/
|
||||||
|
if ($product['image']) {
|
||||||
|
$image = $this->generateImage($product['image']);
|
||||||
|
$e->appendChild($this->dd->createElement('picture'))
|
||||||
|
->appendChild($this->dd->createTextNode($image));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Url
|
||||||
|
*/
|
||||||
|
$this->url = new Url(
|
||||||
|
HTTP_CATALOG,
|
||||||
|
$this->config->get('config_secure')
|
||||||
|
? HTTP_CATALOG
|
||||||
|
: HTTPS_CATALOG
|
||||||
|
);
|
||||||
|
$e->appendChild($this->dd->createElement('url'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
$this->dd->createTextNode(
|
$this->dd->createTextNode(
|
||||||
$offerManufacturers[$offer['manufacturer_id']]
|
$this->url->link(
|
||||||
|
'product/product&product_id=' . $product['product_id']
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
// Options
|
||||||
|
if(!empty($options)) {
|
||||||
/**
|
foreach($options as $optionKey => $optionData) {
|
||||||
* Image
|
$param = $this->dd->createElement('param');
|
||||||
*/
|
$param->setAttribute('code', $optionKey);
|
||||||
if ($offer['image']) {
|
$param->setAttribute('name', $optionData['name']);
|
||||||
$image = $this->generateImage($offer['image']);
|
$param->appendChild($this->dd->createTextNode($optionData['value']));
|
||||||
$e->appendChild($this->dd->createElement('picture'))
|
$e->appendChild($param);
|
||||||
->appendChild($this->dd->createTextNode($image));
|
}
|
||||||
}
|
}
|
||||||
|
if ($product['sku']) {
|
||||||
/**
|
$sku = $this->dd->createElement('param');
|
||||||
* Url
|
$sku->setAttribute('code', 'article');
|
||||||
*/
|
$sku->setAttribute('name', $this->language->get('article'));
|
||||||
$this->url = new Url(
|
$sku->appendChild($this->dd->createTextNode($product['sku']));
|
||||||
HTTP_CATALOG,
|
$e->appendChild($sku);
|
||||||
$this->config->get('config_secure')
|
}
|
||||||
? HTTP_CATALOG
|
if ($product['weight'] != '') {
|
||||||
: HTTPS_CATALOG
|
$weight = $this->dd->createElement('param');
|
||||||
);
|
$weight->setAttribute('code', 'weight');
|
||||||
|
$weight->setAttribute('name', $this->language->get('weight'));
|
||||||
$e->appendChild($this->dd->createElement('url'))
|
$weightValue = (isset($offer['weight_class']))
|
||||||
->appendChild(
|
? round($product['weight'], 3) . ' ' . $product['weight_class']
|
||||||
$this->dd->createTextNode(
|
: round($product['weight'], 3)
|
||||||
$this->url->link(
|
;
|
||||||
'product/product&product_id=' . $offer['product_id']
|
$weight->appendChild($this->dd->createTextNode($weightValue));
|
||||||
)
|
$e->appendChild($weight);
|
||||||
)
|
}
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if ($offer['sku']) {
|
|
||||||
$sku = $this->dd->createElement('param');
|
|
||||||
$sku->setAttribute('code', 'article');
|
|
||||||
$sku->setAttribute('name', $this->language->get('article'));
|
|
||||||
$sku->appendChild($this->dd->createTextNode($offer['sku']));
|
|
||||||
$e->appendChild($sku);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($offer['weight'] != '') {
|
|
||||||
$weight = $this->dd->createElement('param');
|
|
||||||
$weight->setAttribute('code', 'weight');
|
|
||||||
$weight->setAttribute('name', $this->language->get('weight'));
|
|
||||||
$weightValue = (isset($offer['weight_class']))
|
|
||||||
? round($offer['weight'], 3) . ' ' . $offer['weight_class']
|
|
||||||
: round($offer['weight'], 3)
|
|
||||||
;
|
|
||||||
$weight->appendChild($this->dd->createTextNode($weightValue));
|
|
||||||
$e->appendChild($weight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,10 +297,41 @@ class ModelRetailcrmIcml extends Model
|
|||||||
{
|
{
|
||||||
$this->load->model('tool/image');
|
$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;
|
||||||
|
|
||||||
|
return $this->model_tool_image->resize(
|
||||||
|
$image,
|
||||||
|
$width,
|
||||||
|
$height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->model_tool_image->resize(
|
return $this->model_tool_image->resize(
|
||||||
$image,
|
$image,
|
||||||
$this->config->get('config_image_product_width'),
|
$this->config->get('config_image_product_width'),
|
||||||
$this->config->get('config_image_product_height')
|
$this->config->get('config_image_product_height')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getOptionData($optionId, $optionValueId) {
|
||||||
|
if(!empty($this->options[$optionId])) {
|
||||||
|
$option = $this->options[$optionId];
|
||||||
|
} else {
|
||||||
|
$option = $this->model_catalog_option->getOption($optionId);
|
||||||
|
$this->options[$optionId] = $option;
|
||||||
|
}
|
||||||
|
if(!empty($this->optionValues[$optionValueId])) {
|
||||||
|
$optionValue = $this->optionValues[$optionValueId];
|
||||||
|
} else {
|
||||||
|
$optionValue = $this->model_catalog_option->getOptionValue($optionValueId);
|
||||||
|
$this->optionValues[$optionValueId] = $optionValue;
|
||||||
|
}
|
||||||
|
return array(
|
||||||
|
'optionName' => $option['name'],
|
||||||
|
'optionValue' => $optionValue['name']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
<?php echo $header; ?>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
<div class="breadcrumb">
|
|
||||||
<?php foreach ($breadcrumbs as $breadcrumb): ?>
|
|
||||||
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php if ($error_warning) : ?>
|
|
||||||
<div class="warning"><?php echo $error_warning; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($saved_settings['retailcrm_url'])): ?>
|
|
||||||
<div class="success">
|
|
||||||
<?php echo $text_notice; ?>
|
|
||||||
<a href="<?php echo $saved_settings['retailcrm_url']; ?>/admin/settings#t-main"><?php echo $saved_settings['retailcrm_url']; ?>/admin/settings#t-main</a>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="box">
|
|
||||||
<div class="heading">
|
|
||||||
<h1><img src="view/image/module.png" alt="" /> <?php echo $heading_title; ?></h1>
|
|
||||||
<div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
|
|
||||||
</div>
|
|
||||||
<div class="content">
|
|
||||||
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
|
|
||||||
<input type="hidden" name="retailcrm_status" value="1">
|
|
||||||
|
|
||||||
<h3><?php echo $retailcrm_base_settings; ?></h3>
|
|
||||||
<div class="retailcrm_unit">
|
|
||||||
<label for="retailcrm_url"><?php echo $retailcrm_url; ?></label><br>
|
|
||||||
<input id="retailcrm_url" type="text" name="retailcrm_url" value="<?php if (isset($saved_settings['retailcrm_url'])): echo $saved_settings['retailcrm_url']; endif; ?>">
|
|
||||||
</div>
|
|
||||||
<div class="retailcrm_unit">
|
|
||||||
<label for="retailcrm_apikey"><?php echo $retailcrm_apikey; ?></label><br>
|
|
||||||
<input id="retailcrm_apikey" type="text" name="retailcrm_apikey" value="<?php if (isset($saved_settings['retailcrm_apikey'])): echo $saved_settings['retailcrm_apikey']; endif;?>">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?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): ?>
|
|
||||||
<div class="warning"><?php echo $retailcrm_error ?></div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php else: ?>
|
|
||||||
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
|
||||||
|
|
||||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
|
||||||
<?php foreach ($delivery['opencart'] as $key => $value): ?>
|
|
||||||
<div class="retailcrm_unit">
|
|
||||||
<select id="retailcrm_delivery_<?php echo $key; ?>" name="retailcrm_delivery[<?php echo $key; ?>]" >
|
|
||||||
<?php foreach ($delivery['retailcrm'] as $k => $v): ?>
|
|
||||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_delivery'][$key]) && $v['code'] == $saved_settings['retailcrm_delivery'][$key]):?>selected="selected"<?php endif;?>>
|
|
||||||
<?php echo $v['name'];?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
<label for="retailcrm_delivery_<?php echo $key; ?>"><?php echo $value; ?></label>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<h4><?php echo $retailcrm_dict_status; ?></h4>
|
|
||||||
<?php foreach ($statuses['opencart'] as $status): ?>
|
|
||||||
<?php $uid = $status['order_status_id']?>
|
|
||||||
<div class="retailcrm_unit">
|
|
||||||
<select id="retailcrm_status_<?php echo $uid; ?>" name="retailcrm_status[<?php echo $uid; ?>]" >
|
|
||||||
<?php foreach ($statuses['retailcrm'] as $k => $v): ?>
|
|
||||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_status'][$uid]) && $v['code'] == $saved_settings['retailcrm_status'][$uid]):?>selected="selected"<?php endif;?>>
|
|
||||||
<?php echo $v['name'];?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
<label for="retailcrm_status_<?php echo $status['order_status_id']; ?>"><?php echo $status['name']; ?></label>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<h4><?php echo $retailcrm_dict_payment; ?></h4>
|
|
||||||
<?php foreach ($payments['opencart'] as $key => $value): ?>
|
|
||||||
<div class="retailcrm_unit">
|
|
||||||
<select id="retailcrm_payment_<?php echo $key; ?>" name="retailcrm_payment[<?php echo $key; ?>]" >
|
|
||||||
<?php foreach ($payments['retailcrm'] as $k => $v): ?>
|
|
||||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_payment'][$key]) && $v['code'] == $saved_settings['retailcrm_payment'][$key]):?>selected="selected"<?php endif;?>>
|
|
||||||
<?php echo $v['name'];?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
<label for="retailcrm_payment_<?php echo $key; ?>"><?php echo $value; ?></label>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<?php echo $footer; ?>
|
|
28
catalog/controller/module/retailcrm.php
Executable file → Normal file
28
catalog/controller/module/retailcrm.php
Executable file → Normal file
@ -18,13 +18,25 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function order_create($order_id)
|
public function order_create($parameter1, $parameter2 = null)
|
||||||
{
|
{
|
||||||
$this->load->model('checkout/order');
|
$this->load->model('checkout/order');
|
||||||
$this->load->model('account/order');
|
$this->load->model('account/order');
|
||||||
|
|
||||||
|
if($parameter2 != null)
|
||||||
|
$order_id = $parameter2;
|
||||||
|
else
|
||||||
|
$order_id = $parameter1;
|
||||||
|
|
||||||
$data = $this->model_checkout_order->getOrder($order_id);
|
$data = $this->model_checkout_order->getOrder($order_id);
|
||||||
|
|
||||||
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
|
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
|
||||||
|
foreach($data['products'] as $key => $product) {
|
||||||
|
$productOptions = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);
|
||||||
|
|
||||||
|
if(!empty($productOptions))
|
||||||
|
$data['products'][$key]['option'] = $productOptions;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($data['fromApi'])) {
|
if (!isset($data['fromApi'])) {
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
@ -43,7 +55,12 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function order_edit($order_id) {
|
public function order_edit($parameter1, $parameter2 = null, $parameter3 = null, $parameter4 = null) {
|
||||||
|
if($parameter4 != null)
|
||||||
|
$order_id = $parameter3;
|
||||||
|
else
|
||||||
|
$order_id = $parameter1;
|
||||||
|
|
||||||
$this->load->model('checkout/order');
|
$this->load->model('checkout/order');
|
||||||
$this->load->model('account/order');
|
$this->load->model('account/order');
|
||||||
|
|
||||||
@ -53,6 +70,13 @@ class ControllerModuleRetailcrm extends Controller
|
|||||||
|
|
||||||
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
|
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
|
||||||
|
|
||||||
|
foreach($data['products'] as $key => $product) {
|
||||||
|
$productOptions = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);
|
||||||
|
|
||||||
|
if(!empty($productOptions))
|
||||||
|
$data['products'][$key]['option'] = $productOptions;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($data['fromApi'])) {
|
if (!isset($data['fromApi'])) {
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$status = $this->model_setting_setting->getSetting('retailcrm');
|
$status = $this->model_setting_setting->getSetting('retailcrm');
|
||||||
|
76
catalog/model/retailcrm/order.php
Executable file → Normal file
76
catalog/model/retailcrm/order.php
Executable file → Normal file
@ -10,6 +10,8 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
||||||
|
|
||||||
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
||||||
|
$this->load->model('catalog/product');
|
||||||
|
|
||||||
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
||||||
|
|
||||||
$this->retailcrm = new RetailcrmProxy(
|
$this->retailcrm = new RetailcrmProxy(
|
||||||
@ -29,8 +31,10 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($customers['customers'] as $customer) {
|
if($customers) {
|
||||||
$order['customer']['id'] = $customer['id'];
|
foreach ($customers['customers'] as $customer) {
|
||||||
|
$order['customer']['id'] = $customer['id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($customers);
|
unset($customers);
|
||||||
@ -59,14 +63,12 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
$payment_code = $order_data['payment_code'];
|
$payment_code = $order_data['payment_code'];
|
||||||
$order['paymentType'] = $settings['retailcrm_payment'][$payment_code];
|
$order['paymentType'] = $settings['retailcrm_payment'][$payment_code];
|
||||||
|
|
||||||
// Совместимость с 1.5.5, когда этот метод вызывается из model/checkout/order->createOrder(), а не из controller/module/retailcrm->order_create()
|
|
||||||
if(!isset($order_data['shipping_iso_code_2']) && isset($order_data['shipping_country_id'])) {
|
if(!isset($order_data['shipping_iso_code_2']) && isset($order_data['shipping_country_id'])) {
|
||||||
$this->load->model('localisation/country');
|
$this->load->model('localisation/country');
|
||||||
$shipping_country = $this->model_localisation_country->getCountry($order_data['shipping_country_id']);
|
$shipping_country = $this->model_localisation_country->getCountry($order_data['shipping_country_id']);
|
||||||
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
|
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$delivery_code = $order_data['shipping_code'];
|
$delivery_code = $order_data['shipping_code'];
|
||||||
$order['delivery'] = array(
|
$order['delivery'] = array(
|
||||||
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
|
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
|
||||||
@ -87,10 +89,40 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$orderProducts = isset($order_data['products']) ? $order_data['products'] : $order_data['order_product'];
|
$orderProducts = isset($order_data['products']) ? $order_data['products'] : $order_data['order_product'];
|
||||||
|
$offerOptions = array('select', 'radio');
|
||||||
|
|
||||||
foreach ($orderProducts as $product) {
|
foreach ($orderProducts as $product) {
|
||||||
|
$offerId = '';
|
||||||
|
|
||||||
|
if(!empty($product['option'])) {
|
||||||
|
$options = array();
|
||||||
|
|
||||||
|
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||||
|
|
||||||
|
foreach($product['option'] as $option) {
|
||||||
|
if(!in_array($option['type'], $offerOptions)) continue;
|
||||||
|
foreach($productOptions as $productOption) {
|
||||||
|
if($productOption['product_option_id'] = $option['product_option_id']) {
|
||||||
|
foreach($productOption['product_option_value'] as $productOptionValue) {
|
||||||
|
if($productOptionValue['product_option_value_id'] == $option['product_option_value_id']) {
|
||||||
|
$options[$option['product_option_id']] = $productOptionValue['option_value_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($options);
|
||||||
|
|
||||||
|
$offerId = array();
|
||||||
|
foreach($options as $optionKey => $optionValue) {
|
||||||
|
$offerId[] = $optionKey.'-'.$optionValue;
|
||||||
|
}
|
||||||
|
$offerId = implode('_', $offerId);
|
||||||
|
}
|
||||||
|
|
||||||
$order['items'][] = array(
|
$order['items'][] = array(
|
||||||
'productId' => $product['product_id'],
|
'productId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id'],
|
||||||
'productName' => $product['name'],
|
'productName' => $product['name'],
|
||||||
'initialPrice' => $product['price'],
|
'initialPrice' => $product['price'],
|
||||||
'quantity' => $product['quantity'],
|
'quantity' => $product['quantity'],
|
||||||
@ -113,6 +145,8 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
||||||
|
|
||||||
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
|
||||||
|
$this->load->model('catalog/product');
|
||||||
|
|
||||||
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
||||||
|
|
||||||
$this->retailcrm = new RetailcrmProxy(
|
$this->retailcrm = new RetailcrmProxy(
|
||||||
@ -166,10 +200,40 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$orderProducts = isset($order_data['products']) ? $order_data['products'] : $order_data['order_product'];
|
$orderProducts = isset($order_data['products']) ? $order_data['products'] : $order_data['order_product'];
|
||||||
|
$offerOptions = array('select', 'radio');
|
||||||
|
|
||||||
foreach ($orderProducts as $product) {
|
foreach ($orderProducts as $product) {
|
||||||
|
$offerId = '';
|
||||||
|
|
||||||
|
if(!empty($product['option'])) {
|
||||||
|
$options = array();
|
||||||
|
|
||||||
|
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||||
|
|
||||||
|
foreach($product['option'] as $option) {
|
||||||
|
if(!in_array($option['type'], $offerOptions)) continue;
|
||||||
|
foreach($productOptions as $productOption) {
|
||||||
|
if($productOption['product_option_id'] = $option['product_option_id']) {
|
||||||
|
foreach($productOption['product_option_value'] as $productOptionValue) {
|
||||||
|
if($productOptionValue['product_option_value_id'] == $option['product_option_value_id']) {
|
||||||
|
$options[$option['product_option_id']] = $productOptionValue['option_value_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($options);
|
||||||
|
|
||||||
|
$offerId = array();
|
||||||
|
foreach($options as $optionKey => $optionValue) {
|
||||||
|
$offerId[] = $optionKey.'-'.$optionValue;
|
||||||
|
}
|
||||||
|
$offerId = implode('_', $offerId);
|
||||||
|
}
|
||||||
|
|
||||||
$order['items'][] = array(
|
$order['items'][] = array(
|
||||||
'productId' => $product['product_id'],
|
'productId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id'],
|
||||||
'productName' => $product['name'],
|
'productName' => $product['name'],
|
||||||
'initialPrice' => $product['price'],
|
'initialPrice' => $product['price'],
|
||||||
'quantity' => $product['quantity'],
|
'quantity' => $product['quantity'],
|
||||||
|
45
system/cron/dispatch.php
Executable file → Normal file
45
system/cron/dispatch.php
Executable file → Normal file
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$_SERVER['HTTPS'] = 'off';
|
||||||
|
$_SERVER['SERVER_PORT'] = 80;
|
||||||
|
|
||||||
// Ensure $cli_action is set
|
// Ensure $cli_action is set
|
||||||
if (!isset($cli_action)) {
|
if (!isset($cli_action)) {
|
||||||
echo 'ERROR: $cli_action must be set in calling script.';
|
echo 'ERROR: $cli_action must be set in calling script.';
|
||||||
@ -31,10 +34,17 @@ if (!defined('DIR_APPLICATION')) {
|
|||||||
require_once(DIR_SYSTEM . 'startup.php');
|
require_once(DIR_SYSTEM . 'startup.php');
|
||||||
|
|
||||||
// Application Classes
|
// Application Classes
|
||||||
require_once(DIR_SYSTEM . 'library/currency.php');
|
if (version_compare(VERSION, '2.2', '>=')) {
|
||||||
require_once(DIR_SYSTEM . 'library/user.php');
|
require_once(DIR_SYSTEM . 'library/cart/currency.php');
|
||||||
require_once(DIR_SYSTEM . 'library/weight.php');
|
require_once(DIR_SYSTEM . 'library/cart/user.php');
|
||||||
require_once(DIR_SYSTEM . 'library/length.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
|
||||||
$registry = new Registry();
|
$registry = new Registry();
|
||||||
@ -58,7 +68,10 @@ foreach ($query->rows as $setting) {
|
|||||||
if (!$setting['serialized']) {
|
if (!$setting['serialized']) {
|
||||||
$config->set($setting['key'], $setting['value']);
|
$config->set($setting['key'], $setting['value']);
|
||||||
} else {
|
} else {
|
||||||
$config->set($setting['key'], unserialize($setting['value']));
|
if (version_compare(VERSION, '2.1', '>='))
|
||||||
|
$config->set($setting['key'], json_decode($setting['value']), true);
|
||||||
|
else
|
||||||
|
$config->set($setting['key'], unserialize($setting['value']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +83,13 @@ $registry->set('url', $url);
|
|||||||
$log = new Log($config->get('config_error_filename'));
|
$log = new Log($config->get('config_error_filename'));
|
||||||
$registry->set('log', $log);
|
$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) {
|
function error_handler($errno, $errstr, $errfile, $errline) {
|
||||||
global $log, $config;
|
global $log, $config;
|
||||||
|
|
||||||
@ -133,10 +153,17 @@ $registry->set('language', $language);
|
|||||||
$document = new Document();
|
$document = new Document();
|
||||||
$registry->set('document', $document);
|
$registry->set('document', $document);
|
||||||
|
|
||||||
$registry->set('currency', new Currency($registry));
|
if (version_compare(VERSION, '2.2', '>=')) {
|
||||||
$registry->set('weight', new Weight($registry));
|
$registry->set('currency', new Cart\Currency($registry));
|
||||||
$registry->set('length', new Length($registry));
|
$registry->set('weight', new Cart\Weight($registry));
|
||||||
$registry->set('user', new User($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);
|
$controller = new Front($registry);
|
||||||
$action = new Action($cli_action);
|
$action = new Action($cli_action);
|
||||||
|
3
system/library/retailcrm/OpencartApiClient.php
Executable file → Normal file
3
system/library/retailcrm/OpencartApiClient.php
Executable file → Normal file
@ -152,7 +152,8 @@ class OpencartApiClient {
|
|||||||
foreach ($data['order_product'] as $order_product) {
|
foreach ($data['order_product'] as $order_product) {
|
||||||
$products[] = array(
|
$products[] = array(
|
||||||
'product_id' => $order_product['product_id'],
|
'product_id' => $order_product['product_id'],
|
||||||
'quantity' => $order_product['quantity']
|
'quantity' => $order_product['quantity'],
|
||||||
|
'option' => $order_product['option']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->request('cart/add', array(), array('product' => $products));
|
$this->request('cart/add', array(), array('product' => $products));
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<modification>
|
|
||||||
<id>Send order to RetailCRM when it created</id>
|
|
||||||
<version>1.5.x</version>
|
|
||||||
<vqmver required="true">2.3.x</vqmver>
|
|
||||||
<author>retailcrm.ru</author>
|
|
||||||
|
|
||||||
<file path="catalog/controller/checkout/" name="success.php">
|
|
||||||
<operation error="skip">
|
|
||||||
<search position="before" ><![CDATA[$this->cart->clear()]]></search>
|
|
||||||
<add><![CDATA[
|
|
||||||
$this->load->model('account/order');
|
|
||||||
$this->load->model('checkout/order');
|
|
||||||
$this->load->model('retailcrm/order');
|
|
||||||
|
|
||||||
$order = $this->model_checkout_order->getOrder($this->session->data['order_id']);
|
|
||||||
$order['products'] = $this->model_account_order->getOrderProducts($this->session->data['order_id']);
|
|
||||||
$order['order_total'] = $this->model_account_order->getOrderTotals($this->session->data['order_id']);
|
|
||||||
|
|
||||||
$this->model_retailcrm_order->sendToCrm($order, $this->session->data['order_id']);
|
|
||||||
]]></add>
|
|
||||||
</operation>
|
|
||||||
</file>
|
|
||||||
|
|
||||||
<file path="admin/model/sale/" name="order.php">
|
|
||||||
<operation error="skip">
|
|
||||||
<search position="after" ><![CDATA[$this->db->query("UPDATE `" . DB_PREFIX . "order` SET total = '" . (float)$total . "', affiliate_id = '" . (int)$affiliate_id . "', commission = '" . (float)$commission . "' WHERE order_id = '" . (int)$order_id . "'");]]></search>
|
|
||||||
<add><![CDATA[
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]></add>
|
|
||||||
</operation>
|
|
||||||
</file>
|
|
||||||
</modification>
|
|
Loading…
Reference in New Issue
Block a user