ecshop在收藏夹中显示产品图片

2009-06-22 09:26 来源:www.chinab4c.com 作者:ecshop专家

      在B4C电子商务中,收藏夹的功能非常重要,收藏夹可以方便购买过程,你在购买过程中,如果感觉产品目前有收藏价值,你可以使用收藏夹功能。ecshop的收藏夹功能却不是非常完美,你可以在产品详细信息通过"收藏"按扭录入收藏.

     收藏夹中如何显示产品的图片?

    首先.打开includes/lib_clips.php中找到

   function get_collection_goods($user_id, $num = 10, $start = 0)
{
    $sql = 'SELECT g.goods_id,g.goods_thumb,g.goods_img, g.goods_name, g.market_price, 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, c.rec_id, c.is_attention' .
            ' FROM ' . $GLOBALS['ecs']->table('collect_goods') . ' AS c' .
            " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ".
                "ON g.goods_id = c.goods_id ".
            " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
                "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
            " WHERE c.user_id = '$user_id' ORDER BY c.rec_id DESC";
    $res = $GLOBALS['db'] -> selectLimit($sql, $num, $start);

    $goods_list = array();
    while ($row = $GLOBALS['db']->fetchRow($res))
    {
        if ($row['promote_price'] > 0)
        {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
        }
        else
        {
            $promote_price = 0;
        }
  
        $goods_list[$row['goods_id']]['thumb']        = get_image_path($row['goods_id'], $row['goods_thumb'], true);;
        $goods_list[$row['goods_id']]['goods_img']        = get_image_path($row['goods_id'], $row['goods_img']);
        $goods_list[$row['goods_id']]['rec_id']        = $row['rec_id'];
        $goods_list[$row['goods_id']]['is_attention']  = $row['is_attention'];
        $goods_list[$row['goods_id']]['goods_id']      = $row['goods_id'];
        $goods_list[$row['goods_id']]['goods_name']    = $row['goods_name'];
        $goods_list[$row['goods_id']]['market_price']  = price_format($row['market_price']);
        $goods_list[$row['goods_id']]['shop_price']    = price_format($row['shop_price']);
        $goods_list[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
        $goods_list[$row['goods_id']]['url']           = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
    }

    return $goods_list;
}

 在sql语句中加入g.goods_thumb,g.goods_img,查询产品图片。

   然后在flow.dwt中.修改<!-- {foreach from=$collection_goods item=goods} -->
   <tr>
   <td><a href="{$goods.url}"><img src="{$goods.thumb}" title="{$goods.name}" width="40" height="40"></a></td>
    <td class="textleft"><a href="goods.php?id={$goods.goods_id}" title="{$goods.name}">{$goods.goods_name}</a></td>
    <td>{if $goods.promote_price}[促销价]{$goods.promote_price}{else}[本店售价]{$goods.shop_price}{/if}</td>
    <td><span class="btnBlue"><a href="javascript:collect_to_flow({$goods.goods_id})">{$lang.btn_add_to_cart}</a></span></td>
   </tr>
   <!-- {/foreach} -->

   假如src="{$goods.thumb}"来显示产品图片。大小可以自由控制.

   以上就实现了ecshop收藏夹显示产品图片的问题.

   相关文章:

   ecshop发布实体产品和虚拟产品

   ecshop数据库结构分析

   ecshop如何去除收货信息中必填项

   ecshop设置促销产品以及显示品牌

   来源:中国B4C电子商务