11 public const AGENT_NAME =
'\Bitrix\Catalog\v2\Integration\Seo\Facebook\FacebookAgent::executeProductUpdate();';
16 !Loader::includeModule(
'crm')
17 && !Loader::includeModule(
'iblock')
23 if (!self::getFacebookFacade()->isExportAvailable() || !self::getFacebookFacade()->hasAuth())
28 if (self::checkRequirements())
30 $lastModifiedProducts = self::getLastModifiedProductIds();
31 if (!empty($lastModifiedProducts))
33 self::getFacebookFacade()->refreshExportedProducts($lastModifiedProducts);
42 $agent = \CAgent::GetList(
44 [
"MODULE_ID" =>
'catalog',
"NAME" => self::AGENT_NAME]
49 \CTimeZone::Disable();
57 \ConvertTimeStamp(time() + 300,
'FULL'),
65 $agent = \CAgent::GetList(
67 [
"MODULE_ID" =>
'catalog',
"NAME" => self::AGENT_NAME]
79 private static function checkRequirements(): bool
81 $facebookFacade = self::getFacebookFacade();
94 private static function getLastModifiedProductIds(): array
97 $elementsIterator = \Bitrix\Catalog\v2\Integration\Seo\Entity\ExportedProductTable::getList([
98 'order' => [
'ID' =>
'ASC'],
99 'select' => [
'ID',
'PRODUCT_ID',
'TIMESTAMP_X'],
101 'SERVICE_ID' =>
'facebook',
108 '=this.PRODUCT_ID' =>
'ref.ID',
109 '<this.TIMESTAMP_X' =>
'ref.TIMESTAMP_X',
112 'join_type' =>
'INNER',
117 while ($element = $elementsIterator->fetch())
119 $productIds[] = (int)$element[
'PRODUCT_ID'];
125 private static function getFacebookFacade(): FacebookFacade
127 return ServiceContainer::get(
'integration.seo.facebook.facade', [
128 'iblockId' => self::getProductIblockId(),
132 private static function getProductIblockId(): int
134 return \CCrmCatalog::EnsureDefaultExists() ?: 0;