fix
This commit is contained in:
parent
0085f1af2c
commit
ae0ebc55b4
@ -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,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user