ContactToOrder::afterBindingDeletion

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ContactToOrder
  4. afterBindingDeletion
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Relation/StorageStrategy/ContactToOrder.php
  • Класс: Bitrix\Crm\Relation\StorageStrategy\ContactToOrder
  • Вызов: ContactToOrder::afterBindingDeletion
protected function afterBindingDeletion(Order $order): void
{
	$collection = $order->getContactCompanyCollection();
	if (!$collection->isPrimaryItemExists(\CCrmOwnerType::Contact))
	{
		/** @var Contact[] $contacts */
		$contacts = iterator_to_array($collection->getContacts());
		$firstNotDeletedContact = array_shift($contacts);
		if ($firstNotDeletedContact)
		{
			$firstNotDeletedContact->setField('IS_PRIMARY', 'Y');
		}
	}
}

Добавить комментарий