• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/controller/action/entity/changebasketitemaction.php
  • Класс: BitrixSaleControllerActionEntityChangeBasketItemAction
  • Вызов: ChangeBasketItemAction::updateOffersProperties
static function updateOffersProperties($oldProps, $newProps): array
{
	if (!is_array($oldProps) || !is_array($newProps))
	{
		return [];
	}

	$result = [];

	if (empty($newProps))
	{
		return $oldProps;
	}

	if (empty($oldProps))
	{
		return $newProps;
	}

	foreach (array_keys($oldProps) as $code)
	{
		$oldValue = $oldProps[$code];
		$found = false;
		$key = false;
		$propId = (isset($oldValue['CODE']) ? (string)$oldValue['CODE'] : '').':'.$oldValue['NAME'];

		foreach ($newProps as $newKey => $newValue)
		{
			$newId = (isset($newValue['CODE']) ? (string)$newValue['CODE'] : '').':'.$newValue['NAME'];
			if ($newId === $propId)
			{
				$key = $newKey;
				$found = true;
				break;
			}
		}

		if ($found)
		{
			$oldValue['VALUE'] = $newProps[$key]['VALUE'];
			unset($newProps[$key]);
		}

		$result[$code] = $oldValue;
		unset($oldValue);
	}

	if (!empty($newProps))
	{
		foreach (array_keys($newProps) as $code)
		{
			$result[$code] = $newProps[$code];
		}
	}

	return $result;
}