TWDesign Posted May 3, 2012 Share Posted May 3, 2012 The default behavior of PrestaShop re breadcrumbs seems a little screwy to me. Lets say I am on the "CATEGORY A" page and use the search box feature. Lets say the product I am looking for is somewhere in "CATEGORY A". If I click the search result it will take me to the product page but the breadcrumb will only show something like >>category A>>product 123 BUT.... what if the product is actually buried one or two deep in the sub-categories. Even having the sub-category correctly set as "Default Category" doesn't seem to change this behavior. What I really want to see is something like >>category A>>sub-category X>>product 123 It seems screwy because if I happen to be in "CATEGORY B" at the time I do the search, it WILL return the full breadcrumb trail down to the Default Category. How can I change this behavior. (btw - looks like another Module opportunity for somebody clever). Link to comment Share on other sites More sharing options...
Mr S Posted June 26, 2012 Share Posted June 26, 2012 Done: http://www.prestashop.com/forums/index.php?/topic/93231-ps-v14-category-table-what-is-nleft-et-nright-for/page__view__findpost__p__862954 Link to comment Share on other sites More sharing options...
ECB2012 Posted November 8, 2012 Share Posted November 8, 2012 Morning I have a question more about this topic ... I dont´t know if I could resolve my problem with your module (HA!*!*). I explain my case below ... I have a shop with a lot of products and 15 cats, and sometimes a product can be into several cats. I´ve got to have unique metas and urls but I don´t know how make the same for the breadcrumb. Ex: Product A = Cat 1 - Sub cat 2 Product A = Cat 3 - Sub cat 3 Product A = Home - Sales I need 3 breadcrumb: - Home > Cat 1 > Subcat2 > Product A - Home > Cat 3 > Subcat3 > Product A - Home > Sales > Product A Prestashop only shows the first breadcrumb because It always takes the category default (Subcat 2). Does anyone know how solve the problem with the breadcrumb?? Thx a lot and regards. Link to comment Share on other sites More sharing options...
bluego78 Posted November 9, 2012 Share Posted November 9, 2012 In the Product.php Class, where get the product path, remove the second parameter and you'll get the full path, but only if the product has default category. Sorry i'm on mobile now and i can't post the code. Tell me if you resolve Link to comment Share on other sites More sharing options...
ECB2012 Posted November 9, 2012 Share Posted November 9, 2012 Hi Bluego78, Now, I have uploaded all products in my catalog with unique url and metas (Ex: www.xxxxxxx.com/catalog/product-name) and this product is into 3 subcategories (Ex; SubA, SubB, Offer) and I need: - Keep my unique url: www.xxxxxxx.com/catalog/product-name - Breadcrumb 1: Home > Cat 1 > SubA > Product name - Breadcrumb 2: Home > Cat 2 > SubB > Product name - Breadcrumb 3: Home > Offer > Product name > Is it possible with the change in te Product.php class Thx a lot for your answer! Link to comment Share on other sites More sharing options...
ECB2012 Posted November 9, 2012 Share Posted November 9, 2012 Excuse me, offerbeat, but I don´t undestand your answer ... Link to comment Share on other sites More sharing options...
bluego78 Posted November 9, 2012 Share Posted November 9, 2012 Hi Bluego78, Now, I have uploaded all products in my catalog with unique url and metas (Ex: www.xxxxxxx.com/catalog/product-name) and this product is into 3 subcategories (Ex; SubA, SubB, Offer) and I need: - Keep my unique url: www.xxxxxxx.com/catalog/product-name - Breadcrumb 1: Home > Cat 1 > SubA > Product name - Breadcrumb 2: Home > Cat 2 > SubB > Product name - Breadcrumb 3: Home > Offer > Product name > Is it possible with the change in te Product.php class Thx a lot for your answer! Hi, sorry, i've checked now that i'm in office... the change is to made to ProductController.php not in Product.php class. In the function assignCategory() Tools::getPath let you get the path... which version of prestashop are you using? 1 Link to comment Share on other sites More sharing options...
ECB2012 Posted November 9, 2012 Share Posted November 9, 2012 I´m using 1.4.8.2 version Thx Link to comment Share on other sites More sharing options...
bluego78 Posted November 9, 2012 Share Posted November 9, 2012 I´m using 1.4.8.2 version Thx Oh.. i've done! But i use 1.5.2 but i think you can adapt my script, it works :-) In ProductController.php modify the assignCategory() method like this: protected function assignCategory() { // Assign category to the template if ($this->category !== false && Validate::isLoadedObject($this->category)) { $all_product_subs = Product::getProductCategoriesFull($this->product->id, $this->context->language->id); if(isset($all_product_subs) && count($all_product_subs)>0) { foreach($all_product_subs as $subcat) $all_product_subs_path[] = Tools::getPath($subcat['id_category'], '', true); } $this->context->smarty->assign(array( 'path' => Tools::getPath($this->category->id, '', true), //THIS CONTAINS ALL PRODUCT SUBCATEGORIES PATH 'all_product_subs'=>$all_product_subs_path, 'category' => $this->category, 'subCategories' => $this->category->getSubCategories($this->context->language->id, true), 'id_category_current' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name) )); } else $this->context->smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name)); $this->context->smarty->assign('categories', Category::getHomeCategories($this->context->language->id)); $this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category)))); } So you'll get all categories path in "all_product_subs", then in your breadcrumb.tpl add: {if isset($all_product_subs)} {foreach from=$all_product_subs item=prod_subcategory} <br /> <a href="{$base_dir}" title="{l s='return to'} {l s='Home'}">{l s='Home'}</a> <span class="navigation-pipe">{$navigationPipe|escape:html:'UTF-8'}</span> {if !$prod_subcategory|strpos:'span'}<span class="navigation_page">{$prod_subcategory}</span> {else} {$prod_subcategory} {/if} {/foreach} {/if} this works fine :-) 2 Link to comment Share on other sites More sharing options...
ECB2012 Posted November 9, 2012 Share Posted November 9, 2012 Thank you so much for your help!! I go to try it now and tello you soon! Regards! Link to comment Share on other sites More sharing options...
bluego78 Posted November 9, 2012 Share Posted November 9, 2012 Ok let me know. Maybe it's better if you put also $all_product_subs_path = array(); //<-- ADD THIS LINE $all_product_subs = Product::getProductCategoriesFull($this->product->id, $this->context->language->id); if(isset($all_product_subs) && count($all_product_subs)>0) { foreach($all_product_subs as $subcat) ... and put the template code in the product.tpl not in breadcrumb.tpl, it's better :-) Bye Link to comment Share on other sites More sharing options...
bluego78 Posted November 9, 2012 Share Posted November 9, 2012 (edited) I've implement the method to get only the "finals" category, because if the product is associated to (example): computer -> hardware -> monitor and office -> display -> lcd you'll get: computer computer -> hardware computer -> hardware ->monitor office office -> display office -> display -> lcd but if you need only monitor and lcd modify the script as this: $all_product_subs = Product::getProductCategoriesFull($this->product->id, $this->context->language->id); $all_product_subs_path = array(); if(isset($all_product_subs) && count($all_product_subs)>0) { foreach($all_product_subs as $subcat) { $sub_category = new Category($subcat['id_category'], $this->context->language->id); $sub_category_children = $sub_category->getSubCategories($this->context->language->id, $active = true); if(count($sub_category_children)<=0) if($subcat['id_category']!=$this->product->id_category_default)//this remove the default category from the list if(Tools::getPath($subcat['id_category'], '', true)!='') $all_product_subs_path[] = Tools::getPath($subcat['id_category'], '', true); } } so you'll get: computer -> hardware -> monitor office -> display -> lcd Edited November 9, 2012 by bluego78 (see edit history) Link to comment Share on other sites More sharing options...
jumprock Posted November 24, 2012 Share Posted November 24, 2012 Just wanted to extend some thanks - this saved me untold hours of trying to reverse engineer the workings of the breadcrumb/category hierarchy system. I love the potential of Prestashop but the documentation is so woefully lacking that it's almost hard to recommend to other developers Too late for me now that I'm already 6 weeks into a 3 week project... Just some background to my problem for anyone else that may have encountered the same thing. My products had all been uploaded through the Store Manager system's CSV import. This process will correctly place products in nested categories, but won't automatically associate those items with the relevant parent categories. The end result means the breadcrumbs would not display the complete path on a product page (at least it had this effect in my case). Your override to the ProductController worked a charm. Thanks again!! Link to comment Share on other sites More sharing options...
jquintana Posted February 19, 2013 Share Posted February 19, 2013 Hi, but i get: Home > Home > Cat Home > Cat > Brand how only get "Home > Cat > Brand"? Thank you very much! Link to comment Share on other sites More sharing options...
seog Posted August 31, 2013 Share Posted August 31, 2013 (edited) All the categories and subcategories have link but the product name don´t have link and this when is very important to improve SEO Home > Summer > Shoes > Nike evo How can put backlink in product name of breadcrumb? Edited August 31, 2013 by seog (see edit history) Link to comment Share on other sites More sharing options...
stefanom4 Posted September 27, 2013 Share Posted September 27, 2013 hello,you managed to get full breadcrumb prestashop 1.4.8.2?does not work the method of bluego78thanks stefano Link to comment Share on other sites More sharing options...
hiousi Posted October 9, 2013 Share Posted October 9, 2013 on my 1.5 install, I've overrided ProductController like this : /override/controllers/front/ProductController.php class ProductController extends ProductControllerCore { public function initContent() { parent::initContent(); if (Validate::isLoadedObject($this->product)) { $id_category = $this->product->id_category_default; $fullpath = Tools::getPath($id_category , $this->product->name, true); $this->context->smarty->assign('path', $fullpath); } } } Link to comment Share on other sites More sharing options...
And63 Posted October 21, 2013 Share Posted October 21, 2013 (edited) on my 1.5 install, I've overrided ProductController like this : /override/controllers/front/ProductController.php class ProductController extends ProductControllerCore { public function initContent() { parent::initContent(); if (Validate::isLoadedObject($this->product)) { $id_category = $this->product->id_category_default; $fullpath = Tools::getPath($id_category , $this->product->name, true); $this->context->smarty->assign('path', $fullpath); } } } In my version 1.5.4.1 not work - in breadcrumb still: home category->default category->product name - it's not full path of category to this product Edited October 21, 2013 by And63 (see edit history) Link to comment Share on other sites More sharing options...
hiousi Posted December 5, 2013 Share Posted December 5, 2013 @and63 that's the way my override is intended to work Link to comment Share on other sites More sharing options...
jfcordova Posted May 6, 2015 Share Posted May 6, 2015 does anyone know if there is a tested solution for this in v1.6? Link to comment Share on other sites More sharing options...
TimTamTom Posted November 23, 2016 Share Posted November 23, 2016 Hey there guys, I have the exact same problem for PS1.6 1 product is in cat. men, women and home. breadcrumb only displays the default category, never the category you come from. Problematic as women end up in men and other way around. If default cat is home then the breadcrumb is useluss to have at all.. Help much appreciated! Thanks Tim Link to comment Share on other sites More sharing options...
ferdinand64 Posted February 15, 2018 Share Posted February 15, 2018 (edited) Hey there, I used parts of scripts above adaped them for v 1.6. I am not good at Prestashop and someone may find this solution ugly but it works fine for me. Either you click on latest product at homepage or use the search field, your breadcrumb navigation shows a full path to the deepest category (assuming they are all checked - I am not sure). Searching from the menu remains unchanged. Function assignCategory(), preferably in override/controllers/front/ProductController.php protected function assignCategory() { // Assign category to the template if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop()) { $path = Tools::getPath($this->category->id, $this->product->name, true); $all_product_subs = Product::getProductCategoriesFull($this->product->id, $this->context->language->id); if(isset($all_product_subs) && count($all_product_subs)>0) { foreach($all_product_subs as $subcat) $all_product_subs_path = array(); //reset array, only last one is used $all_product_subs_path[] = Tools::getPath($subcat['id_category'], '', true); } } elseif (Category::inShopStatic($this->product->id_category_default, $this->context->shop)) { $this->category = new Category((int)$this->product->id_category_default, (int)$this->context->language->id); if (Validate::isLoadedObject($this->category) && $this->category->active && $this->category->isAssociatedToShop()) { $path = Tools::getPath((int)$this->product->id_category_default, $this->product->name); } } if (!isset($path) || !$path) { $path = Tools::getPath((int)$this->context->shop->id_category, $this->product->name); } if (Validate::isLoadedObject($this->category)) { // various assignements before Hook::exec $this->context->smarty->assign(array( 'path' => Tools::getPath($this->category->id, '', true), //THIS CONTAINS ALL PRODUCT SUBCATEGORIES PATH 'all_product_subs'=>$all_product_subs_path, 'category' => $this->category, 'subCategories' => $this->category->getSubCategories($this->context->language->id, true), 'id_category_current' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name) )); } $this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category)))); } themes/(default-bootstrap)/breadcrumb.tpl <!-- Breadcrumb --> {if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if} <div class="breadcrumb clearfix"> <a class="home" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}"><i class="icon-home"></i></a> {if isset($all_product_subs)} {foreach from=$all_product_subs item=prod_subcategory} <span class="navigation-pipe">{$navigationPipe|escape:html:'UTF-8'}</span> {if $prod_subcategory|strpos:'span'} <span class="navigation_page">{$prod_subcategory|@replace:'<a ': '<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a itemprop="url" '|@replace:'data-gg="">': '><span itemprop="title">'|@replace:'</a>': '</span></a></span>'}<span class="navigation-pipe">></span>{$product->name}</span> {else} {$prod_subcategory} {/if} {/foreach} {else} <span class="navigation-pipe"{if isset($category) && isset($category->id_category) && $category->id_category == (int)Configuration::get('PS_ROOT_CATEGORY')} style="display:none;"{/if}>{$navigationPipe|escape:'html':'UTF-8'}</span> {if $path|strpos:'span' !== false} <span class="navigation_page">{$path|@replace:'<a ': '<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a itemprop="url" '|@replace:'data-gg="">': '><span itemprop="title">'|@replace:'</a>': '</span></a></span>'}</span> {else} {$path} {/if} {/if} </div> {if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)} <div class="pull-right"> <strong> {capture}{if isset($smarty.get.HTTP_REFERER) && $smarty.get.HTTP_REFERER}{$smarty.get.HTTP_REFERER}{elseif isset($smarty.server.HTTP_REFERER) && $smarty.server.HTTP_REFERER}{$smarty.server.HTTP_REFERER}{/if}{/capture} <a href="{$smarty.capture.default|escape:'html':'UTF-8'|secureReferrer|regex_replace:'/[\?|&]content_only=1/':''}" name="back"> <i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]} </a> </strong> </div> {/if} <!-- /Breadcrumb --> Edited February 15, 2018 by ferdinand64 note refinement (see edit history) Link to comment Share on other sites More sharing options...
JohanLarsson26 Posted August 22, 2018 Share Posted August 22, 2018 On 2016-11-23 at 9:37 AM, TimTamTom said: Hey there guys, I have the exact same problem for PS1.6 1 product is in cat. men, women and home. breadcrumb only displays the default category, never the category you come from. Problematic as women end up in men and other way around. If default cat is home then the breadcrumb is useluss to have at all.. Help much appreciated! Thanks Tim Someone have fix this problem? Link to comment Share on other sites More sharing options...
Maneesh Posted March 3, 2020 Share Posted March 3, 2020 I Got one solutions (Ps 1.7). If you want to show all child category with product name. then you need to select radio button in last category. this will work fine. check screen shot. Best Regards Maneesh Tiwari 1 Link to comment Share on other sites More sharing options...
maldor Posted June 1, 2020 Share Posted June 1, 2020 On 3/3/2020 at 7:25 AM, Maneesh said: I Got one solutions (Ps 1.7). If you want to show all child category with product name. then you need to select radio button in last category. this will work fine. check screen shot. Best Regards Maneesh Tiwari Tried so but it doesn't show the categories, just Home > Product name. I'm on Prestashop v1.7.6.4 Link to comment Share on other sites More sharing options...
blueblot Posted November 1, 2020 Share Posted November 1, 2020 I have the same problem with 1.7.6. Product in multiple categories but the path is the path from the default category. Link to comment Share on other sites More sharing options...
Gaunero Posted November 6, 2020 Share Posted November 6, 2020 (edited) On 6/1/2020 at 9:23 AM, maldor said: Tried so but it doesn't show the categories, just Home > Product name. I'm on Prestashop v1.7.6.4 same problem here...and solved it to change main category as on image from Maneesh Edited November 6, 2020 by Gaunero (see edit history) Link to comment Share on other sites More sharing options...
blueblot Posted November 7, 2020 Share Posted November 7, 2020 ok, for that example this would work, but this doens't work if you would check the product in 'accessoires' too (image from Maneesh). the breadcrumb will be the same for stationery and home accessoires. Link to comment Share on other sites More sharing options...
Sub217 Posted September 28, 2021 Share Posted September 28, 2021 Hi all, I have the same issue with my PrestaShop 1.7.6.3 By example, you can access to: https://www.racealtered-import.com/shop/fr/2131-turbo In this category "Impreza 2.0R/WRX/STI 2001-2007 (GDA/GGA/GDB/GGB)", you can select this product "Boost contrôleur électronique BLITZ SBC i-Color Type-R - 2.5bar". This product is also in another category, and if you click on it, you will see his default category in breadcrumbs: "Impreza GT/STI 1993-2000 (GC8-GF8)" The current category is not saving. I found a post in this forum: Somone spoke about issue regarding "HTTP referer" in php.ini I checked it on my side, but the value is the one by default: session.referer_checkno value If someone has found something...! 😄 Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now