Add category path to breadcrumbs on product view pageHow to show catalog/product name , title above the breadcrumbs?Magento2 Get Category Id like breadcrumbs of Current ProductGetting different category id for the productsIs it possible for breadcrumbs to always display on a product page? Not just when navigated to through category layersFull breadcrumb in product listing pageDynamic Breadcrumbs on Product View with Full Page Cache EnabledHow to get Search result Product collection outside result.phtmlDisplay the Search Query Along With the BreadcrumbsDisplay breadcrumbs on a custom phtml pageHow to add breadcrumbs in my account pagesBreadcrumbs not working on Product Page Magento 2.2.4Magento2 Improper Breadcrumb On Product Detail PageMagento 2 breadcrumbs issue on product view page?
What can cause a never-frozen indoor copper drain pipe to crack?
How does Howard Stark know this?
Exception propagation: When to catch exceptions?
Can you book a one-way ticket to the UK on a visa?
How to deal with inappropriate comments during interviews for academic positions?
Can 'sudo apt-get remove [write]' destroy my Ubuntu?
Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?
How to make a language evolve quickly?
When do you stop "pushing" a book?
A musical commute to work
How to slow yourself down (for playing nice with others)
How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?
Guns in space with bullets that return?
How do car rear-view mirrors work?
Is Simic Ascendancy triggered by Awakening of Vitu-Ghazi?
International Code of Ethics for order of co-authors in research papers
Is it a bad idea to replace pull-up resistors with hard pull-ups?
Was there a contingency plan in place if Little Boy failed to detonate?
On studying Computer Science vs. Software Engineering to become a proficient coder
Why is it so slow when assigning a concatenated string to a variable in python?
What is the significance of 4200 BCE in context of farming replacing foraging in Europe?
What are the ramifications of setting ARITHABORT ON for all connections in SQL Server?
"Right on the tip of my tongue" meaning?
Is calcium chloride an acidic or basic salt?
Add category path to breadcrumbs on product view page
How to show catalog/product name , title above the breadcrumbs?Magento2 Get Category Id like breadcrumbs of Current ProductGetting different category id for the productsIs it possible for breadcrumbs to always display on a product page? Not just when navigated to through category layersFull breadcrumb in product listing pageDynamic Breadcrumbs on Product View with Full Page Cache EnabledHow to get Search result Product collection outside result.phtmlDisplay the Search Query Along With the BreadcrumbsDisplay breadcrumbs on a custom phtml pageHow to add breadcrumbs in my account pagesBreadcrumbs not working on Product Page Magento 2.2.4Magento2 Improper Breadcrumb On Product Detail PageMagento 2 breadcrumbs issue on product view page?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
By Default Manual Navigation Products breadcrumb
looks like,
Wanted product detail page:
When I reached to product page using by search
the breadcrumb looks like,
Current product detail page:
How can I get Complete Breadcrumb of the desired products even reached
by search?
magento-1.9 catalogsearch navigation product-page breadcrumbs
add a comment |
By Default Manual Navigation Products breadcrumb
looks like,
Wanted product detail page:
When I reached to product page using by search
the breadcrumb looks like,
Current product detail page:
How can I get Complete Breadcrumb of the desired products even reached
by search?
magento-1.9 catalogsearch navigation product-page breadcrumbs
add a comment |
By Default Manual Navigation Products breadcrumb
looks like,
Wanted product detail page:
When I reached to product page using by search
the breadcrumb looks like,
Current product detail page:
How can I get Complete Breadcrumb of the desired products even reached
by search?
magento-1.9 catalogsearch navigation product-page breadcrumbs
By Default Manual Navigation Products breadcrumb
looks like,
Wanted product detail page:
When I reached to product page using by search
the breadcrumb looks like,
Current product detail page:
How can I get Complete Breadcrumb of the desired products even reached
by search?
magento-1.9 catalogsearch navigation product-page breadcrumbs
magento-1.9 catalogsearch navigation product-page breadcrumbs
edited Jul 26 '17 at 0:21
sv3n
10.1k62557
10.1k62557
asked Jun 9 '17 at 11:27
user51361
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
You can try this one ... create an extension with this code:
app/etc/modules/My_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<My_Module>
<active>true</active>
<codePool>local</codePool>
</My_Module>
</modules>
</config>
app/code/local/My/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Module>
<version>0.0.1</version>
</My_Module>
</modules>
<global>
<models>
<my_module>
<class>My_Module_Model</class>
</my_module>
</models>
</global>
<frontend>
<events>
<catalog_controller_product_view>
<observers>
<add_category_to_breadcrumbs>
<class>my_module/observer</class>
<method>addCategoryToBreadcrumbs</method>
</add_category_to_breadcrumbs>
</observers>
</catalog_controller_product_view>
</events>
</frontend>
</config>
app/code/local/My/Module/Model/Observer.php
class My_Module_Model_Observer extends Mage_Core_Model_Observer
public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)
if (Mage::registry('current_category'))
return;
$product = $observer->getProduct();
$product->setDoNotUseCategoryId(false);
$categoryIds = $product->getCategoryIds();
if (count($categoryIds))
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('entity_id', $categoryIds)
->addAttributeToFilter('is_active', 1);
$categories->getSelect()->order('level DESC')->limit(1);
Mage::register('current_category', $categories->getFirstItem());
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) toaddCategoryToBreadcrumbs
beforeif (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
Its working good,,
– user51361
Jun 13 '17 at 7:31
1
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
|
show 1 more comment
The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html
add a comment |
You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...
if(empty($path))
if ($this->getProduct())
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addAttributeToSelect('is_active')
->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));
$categories = array();
$cate = false;
foreach ($collection as $category)
if($category->getId())
$cate = $category;
$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
if($cate)
$categories = $cate->getParentCategories();
if($categories)
foreach($pathIds as $categoryId)
$path['category'.$categoryId] = array(
'label' => $categories[$categoryId]->getName(),
'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
);
else
$path['category'] = array('label' => $cate->getName());
add a comment |
Just a comment to the awesome answer of @sv3n.
Let's assume we have this category structure
root > category 1 > category 2 > category 3 > category 4
A product of the category 4 can be listed in Category 1, 2, 3 or 4
If the user clicks the product in the category 2 listing the breadcrumb will be
root > category 1 > category 2 > product
So if always the complete product breadcrumb path must be shown a change is needed
if (Mage::registry('current_category'))
return;
for
if (Mage::registry('current_category'))
Mage::unregister('current_category');
New contributor
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f178268%2fadd-category-path-to-breadcrumbs-on-product-view-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try this one ... create an extension with this code:
app/etc/modules/My_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<My_Module>
<active>true</active>
<codePool>local</codePool>
</My_Module>
</modules>
</config>
app/code/local/My/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Module>
<version>0.0.1</version>
</My_Module>
</modules>
<global>
<models>
<my_module>
<class>My_Module_Model</class>
</my_module>
</models>
</global>
<frontend>
<events>
<catalog_controller_product_view>
<observers>
<add_category_to_breadcrumbs>
<class>my_module/observer</class>
<method>addCategoryToBreadcrumbs</method>
</add_category_to_breadcrumbs>
</observers>
</catalog_controller_product_view>
</events>
</frontend>
</config>
app/code/local/My/Module/Model/Observer.php
class My_Module_Model_Observer extends Mage_Core_Model_Observer
public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)
if (Mage::registry('current_category'))
return;
$product = $observer->getProduct();
$product->setDoNotUseCategoryId(false);
$categoryIds = $product->getCategoryIds();
if (count($categoryIds))
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('entity_id', $categoryIds)
->addAttributeToFilter('is_active', 1);
$categories->getSelect()->order('level DESC')->limit(1);
Mage::register('current_category', $categories->getFirstItem());
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) toaddCategoryToBreadcrumbs
beforeif (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
Its working good,,
– user51361
Jun 13 '17 at 7:31
1
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
|
show 1 more comment
You can try this one ... create an extension with this code:
app/etc/modules/My_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<My_Module>
<active>true</active>
<codePool>local</codePool>
</My_Module>
</modules>
</config>
app/code/local/My/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Module>
<version>0.0.1</version>
</My_Module>
</modules>
<global>
<models>
<my_module>
<class>My_Module_Model</class>
</my_module>
</models>
</global>
<frontend>
<events>
<catalog_controller_product_view>
<observers>
<add_category_to_breadcrumbs>
<class>my_module/observer</class>
<method>addCategoryToBreadcrumbs</method>
</add_category_to_breadcrumbs>
</observers>
</catalog_controller_product_view>
</events>
</frontend>
</config>
app/code/local/My/Module/Model/Observer.php
class My_Module_Model_Observer extends Mage_Core_Model_Observer
public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)
if (Mage::registry('current_category'))
return;
$product = $observer->getProduct();
$product->setDoNotUseCategoryId(false);
$categoryIds = $product->getCategoryIds();
if (count($categoryIds))
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('entity_id', $categoryIds)
->addAttributeToFilter('is_active', 1);
$categories->getSelect()->order('level DESC')->limit(1);
Mage::register('current_category', $categories->getFirstItem());
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) toaddCategoryToBreadcrumbs
beforeif (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
Its working good,,
– user51361
Jun 13 '17 at 7:31
1
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
|
show 1 more comment
You can try this one ... create an extension with this code:
app/etc/modules/My_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<My_Module>
<active>true</active>
<codePool>local</codePool>
</My_Module>
</modules>
</config>
app/code/local/My/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Module>
<version>0.0.1</version>
</My_Module>
</modules>
<global>
<models>
<my_module>
<class>My_Module_Model</class>
</my_module>
</models>
</global>
<frontend>
<events>
<catalog_controller_product_view>
<observers>
<add_category_to_breadcrumbs>
<class>my_module/observer</class>
<method>addCategoryToBreadcrumbs</method>
</add_category_to_breadcrumbs>
</observers>
</catalog_controller_product_view>
</events>
</frontend>
</config>
app/code/local/My/Module/Model/Observer.php
class My_Module_Model_Observer extends Mage_Core_Model_Observer
public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)
if (Mage::registry('current_category'))
return;
$product = $observer->getProduct();
$product->setDoNotUseCategoryId(false);
$categoryIds = $product->getCategoryIds();
if (count($categoryIds))
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('entity_id', $categoryIds)
->addAttributeToFilter('is_active', 1);
$categories->getSelect()->order('level DESC')->limit(1);
Mage::register('current_category', $categories->getFirstItem());
You can try this one ... create an extension with this code:
app/etc/modules/My_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<My_Module>
<active>true</active>
<codePool>local</codePool>
</My_Module>
</modules>
</config>
app/code/local/My/Module/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Module>
<version>0.0.1</version>
</My_Module>
</modules>
<global>
<models>
<my_module>
<class>My_Module_Model</class>
</my_module>
</models>
</global>
<frontend>
<events>
<catalog_controller_product_view>
<observers>
<add_category_to_breadcrumbs>
<class>my_module/observer</class>
<method>addCategoryToBreadcrumbs</method>
</add_category_to_breadcrumbs>
</observers>
</catalog_controller_product_view>
</events>
</frontend>
</config>
app/code/local/My/Module/Model/Observer.php
class My_Module_Model_Observer extends Mage_Core_Model_Observer
public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)
if (Mage::registry('current_category'))
return;
$product = $observer->getProduct();
$product->setDoNotUseCategoryId(false);
$categoryIds = $product->getCategoryIds();
if (count($categoryIds))
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('entity_id', $categoryIds)
->addAttributeToFilter('is_active', 1);
$categories->getSelect()->order('level DESC')->limit(1);
Mage::register('current_category', $categories->getFirstItem());
edited Jun 12 '17 at 13:46
answered Jun 12 '17 at 11:49
sv3nsv3n
10.1k62557
10.1k62557
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) toaddCategoryToBreadcrumbs
beforeif (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
Its working good,,
– user51361
Jun 13 '17 at 7:31
1
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
|
show 1 more comment
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) toaddCategoryToBreadcrumbs
beforeif (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
Its working good,,
– user51361
Jun 13 '17 at 7:31
1
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
not working, getting the same error
– user51361
Jun 12 '17 at 12:30
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to
addCategoryToBreadcrumbs
before if (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to
addCategoryToBreadcrumbs
before if (Mage::registry('current_category'))
– sv3n
Jun 12 '17 at 13:48
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…
– user51361
Jun 13 '17 at 5:24
Its working good,,
– user51361
Jun 13 '17 at 7:31
Its working good,,
– user51361
Jun 13 '17 at 7:31
1
1
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
Working fine. great work.
– Chandra Bhushan
Apr 22 at 6:26
|
show 1 more comment
The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html
add a comment |
The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html
add a comment |
The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html
The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html
answered Nov 13 '17 at 15:26
MagestyAppsMagestyApps
34613
34613
add a comment |
add a comment |
You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...
if(empty($path))
if ($this->getProduct())
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addAttributeToSelect('is_active')
->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));
$categories = array();
$cate = false;
foreach ($collection as $category)
if($category->getId())
$cate = $category;
$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
if($cate)
$categories = $cate->getParentCategories();
if($categories)
foreach($pathIds as $categoryId)
$path['category'.$categoryId] = array(
'label' => $categories[$categoryId]->getName(),
'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
);
else
$path['category'] = array('label' => $cate->getName());
add a comment |
You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...
if(empty($path))
if ($this->getProduct())
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addAttributeToSelect('is_active')
->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));
$categories = array();
$cate = false;
foreach ($collection as $category)
if($category->getId())
$cate = $category;
$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
if($cate)
$categories = $cate->getParentCategories();
if($categories)
foreach($pathIds as $categoryId)
$path['category'.$categoryId] = array(
'label' => $categories[$categoryId]->getName(),
'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
);
else
$path['category'] = array('label' => $cate->getName());
add a comment |
You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...
if(empty($path))
if ($this->getProduct())
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addAttributeToSelect('is_active')
->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));
$categories = array();
$cate = false;
foreach ($collection as $category)
if($category->getId())
$cate = $category;
$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
if($cate)
$categories = $cate->getParentCategories();
if($categories)
foreach($pathIds as $categoryId)
$path['category'.$categoryId] = array(
'label' => $categories[$categoryId]->getName(),
'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
);
else
$path['category'] = array('label' => $cate->getName());
You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...
if(empty($path))
if ($this->getProduct())
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addAttributeToSelect('is_active')
->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));
$categories = array();
$cate = false;
foreach ($collection as $category)
if($category->getId())
$cate = $category;
$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
if($cate)
$categories = $cate->getParentCategories();
if($categories)
foreach($pathIds as $categoryId)
$path['category'.$categoryId] = array(
'label' => $categories[$categoryId]->getName(),
'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
);
else
$path['category'] = array('label' => $cate->getName());
answered Jan 30 '18 at 14:04
LipaLipa
11
11
add a comment |
add a comment |
Just a comment to the awesome answer of @sv3n.
Let's assume we have this category structure
root > category 1 > category 2 > category 3 > category 4
A product of the category 4 can be listed in Category 1, 2, 3 or 4
If the user clicks the product in the category 2 listing the breadcrumb will be
root > category 1 > category 2 > product
So if always the complete product breadcrumb path must be shown a change is needed
if (Mage::registry('current_category'))
return;
for
if (Mage::registry('current_category'))
Mage::unregister('current_category');
New contributor
add a comment |
Just a comment to the awesome answer of @sv3n.
Let's assume we have this category structure
root > category 1 > category 2 > category 3 > category 4
A product of the category 4 can be listed in Category 1, 2, 3 or 4
If the user clicks the product in the category 2 listing the breadcrumb will be
root > category 1 > category 2 > product
So if always the complete product breadcrumb path must be shown a change is needed
if (Mage::registry('current_category'))
return;
for
if (Mage::registry('current_category'))
Mage::unregister('current_category');
New contributor
add a comment |
Just a comment to the awesome answer of @sv3n.
Let's assume we have this category structure
root > category 1 > category 2 > category 3 > category 4
A product of the category 4 can be listed in Category 1, 2, 3 or 4
If the user clicks the product in the category 2 listing the breadcrumb will be
root > category 1 > category 2 > product
So if always the complete product breadcrumb path must be shown a change is needed
if (Mage::registry('current_category'))
return;
for
if (Mage::registry('current_category'))
Mage::unregister('current_category');
New contributor
Just a comment to the awesome answer of @sv3n.
Let's assume we have this category structure
root > category 1 > category 2 > category 3 > category 4
A product of the category 4 can be listed in Category 1, 2, 3 or 4
If the user clicks the product in the category 2 listing the breadcrumb will be
root > category 1 > category 2 > product
So if always the complete product breadcrumb path must be shown a change is needed
if (Mage::registry('current_category'))
return;
for
if (Mage::registry('current_category'))
Mage::unregister('current_category');
New contributor
New contributor
answered May 7 at 16:29
rekobekorekobeko
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f178268%2fadd-category-path-to-breadcrumbs-on-product-view-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown