By default clicking breadcrumbs Home will go to home page.
How can I change the URL for home link to be different than store home page?
For Magento 2.1.
Magento – Change Breadcrumbs Home link’s URL 2.1
breadcrumbsmagento2
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);
Replace your breadcrumbs.phtml with this:
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->escapeHtml($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>/ </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Ensure that:
System > Configuration > General > Web > Search Engine Optimizations > Use Web Server Rewrites = 'Yes'
System > Configuration > Catalog > Catalog > Web > Search Engine Optimizations > Product URL Suffix is empty
System > Configuration > Catalog > Catalog > Web > Search Engine Optimizations > Use Categories Path for Product URLs = 'Yes'
Reindex Catalog URL Rewrites
Flush Cache
Reload Page
Best Answer
You have to override Breadcrumbs block under
So, create your module and your di.xml in vendorName/moduleName/etc folder:
Then create your Breadcrumbs.php block file in vendorName/moduleName/Block folder:
In this file you can change parameters in addCrumb() method: label, title and link.