diff --git a/app/code/community/Aoe/Profiler/Block/Adminhtml/Profiler/Grid.php b/app/code/community/Aoe/Profiler/Block/Adminhtml/Profiler/Grid.php index f988bca..8a2b521 100755 --- a/app/code/community/Aoe/Profiler/Block/Adminhtml/Profiler/Grid.php +++ b/app/code/community/Aoe/Profiler/Block/Adminhtml/Profiler/Grid.php @@ -20,6 +20,17 @@ public function __construct() $this->setUseAjax(true); } + protected function _prepareMassaction() { + $this->setMassactionIdField('stack_id'); + $this->getMassactionBlock()->setFormFieldName('stack'); + + $this->getMassactionBlock()->addItem('delete', array( + 'label' => Mage::helper('aoe_profiler')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('aoe_profiler')->__('Are you sure?') + ) ); + } + /** * Prepare grid collection object * @@ -108,4 +119,4 @@ public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current'=>true)); } -} \ No newline at end of file +} diff --git a/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php b/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php index 7debfb7..25ad336 100755 --- a/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php +++ b/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php @@ -89,6 +89,32 @@ public function gridAction() $this->renderLayout(); } + /** + * @return void + */ + public function massDeleteAction() + { + $ids = $this->getRequest()->getParam('stack'); + if (!is_array($ids)) { + $this->_getSession()->addError($this->__('Please select stack(s).')); + } else { + if (!empty($ids)) { + try { + foreach ($ids as $id) { + $stack = Mage::getSingleton('aoe_profiler/run')->load($id); + $stack->delete(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d record(s) have been deleted.', count($ids)) + ); + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + } + } + $this->_redirect('*/*/index'); + } + /** * Edit layout instance action *