checkUpdate(); } public function getFrequency() { return Mage::getStoreConfig(self::XML_FREQUENCY_PATH) * 3600; } public function getLastUpdate() { //return 100; return Mage::app()->loadCache('awall_notifications_lastcheck'); } public function setLastUpdate() { Mage::app()->saveCache(time(), 'awall_notifications_lastcheck'); return $this; } public function getFeedUrl() { if (is_null($this->_feedUrl)) { $this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://') . Mage::getStoreConfig(self::XML_FEED_URL_PATH); } return $this->_feedUrl; } public function checkUpdate() { if (($this->getFrequency() + $this->getLastUpdate()) > time()) { return $this; } $feedData = array(); $feedXml = $this->getFeedData(); if ($feedXml && $feedXml->channel && $feedXml->channel->item) { foreach ($feedXml->channel->item as $item) { $feedData[] = array( 'severity' => (int)$item->severity ? (int)$item->severity : 3, 'date_added' => $this->getDate((string)$item->pubDate), 'title' => (string)$item->title, 'description' => (string)$item->description, 'url' => (string)$item->link, ); } if ($feedData) { Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData)); } } $this->setLastUpdate(); return $this; } }