[-] MO : Fix cms passing to multishop cf: https://github.com/PrestaShop/PrestaShop/commit/67789cac1f1c94d19a173cd2c6f5b53e81e0d232
This commit is contained in:
+30
-10
@@ -683,12 +683,13 @@ class Blocktopmenu extends Module
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCMSOptions($parent = 0, $depth = 1, $id_lang = false, $items_to_skip = null)
|
protected function getCMSOptions($parent = 0, $depth = 1, $id_lang = false, $items_to_skip = null, $id_shop = false)
|
||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
||||||
$categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang);
|
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
|
||||||
$pages = $this->getCMSPages((int)$parent, false, (int)$id_lang);
|
$categories = $this->getCMSCategories(false, (int)$parent, (int)$id_lang, (int)$id_shop);
|
||||||
|
$pages = $this->getCMSPages((int)$parent, false, (int)$id_lang, (int)$id_shop);
|
||||||
|
|
||||||
$spacer = str_repeat(' ', $this->spacer_size * (int)$depth);
|
$spacer = str_repeat(' ', $this->spacer_size * (int)$depth);
|
||||||
|
|
||||||
@@ -744,29 +745,43 @@ class Blocktopmenu extends Module
|
|||||||
return $this->hookDisplayTop($params);
|
return $this->hookDisplayTop($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCMSCategories($recursive = false, $parent = 1, $id_lang = false)
|
private function getCMSCategories($recursive = false, $parent = 1, $id_lang = false, $id_shop = false)
|
||||||
{
|
{
|
||||||
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
||||||
|
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
|
||||||
|
$join_shop = '';
|
||||||
|
$where_shop = '';
|
||||||
|
|
||||||
|
if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true)
|
||||||
|
{
|
||||||
|
$join_shop = ' INNER JOIN `'._DB_PREFIX_.'cms_category_shop` cs
|
||||||
|
ON (bcp.`id_cms_category` = cs.`id_cms_category`)';
|
||||||
|
$where_shop = ' AND cs.`id_shop` = '.(int)$id_shop.' AND cl.`id_shop` = '.(int)$id_shop;
|
||||||
|
}
|
||||||
|
|
||||||
if ($recursive === false)
|
if ($recursive === false)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
||||||
FROM `'._DB_PREFIX_.'cms_category` bcp
|
FROM `'._DB_PREFIX_.'cms_category` bcp'.
|
||||||
|
$join_shop.'
|
||||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
||||||
ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
||||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||||
AND bcp.`id_parent` = '.(int)$parent;
|
AND bcp.`id_parent` = '.(int)$parent.
|
||||||
|
$where_shop;
|
||||||
|
|
||||||
return Db::getInstance()->executeS($sql);
|
return Db::getInstance()->executeS($sql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
||||||
FROM `'._DB_PREFIX_.'cms_category` bcp
|
FROM `'._DB_PREFIX_.'cms_category` bcp'.
|
||||||
|
$join_shop.'
|
||||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
||||||
ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
||||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||||
AND bcp.`id_parent` = '.(int)$parent;
|
AND bcp.`id_parent` = '.(int)$parent.
|
||||||
|
$where_shop;
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
foreach ($results as $result)
|
foreach ($results as $result)
|
||||||
@@ -782,11 +797,15 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCMSPages($id_cms_category, $id_shop = false, $id_lang = false)
|
private function getCMSPages($id_cms_category, $id_shop = false, $id_lang = false, $id_shop = false)
|
||||||
{
|
{
|
||||||
$id_shop = ($id_shop !== false) ? (int)$id_shop : (int)Context::getContext()->shop->id;
|
$id_shop = ($id_shop !== false) ? (int)$id_shop : (int)Context::getContext()->shop->id;
|
||||||
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
|
||||||
|
|
||||||
|
$where_shop = '';
|
||||||
|
if (Tools::version_compare(_PS_VERSION_, '1.6.0.12', '>=') == true)
|
||||||
|
$where_shop = ' AND cl.`id_shop` = '.(int)$id_shop;
|
||||||
|
|
||||||
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||||
FROM `'._DB_PREFIX_.'cms` c
|
FROM `'._DB_PREFIX_.'cms` c
|
||||||
INNER JOIN `'._DB_PREFIX_.'cms_shop` cs
|
INNER JOIN `'._DB_PREFIX_.'cms_shop` cs
|
||||||
@@ -795,7 +814,8 @@ class Blocktopmenu extends Module
|
|||||||
ON (c.`id_cms` = cl.`id_cms`)
|
ON (c.`id_cms` = cl.`id_cms`)
|
||||||
WHERE c.`id_cms_category` = '.(int)$id_cms_category.'
|
WHERE c.`id_cms_category` = '.(int)$id_cms_category.'
|
||||||
AND cs.`id_shop` = '.(int)$id_shop.'
|
AND cs.`id_shop` = '.(int)$id_shop.'
|
||||||
AND cl.`id_lang` = '.(int)$id_lang.'
|
AND cl.`id_lang` = '.(int)$id_lang.
|
||||||
|
$where_shop.'
|
||||||
AND c.`active` = 1
|
AND c.`active` = 1
|
||||||
ORDER BY `position`';
|
ORDER BY `position`';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user