修改includes/lib_goods.php
1.在sql语句
$sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' .
'FROM ' . $GLOBALS['ecs']->table('category') .
"WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
$res = $GLOBALS['db']->getAll($sql);
的下面增加
$sql = "SELECT cat_id, COUNT(*) AS goods_num " .
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g " .
" GROUP BY cat_id";
$res2 = $GLOBALS['db']->getAll($sql);
$newres = array();
foreach($res2 AS $row)
{
$newres[$row['cat_id']] = $row['goods_num'];
}
2.在cat_arr[$row['cat_id']]['id'] = $row['cat_id'];
下面增加
$cat_arr[$row['cat_id']]['num'] = !empty($newres[$row['cat_id']]) ? $newres[$row['cat_id']] : 0;
3.
修改category_tree.lib库,写入num变量。
{$cat.name|escape:html}({$cat.num})
这样就可以搞定了!!
阅读(1379) | 评论(0) | 转发(0) |