- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/controller/document.php
- Класс: BitrixCatalogControllerDocument
- Вызов: Document::deleteListAction
public function deleteListAction(array $documentIds): ?bool
{
global $APPLICATION;
if (!Feature::isInventoryManagementEnabled())
{
$this->addError(new Error(Loc::getMessage('DOCUMENT_CONTROLLER_NO_INVENTORY_MANAGEMENT_ENABLED_ERROR')));
return null;
}
/**
* @var CMain $APPLICATION
*/
$documentData = $this->getDocumentData($documentIds);
foreach ($documentIds as $documentId)
{
$exception = null;
$document = $documentData[(int)$documentId] ?? null;
if (!$document)
{
$this->addError(
new Error(Loc::getMessage(
'DOCUMENT_CONTROLLER_DELETE_ERROR',
[
'#DOC_TITLE#' => "#{$documentId}",
'#ERROR#' => Loc::getMessage('CATALOG_CONTROLLER_DOCUMENT_NOT_FOUND'),
]
))
);
continue;
}
$can = $this->accessController->check(
ActionDictionary::ACTION_STORE_DOCUMENT_DELETE,
StoreDocument::createFromArray($document)
);
if ($can)
{
CCatalogDocs::delete($documentId);
$exception = $APPLICATION->GetException();
}
else
{
$exception = new CApplicationException(
Loc::getMessage('DOCUMENT_CONTROLLER_NO_RIGHTS_ERROR')
);
}
if ($exception)
{
$documentTitle = $document['TITLE'] ?: StoreDocumentTable::getTypeList(true)[$document['DOC_TYPE']];
if ($exception->GetID() === CCatalogDocs::DELETE_CONDUCTED_ERROR)
{
$this->addError(
new Error(Loc::getMessage(
'DOCUMENT_CONTROLLER_DELETE_CONDUCTED_ERROR',
[
'#DOC_TITLE#' => htmlspecialcharsbx($documentTitle),
]
))
);
}
else
{
$this->addError(
new Error(Loc::getMessage(
'DOCUMENT_CONTROLLER_DELETE_ERROR',
[
'#DOC_TITLE#' => htmlspecialcharsbx($documentTitle),
'#ERROR#' => htmlspecialcharsbx($exception->GetString()),
]
))
);
}
$APPLICATION->ResetException();
}
}
return $this->errorCollection->isEmpty() ? true : null;
}