-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Problems with breadcrumbs #7967
Comments
@susmithaN thank you for your submission. |
Hi , Steps to reproduce 1 . GO to category page (product list page ) from home page . |
I have same problem. How to display breadcrumbs with full path on product view pages? |
Same issue on CE 2.1.3 |
We have created internal ticket MAGETWO-63011 |
Hi , Kindly let us know if any updates regarding this issue . |
Is there any updates regarding this issue ? |
Anyone have any idea about this issue ? |
Just made an update to version 2.1.4 via web wizard, still got those broken breadcrumbs. |
Hi , |
Is it correct? This PHP version is not supported yet. Is issue reproducible when you disable caches? |
I am on PHP Version 5.3.6 and Magento 2 Version 2.1.4. Issue occures even with cache disabled. Dev and production mode are equally affected. |
Hi , Anyone have any suggestion to solve this issue . |
Hi , Please let me know if you have any suggestion regarding this issue. |
Hi @susmithaN , disclaimer: this is just an idea for a workaround and not yet tested completely, but maybe you can get a hint from it:
|
Hi , Thank you for your information . I tried this one . But Still got the same problem . I cant able to add missing categories on registry . |
Hi , Any other suggestion to solve this problem . |
This was the case in M1 as well, if you had "Use category path for product URL" set to "No" https://www.creare.co.uk/wp-content/uploads/2014/03/fdf-2-658x328.jpg Only with category path in URL, Magento could resolve which category should be in breadcrumbs path. This sure is unfortunate, but don't believe it's a bug, as we cannot simply guess what category to show at the top, unless we add some sort of query parameter to URL that would identify which category the product was accessed from. |
If a product belongs to only one category, we can use it in breadcrumbs. However, if in this issue |
Exactly. Presume we have two choices here:
To conclude, this is more of a feature request than a bug report. |
Thank you for the information , |
Fine but why do I sometimes get a full breadcrumb when I follow my category up to the product from the front page and sometimes not? That makes no sense. |
Totally agree with salacis I have the same problem, one moment i have full category path - the next i don't. Sometimes I can have the full path in the breadcrumb, 5 mins later I can refresh the page, and it changes. |
As a solution; with the following; |
I have a same issue with 2.1.6. Still looking for a solution. |
Breadcrumbs use catalog session data (the last category the user viewed) for rendering, which seems to be a flaw since this is then cached and displayed to other users. One workaround is to use another event observer (such as layout_load_before) along with #7967 (comment) to remove this data:
|
Based on @novakivskiy suggestion we have created a temporary solution magefan/module-catalog. You can simply install it via composer |
I'm using this in following way so this doesn't affect performance - don't load unnecessary objects : File contents for <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_MyModuleName" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config> File contents for <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_controller_product_init_after">
<observer instance="Vendor\MyModuleName\Observer\Catalog\Product\InitAfter" name="execute"/>
</event>
</config> File contents for <?php
namespace Vendor\MyModuleName\Observer\Catalog\Product;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
class InitAfter implements \Magento\Framework\Event\ObserverInterface
{
const LEVEL_LARGER_THAN = 2;
/**
* @var \Magento\Framework\Registry
*/
private $registry;
/**
* @var \Magento\Catalog\Api\CategoryRepositoryInterface
*/
private $categoryRepository;
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
/**
* @var \Magento\Framework\App\ResourceConnection
*/
private $resource;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Magento\Framework\DB\Adapter\AdapterInterface
*/
private $connection;
public function __construct(
\Magento\Framework\Registry $registry,
\Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
ScopeConfigInterface $scopeConfig,
\Magento\Framework\App\ResourceConnection $resource,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->registry = $registry;
$this->categoryRepository = $categoryRepository;
$this->scopeConfig = $scopeConfig;
$this->resource = $resource;
$this->storeManager = $storeManager;
}
/**
* Execute observer
*
* @param \Magento\Framework\Event\Observer $observer
*
* @return void
*/
public function execute(
\Magento\Framework\Event\Observer $observer
) {
/** @var \Magento\Catalog\Model\Product $currentProduct */
$currentProduct = $observer->getEvent()->getProduct();
/** @var \Magento\Catalog\Model\Category $currentCategory */
$currentCategory = $this->registry->registry('current_category');
$categoryIds = (array)$currentProduct->getAvailableInCategories();
if ($currentCategory !== null
&& in_array($currentCategory->getId(), $categoryIds)
&& array_search($currentCategory->getId(), $categoryIds) === 0
) {
return;
}
if (empty($categoryIds)) {
return;
}
$connection = $this->resource->getConnection();
$categoryId = $connection->fetchOne(
$connection->select()->from(
$this->resource->getTableName('catalog_category_product_index'), 'category_id'
)->join(
array('ce' => $this->resource->getTableName('catalog_category_entity')), 'ce.entity_id = category_id', array()
)->where(
'product_id = ?', $currentProduct->getId()
)->where(
'store_id = ?', $this->storeManager->getStore()->getId()
)->where(
'is_parent = 1'
)->where(
'category_id IN (?)', $categoryIds
)->where('ce.level > ?', self::LEVEL_LARGER_THAN)
);
if (empty($categoryId)) {
return;
}
if ($currentCategory) {
$this->registry->unregister('current_category');
}
try {
$category = $this->categoryRepository->get($categoryId);
} catch (NoSuchEntityException $e) {
$category = null;
}
if ($category) {
$currentProduct->setCategory($category);
$this->registry->register('current_category', $category, true);
}
}
} |
Has this issue been fixed in any 2.1 version? I am also currently experiencing this in 2.1.10- Products will show home > category > category > product name and then after some time it just shows home > product name. |
Hello - @magento-engcom-team Is there an update on this issue ? Can we expect a fix anytime soon ? |
since 2.2.3 breadcrumbs are a JS widget that relies on page referer to get category path https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Catalog/view/frontend/web/js/product/breadcrumbs.js |
@susmithaN @magento-engcom-team looks like the issue is fixed in |
Hi Guys
As the author of this post, I have come to the conclusion a year on, that it cannot be done. I am not a programmer. But I have asked a lot of programmers the question and have drawn a blank.
After some investigation, I believe this extension will sort the issue out:
https://amasty.com/unique-product-url-for-magento-2.html
We will be launching this extension as part of a bigger upgrade later this month… after using the demo I see no reason why this won’t work for our website too.
Hope that helps…
Matt
From: Subramaniam Swamynathan <notifications@github.com>
Sent: 02 July 2018 23:10
To: magento/magento2 <magento2@noreply.github.com>
Cc: Matt Timmins <Matt@thesewingstudio.co.uk>; Mention <mention@noreply.github.com>
Subject: Re: [magento/magento2] Problems with breadcrumbs (#7967)
Hello - @magento-engcom-team<https://github.com/magento-engcom-team>
Is there an update on this issue ?
Can we expect a fix anytime soon ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#7967 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Abt2087NJifcusJ4fdT4LA6dUQtbhGBWks5uCpocgaJpZM4LWN0f>.
|
Well, any kind of logic can be done :) But without referer and if product can be assigned to more than one category, logic is really not clear to me. |
@magento-engcom-team @orlangur please close this issue, because it is not an issue. |
Closing. Thank you |
The problem appears to be a typo in this file
useCategoryPathInUrl instead because
|
Hi @susmithaN. Thank you for your report. The fix will be available with the upcoming 2.2.9 release. |
yes I saw that the issue caused by the cache when someone opens the product from the search or from a custom widget the product page will be opened without category breadcrumbs and as well will be cached as it |
Preconditions
I have some problems with breadcrumbs .
Im using
Steps to reproduce
List page - http://prnt.sc/doeoxy
Expected result
details page should contain breadcrumbs in this format Home -> Category name ->Product Name
Home > Proteasome Inhibitors > MG-132
Actual result
Detail page - http://prnt.sc/doeqa2
Is it possible to get full breadcrumb with Magento 2 ?
The text was updated successfully, but these errors were encountered: