diff --git a/app/code/community/Firegento/AdminLogger/Model/Clean.php b/app/code/community/Firegento/AdminLogger/Model/Clean.php
new file mode 100644
index 0000000..49d4b4f
--- /dev/null
+++ b/app/code/community/Firegento/AdminLogger/Model/Clean.php
@@ -0,0 +1,33 @@
+getCollection()
+ ->addFieldToFilter('created_at', array(
+ 'lt' => new Zend_Db_Expr("DATE_SUB('" . now() . "', INTERVAL $interval DAY)")));
+
+ foreach ($adminLoggerCollection as $history) {
+ $history->delete();
+ }
+ }
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/app/code/community/Firegento/AdminLogger/Model/Observer.php b/app/code/community/Firegento/AdminLogger/Model/Observer.php
index a2f1f29..3739eec 100644
--- a/app/code/community/Firegento/AdminLogger/Model/Observer.php
+++ b/app/code/community/Firegento/AdminLogger/Model/Observer.php
@@ -2,6 +2,7 @@
class Firegento_AdminLogger_Model_Observer {
const ACTION_SAVE = 'save';
const ACTION_DELETE = 'delete';
+ const XML_PATH_ADMINLOGGER_CLEAN_ENABLED = 'admin/firegento_adminlogger/enable_cleaning';
/**
* @var Firegento_AdminLogger_Model_History_Diff
@@ -207,4 +208,23 @@ function ($className) use($savedModel) {
private function isUpdate (Mage_Core_Model_Abstract $savedModel) {
return $this->getAction($savedModel) == Firegento_AdminLogger_Helper_Data::ACTION_UPDATE;
}
+
+ /**
+ * Cleaning Database Entries
+ *
+ * @param Mage_Cron_Model_Schedule $schedule
+ */
+ public function scheduledCleanAdminLogger (Mage_Cron_Model_Schedule $schedule) {
+
+ if (!Mage::getStoreConfigFlag(self::XML_PATH_ADMINLOGGER_CLEAN_ENABLED)) {
+ return $this;
+ }
+
+ try {
+ Mage::getModel('firegento_adminlogger/clean')->clean();
+ }
+ catch (Exception $e) {
+ Mage::logException($e);
+ }
+ }
}
\ No newline at end of file
diff --git a/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml b/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml
index 165e235..596dea6 100644
--- a/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml
+++ b/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml
@@ -3,7 +3,7 @@