-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Prevent not category links in breadcrumbs at product page #14994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
@@ -193,6 +193,11 @@ define([ | |||
if (categoryUrl.indexOf('?') > 0) { | |||
categoryUrl = categoryUrl.substr(0, categoryUrl.indexOf('?')); | |||
} | |||
|
|||
// prevent double home link, when menu has link to the home | |||
if (categoryUrl === BASE_URL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Right before
Contribution checklist