RSS Feed

How to not cache the footer in magento


With some advanced scheduled-post-voodoo i successfully managed to publish this post already yesterday with some completely unrelated queries and no text. this was not intended – please accept my apologies :P

Anyway: In the footer of my magento shop we might have a summary of the shopping cart,
which i simply put in the footer.phtml template file:

<?php if (Mage::getModel('checkout/cart')->getItemsCount() > 0): ?>
  <div class="footer_cart_widget">
    <a href="/checkout/cart" class="cart">
      <?php echo $this->__('Warenkorb') ?>:<br />
      <span class="cart_meta">
        <?php echo Mage::getModel('checkout/cart')->getItemsCount() ?>
        <?php if (Mage::getModel('checkout/cart')->getItemsCount() == 1): ?>
        <?php else: ?>
        <?php endif; ?>
        <?php echo $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()); ?>
<?php endif; ?>

Magento Footer Shopping cart Widget disable cache

This means we might need to disable the caching for the footer HTML block,
so that my cart summary will stay dynamically generated.

This is how you can do it:





and just comment out the following lines:

//    'cache_lifetime'=> false,
//    'cache_tags'    => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)

you could also put the cart values in the getCacheKeyInfo() method, but as this would result in caching a footer for any state of the shopping cart from my understanding, i don’t think it’s necessarily a good idea.

5 responses to “how to not cache the footer in magento”

  1. Chris says:

    Thanks so much for pointing out that issue I thought i would have to re-write my session variable code.
    Quick easy fix, worked well.

  2. swati says:

    thank you so much, it saved my day

  3. cayen says:

    change the type in xml to “core/template”

  4. Robert Readman says:

    If you do what cayen said, by changing the type in the page.xml to “core/template” you will find that the echo $this->getCopyright() PHP will no longer work.
    So the correct way to do it is as above by making a local version of a core file.

  5. Rakesh says:

    Thank you so much, it saved my day. Worked well.

Leave a Reply

Your email address will not be published. Required fields are marked *