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:
|
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
|
#### 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
|
#### Получение изменение из RetailCRM
|
||||||
|
@ -43,7 +43,7 @@ class RCrmActions
|
|||||||
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
||||||
$crmOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $umiOrderDeliveryId);
|
$crmOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $umiOrderDeliveryId);
|
||||||
|
|
||||||
$customer = customer::get($order->getCustomerId());
|
$customer = new umiObject($order->getCustomerId());
|
||||||
$orderItems = $order->getItems();
|
$orderItems = $order->getItems();
|
||||||
|
|
||||||
$orderItemsToCrm = array();
|
$orderItemsToCrm = array();
|
||||||
@ -98,7 +98,7 @@ class RCrmActions
|
|||||||
$oneClickObj = new umiObject($order->getObject()->getValue('purchaser_one_click'));
|
$oneClickObj = new umiObject($order->getObject()->getValue('purchaser_one_click'));
|
||||||
|
|
||||||
$orderToCrm = array(
|
$orderToCrm = array(
|
||||||
'number' => $order->getObject()->getName(),
|
'number' => $order->getObject()->getValue('number'),
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
'phone' => $oneClickObj->getValue('phone'),
|
'phone' => $oneClickObj->getValue('phone'),
|
||||||
'customer' => array(
|
'customer' => array(
|
||||||
@ -169,7 +169,7 @@ class RCrmActions
|
|||||||
}
|
}
|
||||||
|
|
||||||
$orderToCrm = array(
|
$orderToCrm = array(
|
||||||
'number' => $order->getObject()->getName(),
|
'number' => $order->getObject()->getValue('number'),
|
||||||
'externalId' => $order->getId(),
|
'externalId' => $order->getId(),
|
||||||
'lastName' => $customer->getValue('lname'),
|
'lastName' => $customer->getValue('lname'),
|
||||||
'firstName' => $customer->getValue('fname'),
|
'firstName' => $customer->getValue('fname'),
|
||||||
|
@ -225,6 +225,10 @@ class RCrmHistory
|
|||||||
$order->getObject()->getPropByName('payment_status_id')->setValue($umiOrderPaymentStatus);
|
$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'])) {
|
if (isset($crmOrder['delivery']['code'])) {
|
||||||
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
||||||
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
|
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
|
||||||
@ -379,6 +383,10 @@ class RCrmHistory
|
|||||||
$order->getObject()->getPropByName('payment_status_id')->setValue($umiOrderPaymentStatus);
|
$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'])) {
|
if (isset($crmOrder['delivery']['code'])) {
|
||||||
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
|
||||||
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
|
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<?php
|
<?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')) {
|
if (isset($_SERVER['argv'][2]) || isset($eventHandlers[$_SERVER['argv'][2]])) {
|
||||||
new umiEventListener('cron', 'RetailCRM', 'onCronGenerateICML');
|
new umiEventListener('cron', 'RetailCRM', $eventHandlers[$_SERVER['argv'][2]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!isset($argv[2]) || $argv[2] == 'history') && !isset($_GET['module']) || (isset($_GET['action']) && $_GET['action'] == 'history')) {
|
if (isset($_GET['action']) && isset($eventHandlers[$_GET['action']])) {
|
||||||
new umiEventListener('cron', 'RetailCRM', 'onCronSyncHistory');
|
new umiEventListener('cron', 'RetailCRM', $eventHandlers[$_GET['action']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
new umiEventListener('systemModifyPropertyValue', 'RetailCRM', 'onModifyProperty');
|
new umiEventListener('systemModifyPropertyValue', 'RetailCRM', 'onModifyProperty');
|
||||||
|
Loading…
Reference in New Issue
Block a user