First of all, I'm attempting to tap into the pre-deletion events of the following:

  1. Categories
  2. Products
  3. 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');
            $title = $model->getTitle();
            // display success message
                Mage::helper('cms')->__('The page has been deleted.'));
            // go to grid
            Mage::dispatchEvent('adminhtml_cmspage_on_delete', array('title' => $title, 'status' => 'success'));

        } catch (Exception $e) {
            Mage::dispatchEvent('adminhtml_cmspage_on_delete', array('title' => $title, 'status' => 'fail'));
            // display error message
            // go back to edit form
            $this->_redirect('*/*/edit', array('page_id' => $id));
    // display error message
    Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('Unable to find a page to delete.'));
    // go to grid

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?


I've implemented a (hopefully) temporary workaround by tapping into the controller_action_predispatch_adminhtml_cms_page_delete to accomplish the goal, however I'd like to see a more consistent solution if anyone has something clever to add.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.