将上面代码改成下面的
- /* 查询商品 */
- $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";
这样就可以在首页搜索的时候,输入商品或产品的型号,也能搜索到产品,当然这只是其中的一个方法,如果在Ecshop高级搜索那里,不管搜索什么商品属性都是可以的,这样更加方便。但是一般用户都是习惯了直接在上面导航条搜索的,不愿意点击高级搜索,这样也是迎合了大家的一个搜索习惯。如有疑问,欢迎到程序员人生网站来提问
- /* 查询商品 */
- $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 ,b.brand_id,b.brand_name,a.attr_value ".
- "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]' ".
- 'JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ' .
- "ON b.brand_id=g.brand_id ".
- 'JOIN ' . $GLOBALS['ecs']->table('goods_attr') . ' AS a ' .
- "ON a.goods_id=g.goods_id and a.attr_id=211 ".
- "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 . " OR a.attr_value LIKE '%{$_REQUEST['keywords']}%' ) ".$tag_where." ) " .
- "ORDER BY $sort $order";
上一篇 ecshop产品列表显示型号
下一篇 如何让网站被搜索引擎更好地收录