only package mode
This commit is contained in:
parent
8d5918cfc3
commit
f564c6c8e0
@ -66,108 +66,34 @@ class ICrmOrderActions
|
||||
'optionsPayment' => $optionsPayment
|
||||
);
|
||||
|
||||
// pack mode enable / disable
|
||||
// can send data evry 500 rows
|
||||
if (!$steps) {
|
||||
while ($arOrder = $dbOrder->GetNext()) { //here orders by id asc; with offset
|
||||
//packmode
|
||||
|
||||
$result = self::orderCreate($arOrder, $api, $arParams);
|
||||
$orderCount = 0;
|
||||
|
||||
if (!$result['order'] || !$result['customer'])
|
||||
continue;
|
||||
while ($arOrder = $dbOrder->GetNext()) { // here orders by id asc
|
||||
|
||||
$resOrders[] = $result['order'];
|
||||
$resCustomers[] = $result['customer'];
|
||||
$result = self::orderCreate($arOrder, $api, $arParams);
|
||||
|
||||
$lastOrderId = $arOrder['ID'];
|
||||
}
|
||||
if (!$result['order'] || !$result['customer'])
|
||||
continue;
|
||||
|
||||
if (!empty($resOrders) && !empty($resCustomers)) {
|
||||
$orderCount++;
|
||||
|
||||
$resOrders[] = $result['order'];
|
||||
$resCustomers[] = $result['customer'];
|
||||
|
||||
$lastOrderId = $arOrder['ID'];
|
||||
|
||||
if($orderCount >= $pSize) {
|
||||
$customers = $api->customerUpload($resCustomers);
|
||||
|
||||
// error pushing customers
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
//self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::customerUpload', $api->getLastError());
|
||||
// error pushing customers
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
//self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::customerUpload', $api->getLastError());
|
||||
|
||||
if ($api->getStatusCode() != 460) // some orders were sent
|
||||
return true;
|
||||
}
|
||||
|
||||
$resOrders[] = $order;
|
||||
|
||||
$lastOrderId = $arOrder['ID'];
|
||||
}
|
||||
|
||||
if (!empty($resOrders)) {
|
||||
$orders = $api->orderUpload($resOrders);
|
||||
|
||||
// error pushing orders
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::orderUpload', $api->getLastError());
|
||||
|
||||
if ($api->getStatusCode() != 460) // some orders were sent
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} else { // package mode (by default runs after install)
|
||||
$orderCount = 0;
|
||||
|
||||
while ($arOrder = $dbOrder->GetNext()) { // here orders by id asc
|
||||
|
||||
$result = self::orderCreate($arOrder, $api, $arParams);
|
||||
|
||||
if (!$result['order'] || !$result['customer'])
|
||||
continue;
|
||||
|
||||
$orderCount++;
|
||||
|
||||
$resOrders[] = $result['order'];
|
||||
$resCustomers[] = $result['customer'];
|
||||
|
||||
$lastOrderId = $arOrder['ID'];
|
||||
|
||||
if($orderCount >= $pSize) {
|
||||
$customers = $api->customerUpload($resCustomers);
|
||||
|
||||
// error pushing customers
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
//self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::customerUpload', $api->getLastError());
|
||||
|
||||
if($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
}
|
||||
|
||||
$orders = $api->orderUpload($resOrders);
|
||||
|
||||
// error pushing orders
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::orderUpload', $api->getLastError());
|
||||
|
||||
if($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
}
|
||||
|
||||
if($lastOrderId)
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, $lastOrderId);
|
||||
|
||||
return true; // end of pack
|
||||
}
|
||||
}
|
||||
if (!empty($resOrders)) {
|
||||
$customers = $api->customerUpload($resCustomers);
|
||||
|
||||
// error pushing customers
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
//self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::customerUpload', $api->getLastError());
|
||||
|
||||
if ($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
if($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
}
|
||||
|
||||
$orders = $api->orderUpload($resOrders);
|
||||
@ -177,9 +103,37 @@ class ICrmOrderActions
|
||||
//handle err
|
||||
self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::orderUpload', $api->getLastError());
|
||||
|
||||
if ($api->getStatusCode() != 460) // some orders were sent
|
||||
if($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
}
|
||||
|
||||
if($lastOrderId)
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, $lastOrderId);
|
||||
|
||||
return true; // end of pack
|
||||
}
|
||||
}
|
||||
if (!empty($resOrders)) {
|
||||
$customers = $api->customerUpload($resCustomers);
|
||||
|
||||
// error pushing customers
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
//self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::customerUpload', $api->getLastError());
|
||||
|
||||
if ($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
}
|
||||
|
||||
$orders = $api->orderUpload($resOrders);
|
||||
|
||||
// error pushing orders
|
||||
if ($api->getStatusCode() != 201) {
|
||||
//handle err
|
||||
self::eventLog('ICrmOrderActions::uploadOrders', 'IntaroCrm\RestApi::orderUpload', $api->getLastError());
|
||||
|
||||
if ($api->getStatusCode() != 460) // some orders were sent
|
||||
return false; // in pack mode return errors
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ class intaro_intarocrm extends CModule
|
||||
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
|
||||
&& isset($_POST['ajax']) && ($_POST['ajax'] == 1)) {
|
||||
ICrmOrderActions::uploadOrders(true); // each 50
|
||||
ICrmOrderActions::uploadOrders(); // each 50
|
||||
|
||||
$lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
|
||||
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$MESS ['STEP_NAME'] = 'Шаг 4';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Завершить установку';
|
||||
$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг';
|
||||
$MESS ['DELIVERY_TYPES_LIST'] = 'Способы доставки';
|
||||
$MESS ['PAYMENT_TYPES_LIST'] = 'Способы оплаты';
|
||||
|
Loading…
Reference in New Issue
Block a user