- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/map.php
- Класс: BitrixSaleTradingPlatformVkMap
- Вызов: Map::updateEntityMapping
static function updateEntityMapping($values, $mapEntityID, $flagKeys)
{
$result = true;
foreach ($values as $item)
{
$fields = array_change_key_case($item, CASE_UPPER); // preserve low case keys
$fields["ENTITY_ID"] = intval($mapEntityID);
$fields["VALUE_EXTERNAL"] = strval($item["VALUE_EXTERNAL"]);
$fields["VALUE_INTERNAL"] = strval($item["VALUE_INTERNAL"]);
$filterToId = $fields;
if ($flagKeys == "ONLY_INTERNAL")
unset($filterToId["VALUE_EXTERNAL"]);
if ($flagKeys == "ONLY_EXTERNAL")
unset($filterToId["VALUE_INTERNAL"]);
unset($filterToId["PARAMS"]);
// get ID for current element
$id = MapTable::getList(
array(
"filter" => $filterToId,
"select" => array("ID"),
)
);
$id = $id->fetch();
// update or create element
if ($id = $id["ID"])
{
$upRes = MapTable::update($id, $fields);
if (!$upRes->isSuccess())
$result = false;
}
else
{
$addRes = MapTable::add($fields);
if (!$addRes->isSuccess())
$result = false;
}
}
// if result == false - we have problem minimum in one item, maybe in all items
return $result;
}