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 ?

  • Magento does cache for the unique URL, I belive your url is same for both cases. Check the URL in both cases, usually magento generates the URLs for all the associated categories unless disabled from admin configuration. Jan 12, 2022 at 4:15

2 Answers 2


Disable cache for product page. But that is bad idea. Only option is to fetch breadcrumbs using js and ajax, because that is not cached. In that call check what is current category (it will be that category, that came from), check if product assigned to that category (could be customer used direct link and current category won't be assigned to product) and return breadcrumb for that category. Of course customer can come direct to that page, then there is will be no current category (or it could be some non related category). Then just show first or last category breadcrumb, or none, as you decide.

  • Thanks for the reply is there any other method or code to resolve this issue? Jan 10, 2022 at 14:12
  • thanks for the reply. Is there any other way to solve this? Jan 11, 2022 at 6:17
  • Don;t know other way. It is cache, that is problem. So you should turn it off for product page or use ajax. If there was only one category for product, then it would be cached and no problems. But you need to change breadcrumbs, depending on from where customer comes. So no other way. Jan 11, 2022 at 6:19

Personally, I would forget the idea of changing breadcrumbs in the HTML. From an SEO perspective, you're much better off with there only ever being 1 path to the product in a PIP breadcrumb. I wrote a module to do away with the default.

THEN, if you want a true user path in there, I'd use javascript to put the category URL into the breadcrumb, possibly utilising a cookie to store the last X pages/URLs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.