// Fix display of breadcrumb (dont show categories disabled) + it's now impossible to browse categories outside of root category for shops
This commit is contained in:
@@ -211,7 +211,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
$category['cms'] = Db::getInstance()->ExecuteS($sql);
|
||||
if ($links == 1)
|
||||
{
|
||||
$category['link'] = $context->link->getCMSCategoryLink($current, $category['link_rewrite']);
|
||||
$category['link'] = $link->getCMSCategoryLink($current, $category['link_rewrite']);
|
||||
foreach($category['cms'] as $key => $cms)
|
||||
$category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']);
|
||||
}
|
||||
|
||||
+20
-2
@@ -596,7 +596,7 @@ class CategoryCore extends ObjectModel
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
return new Category($context->shop->getCategory(), $id_lang);
|
||||
return new Category($shop->getCategory(), $id_lang);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -986,12 +986,30 @@ class CategoryCore extends ObjectModel
|
||||
*/
|
||||
public static function getInterval($id)
|
||||
{
|
||||
$sql = 'SELECT nleft, nright FROM '._DB_PREFIX_.'category
|
||||
$sql = 'SELECT nleft, nright, level_depth
|
||||
FROM '._DB_PREFIX_.'category
|
||||
WHERE id_category = '.(int)$id;
|
||||
if (!$result = Db::getInstance()->getRow($sql))
|
||||
return false;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current category is a child of shop root category
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param Shop $shop
|
||||
* @return bool
|
||||
*/
|
||||
public function inShop(Shop $shop = null)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
if (!$interval = Category::getInterval($shop->getCategory()))
|
||||
return false;
|
||||
return ($this->nleft >= $interval['nleft'] && $this->nright <= $interval['nright']);
|
||||
}
|
||||
|
||||
public function getChildrenWs()
|
||||
{
|
||||
|
||||
+28
-22
@@ -819,7 +819,8 @@ class ToolsCore
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
|
||||
$id_category = (int)$id_category;
|
||||
if ($id_category == 1)
|
||||
return '<span class="navigation_end">'.$path.'</span>';
|
||||
|
||||
@@ -828,23 +829,23 @@ class ToolsCore
|
||||
$pipe = '>';
|
||||
|
||||
$fullPath = '';
|
||||
|
||||
if ($categoryType === 'products')
|
||||
{
|
||||
$category = Db::getInstance()->getRow('
|
||||
SELECT id_category, level_depth, nleft, nright
|
||||
FROM '._DB_PREFIX_.'category
|
||||
WHERE id_category = '.(int)$id_category);
|
||||
|
||||
if (isset($category['id_category']))
|
||||
$interval = Category::getInterval($id_category);
|
||||
$intervalRoot = Category::getInterval($context->shop->getCategory());
|
||||
if ($interval)
|
||||
{
|
||||
$categories = Db::getInstance()->ExecuteS('
|
||||
SELECT c.id_category, cl.name, cl.link_rewrite
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category)
|
||||
WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)$context->language->id.' AND c.id_category != 1
|
||||
ORDER BY c.level_depth ASC
|
||||
LIMIT '.(int)$category['level_depth']);
|
||||
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$context->shop->sqlLang('cl').')
|
||||
WHERE c.nleft <= '.$interval['nleft'].'
|
||||
AND c.nright >= '.$interval['nright'].'
|
||||
AND c.nleft >= '.$intervalRoot['nleft'].'
|
||||
AND c.nright <= '.$intervalRoot['nright'].'
|
||||
AND cl.id_lang = '.(int)$context->language->id.'
|
||||
AND c.active = 1
|
||||
ORDER BY c.level_depth ASC';
|
||||
$categories = Db::getInstance()->ExecuteS($sql);
|
||||
|
||||
$n = 1;
|
||||
$nCategories = (int)sizeof($categories);
|
||||
@@ -860,7 +861,7 @@ class ToolsCore
|
||||
return $fullPath.$path;
|
||||
}
|
||||
}
|
||||
elseif ($categoryType === 'CMS')
|
||||
else if ($categoryType === 'CMS')
|
||||
{
|
||||
$category = new CMSCategory($id_category, $context->language->id);
|
||||
if (!Validate::isLoadedObject($category))
|
||||
@@ -872,7 +873,7 @@ class ToolsCore
|
||||
else
|
||||
$fullPath = ($linkOntheLastItem ? '<a href="'.self::safeOutput($categoryLink).'">' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($linkOntheLastItem ? '</a>' : '');
|
||||
|
||||
return self::getPath((int)($category->id_parent), $fullPath, $linkOntheLastItem, $categoryType);
|
||||
return self::getPath($category->id_parent, $fullPath, $linkOntheLastItem, $categoryType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,17 +884,22 @@ class ToolsCore
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
|
||||
$id_category = (int)$id_category;
|
||||
$pipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>');
|
||||
|
||||
if($type_cat === 'products')
|
||||
$category = new Category($id_category, $context->language->id);
|
||||
$defaultCategory = 1;
|
||||
if ($type_cat === 'products')
|
||||
{
|
||||
$defaultCategory = $context->shop->getCategory();
|
||||
$category = new Category($id_category, $context->language->id);
|
||||
}
|
||||
else if ($type_cat === 'CMS')
|
||||
$category = new CMSCategory($id_category, $context->language->id);
|
||||
|
||||
if (!Validate::isLoadedObject($category))
|
||||
$id_category = 1;
|
||||
if ($id_category == 1)
|
||||
$id_category = $defaultCategory;
|
||||
if ($id_category == $defaultCategory)
|
||||
return htmlentities($end, ENT_NOQUOTES, 'UTF-8');
|
||||
|
||||
return self::getPath($id_category, $category->name, true, $type_cat).'<span class="navigation-pipe">'.$pipe.'</span> <span class="navigation_product">'.htmlentities($end, ENT_NOQUOTES, 'UTF-8').'</span>';
|
||||
|
||||
Reference in New Issue
Block a user