// MERGE with trunk revision 7754

This commit is contained in:
rMalie
2011-07-27 12:48:42 +00:00
parent 21017fb5d8
commit 233c0076b7
182 changed files with 6179 additions and 1333 deletions
+14 -22
View File
@@ -179,6 +179,16 @@ class CategoryCore extends ObjectModel
return $ret;
}
/**
* @see ObjectModel::toggleStatus()
*/
public function toggleStatus()
{
$result = parent::toggleStatus();
Module::hookExec('categoryUpdate');
return $result;
}
/**
* Recursive scan of subcategories
*
@@ -594,37 +604,19 @@ class CategoryCore extends ObjectModel
* @param int $id_lang
* @return array
*/
public static function getChildrenWithNbSelectedSubCatForProduct($id_parent, $id_product = 0, $ids_categories = null, $id_lang)
public static function getChildrenWithNbSelectedSubCat($id_parent, $selectedCat, $id_lang)
{
$categories_product_str = '';
if ($id_product)
{
$categories_product = Db::getInstance()->ExecuteS('
SELECT `id_category`
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_product` = '.(int)$id_product);
if (sizeof($categories_product))
foreach ($categories_product as $category_product)
$categories_product_str .= $category_product['id_category'].',';
}
else
{
$categories_product = array();
$categories_product_str = $ids_categories;
}
$categories_product_str = rtrim($categories_product_str, ',');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.`id_category`, cl.`name`, IF((
SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
SELECT COUNT(*)
FROM `'._DB_PREFIX_.'category` c2
WHERE c2.`id_parent` = c.`id_category`
) > 0, 1, 0) AS has_children, '.($categories_product_str ? '(
) > 0, 1, 0) AS has_children, '.($selectedCat ? '(
SELECT count(c3.`id_category`)
FROM `'._DB_PREFIX_.'category` c3
WHERE c3.`nleft` > c.`nleft`
AND c3.`nright` < c.`nright`
AND c3.`id_category` IN ('.$categories_product_str.')
AND c3.`id_category` IN ('.$selectedCat.')
)' : '0').' AS nbSelectedSubCat
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`