- /* 获得商品列表 */
- $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
- "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
- 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
- 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
- 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
- "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
- "WHERE $where $ext ORDER BY $sort $order";
更改为:
- /* 获得商品列表 */
- $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
- "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
- 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ,b.brand_id,b.brand_name,a.attr_value ' .
- 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
- 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
- "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
- 'JOIN ' . $GLOBALS['ecs']->table('goods_attr') . ' AS a ' .
- "ON a.goods_id=g.goods_id and a.attr_id=211 ".
- "WHERE $where $ext ORDER BY $sort $order";
上面那个a.attr_id=211要根据大家商品属性数据库表goods_attr来查看,就是自己定义的型号那个。
然后在第510行的位置,加上下面这个变量,还是在根目录/category.php文件更改
- $arr[$row['goods_id']]['wlsh_gn'] = $row['attr_value'];
- /增加这个型号变量
三、前台调用即可
一般产品列表文件都是放在项目库文件中,goods_list.lbi这个,找到下面语句
- <!--{foreach name=goods_list from=$goods_list item=goods}-->
- 。。
- 。。
- <!--{/foreach}-->
在这个循环里面直接{$goods.wlsh_gn},就能输出产品的型号,大家赶快去试试吧,还有不明白的地方可以个程序员人生网站留言