ResultEntity::getDataForOrderBuilder

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ResultEntity
  4. getDataForOrderBuilder
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/webform/resultentity.php
  • Класс: Bitrix\Crm\WebForm\ResultEntity
  • Вызов: ResultEntity::getDataForOrderBuilder
protected function getDataForOrderBuilder()
{
	if ($this->dealId)
	{
		$ownerTypeId = \CCrmOwnerType::Deal;
		$ownerId = $this->dealId;
	}
	elseif ($this->leadId)
	{
		$ownerTypeId = \CCrmOwnerType::Lead;
		$ownerId = $this->leadId;
	}
	elseif ($this->contactId)
	{
		$ownerTypeId = \CCrmOwnerType::Contact;
		$ownerId = $this->contactId;
	}
	elseif ($this->companyId)
	{
		$ownerTypeId = \CCrmOwnerType::Company;
		$ownerId = $this->companyId;
	}
	else
	{
		return [];
	}

	$formData = [
		'RESPONSIBLE_ID' => $this->assignedById,
	];

	$paySystem = $this->getDefaultOrderPaySystem();
	if ($paySystem)
	{
		$formData['PAYMENT'] = [
			[
				'PAY_SYSTEM_ID' => $paySystem->getField('ID'),
				'SUM' => $this->getProductRowsSum(),
			],
		];
	}

	$client = ClientInfo::createFromOwner($ownerTypeId, $ownerId)->toArray();

	if(
		!empty($client['OWNER_ID'])
		&& !empty($client['OWNER_TYPE_ID'])
	)
	{
		$formData['OWNER_ID'] = $client['OWNER_ID'];
		$formData['OWNER_TYPE_ID'] = $client['OWNER_TYPE_ID'];
		unset($client['OWNER_ID'], $client['OWNER_TYPE_ID']);
	}

	$formData['CLIENT'] = $client;

	$code = TradingPlatform\WebForm::getCodeByFormId($this->formId);
	$platform = TradingPlatform\WebForm::getInstanceByCode($code);
	if ($platform->isInstalled())
	{
		$formData['TRADING_PLATFORM'] = $platform->getId();
	}

	$formData['PRODUCT'] = Catalog::create()->setItems($this->getProductRows())->getOrderProducts();


	return $formData;
}

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