2

I have a block that uses addLink to create a checkout link in the header, to get the URL it uses a custom function $helper->getCheckoutUrl() ($helper being a utility helper created by someone else) which does a condition check to return what URL we need for the checkout link, the conditions are

If Rewrite Checkout links are enabled
    return result from parent::getCheckoutUrl();
else if Precheckout is Available
    return result from Mage::getUrl('precheckout', array('_secure'=>true));
otherwise return result from Mage::getUrl('onestepcheckout', array('_secure'=>true));

to determine if Precheckout is avaliable we use these checks

if items in cart = 0 and user is a guest and module is enabled
    if minimum order limit set and cart total > minimum order limit
        return true
    else if minimum order limit is not set
        return true
otherwise return false

Effectively what we are doing is that if the user is a guest and meets the conditions to go into the checkout we want to redirect them to a pre-checkout page where we ask for either their email, to make an account or to log into their own account

while testing I noticed that the URL is getting cached, as such if I’m a guest and had an item in my cart then go to a page (say a category or CMS), the checkout link in the header is our pre-checkout link however when I remove the item, and return to the page I was once on it retains how pre-checkout link yet if I got to a page that hasn't been visited (as such hasn't been cached) it's the correct link, pages with the pre-checkout link only change if we wipe out the cache (not just a refresh of every cache though the backend)

Now I want to look up what cache tag is set for the block that calls the addLink

3

You get the cache tags with $blockObject->getData('cache_tags')
But what you search for is the cache_key, because you should change this to match your different cases. (every case gets a different cache key, so they dont overlap anymore)

The Aoe_TemplateHints could also get handy, but they dont show cache_key,cache_tags yet, but if you add them, this could get even better :)

http://www.magentocommerce.com/wiki/5_-_modules_and_development/block_cache_and_html_ouput

https://github.com/fbrnc/Aoe_TemplateHints

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.