核心开发看看我改的代码错在哪里了?
2016-07-07 16:43 来源:www.chinab4c.com 作者:ecshop专家
想在商品列表里加上品牌字段,根据luhengqi ( Xeon[祺]) 的提示,修改了lib_goodscat.php文件,品牌已经可以在首页的商品列表显示,但在分类商品显示就失效了,admin提示需要修改category.php,于是修改如下: $sql = "SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price, g.promote_price, g.promote_start, ". "g.promote_end, g.goods_brief, g.goods_thumb, b.brand_name ". "FROM " .$ecs->table('goods'). " AS g ". "LEFT JOIN ".$ecs->table('brand'). " AS b ON b.brand_id=g.brand_id ". "WHERE (g.is_on_sale=1) AND (g.is_gift=1 OR g.is_alone_sale=1) AND g.is_delete=0 "; "ORDER BY $sort $order"; $res = $db->SelectLimit($sql, $size, ($page-1) * $size); $arr = array(); if ($res) { while ($row = $res->FetchRow()) { $promote_price = bargain_price($row['promote_price'], $row['promote_start'], $row['promote_end']); $arr[$row['goods_id']]['goods_id']= $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['brand_name']]['brand_name']= $row['brand_name'];$arr[$row['goods_id']]['market_price']= price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = goods_price($row['goods_id'], $row['shop_price']); $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief']= $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb']= empty($row['goods_thumb']) ? 'images/no_picture.gif' : $row['goods_thumb']; $arr[$row['goods_id']]['url']= build_url('goods', $row['goods_id'], $row['goods_name']); } } 其中红字部分是另加的,结果显示如附件效果,品牌显示出的,没有其选项和图片,有图和其他项的显示不出,求解: |
-
12.gif (16.16 KB)
修改后品牌显示问题
回答:
上面代码中红色标识的第二部分应该这样写
|
核心就是核心 |
这个问题解决了,本想依葫芦画瓢,把search.php也改改,但怎么也不成功,请看看问题出在哪里?红字为增加的代码: /* 有属性检索的处理 */ if($i> 0) { /* 获得符合条件的商品总数 */ $sql = "SELECT COUNT(DISTINCT (g.goods_id)) FROM " .$ecs->table('goods'). " AS g ". $attr_table . "WHERE g.is_delete=0 AND (g.is_alone_sale=1 OR g.is_gift=0) ". " AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro ." )".$tag_where." )" . $attr_where ; $count= $db->GetOne($sql); /* 查询商品 */ $sql = "SELECT DISTINCT g.goods_id, g.goods_name, g.market_price, g.shop_price, g.promote_price, ". "g.promote_start, g.promote_end, g.goods_thumb, g.goods_brief , b.brand_name ". "FROM " .$ecs->table('goods'). " AS g ".$attr_table . "LEFT JOIN ".$ecs->table('brand'). " AS b ON b.brand_id=g.brand_id ". "WHERE g.is_delete=0 AND (g.is_alone_sale=1 OR g.is_gift=0) ". " AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro ." )".$tag_where." )" .$attr_where . " ORDER BY $sort $order"; } else { /* 获得符合条件的商品总数 */ $sql = "SELECT COUNT(*) FROM " .$ecs->table('goods'). " AS g ". "WHERE g.is_delete=0 AND (g.is_alone_sale=1 OR g.is_gift=0) ". " AND ( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro ." )".$tag_where ; $count= $db->GetOne($sql); /* 查询商品 */ $sql = "SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price, g.promote_price, ". "g.promote_start, g.promote_end, g.goods_thumb, g.goods_brief , b.brand_name ". "FROM " .$ecs->table('goods'). " AS g ". "LEFT JOIN ".$ecs->table('brand'). " AS b ON b.brand_id=g.brand_id ". "WHERE g.is_delete=0 AND (g.is_alone_sale=1 OR g.is_gift=0) ". " AND ( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro ." ) ".$tag_where. " ORDER BY $sort $order"; } $res = $db->SelectLimit($sql, $size, ($page-1) * $size); $arr = array(); while ($row = $res->FetchRow()) { $promote_price = bargain_price($row['promote_price'], $row['promote_start'], $row['promote_end']); $arr[$row['goods_id']]['goods_id']= $row['goods_id']; $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; $arr[$row['goods_id']]['brand_name'] = $row['brand_name']; $arr[$row['goods_id']]['market_price']= price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = goods_price($row['goods_id'], $row['shop_price']); $arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_brief']= $row['goods_brief']; $arr[$row['goods_id']]['goods_thumb']= empty($row['goods_thumb']) ? 'images/no_picture.gif' : $row['goods_thumb']; $arr[$row['goods_id']]['url']= build_url('goods', $row['goods_id'], $row['goods_name']); |
最近更新
常用插件
- ecshop没登陆情况下订单查
ecshop没登陆情况下订单查询插件,主要是针对ecshop在没有登陆的情况下...
- ecshop注册审核插件
ecshop插件介绍:ecshop会员注册审核插件,主要是在前台提供给注册的时候...
- ecshop虚拟发货插件
ecshop虚拟发货插件介绍: ecshop虚拟发货插件,主要为了通过后台手动录...
- ecshop订单聚合插件
ecshop订单聚合插件,主要是为了方便ecshop中订单产品到货情况的分析和...
- ecshop的oss插件
ecshop的oss插件免费共享了,oss,ecshoposs...
ecshop热门问答
ecshop热门资料
ecshop服务器时间
ecshopgouwu
ecshop最大限度
ecshop找不到
ecshopFatal
B4C网站地图
ecshop红线
ecshop电脑硬盘
ecshop简单问题
ecshop落款
ecshop客服在线系统
ecshop客流量
ecshoplang
ecshoplibrary
ecshopconfig
ecshop备案号
ecshop根本
ecshop表字
ecmall注册
ecshopfull
ecshop畅销
ecshop匿名
ecshop库文件
ecshop如图所示
ecshopput
ecshop配送打印模板
ecshop网页错误
ecshop首页文章调用
ecshop展现
ecshopquot