• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/update/order/dealgenerator.php
  • Класс: Bitrix\Crm\Update\Order\DealGenerator
  • Вызов: DealGenerator::execute
public function execute(array &$option)
{
	if (empty($option))
	{
		$option["steps"] = 0;
		$option["count"] = self::getUnbindingActiveOrdersCount();
	}

	foreach (self::getUnbindingActiveOrders() as $order)
	{
		$order = Crm\Order\Order::load($order['ID']);

		$dealId = $this->createDeal($order);
		if ($dealId !== false)
		{
			$this->addProductToDeal($dealId, $order);

			$this->bindDealToOrder($dealId, $order);
			$this->fillPayableCollection($order);

			$order->save();
		}

		$option["steps"]++;
	}

	if (self::getUnbindingActiveOrdersCount() > 0)
	{
		return self::CONTINUE_EXECUTION;
	}

	return self::FINISH_EXECUTION;
}