// Fix categories (duplicate cause of multishop)
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7861 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+25
-22
@@ -606,25 +606,28 @@ class CategoryCore extends ObjectModel
|
|||||||
* @param int $id_lang
|
* @param int $id_lang
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getChildrenWithNbSelectedSubCat($id_parent, $selectedCat, $id_lang)
|
public static function getChildrenWithNbSelectedSubCat($id_parent, $selectedCat, $id_lang, Shop $shop = null)
|
||||||
{
|
{
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
if (!$shop)
|
||||||
SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
|
$shop = Context::getContext()->shop;
|
||||||
SELECT COUNT(*)
|
|
||||||
FROM `'._DB_PREFIX_.'category` c2
|
$sql = 'SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
|
||||||
WHERE c2.`id_parent` = c.`id_category`
|
SELECT COUNT(*)
|
||||||
) > 0, 1, 0) AS has_children, '.($selectedCat ? '(
|
FROM `'._DB_PREFIX_.'category` c2
|
||||||
SELECT count(c3.`id_category`)
|
WHERE c2.`id_parent` = c.`id_category`
|
||||||
FROM `'._DB_PREFIX_.'category` c3
|
) > 0, 1, 0) AS has_children, '.($selectedCat ? '(
|
||||||
WHERE c3.`nleft` > c.`nleft`
|
SELECT count(c3.`id_category`)
|
||||||
AND c3.`nright` < c.`nright`
|
FROM `'._DB_PREFIX_.'category` c3
|
||||||
AND c3.`id_category` IN ('.$selectedCat.')
|
WHERE c3.`nleft` > c.`nleft`
|
||||||
)' : '0').' AS nbSelectedSubCat
|
AND c3.`nright` < c.`nright`
|
||||||
FROM `'._DB_PREFIX_.'category` c
|
AND c3.`id_category` IN ('.$selectedCat.')
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
|
)' : '0').' AS nbSelectedSubCat
|
||||||
WHERE `id_lang` = '.(int)($id_lang).'
|
FROM `'._DB_PREFIX_.'category` c
|
||||||
AND c.`id_parent` = '.(int)($id_parent).'
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.$shop->sqlLang('cl').'
|
||||||
ORDER BY `position` ASC');
|
WHERE `id_lang` = '.(int)($id_lang).'
|
||||||
|
AND c.`id_parent` = '.(int)($id_parent).'
|
||||||
|
ORDER BY `position` ASC';
|
||||||
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -636,10 +639,10 @@ class CategoryCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function duplicateProductCategories($id_old, $id_new)
|
public static function duplicateProductCategories($id_old, $id_new)
|
||||||
{
|
{
|
||||||
$result = Db::getInstance()->ExecuteS('
|
$sql = 'SELECT `id_category`
|
||||||
SELECT `id_category`
|
FROM `'._DB_PREFIX_.'category_product`
|
||||||
FROM `'._DB_PREFIX_.'category_product`
|
WHERE `id_product` = '.(int)$id_old;
|
||||||
WHERE `id_product` = '.(int)($id_old));
|
$result = Db::getInstance()->ExecuteS($sql);
|
||||||
|
|
||||||
$row = array();
|
$row = array();
|
||||||
if ($result)
|
if ($result)
|
||||||
|
|||||||
Reference in New Issue
Block a user