- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/lib/engine/yandexdirect.php
- Класс: BitrixSeoEngineYandexDirect
- Вызов: YandexDirect::updateAgent
static function updateAgent()
{
try
{
$engine = new self();
}
catch (BitrixMainSystemException $e)
{
return __CLASS__ . "::updateAgent();";
}
if ($engine->getAuthSettings())
{
try
{
$dbRes = YandexCampaignTable::getList(array(
'filter' => array(
' DateTime::createFromTimestamp(time() - YandexCampaignTable::CACHE_LIFETIME),
'=ENGINE_ID' => $engine->getId(),
),
'select' => array('CNT'),
'runtime' => array(
new ExpressionField('CNT', 'COUNT(*)'),
),
));
$res = $dbRes->fetch();
if ($res['CNT'] > 0)
{
$engine->updateCampaignManual();
}
$availableCampaigns = array();
$campaignList = $engine->getCampaignList();
foreach ($campaignList as $campaignInfo)
{
$availableCampaigns[] = $campaignInfo['CampaignID'];
}
if (count($availableCampaigns) > 0)
{
$dbRes = YandexBannerTable::getList(array(
'group' => array('CAMPAIGN_ID'),
'filter' => array(
' DateTime::createFromTimestamp(time() - YandexBannerTable::CACHE_LIFETIME),
'=ENGINE_ID' => $engine->getId(),
'=CAMPAIGN.XML_ID' => $availableCampaigns,
),
'select' => array('CAMPAIGN_ID'),
));
$campaignId = array();
while ($res = $dbRes->fetch())
{
$campaignId[] = $res['CAMPAIGN_ID'];
}
if (count($campaignId) > 0)
{
$engine->updateBannersManual($campaignId);
}
}
}
catch (YandexDirectException $e)
{
}
}
return __CLASS__ . "::updateAgent();";
}