• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/orm/commonelement.php
  • Класс: BitrixIblockORMCommonElement
  • Вызов: CommonElement::sysSetValue
public function sysSetValue($fieldName, $value)
{
	$field = $this->entity->getField($fieldName);

	if ($field instanceof PropertyReference)
	{
		// convert PropertyValue to regular reference
		$value = $this->sysConvertPropertyValue($value, $field);

		/** @var EntityObject $currentValue */
		$currentValue = $this->get($fieldName);

		if (empty($currentValue))
		{
			parent::sysSetValue($fieldName, $value);
		}
		else
		{
			// set value directly
			$currentValue->set('VALUE', $value->get('VALUE'));

			if ($this->entity->hasField('DESCRIPTION') && $value->sysHasValue('DESCRIPTION'))
			{
				$currentValue->set('DESCRIPTION', $value->get('DESCRIPTION'));
			}
		}

		// mark current object as changed, or else save() will be skipped
		if ($this->state === State::ACTUAL)
		{
			$this->sysChangeState(State::CHANGED);
		}

		return $this;
	}

	return parent::sysSetValue($fieldName, $value);
}