ECSHOP搜索添加“品牌名”、“父分类名”搜索范围,可根据这些搜索出符合条件商品
LYECS,LYECS+商城系统,多用户商城系统,开源商城系统 发布日期:2013-06-29 作者:老杨
添加搜索,按品牌搜索,按分类名搜索:
打开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)";//老杨ecshop www.lyecs.com
找到:
复制内容到剪贴板
- /* 获得符合条件的商品总数 */
- $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 ".//老杨ecshop www.lyecs.com
- "LEFT JOIN " . $GLOBALS['ecs']->table('category') . " AS c ON c.cat_id = g.cat_id ".//老杨ecshop www.lyecs.com
- "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]' ".
- '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 ". //老杨ecshop www.lyecs.com
- "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);