Magento FPC Breadcrumb Dissapearing

  • SumoMe

Let’s fix the Magento FPC breadcrumb dissapearing on the site

We all know how Magento’s full page cache works and we know it is pretty awesome. We also know that most software is bound to have bugs.

Magento’s FPC has a very annoying one: The breadcrumb tends to disappear.

Fixing this one is actually pretty straight forward:

First and foremost ensure that you don’t have the developers mode enabled by either removing this from your .htaccess file:

    <IfModule mod_setenvif.c>
        SetEnvIf Server_Addr 127.0.0.1 MAGE_IS_DEVELOPER_MODE
    </IfModule>

Because your index.php contains this:

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}

Now comes the fun part, under any module you want (create one if you wish) create a cache.xml file and add the following code to it:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <placeholders>
        <catalog_breadcrumbs>
            <block>page/html_breadcrumbs</block>
            <name>breadcrumbs</name>
            <placeholder>CONTAINER_BREADCRUMBS</placeholder>
            <container>Enterprise_PageCache_Model_Container_Breadcrumbs</container>
            <cache_lifetime>86400</cache_lifetime>
        </catalog_breadcrumbs>
    </placeholders>
</config>

Now save this file and clear your Magento configuration cache. To see this code in action you need to make sure that Full Page Cache is enabled.

Why do you need to do this?

If you look at this container class: Enterprise_PageCache_Model_Container_Breadcrumbs

You will find this code:

    protected function _getCacheId()
    {
        if ($this->_getCategoryId() || $this->_getProductId()) {
            $cacheSubKey = '_' . $this->_getCategoryId()
                . '_' . $this->_getProductId();
        } else {
            $cacheSubKey = $this->_getRequestId();
        }
        return 'CONTAINER_BREADCRUMBS_'
            . md5($this->_placeholder->getAttribute('cache_id') . $cacheSubKey);
    }

However this is the cache.xml definition for the breadcrumbs:

        <catalog_breadcrumbs>
            <block>page/html_breadcrumbs</block>
            <name>breadcrumbs</name>
            <placeholder>PAGE_BREADCRUMBS</placeholder>
            <container>Enterprise_PageCache_Model_Container_Breadcrumbs</container>
            <cache_lifetime>86400</cache_lifetime>
        </catalog_breadcrumbs>

As you can see the placeholder container doesn’t match. This is why you need to change that little piece of the XML.

There are other bugs with the FPC but for now let’s tackle one at the time.

I hope this helps!!!

VN:F [1.9.22_1171]
Rating: 10.0/10 (4 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)
Magento FPC Breadcrumb Dissapearing, 10.0 out of 10 based on 4 ratings

Author: Luis Tineo

Husband, Father, performance improvement junkie, biker and video gamer, Linux user and in my day job I'm a Systems Architect at Blue Acorn.

Share This Post On
  • http://www.magentodevelopments.com/magento-development.php magento development

    FPC is tracking inventory changes because the purpose is to show out of inventory for any products that have been decremented to zero inventory. The fix would be to make a conference distribution when a product attacks zero rather than whenever any product changes inventory and change FPC to get apparent that occasion instead of the unique. Another technique would be to only invalidate the places storage space cache associated with the products being customized.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Martin Kolev

    Hi there, you have a great articles. I have one question about magento and breadcrumbs. Why sometime the breadcrumbs look like this – home/category/subcategory/milk and sometime – home/milk

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • http://magentotutorial.net/ Quang Hiếu Phạm

      I have found that there are some similar point between your post and this post magento for beginners. Do they copy from your blog?

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)