- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/businessvalue.php
- Класс: BitrixSaleBusinessValue
- Вызов: BusinessValue::updateMapping
static function updateMapping($codeKey, array $oldMapping, array $newMapping, $consumerKey = null, $personTypeId = null): BitrixMainEntityResult
{
if (!isset($oldMapping['PROVIDER_KEY'], $oldMapping['PROVIDER_VALUE']))
{
throw new BitrixMainArgumentException("Parameters $oldMapping['PROVIDER_KEY'] and $oldMapping['PROVIDER_VALUE'] are required.", 'oldMapping');
}
$result = new BitrixMainEntityResult();
$filter = [
'CODE_KEY' => $codeKey,
'PROVIDER_KEY' => $oldMapping['PROVIDER_KEY'],
'PROVIDER_VALUE' => $oldMapping['PROVIDER_VALUE'],
];
if ($consumerKey)
{
$filter['CONSUMER_KEY'] = $consumerKey;
}
if ($personTypeId)
{
$filter['PERSON_TYPE_ID'] = $personTypeId;
}
$businessValueResult = BusinessValueTable::getList(array(
'select' => ['CONSUMER_KEY', 'PERSON_TYPE_ID'],
'filter' => $filter,
));
while ($item = $businessValueResult->fetch())
{
$setMappingResult = self::setMapping($codeKey, $item['CONSUMER_KEY'], $item['PERSON_TYPE_ID'], $newMapping);
if (!$setMappingResult->isSuccess())
{
$result->addErrors($setMappingResult->getErrors());
}
}
return $result;
}