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): ?> Produkt: <?php else: ?> Produkte: <?php endif; ?> <?php echo $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()); ?> </span> </a> </div> <?php endif; ?>
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:
//$this->addData(array( // '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.