...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/agent/opportunity/dealmanualopportunityagent.php
- Класс: Bitrix\Crm\Agent\Opportunity\DealManualOpportunityAgent
- Вызов: DealManualOpportunityAgent::doRun
static function doRun() { $instance = static::getInstance(); if ($instance === null) { return false; } if (!$instance->isEnabled()) { return false; } $progressData = $instance->getProgressData(); $offsetId = isset($progressData['LAST_ITEM_ID']) ? (int)($progressData['LAST_ITEM_ID']) : 0; $limit = (int)Option::get('crm', '~CRM_DEAL_MANUAL_OPPORTUNITY_INITIATED_LIMIT', 50); if ($limit <= 0) { $instance->markAsDisabled(); return false; } $items = $instance->getItems($offsetId, $limit); if (!count($items)) { $instance->markAsDisabled(); return false; } $dealId = $offsetId; $connection = Application::getConnection(); $tableName = \CCrmDeal::TABLE_NAME; foreach ($items as $item) { $dealId = (int)$item['ID']; if ($item['IS_MANUAL_OPPORTUNITY'] === 'N' && $item['OPPORTUNITY'] > 0) { $productCount = \CCrmProductRow::GetRowQuantity('D', $dealId); if (!$productCount) { $connection->query("UPDATE {$tableName} SET IS_MANUAL_OPPORTUNITY='Y' WHERE ID={$dealId}"); } } } $instance->setProgressData(['LAST_ITEM_ID' => $dealId]); return true; }