如何在首页显示产品编号
2016-07-07 15:05 来源:www.chinab4c.com 作者:ecshop专家
如何在首页显示产品编号请高手帮忙。在线等 |
回答:
需要更改 模板文件 |
1、修改文件lib_good.php查询语句 /** * 获得推荐商品 * * @accesspublic * @paramstring$type 推荐类型,可以是 best, new, hot * @returnarray */ function get_recommend_goods($type = '', $cats = '') { if (!in_array($type, array('best', 'new', 'hot'))) { return array(); } //取不同推荐对应的商品 static $type_goods = array(); if (empty($type_goods[$type])) { //初始化数据 $type_goods['best'] = array(); $type_goods['new'] = array(); $type_goods['hot'] = array(); $data = read_static_cache('recommend_goods'); if ($data === false) { $sql = 'SELECT g.goods_id, g.goods_sn, g.is_best, g.is_new, g.is_hot, g.is_promote, b.brand_name ' . ' FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . ' LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.is_best = 1 OR g.is_new =1 OR g.is_hot = 1)'; $goods_res = $GLOBALS['db']->getAll($sql); //定义推荐,最新,热门,促销商品 $goods_data['best'] = array(); $goods_data['new'] = array(); $goods_data['hot'] = array(); $goods_data['brand'] = array(); if (!empty($goods_res)) { foreach($goods_res as $data) { if ($data['is_best'] == 1) { $goods_data['best'][] = $data['goods_id']; } if ($data['is_new'] == 1) { $goods_data['new'][] = $data['goods_id']; } if ($data['is_hot'] == 1) { $goods_data['hot'][] = $data['goods_id']; } if ($data['brand_name'] != '') { $goods_data['brand'][$data['goods_id']] = $data['brand_name']; } } } write_static_cache('recommend_goods', $goods_data); } else { $goods_data = $data; } $time = gmtime(); $order_type = $GLOBALS['_CFG']['recommend_order']; //按推荐数量及排序取每一项推荐显示的商品 order_type可以根据后台设定进行各种条件显示 static $type_array = array(); $type2lib = array('best'=>'recommend_best', 'new'=>'recommend_new', 'hot'=>'recommend_hot'); if (empty($type_array)) { foreach($type2lib as $key => $data) { if (!empty($goods_data[$key])) { $num = get_library_number($data); $data_count = count($goods_data[$key]); $num = $data_count > $num? $num : $data_count; if ($order_type == 0) { rsort($goods_data[$key]); $type_array[$key] = array_slice($goods_data[$key], 0, $num); } else { $rand_key = array_rand($goods_data[$key], $num); foreach($rand_key as $key_data) { $type_array[$key][] = $goods_data[$key][$key_data]; } } } else { $type_array[$key] = array(); } } } //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中 $sql = 'SELECT g.goods_id, g.goods_sn, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . '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]' "; $type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']); $type_merge = array_unique($type_merge); $sql .= ' WHERE g.goods_id ' . db_create_in($type_merge); $sql .= ' ORDER BY goods_id DESC'; $result = $GLOBALS['db']->getAll($sql); foreach ($result AS $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id']= $row['goods_id']; $goods[$idx]['name']= $row['goods_name']; $goods[$idx]['goods_sn']= $row['goods_sn']; $goods[$idx]['brief']= $row['goods_brief']; $goods[$idx]['brand_name']= isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ''; $goods[$idx]['goods_style_name']= add_style($row['goods_name'],$row['goods_name_style']); $goods[$idx]['short_name']= $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name']= add_style($goods[$idx]['short_name'],$row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price']= price_format($row['shop_price']); $goods[$idx]['thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); if (in_array($row['goods_id'], $type_array['best'])) { $type_goods['best'][] = $goods[$idx]; } if (in_array($row['goods_id'], $type_array['new'])) { $type_goods['new'][] = $goods[$idx]; } if (in_array($row['goods_id'], $type_array['hot'])) { $type_goods['hot'][] = $goods[$idx]; } } } return $type_goods[$type]; } 2、在模板中直接调用数据 {$goods.goods_sn} |
4# fareign 为何我无效,我也是按上述代码进行更改的,不过我现是2.70版本了。不知哪出错,大家帮我看看 网址:http://hi.microsoul.com/shop或http://www.king9999.cn. |
最近更新
常用插件
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
ecshop热门问答
ecshop热门资料
ecshop数据库问题
ecshop商品简单描述
ecshop折腾
ecshopAPM
ecshopupgade
ecshop190
ecshop计算
ecshop二次
ecshopagency
ecshop浮动广告
ecshop丁字湾麻石网
ecshop51EC
ecshop卓流应用网
ajaxecshop
ecshoppath
会员等级
ecshop注册项强大功能
ecshop概要
ecshop下级地区
ecshopECshop优化
ecshop优势网络
ecshopDeprecated
ecshopintro
ecshop负数
ecshop臻福网络
ecshopNEWER
ecshop模板文件
ecshop解方法
ecshop品牌分类
ecshop理念