Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
IblockElement.php
1<?php
2
4
8
10{
11 public static function onBeforeIBlockElementDelete($productId)
12 {
13 global $APPLICATION;
14
15 $productId = (int)$productId;
16 if ($productId >= 0)
17 {
18 $agentProduct = Catalog\AgentProductTable::getRow([
19 'select' => [
20 'ID',
21 ],
22 'filter' => [
23 '=PRODUCT_ID' => $productId,
24 ],
25 ]);
26 if ($agentProduct)
27 {
28 Main\Loader::includeModule('iblock');
29
30 $element = Iblock\ElementTable::getList([
31 'select' => ['ID', 'NAME'],
32 'filter' => ['=ID' => $productId],
33 ])->fetch();
34
35 $error = Main\Localization\Loc::getMessage(
36 'CATALOG_AGENT_CONTRACT_ERROR_ELEMENT_IN_DOCUMENT_EXISTS',
37 [
38 '#ID#' => $element['ID'],
39 '#NAME#' => $element['NAME'],
40 ]
41 );
42 $APPLICATION->ThrowException($error);
43
44 return false;
45 }
46 }
47
48 return true;
49 }
50}