1
0
mirror of synced 2024-11-29 08:46: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) { if ('ordersEdit' == $methodApi) {
$response = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $order['externalId']); $response = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $order['externalId']);
if (isset($response['order'])) { if (isset($response['order'])) {
foreach ($response['order']['items'] as $item) { foreach ($response['order']['items'] as $k => $item) {
$orderItems[$item['offer']['externalId']] = $item; $externalId = $k ."_". $item['offer']['externalId'];
$orderItems[$externalId] = $item;
} }
} }
} }
//basket //basket
foreach ($arFields['BASKET'] as $product) { foreach ($arFields['BASKET'] as $position => $product) {
if (isset($orderItems[$product['PRODUCT_ID']])) { //update $externalId = $position ."_". $product['PRODUCT_ID'];
$externalIds = $orderItems[$product['PRODUCT_ID']]['externalIds']; if (isset($orderItems[$externalId])) { //update
$externalIds = $orderItems[$externalId]['externalIds'];
$key = array_search("bitrix", array_column($externalIds, 'code')); $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( $externalIds[] = array(
'code' => 'bitrix', 'code' => 'bitrix',
'value' => $product['PRODUCT_ID'], 'value' => $externalId,
); );
} }
} else { //create } else { //create
$externalIds = array( $externalIds = array(
array( array(
'code' => 'bitrix', 'code' => 'bitrix',
'value' => $product['PRODUCT_ID'], 'value' => $externalId,
) )
); );
} }