I upgraded my Magento to 2.2.4 & noticed that the breadcrumbs disappeared from product pages.
So after some research I found out that you started building the breadcrumbs on product pages based on the top-menu using JS & since I customized my top menu on my theme with different CSS selectors & structure - it just stopped working.
I have no idea why you did it that way, but that makes it really fragile since a lot of times people are overriding , customizing or replacing the main navigation for their taste & purposes.
I pasted my temporary workaround in here (If it helps someone...)
I'm using 2.2.4 and didn't have this problem on 2.2.3. The breadcrumbs are missing on the productpage. The category page is still showing the breadcrumb, but when selecting a product, the product page is missing the breadcrumb. I'm using Porto and checked that when using Luma the breadcrumb is still missing.
@pini-girit I've noticed your workaround, but can you explain more about how to implement this?
@robkor, You need to build a simple module & extend MagentoThemeBlockHtmlBreadcrumbs, you don't need di.xml, just create a Block class & paste the first code snippet (you'll need to adjust the names...). After that, you'll have to override app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/breadcrumbs.phtml by copying it to your theme app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/breadcrumbs.phtml (easier) or by layout.xml if you like & replace it's contents with the second code snippet.
@magento-engcom-team is there an update on this issue?
I fixed this with my own module making sure that the Product page uses the same breadcrumbs phtml then the other pages and then with an after plugin on the execute of the product view class added the crumbs to the page. Its the only good fix in my opinion.
Not sure why Magento decided to use JS on the product page.
And it works just fine.
If anyone needs the module fix you can ask me on skype : rob.conings.
I can not upload it to github under this account. I will create a company account and will comment on this github in the future with the fix that i did
@pini-girit Thanks. You solution works perfect.
I have created a Fix module for this that will generate the product breadcrumbs trough PHP and not trough JS
https://github.com/CompactCodeEU/FixProductBreadcrumbs.git
This also fixed a number of other issues and makes it more reliable. It also adds a Home breadcrumb and adds the product breadcrumb
@CompactCodeEU thank you, your module works great!
@pskigen thanks. Versdivers is my other account so my apologies about the delay. Been busy.
@pini-girit, please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this issue. The GitHub issue tracker is intended for Magento Core technical issues only.
@CompactCodeEU thanks. your module works great! is there any solutions to show full product path (from home). Now is show Home > Product name. instead Home > Category > Product Name.
@PitzyRo Do you have this problem also when you navigate to a product trough your category? You can add me on skype onder rob.conings if you want me to look at it together
@CompactCodeEU No. Only when i click on product from homepage (like new products or featured products). Thank you!
@PitzyRo The reason why it does not show the category is because there is none. As you know products can be placed in multiple categories or even in none at all. There is no way to know for sure what category the customer wants there. If you click from the home page you clicked on the url without a category in it.
Let's say you have Product A in Category B and Category C.
Then Magento creates 3 urls.
Now you have in fact 3 urls that will lead to your product. It gets its information from the first url. The second an thirth one (if im wrong here correct me) gets their information from url 1 except for 1 thing : the data from what category it is from
Since your url on your homepage goes to url 1 it does not contain any category information. The only thing what i could do is to give you an option that it should take the next available category from that list or you point a custom one. But that part is not included in our opensource and free module to extend this. That is a customization. The free module is just to correct the way how Magento handles the breadcrumbs after the update.
Let me know if this clears up your question
Hi @engcom-backlog-pb,
Why is this issue closed? It's still not fixed on 2.2.5.
I have no idea why you did it that way, but that makes it really fragile since a lot of times people are overriding , customizing or replacing the main navigation for their taste & purposes.
Why did you do it that way? It doesn't work for us and we don't know if something other will stop working if we patch this to generate it static. The workarounds posted here didn't work for us. @engcom-backlog-pb
After that you have to overwrite the file app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/breadcrumbs.phtml by copying it to your theme app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/breadcrumbs.phtml you like to it's contents with the second code snippet.
saw problem here ..my breadcums are reversed..showing the category first and menu title later example
url shop/chocolate-boxes/artist-collection-6-piece-box.html
breadcum Home Chocolate Boxes Shop Artist Collection - 6 piece box..
any help please
I have created a Fix module for this that will generate the product breadcrumbs trough PHP and not trough JS
https://github.com/CompactCodeEU/FixProductBreadcrumbs.git
This also fixed a number of other issues and makes it more reliable. It also adds a Home breadcrumb and adds the product breadcrumb
when i use this extesnion it show me error .
@CompactCodeEU This module works for me thanks for your module and explanation. I just need to do below changes.
Replace
if(null == $product->getCategory() || null == $product->getCategory()->getPath()){
Withif(null == $product->getCategoryIds()){
And
``
$categories = $product->getCategory()->getPath();
$categoriesids = explode('/', $categories); With
$categoriesids = $product->getCategoryIds();`
I am using 2.2.6. Will my changes affect anything?
@ashishjob0424 do not think it would change anything no. Glad it helped you out
@atwixfirster I do not think it would change anything no. Glad it helped you out
@CompactCodeEU , why did you mention me here?
Thanks!
@atwixfirster I do not think it would change anything no. Glad it helped you out
@CompactCodeEU , why did you mention me here?
Thanks!
Wrong mention. My bad!
Most helpful comment
I have created a Fix module for this that will generate the product breadcrumbs trough PHP and not trough JS
https://github.com/CompactCodeEU/FixProductBreadcrumbs.git
This also fixed a number of other issues and makes it more reliable. It also adds a Home breadcrumb and adds the product breadcrumb