I found recently that When I go from home to a product description page its breadcrumb not showing full path in Magento 2.1.8 just showing home -> product . in magento 1.9 there is a fix but In magento 2.1.8 I am still unable to find any. is there any fix available ?
Magento – Magento 2- Force Display Full Breadcrumb Path
breadcrumbsmagento-2.1magento-2.1.7magento2
Related Solutions
Now if you paste the URL you copied from the Coat, the Breadcrumbs will be "Home > Women's > Footwear> Heels > Men's Coat 1" which isn't correct
In my experience this is local to 1.11EE - This is due to the fact that Magento uses the cookie value from LAST_CATEGORY
. I requested a patch from EE support for this and they provided one to me. I'd be surprised if this wasn't fixed in 1.12.
While I don't have the patchfile at the moment, an SVN diff yielded the following:
Index: app/code/core/Enterprise/PageCache/Model/Processor/Default.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Processor/Default.php (revision 717)
+++ app/code/core/Enterprise/PageCache/Model/Processor/Default.php (revision 718)
@@ -103,6 +103,7 @@
*/
if ($container && !Mage::getIsDeveloperMode()) {
$container = new $container($this->_placeholder);
+ $container->setProcessor(Mage::getSingleton('enterprise_pagecache/processor'));
$blockContent = $matches[1];
$container->saveCache($blockContent);
}
Index: app/code/core/Enterprise/PageCache/Model/Container/Breadcrumbs.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Container/Breadcrumbs.php (revision 717)
+++ app/code/core/Enterprise/PageCache/Model/Container/Breadcrumbs.php (revision 718)
@@ -51,6 +51,10 @@
protected function _renderBlock()
{
$productId = $this->_getProductId();
+
+ /** @var $product null|Mage_Catalog_Model_Product */
+ $product = null;
+
if ($productId) {
$product = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
@@ -60,6 +64,12 @@
}
}
$categoryId = $this->_getCategoryId();
+
+ if ($product !== null && !$product->canBeShowInCategory($categoryId)) {
+ $categoryId = null;
+ Mage::unregister('current_category');
+ }
+
if ($categoryId && !Mage::registry('current_category')) {
$category = Mage::getModel('catalog/category')->load($categoryId);
if ($category) {
@@ -68,7 +78,7 @@
}
//No need breadcrumbs on CMS pages
- if (!$categoryId) {
+ if (!$productId && !$categoryId) {
return '';
}
Index: app/code/core/Enterprise/PageCache/Model/Observer.php
===================================================================
--- app/code/core/Enterprise/PageCache/Model/Observer.php (revision 717)
+++ app/code/core/Enterprise/PageCache/Model/Observer.php (revision 718)
@@ -546,6 +546,10 @@
*/
public function updateProductInfo(Varien_Event_Observer $observer)
{
+ if (!$this->isCacheEnabled()) {
+ return $this;
+ }
+
$paramsObject = $observer->getEvent()->getParams();
if ($paramsObject instanceof Varien_Object) {
if (array_key_exists(Enterprise_PageCache_Model_Cookie::COOKIE_CATEGORY_ID, $_COOKIE)) {
Index: app/code/core/Mage/Catalog/Helper/Product.php
===================================================================
--- app/code/core/Mage/Catalog/Helper/Product.php (revision 717)
+++ app/code/core/Mage/Catalog/Helper/Product.php (revision 718)
@@ -307,6 +307,8 @@
if ($product->canBeShowInCategory($lastId)) {
$categoryId = $lastId;
}
+ } elseif (!$product->canBeShowInCategory($categoryId)) {
+ $categoryId = null;
}
if ($categoryId) {
@@ -322,9 +324,7 @@
try {
Mage::dispatchEvent('catalog_controller_product_init', array('product' => $product));
Mage::dispatchEvent('catalog_controller_product_init_after',
- array('product' => $product,
- 'controller_action' => $controller
- )
+ array('product' => $product, 'controller_action' => $controller)
);
} catch (Mage_Core_Exception $e) {
Mage::logException($e);
I know this is quite old, but I'd like to share my solution anyway as it doesn't override/clone any core files.
In your custom module add the following to your
config.xml
:<config> ... <frontend> <events> <catalog_controller_product_init> <observers> <breadcrumb_categorypath_product_init> <type>singleton</type> <class><Your Namespace>_<Your Module>_Model_Observer</class> <method>fullBreadcrumbCategoryPath</method> </breadcrumb_categorypath_product_init> </observers> </catalog_controller_product_init> </events> </frontend> </config>
Create an
Observer.php
in/app/code/local/<Your Namespace>/<Your Module>/Model/
Add the following to your
Observer.php
:class <Your Namespace>_<Your Module>_Model_Observer { public function fullBreadcrumbCategoryPath(Varien_Event_Observer $observer) { $current_product = Mage::registry('current_product'); if( $current_product ) { $categories = $current_product->getCategoryCollection()->addAttributeToSelect('name')->setPageSize(1); foreach( $categories as $category ) { Mage::unregister('current_category'); Mage::register('current_category', $category); } } } }
You should be good to go.
Best Answer
There is no fix until now. Also Magento only links to single products (to avoid duplicate content and other issues).
See
https://magento.stackexchange.com/a/21412/66934
https://github.com/magento/magento2/issues/7967