Skip to content

Commit

Permalink
[FEATURE] Added delete option to error log grid.
Browse files Browse the repository at this point in the history
When you log entries to the database, you can (multi-)select entries and delete them from the grid.
  • Loading branch information
mzeis committed Aug 25, 2014
1 parent 3d6284a commit 092a8e4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ protected function _prepareColumns()
return parent::_prepareColumns();
}

protected function _prepareMassaction()
{
$this->setMassactionIdField('log_id');
$this->getMassactionBlock()->setFormFieldName('log');
$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('firegento_logger')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('firegento_logger')->__('Are you sure?')
));
return $this;
}

/**
* Add a severity css class to the value
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ public function liveViewAction()
$this->renderLayout();
}

public function massDeleteAction()
{
$ids = $this->getRequest()->getParam('log');
if(!is_array($ids)) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('firegento_logger')->__('Please select entries.'));
} else {
try {
$logModel = Mage::getModel('firegento_logger/db_entry');
foreach ($ids as $id) {
$logModel->load($id)->delete();
}
Mage::getSingleton('adminhtml/session')->addSuccess(
Mage::helper('firegento_logger')->__(
'Total of %d record(s) were deleted.', count($ids)
)
);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}

/**
* Show the report viewer
*/
Expand Down

0 comments on commit 092a8e4

Please sign in to comment.