ECSHOP头部搜索如何添加品牌、分类名搜索条件
发布:smiling 来源: PHP粉丝网 添加日期:2014-11-18 16:05:16 浏览: 评论:0
添加搜索条件,按品牌搜索,按分类名搜索,方法如下,打开search.php,搜索下面代码:
$keywords .= "(goods_name LIKE '%$val%' OR goods_sn LIKE '%$val%' OR keywords LIKE '%$val%' $sc_dsad)";
将上面代码替换为:
$keywords .= "(goods_name LIKE '%$val%' OR cat_name LIKE '%$val%' OR brand_name LIKE '%$val%' OR goods_sn LIKE '%$val%' OR g.keywords LIKE '%$val%' $sc_dsad)";
搜索下面代码:
- $sql="SELECT COUNT(*) FROM " .$ecs->table('goods'). " AS g "."WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in ". "AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro . $outstock ." ) ".$tag_where." )";
- $count = $db->getOne($sql);
- $sql = "SELECT COUNT(*) FROM " .$ecs->table('goods'). " AS g ". "WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in "."AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro . $outstock ." ) ".$tag_where." )";
- $count = $db->getOne($sql);
将上面代码替换为:
- $sql = "SELECT COUNT(*) FROM " .$ecs->table('goods'). " AS g ".
- "LEFT JOIN " . $GLOBALS['ecs']->table('brand') . " AS b ON b.brand_id =g.brand_id ".
- "LEFT JOIN " . $GLOBALS['ecs']->table('category') . " AS c ON c.cat_id = g.cat_id ".
- "WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in ".
- "AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro . $outstock ." ) ".$tag_where." )";
- $count = $db->getOne($sql);
搜索下面代码:
- $sql = "SELECT g.goods_id, g.goods_name, 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.promote_start_date, g.promote_end_date, g.goods_thumb, g.goods_img, g.goods_brief, g.goods_type ".
- "FROM " .$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 g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in ".
- "AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro . $outstock . " ) ".$tag_where." ) " .
- "ORDER BY $sort $order";
- $res = $db->SelectLimit($sql, $size, ($page - 1) * $size);
将上面代码替换为:
- $sql = "SELECT g.goods_id, g.goods_name, 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.promote_start_date, g.promote_end_date, g.goods_thumb, g.goods_img, g.goods_brief, g.goods_type ".
- "FROM " .$ecs->table('goods'). " AS g ".
- "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ". //开源软件:phpfensi.com
- "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
- "WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in ".
- "AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro . $outstock . " ) ".$tag_where." ) " .
- "ORDER BY $sort $order";
- $res = $db->SelectLimit($sql, $size, ($page - 1) * $size);
Tags: ECSHOP头部搜索 ECSHOP分类搜索
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)