_init('wsalogger/log', 'notification_id'); } public function loadLatestNotice(Webshopapps_Wsalogger_Model_Log $object) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable()) ->order($this->getIdFieldName() . ' desc') ->where('is_read <> 1') ->where('is_remove <> 1') ->limit(1); $data = $this->_getReadAdapter()->fetchRow($select); if ($data) { $object->setData($data); } $this->_afterLoad($object); return $this; } public function getNoticeStatus(Webshopapps_Wsalogger_Model_Log $object) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), array( 'severity' => 'severity', 'count_notice' => 'COUNT(' . $this->getIdFieldName() . ')')) ->group('severity') ->where('is_remove=?', 0) ->where('is_read=?', 0); $return = array(); $rowSet = $this->_getReadAdapter()->fetchAll($select); foreach ($rowSet as $row) { $return[$row['severity']] = $row['count_notice']; } return $return; } public function parse(Webshopapps_Wsalogger_Model_Log $object, array $data) { $write = $this->_getWriteAdapter(); foreach ($data as $item) { $write->insert($this->getMainTable(), $item); } } public function truncate() { try { $this->_getWriteAdapter()->truncate($this->getMainTable()); }catch(Exception $e){ Mage::logException("WebShopApps Logger Exception"); Mage::logException($e); } } }