- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/v2/AgentContract/EventHandlers/IblockElement.php
- Класс: BitrixCatalogv2AgentContractEventHandlersIblockElement
- Вызов: IblockElement::onBeforeIBlockElementDelete
static function onBeforeIBlockElementDelete($productId)
{
global $APPLICATION;
$productId = (int)$productId;
if ($productId >= 0)
{
$agentProduct = CatalogAgentProductTable::getRow([
'select' => [
'ID',
],
'filter' => [
'=PRODUCT_ID' => $productId,
],
]);
if ($agentProduct)
{
MainLoader::includeModule('iblock');
$element = IblockElementTable::getList([
'select' => ['ID', 'NAME'],
'filter' => ['=ID' => $productId],
])->fetch();
$error = MainLocalizationLoc::getMessage(
'CATALOG_AGENT_CONTRACT_ERROR_ELEMENT_IN_DOCUMENT_EXISTS',
[
'#ID#' => $element['ID'],
'#NAME#' => $element['NAME'],
]
);
$APPLICATION->ThrowException($error);
return false;
}
}
return true;
}