cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Breadcrumbs show wrong on product page because of cache

Magento 2 Breadcrumbs show wrong on product page because of cache

Magento 2.3.5 and 2.4 both versions have these issues.

The same product is assigned in two categories.

Suppose two main categories -

Category One and Category Two

Category One subcategories are Category OneA and Category OneB

Category Two subcategories are Category TwoA and Category TwoB

Product name is Sample product

Sample product is assigned on these two categories Category OneB and Category TwoA

If we are coming from a Navigation step by step Category One -> Category OneB then Breadcrumbs should be like this on the product detail page

Home->Category One->Category OneB->Sample product

If we are coming from a Navigation step by step Category Two -> Category TwoB then Breadcrumbs should be like this on the product detail page

Home->Category Two->Category TwoA->Sample product

But right now it is always coming from the cache, sometimes show

Home->Category One->Category OneB->Sample product in both path

Sometimes show Home->Category Two->Category TwoA->Sample product

How can we show breadcrumbs proper ?

1 REPLY 1

Re: Magento 2 Breadcrumbs show wrong on product page because of cache

I had tried a lot of different things but none of them seemed to override Breadcrumbs block. It was still being cached by FPC.

So here is the solution which I implemented to fix my issues:

Created a new extension named CacheBust which overrides BREADCRUMBS_BLOCK and then modifies the getCacheKeyInfo function
Added microtime() in getCacheKeyInfo() to avoid it from being cached
Download Full Extension

Just paste the code in your app, clear Config, FPC, Block caches, and it's ready to be used.

If issue solved, Click Kudos & Accept as Solution.
LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool