magento2: Invisible breadcrumbs at product page when mageMenu widget is not used

Preconditions

  1. Magento 2.2.4 only

Steps to reproduce

  1. Open app/code/Magento/Theme/view/frontend/templates/html/topmenu.phtml
  2. Remove the following code from the template:
data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'
  1. Navigate to the product page

Expected result

  1. Breadcrumbs should remain visible

Actual result

  1. Breadcrumbs are not rendered

Explanation

2.2.4 release uses js component to render breadcrumbs on the product page. Here is its init method:

https://github.com/magento/magento2/blob/3bd8afbbd7fbd876ab65cd2288c52145856a5dc0/app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js#L23-L36

I don’t really know what is this check for if (typeof menu === 'undefined') {, and why do we even need to get mageMenu, maybe @ameysar can help with explanation?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 15 (7 by maintainers)

Most upvoted comments

on one of our sites we use a custom menu - even with the fix it seems we are forced to use some sort of compatible menu, just for the breadcrumbs - that has to be crazy doesn’t it - surely there should be a fall back option? Perhaps some sort of config setting?

The only problem is that the categories do not show on the breadcrumbs while navigating from a category page to the product page

I can confirm this bug on 2.2.5.

EDIT: you have to debug vendor/magento/module-catalog/view/frontend/web/js/product/breadcrumbs.js. The function _resolveCategoryMenuItem() probably returns null, that’s why it doesn’t work. In my case, I had to add data-action="navigation" to my <nav> section. Also, I had to add the class category-item on my <li> items because of the categoryItemSelector option.

Same issue here (magento 2.2.4)