• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/product/systemfield.php
  • Класс: BitrixCatalogProductSystemField
  • Вызов: SystemField::handlerHighloadBlockBeforeDelete
static function handlerHighloadBlockBeforeDelete(ORMEvent $event): ORMEventResult
{
	$result = new ORMEventResult();

	if (CatalogProductSystemFieldTypeHighloadBlock::isAllowed())
	{
		$primary = $event->getParameter('primary');
		if (!empty($primary))
		{
			$iterator = HighloadHighloadBlockTable::getList([
				'filter' => $primary,
			]);
			$row = $iterator->fetch();
			unset($iterator);

			if (!empty($row))
			{
				$fieldList = self::getBuildedFieldList();
				foreach ($fieldList as $field)
				{
					if ($field::getTypeId() !== CatalogProductSystemFieldTypeHighloadBlock::class)
					{
						continue;
					}
					if (!$field::isAllowed() || !$field::isExists())
					{
						continue;
					}
					$config = $field::getConfig();

					if ($row['NAME'] === $config['HIGHLOADBLOCK']['NAME'])
					{
						$result->addError(new ORMEntityError(
							Loc::getMessage(
								'BX_CATALOG_PRODUCT_SYSTEMFIELD_ERR_CANNOT_DELETE_HIGHLOADBLOCK',
								['#NAME#' => $row['NAME']]
							)
						));
					}
					unset($config);
				}
				unset($field, $fieldList);
			}
			unset($row);
		}
		unset($primary);
	}

	return $result;
}