Download the source for this entire series here!

CRUD – Delete

  1. The simplest step thus far, add a new function to your AdminController.php
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    
    <?php
    class SavantDegrees_Twits_AdminController extends Mage_Adminhtml_Controller_Action
    {
        public function indexAction()
        {
    		$this->loadLayout()
    			->_addContent($this->getLayout()->createBlock('twits/admin_main'))
    			->renderLayout();
        }
     
        public function deleteAction()
        {
            $tipId = $this->getRequest()->getParam('id', false);
     
            try {
                Mage::getModel('twits/tip')->setId($tipId)->delete();
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('twits')->__('Tip successfully deleted'));
                $this->getResponse()->setRedirect($this->getUrl('*/*/'));
     
                return;
            } catch (Exception $e){
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            }
     
            $this->_redirectReferer();
        }
    }

» Almost there … CRUD – Create


One Response to “Howto: Repackageable custom extension development in Magento – Part 6 – CRUD – Delete”

Leave a Reply


Recent Comments