1
0
mirror of synced 2024-11-22 05:16:09 +03:00
This commit is contained in:
gorokh 2019-12-24 15:41:12 +03:00
parent 0085f1af2c
commit ae0ebc55b4

View File

@ -142,28 +142,35 @@ class RetailCrmOrder
if ('ordersEdit' == $methodApi) {
$response = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $order['externalId']);
if (isset($response['order'])) {
foreach ($response['order']['items'] as $item) {
$orderItems[$item['offer']['externalId']] = $item;
foreach ($response['order']['items'] as $k => $item) {
$externalId = $k ."_". $item['offer']['externalId'];
$orderItems[$externalId] = $item;
}
}
}
//basket
foreach ($arFields['BASKET'] as $product) {
if (isset($orderItems[$product['PRODUCT_ID']])) { //update
$externalIds = $orderItems[$product['PRODUCT_ID']]['externalIds'];
foreach ($arFields['BASKET'] as $position => $product) {
$externalId = $position ."_". $product['PRODUCT_ID'];
if (isset($orderItems[$externalId])) { //update
$externalIds = $orderItems[$externalId]['externalIds'];
$key = array_search("bitrix", array_column($externalIds, 'code'));
if (!$key) {
if ($externalIds[$key]['code'] == "bitrix") {
$externalIds[$key] = array(
'code' => 'bitrix',
'value' => $externalId,
);
} else {
$externalIds[] = array(
'code' =>'bitrix',
'value' => $product['PRODUCT_ID'],
'code' => 'bitrix',
'value' => $externalId,
);
}
} else { //create
$externalIds = array(
array(
'code' =>'bitrix',
'value' => $product['PRODUCT_ID'],
'code' => 'bitrix',
'value' => $externalId,
)
);
}