Ecshop模板网
首页 > ecshop教程 > ecshop安装使用 > 网店ECSHOP头部搜索添加品牌、分类名搜索条件
文章详情

网店ECSHOP头部搜索添加品牌、分类名搜索条件

ecshop模板网 / 2014-08-20

添加搜索条件,按品牌搜索,按分类名搜索,方法如下:
打开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 ".  
                "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); 

下一篇: ECSHOP商品详情页相关属性商品排序方法 上一篇: 分析ecshop后台促销时间无法选定
 用户评论(共 0 条评论)
  • 暂时还没有任何用户评论
用户名: 匿名用户 E-mail:
当前心情:
评论内容:
验证码: captcha
返回顶部 返回首页
 
QQ在线咨询
售前电话热线
130-5800-8007
售前QQ客服