if ($emailProp = $collection->getUserEmail()) {
$emailProp->setValue($email);
} else {
$emailProp = $collection->createItem([
'ID' => 3,
'NAME' => 'NAME',
'TYPE' => 'STRING',
'CODE' => 'PROP_Email',
]);
$emailProp->setField('VALUE', $email);
}
$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();
if ($(selector).inputmask("isComplete")){
//do something
}
<?
function OnSaleOrderBeforeSaved(\Bitrix\Main\Event $event)
{
/** @var \Bitrix\Sale\Order $order */
$order = $event->getParameter("ENTITY");
if ($order->isNew() ) {//Если проверка требуется только для нового заказа, а не при его редактировании
$propertyCollection = $order->getPropertyCollection();
$phoneProperty = $propertyCollection->getPhone();
$isPhoneValid = validatePhone($phoneProperty);
if (!$isPhoneValid) {
$event->addResult(new \Bitrix\Main\EventResult(
\Bitrix\Main\EventResult::ERROR,
new \Bitrix\Sale\ResultError('Текст ошибки', 'PHONE_PROPERTY_INVALID')
));
}
}
}
$eventManager = Main\EventManager::getInstance();
$eventManager->addEventHandler(
"sender",
"\Bitrix\Sender\ContactTable::onAfterAdd",
['myEvents','onBeforeAddHandler']
);
И где расположить сам код агента в структуре модуля