ecshop商品列表调用你喜欢产品

2015-06-04 00:32 来源:www.chinab4c.com 作者:ecshop专家

  ecshop商品列表调用你喜欢产品,这个功能在ecshop分类里面是一个非常重要的功能。可以通过ecshop产品的一些调用规则,去调用相关的产品,显示出来。我们就谈谈ecshop如何实现你喜欢产品调用。

  1:ALTER TABLE `ecs_goods` ADD `love` INT( 10 ) NOT NULL DEFAULT '0';

  2:、打开category.php找到category_get_goods 这个函数 把要显示的 love也给放进去 会程序的网友应该明白意思 。


        /* 获得商品列表 */
        $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price,g.love, 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.goods_type, " .
                    'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
                'FROM ' . $GLOBALS['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 $where $ext ORDER BY $sort $order";

   3:  $arr[$row['goods_id']]['love']             = $row['love'];
            $arr[$row['goods_id']]['name']             = $row['goods_name'];

  4:打开goods_list.lbi


      <a href="javascript:;"  onClick="change_love({$goods.goods_id})">喜欢</a><font id="show_loves_{$goods.goods_id}">{$goods.love} </font>

 5:
    f($_REQUEST['act']=='chage_usenum')
{
    include('includes/cls_json.php');
    $json   = new JSON;
    $res    = array('err_msg' => '', 'result' => '', 'qty' => 1);
$id = $_REQUEST['id'];

$sql = $GLOBALS['db']->query("update ".$GLOBALS['ecs']->table('goods')." set love=love+1 where goods_id='$id'");
$res['id']= $id;
$res['usenum'] = $GLOBALS['db']->getOne("select love from ".$GLOBALS['ecs']->table('goods')." where goods_id='$id'");
die($json->encode($res));
}

来源:http://www.chinab4c.com