Daniel Patilea Posted April 12, 2014 Share Posted April 12, 2014 (edited) I have a problem with breadcrumbs on the product page, it does not show the real path of the product. Here's how I set it on the backend: Here's how it shows it: And here's what my breadcrumb.tpl file contains: <!-- Breadcrumb --> {if $page_name != index} {if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if} <div id="breadcrumb"> <ul class="breadcrumb"> {if $page_name!='product'} <li> <a href="{$base_dir}" title="{l s='return to Home'}">{l s='Home'} {$navigationPipe|escape:html:'UTF-8'} {l s='Shop'}</a> {if isset($path) AND $path} {if $page_name!='product'} <span class="divider" {if isset($category) && $category->id_category == 1}style="display:none;"{/if}> {$navigationPipe|escape:html:'UTF-8'} </span> {/if} {/if} </li> {/if} {if isset($path) AND $path} {if !$path|strpos:'span'} <li>{$path}</li> {else} <li class="active">{$path}</li> {/if} {/if} </ul> </div> {/if} <!-- /Breadcrumb --> Please anybody help me with this. Any advice is helpful. Thanks! Edited April 12, 2014 by corsenium (see edit history) Link to comment Share on other sites More sharing options...
Daniel Patilea Posted April 14, 2014 Author Share Posted April 14, 2014 Nobody can help me? Link to comment Share on other sites More sharing options...
NemoPS Posted April 15, 2014 Share Posted April 15, 2014 Did you try with the default theme? Using any override? Link to comment Share on other sites More sharing options...
Daniel Patilea Posted May 7, 2014 Author Share Posted May 7, 2014 I managed to solve the problem by deleting the multiple useless categories parent declarations directly from database. I found ps_category messed up. In the past I had deleted some categories and added other ones, so this is a Prestashop bug. 1 Link to comment Share on other sites More sharing options...
Prestafan1234 Posted August 15, 2014 Share Posted August 15, 2014 I have just experienced the same in PS 1.5.5.2 - it is indeed a mess. Did you create a bug for it? Link to comment Share on other sites More sharing options...
Radi Posted October 9, 2014 Share Posted October 9, 2014 (edited) I have similar problem. If change default category product breadcrumb show old default category but if clear cache browser show new breadcrumb. Clear smarty cache not resolve problem. Is any fix ? Edited October 9, 2014 by Radi (see edit history) Link to comment Share on other sites More sharing options...
Agence web Cibles.fr Posted October 20, 2014 Share Posted October 20, 2014 I have solved the problem in Prestashop 1.6.0.9 It is in controllers/ProductController.php We have that : class ProductControllerCore extends FrontController { /** * Assign template vars related to category */ 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); 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); $subCategories = array(); if (Validate::isLoadedObject($this->category)) { $subCategories = $this->category->getSubCategories($this->context->language->id, true); // various assignements before Hook::exec $this->context->smarty->assign(array( 'path' => $path, 'category' => $this->category, 'subCategories' => $subCategories, 'id_category_current' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->getFieldByLang('name')), 'categories' => Category::getHomeCategories($this->context->language->id, true, (int)$this->context->shop->id) )); } $this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category)))); } } The problem is : $path = Tools::getPath($this->category->id, $this->product->name, true); Instead, you should have : $this->category = new Category((int)$this->product->id_category_default, (int)$this->context->language->id); $path = Tools::getPath($this->product->id_category_default, $this->product->name, true); You can add override/controllers/front/ProductController.php file with this content instead : class ProductController extends ProductControllerCore { protected function assignCategory() { // Assign category to the template if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop()) { // full path $this->category = new Category((int)$this->product->id_category_default, (int)$this->context->language->id); $path = Tools::getPath($this->product->id_category_default, $this->product->name, 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); $subCategories = array(); if (Validate::isLoadedObject($this->category)) { $subCategories = $this->category->getSubCategories($this->context->language->id, true); // various assignements before Hook::exec $this->context->smarty->assign(array( 'path' => $path, 'category' => $this->category, 'subCategories' => $subCategories, 'id_category_current' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->getFieldByLang('name')), 'categories' => Category::getHomeCategories($this->context->language->id, true, (int)$this->context->shop->id) )); } $this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category)))); } } And it will works. Link to comment Share on other sites More sharing options...
Tardos Posted October 30, 2014 Share Posted October 30, 2014 I still have this problem. My breadcrumb is shown as: Home > Category > Category > ProductCant seem to find any problems in the ps_category table.The fix posted for 1.6.0.9 doesnt work for my 1.6.0.6.I use a custom theme. But doesnt see how it affects the breadcrumb.tpl as it is the same as default theme breadcrumb.tpl.Anyone have an idea? Link to comment Share on other sites More sharing options...
NemoPS Posted October 31, 2014 Share Posted October 31, 2014 Even if they have the same .tpl, did you try enabling the default one as a test? Link to comment Share on other sites More sharing options...
Tardos Posted October 31, 2014 Share Posted October 31, 2014 Just did. Problem is still there unfortunately. Link to comment Share on other sites More sharing options...
gerHard Posted March 10, 2017 Share Posted March 10, 2017 Try to regenerate positions: Step 1.) Set nright and nleft from categories to null Db::getInstance()->execute('UPDATE `ps_category` SET `nleft`=0,`nright`=0 WHERE 1'); Step 2.) Regenerate Category Tree Category::regenerateEntireNtree(); Link to comment Share on other sites More sharing options...
NemoPS Posted March 10, 2017 Share Posted March 10, 2017 You can try with the above step 2 only, no need for the first query actually Link to comment Share on other sites More sharing options...
Recommended Posts