0

I created a module a few minutes ago to pull information from a RSS feed and display it in the admin panels notification inbox and toolbar that's right below the admin menu.

This works perfect, but unfortunately it doesn't load new messages when i refresh. I have to flush magento's cache and then refresh for it to load the new messages.

I would like to disable cache for the notifications module/block, so all new messages can be loaded each time the page is loaded.

i tired this line of code but it didnt seem to work:

<reference name="notification_toolbar">
<action method="setCacheLifetime"><s>0</s></action>
</reference>

I didnt expect this to work, since its not the one that generates the information, only displays it.

Can someone please advise me on how to disable the cache from this module/block.

thanks.

1

I figured it out by myself!

after looking through some codes i realize it has a update frequency timer, so i looked in the system section of the admin panel and found a update frequency selector under configuration => system => notification. Unfortunately the least time it had is 1 hour.

I went through the mage folders and found the following that provides the times.

Mage/Adminhtml/Model/System/Config/Source/Notification/Frequency.php

class Mage_Adminhtml_Model_System_Config_Source_Notification_Frequency
{
    public function toOptionArray()
    {
        return array(
            1   => Mage::helper('adminhtml')->__('1 Hour'),
            2   => Mage::helper('adminhtml')->__('2 Hours'),
            6   => Mage::helper('adminhtml')->__('6 Hours'),
            12  => Mage::helper('adminhtml')->__('12 Hours'),
            24  => Mage::helper('adminhtml')->__('24 Hours')
        );
    }
}

I then added the follow code and ran some tests, which worked!

0 => Mage::helper('adminhtml')->__('0 Minute'),

Not sure if i did it correctly, but it does exactly what i need it to. i then override this with my module to complete it.

Hope it helps others!

0

why do you want this to update so common, wouldn't it bloat your inbox?

There might be 2 options for you, you could write an event observer that clears this cache. admin_notifications_lastcheck is the cache tag i could find about the notifications.

The other option is to make the cache lifetime really short by writing a rewrite of the setLastUpdate function in core/AdminNotification/model/feed.php You can give this function a parameter with a cache lifetime.

I didn't try it and i'm in a hurry but since there are no answers i thought i should share it. I can add more info tomorrow if you require it.

  • thanks for the feedback, but i found a solution by myself. see my answer. not sure if what i typed makes sense but that what i did and it works. – Nxlevel Aug 23 '15 at 1:59
  • 1
    regarding you question why... i modified it to provide me with notification from external sources and i don't want to wait 1hr for it to update. – Nxlevel Aug 23 '15 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.