Здравствуйте.
Мне надо произвести экспорт товаров и заказов из админки интернет-магазина на опенкарте в 1С. Кто нибудь может помочь?
_____________
Лэт ит би
public function modeQueryOrders() {
$this->load->model('tool/exchange1c');
$orders = $this->model_tool_exchange1c->queryOrders(array(
'from_date' => $this->config->get('exchange1c_order_date')
,'new_status' => $this->config->get('exchange1c_order_status')
,'notify' => $this->config->get('exchange1c_order_notify')
,'currency' => $this->config->get('exchange1c_order_currency') ? $this->config->get('exchange1c_order_currency') : 'руб.'
));
// Обновляем данные о последнем запросе заказов
$this->load->model('setting/setting');
$config = $this->model_setting_setting->getSetting('exchange1c');
$config['exchange1c_order_date'] = date('Y-m-d H:i:s');
$this->model_setting_setting->editSetting('exchange1c', $config);
echo iconv('utf-8', 'cp1251', $orders);
}
public function queryOrders($params) {
$this->load->model('sale/order');
$query = $this->db->query("SELECT order_id FROM `" . DB_PREFIX . "order` WHERE `date_added` >= '" . $params['from_date'] . "'");
$document = array();
$document_counter = 0;
if ($query->num_rows) {
foreach ($query->rows as $orders_data) {
$order = $this->model_sale_order->getOrder($orders_data['order_id']);
$date = date('Y-m-d', strtotime($order['date_added']));
$time = date('H:i:s', strtotime($order['date_added']));
$document['Документ' . $document_counter] = array(
'Ид' => $order['order_id']
,'Номер' => $order['order_id']
,'Дата' => $date
,'Время' => $time
,'Валюта' => $params['currency']
,'Курс' => 1
,'ХозОперация' => 'Заказ товара'
,'Роль' => 'Продавец'
,'Сумма' => $order['total']
,'Комментарий' => $order['comment']
);
$document['Документ' . $document_counter]['Контрагенты']['Контрагент'] = array(
'Ид' => $order['customer_id'] . '#' . $order['email']
,'Наименование' => $order['payment_lastname'] . ' ' . $order['payment_firstname']
,'Роль' => 'Покупатель'
,'ПолноеНаименование' => $order['payment_lastname'] . ' ' . $order['payment_firstname']
,'Фамилия' => $order['payment_lastname']
,'Имя' => $order['payment_firstname']
,'Адрес' => array(
'Представление' => $order['shipping_address_1'].', '.$order['shipping_city'].', '.$order['shipping_postcode'].', '.$order['shipping_country']
)
,'Контакты' => array(
'Контакт1' => array(
'Тип' => 'ТелефонРабочий'
,'Значение' => $order['telephone']
)
,'Контакт2' => array(
'Тип' => 'Почта'
,'Значение' => $order['email']
)
)
);
// Товары
$products = $this->model_sale_order->getOrderProducts($orders_data['order_id']);
$product_counter = 0;
foreach ($products as $product) {
$id = $this->get1CProductIdByProductId($product['product_id']);
$document['Документ' . $document_counter]['Товары']['Товар' . $product_counter] = array(
'Ид' => $id
,'Наименование' => $product['name']
,'ЦенаЗаЕдиницу' => $product['price']
,'Количество' => $product['quantity']
,'Сумма' => $product['total']
);
$product_counter++;
}
$data = $order;
$this->model_sale_order->addOrderHistory($orders_data['order_id'], array(
'order_status_id' => $params['new_status'],
'comment' => '',
'notify' => $params['notify']
));
$document_counter++;
}
}
$root = '<?xml version="1.0" encoding="utf-8"?><КоммерческаяИнформация ВерсияСхемы="2.04" ДатаФормирования="' . date('Y-m-d', time()) . '" />';
$xml = $this->array_to_xml($document, new SimpleXMLElement($root));
return $xml->asXML();
}