0

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
  • 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 at 4:15

1 Answer 1

0

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.

3
  • Thanks for the reply is there any other method or code to resolve this issue? Jan 10 at 14:12
  • thanks for the reply. Is there any other way to solve this? Jan 11 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.
    – KestutisK
    Jan 11 at 6:19

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.