0
votes

We are currently developing a site with Magento, and for whatever reason, the first time we view a category page the breadcrumbs are there, however, if we refresh the page, the breadcrumbs disappear.

Any ideas on why this might be happening are greatly appreciated!

Thank you!

Jeff

Edit/Update: I have gone into the breadcrumbs.phtml file and placed a var_dump on the $crumbs variable, it is returning NULL when the breadcrumbs are not showing up, Why would the variable become NULL on page refresh?

Edit/Update 2: It appears that the full page caching is not caching the breadcrumbs

Edit/Update 3: It is definitely a full page caching issue, when FPC is disabled, the breadcrumbs work every page load

4
Are you sure it's when you refresh the page, and that it doesn't disappear when you log in or something?Peter O'Callaghan
on page refresh, they disappearJeffrey L. Roberts

4 Answers

4
votes

I have the same issue with EE, it appears to be connected to Developer mode being turned on.

I commented out the code in index.php and everything works.

For some strange reason, the breadcrumbs do not cache when developer mode is on, but then pulls the empty cache to display (which is nothing) within FPC

I have contacted Magento EE Support today regarding this issue. I will update with feedback but I suggest anyone else with this issue contacts support as this is an out of the box issue.

1
votes

Just spent a few hours looking into this. The problem is that for good reason the page cache doesn't load the page layout, which means that Mage_Catalog_Block_Breadcrumbs->_prepareLayout() doesn't get called when the page cache attempts to reload the cache for this block. _prepareLayout() is what loads the breadcrumb before calling Mage_Page_Block_Html_Breadcrumbs->_toHtml()

A quick way to replicate the problem with full page cache that is saved to the file system is to:

  1. Go to a product or category page
  2. Flush the full page cache
  3. Go into /var/full_page_cache and search for the folder containing two files that look like "%CONTAINER_BREADCRUMBS%" and delete them

This will require that the page cache attempt to reload just that block. Since the load doesn't call Mage_Catalog_Block_Breadcrumbs->_prepareLayout() the call to Mage_Page_Block_Html_Breadcrumbs->_toHtml() returns an empty string and the new cache files are empty until cache is completely purged and the full page is reloaded.

The fix I came up with for this isn't pretty, but it seemed to be the least invasive. Simply create a block override for the _toHtml() method that does what _prepareLayout() does.

class Package_Module_Block_Html_Breadcrumbs extends Mage_Page_Block_Html_Breadcrumbs
{
    protected function _toHtml()
    {
        if (!is_array($this->_crumbs)) {
            $this->addCrumb('home', array(
                'label'=>Mage::helper('catalog')->__('Home'),
                'title'=>Mage::helper('catalog')->__('Go to Home Page'),
                'link'=>Mage::getBaseUrl()
            ));

            $path  = Mage::helper('catalog')->getBreadcrumbPath();

            foreach ($path as $name => $breadcrumb) {
                $this->addCrumb($name, $breadcrumb);
            }
        }
        return parent::_toHtml();
    }
}
0
votes

you might have to add the following line to your temmplate file - it might be as simple as that!

  echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();
0
votes

This is a known bug in Magento EE versions. You can check out this link for a solution.

We recently had an issue like this, but in our case the code from the article above was already added to the codebase. By simply removing it (from the cache.xml), the breadcrumbs started to behave as they should. Weird stuff.