Answer the question
In order to leave comments, you need to log in
Bitrix how to start catalog export through an event?
There is a cron that starts the export of the directory with ID # 7 on a schedule
0 7 * * * /usr/bin/php -f /home/bitrix/ext_www/site.ru/bitrix/php_interface/include/catalog_export/cron_frame.php 7
AddEventHandler("catalog", "OnSuccessCatalogImport1C", "DSOnSuccessCatalogImport1C");
function DSOnSuccessCatalogImport1C(&$arParams,&$arFields){
// как здесь запустить экспорт каталога по ID
}
Answer the question
In order to leave comments, you need to log in
Open the /bitrix/php_interface/include/catalog_export/cron_frame.php file, it contains everything you need to start the export. Copy what you need into a method / function and run on an event. If the catalog is large, then it is better to create an agent on the OnSuccessCatalogImport1C event that will already perform the export (in this case, it is better to transfer agents to cron).
$profile_id = 7;
$ar_profile = CCatalogExport::GetByID($profile_id);
if (!$ar_profile)
die('No profile');
$strFile = CATALOG_PATH2EXPORTS.$ar_profile["FILE_NAME"]."_run.php";
if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile))
{
$strFile = CATALOG_PATH2EXPORTS_DEF.$ar_profile["FILE_NAME"]."_run.php";
if (!file_exists($_SERVER["DOCUMENT_ROOT"].$strFile))
die('No export script');
}
$arSetupVars = array();
$intSetupVarsCount = 0;
if ($ar_profile["DEFAULT_PROFILE"] != 'Y')
{
parse_str($ar_profile["SETUP_VARS"], $arSetupVars);
if (!empty($arSetupVars) && is_array($arSetupVars))
$intSetupVarsCount = extract($arSetupVars, EXTR_SKIP);
}
$firstStep = true;
global $arCatalogAvailProdFields;
$arCatalogAvailProdFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_ELEMENT);
global $arCatalogAvailPriceFields;
$arCatalogAvailPriceFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_CATALOG);
global $arCatalogAvailValueFields;
$arCatalogAvailValueFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_PRICE);
global $arCatalogAvailQuantityFields;
$arCatalogAvailQuantityFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_PRICE_EXT);
global $arCatalogAvailGroupFields;
$arCatalogAvailGroupFields = CCatalogCSVSettings::getSettingsFields(CCatalogCSVSettings::FIELDS_SECTION);
global $defCatalogAvailProdFields;
$defCatalogAvailProdFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_ELEMENT);
global $defCatalogAvailPriceFields;
$defCatalogAvailPriceFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_CATALOG);
global $defCatalogAvailValueFields;
$defCatalogAvailValueFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_PRICE);
global $defCatalogAvailQuantityFields;
$defCatalogAvailQuantityFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_PRICE_EXT);
global $defCatalogAvailGroupFields;
$defCatalogAvailGroupFields = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_SECTION);
global $defCatalogAvailCurrencies;
$defCatalogAvailCurrencies = CCatalogCSVSettings::getDefaultSettings(CCatalogCSVSettings::FIELDS_CURRENCY);
CCatalogDiscountSave::Disable();
include($_SERVER["DOCUMENT_ROOT"].$strFile);
CCatalogDiscountSave::Enable();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question