收藏 分享(赏)

ecshop2.7.0商品分类显示数量.doc

上传人:myk79025 文档编号:12303245 上传时间:2021-12-10 格式:DOC 页数:6 大小:36KB
下载 相关 举报
ecshop2.7.0商品分类显示数量.doc_第1页
第1页 / 共6页
ecshop2.7.0商品分类显示数量.doc_第2页
第2页 / 共6页
ecshop2.7.0商品分类显示数量.doc_第3页
第3页 / 共6页
ecshop2.7.0商品分类显示数量.doc_第4页
第4页 / 共6页
ecshop2.7.0商品分类显示数量.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、ecshop2.7.0商品分类显示数量ecshop 模板堂() 修改 includes/lib_goods.php,改写下两个函数。/* 获得指定分类同级的所有分类以及该分类下的子分类* access public* param integer $cat_id 分类编号* return array*/function get_categories_tree($cat_id = 0)if ($cat_id 0)$sql = 'SELECT parent_id FROM ' . $GLOBALS'ecs'-table('category') . “

2、WHERE cat_id = '$cat_id'“;$parent_id = $GLOBALS'db'-getOne($sql);else$parent_id = 0;/*判断当前分类中全是是否是底级分类,如果是取出底级分类上级分类,如果不是取当前分类及其下的子分类*/$sql = 'SELECT count(*) FROM ' . $GLOBALS'ecs'-table('category') . “ WHERE parent_id = '$parent_id' AND is_show = 1 “

3、;if ($GLOBALS'db'-getOne($sql) | $parent_id = 0)/* 获取当前分类及其子分类 */$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 =

4、 $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

5、'foreach ($res AS $row)if ($row'is_show')$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;$cat_arr$row'cat_id''name' = $row'cat_name'$ca

6、t_arr$row'cat_id''url' = build_uri('category', array('cid' = $row'cat_id'), $row'cat_name');if (isset($row'cat_id') != NULL)$cat_arr$row'cat_id''cat_id' = get_child_tree($row'cat_id');if(isset($cat_arr)return $cat_arr;fu

7、nction get_child_tree($tree_id = 0)$three_arr = array();$sql = 'SELECT count(*) FROM ' . $GLOBALS'ecs'-table('category') . “ WHERE parent_id = '$tree_id' AND is_show = 1 “;if ($GLOBALS'db'-getOne($sql) | $tree_id = 0)$child_sql = 'SELECT cat_id, cat_name,

8、parent_id, is_show ' .'FROM ' . $GLOBALS'ecs'-table('category') .“WHERE parent_id = '$tree_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC“;$res = $GLOBALS'db'-getAll($child_sql);$sql = “SELECT cat_id, COUNT(*) AS goods_num “ .“ FROM “ . $GLOBALS&#

9、39;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'foreach ($res AS $row)if ($row'is_show')$three_arr$row'cat_id''num' = !empt

10、y($newres$row'cat_id') ? $newres$row'cat_id' : 0;$three_arr$row'cat_id''id' = $row'cat_id'$three_arr$row'cat_id''name' = $row'cat_name'$three_arr$row'cat_id''url' = build_uri('category', array('cid' = $ro

11、w'cat_id'), $row'cat_name');if (isset($row'cat_id') != NULL)$three_arr$row'cat_id''cat_id' = get_child_tree($row'cat_id');return $three_arr; 2.修改 category_tree.lib 库,写入 num 变量。$cat.name|escape:html($cat.num)$child.name|escape:html($child.num)$childer.name|escape:html($childer.num)【ECSHOP 模板堂出品】

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报