求助:商品搜索的范围中加上商品品牌
2016-07-07 15:24 来源:www.chinab4c.com 作者:ecshop专家
求助: 在搜索商品的时候,可是实现品牌搜索的功能。即在搜索框中输入品牌可以搜索出该品牌底下的商品。也就是可以搜索商品品牌这个属性。 |
回答:
你可以在添加商品的时候在关键字里添加改品牌名字 ,这个搜索的时候就可以搜到了 |
恩 好的 谢谢 因为加了好多商品所以不想再一个一个的加上去我改了一下程序 实现了 $keywords.= "(goods_name LIKE '%$val%' OR goods_sn LIKE '%$val%' OR brand_name LIKE '%$val%' OR keywords LIKE '%$val%' $sc_dsad)"; /* 获得符合条件的商品总数 */ $sql= "SELECT COUNT(*) FROM " .$basic->table('goods'). " AS g ". "LEFT JOIN " . $GLOBALS['basic']->table('brand') . " AS p ". "ON p.brand_id = g.brand_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." )"; /* 查询商品 */ $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 " .$basic->table('goods'). " AS g ". "LEFT JOIN " . $GLOBALS['basic']->table('member_price') . " AS mp ". "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". "LEFT JOIN " . $GLOBALS['basic']->table('brand') . " AS p ". "ON p.brand_id = g.brand_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." ) " . "ORDER BY $sort $order"; |
很强啊。。。 |
楼主这个是哪个文件修改的啊 |
帮顶呵呵 |
谁知道这是修改的那个文件呢 |
search.php 文件里面修改 $keywords.= "(goods_name LIKE '%$val%' OR goods_sn LIKE '%$val%' OR keywords LIKE '%$val%' $sc_dsad)"; 替换为 $keywords.= "(goods_name LIKE '%$val%' OR goods_sn LIKE '%$val%' OR brand_name LIKE '%$val%' OR 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); $max_page = ($count> 0) ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } /* 查询商品 */ $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"; ------------- 替换为 --------------- /* 获得符合条件的商品总数 */ $sql= "SELECT COUNT(*) FROM " .$basic->table('goods'). " AS g ". "LEFT JOIN " . $GLOBALS['basic']->table('brand') . " AS p ". "ON p.brand_id = g.brand_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." )"; /* 查询商品 */ $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 " .$basic->table('goods'). " AS g ". "LEFT JOIN " . $GLOBALS['basic']->table('member_price') . " AS mp ". "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". "LEFT JOIN " . $GLOBALS['basic']->table('brand') . " AS p ". "ON p.brand_id = g.brand_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." ) " . "ORDER BY $sort $order"; ----------- 可惜出错了。。。。 Fatal error: Call to a member function table() on a non-object in F:\usr\LocalUser\hgc15078\search.php on line 366 |
不错啊。懂程序的改一下就行啊。 |
关键是我不会 我只会拿来用哦 呵呵 谁知道怎么改哈 |
好像不可以吧 |
顶起来,楼主的方法好像不对哦 |
搞了一下 显示错误 囧 |
最近更新
常用插件
- ecshop供应商插件免费下载
ecshop供应商插件免费下载...
- ecshop快递发货单打印商品
ecshop快递发货单打印商品信息,大家都知道ecshop快递单打印的时候,只能...
- ecshop二次开发售后维修卡
插件介绍: 本插件是用于专门从事电子,信息,软件等售后服务关键比...
- ecshop按分类筛选销售排行
ecshop按分类筛选销售排行...
- ecshop选择下单时间插件
ecshop选择下单时间插件主要是根据不同的下单配送要求,在ecshop购物车...
ecshop热门问答
ecshop热门资料
ecshop面的
ecshop学生
ecshop助手
ecshop不同
ecshop好消息
ecshop企业版
ecshop比较严重
ecshop一步购物
ecshophosting
ecshop晒晒
ecshopVISA
ecshop模糊
ecshopokbuy
ecshopnote
ecshop租用
ecshop爱好者
ecshopcomplete
ecshop文章随意调用
ecshop点选
ecshop腾讯
ecshopjade
ecshop时间格式
ecshop百度搜索
ecshop商品分类页
ecshop诚聘
ecshop的操作方法
ecshop英文
ecshop票务
ecshop焦点图
手机QQ登陆