fixes (#4)
* add delivery price * Update events.php * fix cron task * fix cron task * fix customer * fix order number
This commit is contained in:
parent
f7ed84d781
commit
e0c23b0852
@ -23,7 +23,7 @@ Module allows integrate UMI.CMS with [RetailCRM](http://www.retailcrm.pro)
|
||||
Add to cron:
|
||||
|
||||
```
|
||||
* */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
|
||||
0 */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
|
||||
```
|
||||
|
||||
#### Getting changes in orders
|
||||
|
@ -20,7 +20,7 @@ UMI.CMS module
|
||||
Добавьте в крон запись вида
|
||||
|
||||
```
|
||||
* */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
|
||||
0 */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
|
||||
```
|
||||
|
||||
#### Получение изменение из RetailCRM
|
||||
|
@ -43,7 +43,7 @@ class RCrmActions
|
||||
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
||||
$crmOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $umiOrderDeliveryId);
|
||||
|
||||
$customer = customer::get($order->getCustomerId());
|
||||
$customer = new umiObject($order->getCustomerId());
|
||||
$orderItems = $order->getItems();
|
||||
|
||||
$orderItemsToCrm = array();
|
||||
@ -98,7 +98,7 @@ class RCrmActions
|
||||
$oneClickObj = new umiObject($order->getObject()->getValue('purchaser_one_click'));
|
||||
|
||||
$orderToCrm = array(
|
||||
'number' => $order->getObject()->getName(),
|
||||
'number' => $order->getObject()->getValue('number'),
|
||||
'externalId' => $order->getId(),
|
||||
'phone' => $oneClickObj->getValue('phone'),
|
||||
'customer' => array(
|
||||
@ -169,7 +169,7 @@ class RCrmActions
|
||||
}
|
||||
|
||||
$orderToCrm = array(
|
||||
'number' => $order->getObject()->getName(),
|
||||
'number' => $order->getObject()->getValue('number'),
|
||||
'externalId' => $order->getId(),
|
||||
'lastName' => $customer->getValue('lname'),
|
||||
'firstName' => $customer->getValue('fname'),
|
||||
|
@ -225,6 +225,10 @@ class RCrmHistory
|
||||
$order->getObject()->getPropByName('payment_status_id')->setValue($umiOrderPaymentStatus);
|
||||
}
|
||||
|
||||
if (isset($crmOrder['delivery']['cost'])) {
|
||||
$order->getObject()->getPropByName('delivery_price')->setValue($crmOrder['delivery']['cost']);
|
||||
}
|
||||
|
||||
if (isset($crmOrder['delivery']['code'])) {
|
||||
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
||||
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
|
||||
@ -379,6 +383,10 @@ class RCrmHistory
|
||||
$order->getObject()->getPropByName('payment_status_id')->setValue($umiOrderPaymentStatus);
|
||||
}
|
||||
|
||||
if (isset($crmOrder['delivery']['cost'])) {
|
||||
$order->getObject()->getPropByName('delivery_price')->setValue($crmOrder['delivery']['cost']);
|
||||
}
|
||||
|
||||
if (isset($crmOrder['delivery']['code'])) {
|
||||
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
||||
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
|
||||
|
@ -1,12 +1,15 @@
|
||||
<?php
|
||||
global $argv;
|
||||
$eventHandlers = array(
|
||||
'icml' => 'onCronGenerateICML',
|
||||
'history' => 'onCronSyncHistory',
|
||||
);
|
||||
|
||||
if ((!isset($argv[2]) || $argv[2] == 'icml') && !isset($_GET['module']) || (isset($_GET['action']) && $_GET['action'] == 'icml')) {
|
||||
new umiEventListener('cron', 'RetailCRM', 'onCronGenerateICML');
|
||||
if (isset($_SERVER['argv'][2]) || isset($eventHandlers[$_SERVER['argv'][2]])) {
|
||||
new umiEventListener('cron', 'RetailCRM', $eventHandlers[$_SERVER['argv'][2]]);
|
||||
}
|
||||
|
||||
if ((!isset($argv[2]) || $argv[2] == 'history') && !isset($_GET['module']) || (isset($_GET['action']) && $_GET['action'] == 'history')) {
|
||||
new umiEventListener('cron', 'RetailCRM', 'onCronSyncHistory');
|
||||
if (isset($_GET['action']) && isset($eventHandlers[$_GET['action']])) {
|
||||
new umiEventListener('cron', 'RetailCRM', $eventHandlers[$_GET['action']]);
|
||||
}
|
||||
|
||||
new umiEventListener('systemModifyPropertyValue', 'RetailCRM', 'onModifyProperty');
|
||||
|
Loading…
Reference in New Issue
Block a user