[-] FO: Don't display categories in breadcrumb if there are not associated to the shop

This commit is contained in:
Rémi Gaillard
2012-11-29 18:01:39 +01:00
parent b13f3b0344
commit 4188bb5f58
+12 -5
View File
@@ -448,10 +448,10 @@ class ProductControllerCore extends FrontController
protected function assignCategory()
{
// Assign category to the template
if ($this->category !== false && Validate::isLoadedObject($this->category))
if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop())
{
$path = Tools::getPath($this->category->id, $this->product->name, true);
$this->context->smarty->assign(array(
'path' => Tools::getPath($this->category->id, $this->product->name, true),
'category' => $this->category,
'subCategories' => $this->category->getSubCategories($this->context->language->id, true),
'id_category_current' => (int)$this->category->id,
@@ -459,9 +459,16 @@ class ProductControllerCore extends FrontController
'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));
elseif (Category::inShopStatic($this->product->id_category_default, $this->context->shop))
{
$cat_default = new Category((int)$this->product->id_category_default);
if (Validate::isLoadedObject($cat_default) && $cat_default->active && $cat_default->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);
$this->context->smarty->assign('path', $path);
$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))));
}