Prevent not category links in breadcrumbs at product page#14994
Conversation
This may happen if menu has a link to the homepage, and product is opened from the homepage
|
Hi, @vovayatsyuk , I took your PR into processing, thank you for collaboration. |
| } | ||
|
|
||
| // prevent double home link, when menu has link to the home | ||
| if (categoryUrl === BASE_URL) { |
There was a problem hiding this comment.
First of all, you should change BASE_URL to window.BASE_URL according to Magento JS code style.
Also, we don't want use global variables, will be great if you pass base URL to the widget configuration.
|
@vovayatsyuk thanks for fast update |
|
Updated PR, because the same issue happens with other non-category links that may be added to navigation (Contacts, for example). |
|
It still doesn’t work well, if non-category links where added programmatically into the tree. They will have ‘nav-‘ css class just like category items and latest logic will detect them as category links. :( It looks like there is no way to detect if item from navigation is a category item or not. Any thoughts? |
ProposeRevert the changes and do the following instead:
This logic will cover both cases: links added manually into template and links added programmatically by third-party modules.
What do you think? |
|
I've rewritten this PR completely because the previous solution does not work |
This change prevents adding custom links, like 'contacts', 'home', etc.into breadcrumbs
0984c97 to
1df8452
Compare
|
Hi @vovayatsyuk.
|
|
Hi @vovayatsyuk. Thank you for your contribution. Please, consider porting this solution across release lines. |
Accepted Public Pull Requests: - #15480: [Forwardport] Prevent not category links in breadcrumbs at product page #14994 (by @vovayatsyuk) - #14700: [2.3] Optimize ID to SKU lookup of tier prices (by @toddbc)
Description
Magento 2.2.4 only.
When a product is opened from a homepage and menu has a link to the homepage,
two home links will be inserted into breadcrumbs.
Update: Added the case with "Contacts" link in the navigation.
Manual testing scenarios
app/code/Magento/Theme/view/frontend/templates/html/topmenu.phtml<li class="level0 level-top" role="presentation"> <a href="<?php echo $block->getUrl() ?>" class="level-top" tabindex="-1" role="menuitem"><span>Home</span></a> </li> <li class="level0 level-top" role="presentation"> <a href="<?php echo $block->getUrl('contact') ?>" class="level-top" tabindex="-1" role="menuitem"><span>Contacts</span></a> </li>Right before
Contribution checklist