1、打开category.php 找到 category_get_goods 函数 修改为
- function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)
- {
- $display = $GLOBALS['display'];
- $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ".
- "g.is_delete = 0 AND ($children OR " . get_extension_goods($children) . ')';
-
- if ($brand > 0)
- {
- $where .= "AND g.brand_id=$brand ";
- }
-
- if ($min > 0)
- {
- $where .= " AND g.shop_price >= $min ";
- }
-
- if ($max > 0)
- {
- $where .= " AND g.shop_price <= $max ";
- }
-
- /* 获得商品列表 */
- $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, IF(g.give_integral > -1, g.give_integral, g.shop_price) as integral, ' .
-
-
- "NULL.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";
- $res = $GLOBALS['db']->sel ectLimit($sql, $size, ($page - 1) * $size);
-
- $arr = array();
- while ($row = $GLOBALS['db']->fetchRow($res))
- {
- $goods_id = $row['goods_id'];
- $sql2= "sel ect sum(goods_number) as count from ".$GLOBALS['ecs']->table('order_goods')."where goods_id ='".$goods_id."'";
- $buy_num = $GLOBALS['db']->getOne($sql2);
- if ($row['promote_price'] > 0)
- {
- $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
- }
- else
- {
- $promote_price = 0;
- }
-
- /* 处理商品水印图片 */
- $watermark_img = '';
-
- if ($promote_price != 0)
- {
- $watermark_img = "watermark_promote_small";
- }
- elseif ($row['is_new'] != 0)
- {
- $watermark_img = "watermark_new_small";
- }
- elseif ($row['is_best'] != 0)
- {
- $watermark_img = "watermark_best_small";
- }
- elseif ($row['is_hot'] != 0)
- {
- $watermark_img = 'watermark_hot_small';
- }
-
- if ($watermark_img != '')
- {
- $arr[$row['goods_id']]['watermark_img'] = $watermark_img;
- }
-
- $arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
- if($display == 'grid')
- {
- $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
- }
- else
- {
- $arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
- }
- $arr[$row['goods_id']]['count'] = $buy_num;
- $arr[$row['goods_id']]['name'] = $row['goods_name'];
- /* 修正积分:转换为可使用多少积分(原来是可以使用多少钱的积分) */
- $arr[$row['goods_id']]['integral'] = round($row['integral'],0);
-
- $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
- $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
- $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
- $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
- $arr[$row['goods_id']]['type'] = $row['goods_type'];
- $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
- $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
- $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
- $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
- }
-
- return $arr;
- }
复制代码
2、模板部分直接加