- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/config/state.php
- Класс: BitrixCatalogConfigState
- Вызов: State::handlerBeforeIblockSectionUpdate
static function handlerBeforeIblockSectionUpdate(array &$fields): bool
{
if (!self::checkIblockId($fields))
{
return true;
}
$limit = self::getIblockLimit((int)$fields['IBLOCK_ID']);
if ($limit['LIMIT'] === 0)
{
return true;
}
if (!array_key_exists('IBLOCK_SECTION_ID', $fields))
{
return true;
}
$parentId = (int)$fields['IBLOCK_SECTION_ID'];
self::loadIblockSections((int)$fields['IBLOCK_ID']);
if (!isset(self::$fullIblockSections[$parentId]))
{
return true;
}
$iterator = IblockSectionTable::getList([
'select' => ['IBLOCK_SECTION_ID'],
'filter' => [
'=ID' => $fields['ID'],
'=IBLOCK_ID' => $fields['IBLOCK_ID'],
],
]);
$row = $iterator->fetch();
unset($iterator);
if (empty($row))
{
return true;
}
$oldParentId = (int)$row['IBLOCK_SECTION_ID'];
if (isset(self::$fullIblockSections[$oldParentId]))
{
return true;
}
$count = (int)CIBlockElement::GetList(
[],
[
'IBLOCK_ID' => $fields['IBLOCK_ID'],
'SECTION_ID' => $fields['ID'],
'INCLUDE_SUBSECTIONS' => 'Y',
'CHECK_PERMISSIONS' => 'N',
],
[],
false,
['ID']
);
if ($count === 0)
{
return true;
}
$limit['COUNT'] += $count;
if ($limit['COUNT'] <= $limit['LIMIT'])
{
return true;
}
$limit['MESSAGE_ID'] = 'CATALOG_STATE_ERR_PRODUCT_IN_SECTION_LIMIT';
self::setProductLimitError(self::getProductLimitError($limit));
unset($limit);
return false;
}