• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/subscribe.php
  • Класс: BitrixCatalogSubscribeTable
  • Вызов: SubscribeTable::runAgentToSendRepeatedNotice
static function runAgentToSendRepeatedNotice($productId)
{
	$productId = (int)$productId;
	if ($productId <= 0 || (string)Option::get('catalog', 'subscribe_repeated_notify') != 'Y')
		return false;

	$connection = Application::getConnection();
	$helper = $connection->getSqlHelper();
	$connection->queryExecute('update '.$helper->quote(static::getTableName()).' set '
		.$helper->quote('NEED_SENDING').' = 'Y' where '.$helper->quote('ITEM_ID').' = '.$productId
		.' and ('.$helper->quote('DATE_TO').' is null or '.$helper->quote('DATE_TO').' > '
		.$helper->getCurrentDateTimeFunction().')'
	);

	if (!static::$agentRepeatedNoticeCreated)
	{
		$t = DateTime::createFromTimestamp(time() + static::AGENT_TIME_OUT);
		static::$agentRepeatedNoticeCreated = true;
		CAgent::AddAgent(
			'BitrixCatalogSubscribeTable::sendRepeatedNotice();',
			'catalog',
			'N',
			static::AGENT_INTERVAL,
			'',
			'Y',
			$t->toString(),
			100,
			false,
			false
		);
	}

	return true;
}