First of all, I'm attempting to tap into the pre-deletion events of the following:
- Categories
- Products
- CMS Pages
Categories and products are fairly straight-forward, tapping the catalog_category_controller_category_delete
and catalog_product_delete_before
events, respectively. CMS pages on the other hand are another story...
I've browsed the source code inside app/code/core/adminhtml/controllers/cms/PageController.php to find the following:
public function deleteAction()
{
// check if we know what should be deleted
if ($id = $this->getRequest()->getParam('page_id')) {
$title = "";
try {
// init model and delete
$model = Mage::getModel('cms/page');
$model->load($id);
$title = $model->getTitle();
$model->delete();
// display success message
Mage::getSingleton('adminhtml/session')->addSuccess(
Mage::helper('cms')->__('The page has been deleted.'));
// go to grid
Mage::dispatchEvent('adminhtml_cmspage_on_delete', array('title' => $title, 'status' => 'success'));
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::dispatchEvent('adminhtml_cmspage_on_delete', array('title' => $title, 'status' => 'fail'));
// display error message
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
// go back to edit form
$this->_redirect('*/*/edit', array('page_id' => $id));
return;
}
}
// display error message
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('Unable to find a page to delete.'));
// go to grid
$this->_redirect('*/*/');
}
There is no indication that there is any event emitted prior to deleting a CMS page, nor does there appear to be any way to retrieve which CMS page ID has been deleted. Am I missing something or is this just another instance of Magento's excessive inconsistency?