ecshop在商品搜索结果页显示商品货号和会员等级价格的方法

需要在商品搜索结果页面显示商品的货号,

开发之余,顺手写了篇文章共享给同样有此需要的朋友.........

(1)、首先编辑模板文件 search.dwt ,在您想要显示商品货号的地方加上下面这句:

产品货号:{$goods.goods_sn}

(2)、修改search.php  文件

找到 “ ” 这行,将该行下面的

$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, ".

修改为

$sql = "SELECT g.goods_id, g.goods_sn, g.goods_name, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ".


继续找到  $arr[$row['goods_id']]['type']          = $row['goods_type'];   这一行,

在这行下面增加以下代码:

$arr[$row['goods_id']]['goods_sn']          = $row['goods_sn'];

######################################################################################

一下介绍后台商品列表显示会员等级价格的解决办法

后台商品列表显示会员等级价格的解决办法

1、修改admin/includes/lib_goods.php的goods_list()函数部分

在return array('goods' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);

后面添加

foreach($row as $key_tmp=>$goods_tmp)

{

$sql = "SELECT rank_id, IFNULL(mp.user_price, r.discount * $goods_tmp[shop_price] / 100) AS price, r.rank_name, r.discount " .

'FROM ' . $GLOBALS['ecs']->table('user_rank') . ' AS r ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . " AS mp ".

"ON mp.goods_id = '$goods_tmp[goods_id]' AND mp.user_rank = r.rank_id " .

"WHERE r.show_price = 1 OR r.rank_id = '$_SESSION[user_rank]'";

$res_up = $GLOBALS['db']->query($sql);

while ($row_up = $GLOBALS['db']->fetchRow($res_up))

{

$row[$key_tmp]['user_price'][$row_up['rank_id']] = array(

'rank_name' => htmlspecialchars($row_up['rank_name']),

'price' => price_format($row_up['price']));

}

}

2、修改模版文件 admin/templates/goods_list.htm

在{$goods.shop_price}与</span>之间增加下面代码

{if $goods.user_price}

{foreach from=$goods.user_price item=user_price }

<br>

{$user_price.rank_name}:{$user_price.price}

{/foreach}

{/if}

 

 

<div id="mainDiv">

{if $goods.user_price}

{foreach from=$goods.user_price item=user_price }

<ul>

<li class="c1">{$user_price.rank_name}</li>

<li class="c2"><span onclick="listTable.edit(this, 'edit_member_price', '{$goods.goods_id}_{$rank.rank_id}')">{$user_price.price}

</span></li>

</ul>

{/foreach}

{/if}

</div>


你可能感兴趣的:(ecshop)