0

When cache is disabled, Mage::getSingleton('cms/page')->getIdentifier(); is working fine and i am getting correct page identifier for all pages.

But when cache is enabled, it is always returning the page identifier that's loaded first.

I am calling it in phtml files. Should it work fine in block classes?

Any workaround?


Update:

Actually all code are being cached somehow AND I cant see any output of new code unless I flush or disable cache. So this does not seem to be an issue of this particular singleton object. On same server, another magento installation/project is fine with cache enabled and I can see uptodate immediately. I am looking into the issue. It might be any other setting or the theme that has come up with some extensions.

4
  • What version of magento EE or CE? Commented Sep 22, 2015 at 17:42
  • Magento ver. 1.9.1.0 and we are using a third party theme too and not sure if anything related to the theme is causing this issue.
    – codelogn
    Commented Sep 22, 2015 at 18:02
  • Can you try factory method instead of singleton? Mage::getModel('cms/page')->getIdentifier();
    – Kalpesh
    Commented Sep 22, 2015 at 18:38
  • I just updated the question. So this is not an issue related to that object anymore, the entire phtml is being cached somehow.
    – codelogn
    Commented Sep 22, 2015 at 19:26

1 Answer 1

1

My entire navigation block was being cached and any changes I was making did not reflect on the frontend at all unless the cache are being cleared. But other phtml files were fine.

In my navigation block class I added the following code and it is now working as expected:

protected function _construct()
{
    parent::_construct();

    $this->addData(array(   'cache_lifetime' => null ));
}

The following link helped me to fix the issue: https://stackoverflow.com/a/25032002/1302297

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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