mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 22:56:07 +03:00
Product properties in the order (#27)
This commit is contained in:
parent
82e6d62076
commit
00f273ff3c
@ -54,13 +54,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
'catalog/model/account/customer/addCustomer/after',
|
'catalog/model/account/customer/addCustomer/after',
|
||||||
'extension/module/retailcrm/customer_create'
|
'extension/module/retailcrm/customer_create'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->model_extension_event
|
|
||||||
->addEvent(
|
|
||||||
'retailcrm',
|
|
||||||
'catalog/model/checkout/order/editOrder/after',
|
|
||||||
'extension/module/retailcrm/order_edit'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -376,6 +369,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
|
|
||||||
$this->load->model('extension/retailcrm/order');
|
$this->load->model('extension/retailcrm/order');
|
||||||
$this->model_extension_retailcrm_order->uploadToCrm($fullOrders);
|
$this->model_extension_retailcrm_order->uploadToCrm($fullOrders);
|
||||||
|
$file = fopen(DIR_SYSTEM . '/cron/export_done.txt', "x");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,8 +64,7 @@ class ModelExtensionRetailcrmHistory extends Model
|
|||||||
$this->ocPayment = $this->model_extension_retailcrm_references
|
$this->ocPayment = $this->model_extension_retailcrm_references
|
||||||
->getOpercartPaymentTypes();
|
->getOpercartPaymentTypes();
|
||||||
|
|
||||||
$this->ocDelivery = $this->model_extension_retailcrm_references
|
$this->ocDelivery = $settings['retailcrm_delivery'];
|
||||||
->getOpercartDeliveryTypes();
|
|
||||||
|
|
||||||
$this->zones = $this->model_localisation_zone->getZones();
|
$this->zones = $this->model_localisation_zone->getZones();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ModelExtensionRetailcrmOrder extends Model {
|
class ModelExtensionRetailcrmOrder extends Model {
|
||||||
|
|
||||||
public function uploadToCrm($orders) {
|
public function uploadToCrm($orders) {
|
||||||
$this->load->model('catalog/product');
|
$this->load->model('catalog/product');
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<?php if ($export_file) : ?>
|
<?php if ($export_file) : ?>
|
||||||
<button type="button" id="export" data-toggle="tooltip" title="Выгрузить клиентов и заказы" class="btn btn-success"><i class="fa fa-download"></i></button>
|
<button type="button" id="export" data-toggle="tooltip" title="<?php echo $text_button_export; ?>" class="btn btn-success"><i class="fa fa-download"></i></button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<button type="button" id="icml" data-toggle="tooltip" title="<?php echo $text_button_catalog; ?>" class="btn btn-success"><i class="fa fa-file-text-o"></i></button>
|
<button type="button" id="icml" data-toggle="tooltip" title="<?php echo $text_button_catalog; ?>" class="btn btn-success"><i class="fa fa-file-text-o"></i></button>
|
||||||
<button type="submit" form="form-retailcrm" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
|
<button type="submit" form="form-retailcrm" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
|
||||||
@ -63,11 +63,6 @@
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h3><?php echo $retailcrm_upload_order; ?></h3>
|
|
||||||
<div class="retailcrm_unit">
|
|
||||||
<label><?php echo $text_button_export_order; ?> № </label><input type="text" name="order_id">
|
|
||||||
<button type="button" id="export_order" data-toggle="tooltip" title="<?php echo $text_button_export_order; ?>" class="btn btn-success"><i class="fa fa-download"></i></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||||
|
|
||||||
@ -76,10 +71,14 @@
|
|||||||
<div class="warning"><?php echo $retailcrm_error ?></div>
|
<div class="warning"><?php echo $retailcrm_error ?></div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
<h3><?php echo $retailcrm_upload_order; ?></h3>
|
||||||
|
<div class="retailcrm_unit">
|
||||||
|
<label><?php echo $text_button_export_order; ?> № </label><input type="text" name="order_id">
|
||||||
|
<button type="button" id="export_order" data-toggle="tooltip" title="<?php echo $text_button_export_order; ?>" class="btn btn-success"><i class="fa fa-download"></i></button>
|
||||||
|
</div>
|
||||||
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
||||||
|
|
||||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
||||||
|
|
||||||
<?php foreach($delivery['opencart'] as $value): ?>
|
<?php foreach($delivery['opencart'] as $value): ?>
|
||||||
|
|
||||||
<div class="pm"><?php echo $value['title'].':'; ?></div>
|
<div class="pm"><?php echo $value['title'].':'; ?></div>
|
||||||
@ -142,7 +141,7 @@
|
|||||||
var token = '<?php echo $token; ?>';
|
var token = '<?php echo $token; ?>';
|
||||||
$('#icml').on('click', function() {
|
$('#icml').on('click', function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?php echo $catalog; ?>'+'system/cron/icml.php',
|
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/icml&token=' + token,
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
$('#icml').button('loading');
|
$('#icml').button('loading');
|
||||||
},
|
},
|
||||||
@ -159,7 +158,7 @@
|
|||||||
|
|
||||||
$('#export').on('click', function() {
|
$('#export').on('click', function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?php echo $catalog; ?>'+'system/cron/export.php',
|
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/export&token=' + token,
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
$('#export').button('loading');
|
$('#export').button('loading');
|
||||||
},
|
},
|
||||||
@ -205,3 +204,4 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ class ControllerApiRetailcrm extends Controller
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($shippingModules as $shippingModule) {
|
foreach ($shippingModules as $shippingModule) {
|
||||||
|
|
||||||
$this->load->model('extension/shipping/' . $shippingModule['code']);
|
$this->load->model('extension/shipping/' . $shippingModule['code']);
|
||||||
|
|
||||||
if ($this->config->get($shippingModule['code'] . '_status')) {
|
if ($this->config->get($shippingModule['code'] . '_status')) {
|
||||||
|
@ -78,7 +78,12 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
|
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($settings['retailcrm_delivery'][$order_data['shipping_code']])) {
|
||||||
$delivery_code = $order_data['shipping_code'];
|
$delivery_code = $order_data['shipping_code'];
|
||||||
|
} else {
|
||||||
|
$delivery_code = stristr($order_data['shipping_code'], '.', TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
$order['delivery'] = array(
|
$order['delivery'] = array(
|
||||||
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
|
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
|
||||||
'cost' => $deliveryCost,
|
'cost' => $deliveryCost,
|
||||||
@ -109,6 +114,14 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||||
|
|
||||||
foreach($product['option'] as $option) {
|
foreach($product['option'] as $option) {
|
||||||
|
if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') {
|
||||||
|
$properties[] = array(
|
||||||
|
'code' => $option['product_option_value_id'],
|
||||||
|
'name' => $option['name'],
|
||||||
|
'value' => $option['value']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(!in_array($option['type'], $offerOptions)) continue;
|
if(!in_array($option['type'], $offerOptions)) continue;
|
||||||
foreach($productOptions as $productOption) {
|
foreach($productOptions as $productOption) {
|
||||||
if($productOption['product_option_id'] = $option['product_option_id']) {
|
if($productOption['product_option_id'] = $option['product_option_id']) {
|
||||||
@ -130,7 +143,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$offerId = implode('_', $offerId);
|
$offerId = implode('_', $offerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$order['items'][] = array(
|
$item = array(
|
||||||
'offer' => array(
|
'offer' => array(
|
||||||
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
||||||
),
|
),
|
||||||
@ -138,6 +151,10 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
'initialPrice' => $product['price'],
|
'initialPrice' => $product['price'],
|
||||||
'quantity' => $product['quantity'],
|
'quantity' => $product['quantity'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isset($properties)) $item['properties'] = $properties;
|
||||||
|
|
||||||
|
$order['items'][] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
||||||
@ -169,8 +186,6 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$order = array();
|
$order = array();
|
||||||
|
|
||||||
$payment_code = $order_data['payment_code'];
|
$payment_code = $order_data['payment_code'];
|
||||||
$delivery_code = $order_data['shipping_code'];
|
|
||||||
|
|
||||||
$order['externalId'] = $order_id;
|
$order['externalId'] = $order_id;
|
||||||
$order['firstName'] = $order_data['firstname'];
|
$order['firstName'] = $order_data['firstname'];
|
||||||
$order['lastName'] = $order_data['lastname'];
|
$order['lastName'] = $order_data['lastname'];
|
||||||
@ -195,6 +210,12 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
|
|
||||||
$country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ;
|
$country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ;
|
||||||
|
|
||||||
|
if(isset($settings['retailcrm_delivery'][$order_data['shipping_code']])) {
|
||||||
|
$delivery_code = $order_data['shipping_code'];
|
||||||
|
} else {
|
||||||
|
$delivery_code = stristr($order_data['shipping_code'], '.', TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
$order['delivery'] = array(
|
$order['delivery'] = array(
|
||||||
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
|
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
|
||||||
'address' => array(
|
'address' => array(
|
||||||
@ -228,6 +249,14 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||||
|
|
||||||
foreach($product['option'] as $option) {
|
foreach($product['option'] as $option) {
|
||||||
|
if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') {
|
||||||
|
$properties[] = array(
|
||||||
|
'code' => $option['product_option_value_id'],
|
||||||
|
'name' => $option['name'],
|
||||||
|
'value' => $option['value']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(!in_array($option['type'], $offerOptions)) continue;
|
if(!in_array($option['type'], $offerOptions)) continue;
|
||||||
foreach($productOptions as $productOption) {
|
foreach($productOptions as $productOption) {
|
||||||
if($productOption['product_option_id'] = $option['product_option_id']) {
|
if($productOption['product_option_id'] = $option['product_option_id']) {
|
||||||
@ -249,7 +278,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$offerId = implode('_', $offerId);
|
$offerId = implode('_', $offerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$order['items'][] = array(
|
$item = array(
|
||||||
'offer' => array(
|
'offer' => array(
|
||||||
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
||||||
),
|
),
|
||||||
@ -257,6 +286,10 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
'initialPrice' => $product['price'],
|
'initialPrice' => $product['price'],
|
||||||
'quantity' => $product['quantity'],
|
'quantity' => $product['quantity'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isset($properties)) $item['properties'] = $properties;
|
||||||
|
|
||||||
|
$order['items'][] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
$cli_action = 'extension/module/retailcrm/export';
|
$cli_action = 'extension/module/retailcrm/export';
|
||||||
require_once('dispatch.php');
|
require_once('dispatch.php');
|
||||||
$file = fopen(DIR_SYSTEM . '/cron/export_done.txt', "x");
|
|
Loading…
Reference in New Issue
Block a user