ecshop2.7.0首页如何调用积分商城的商品
2009-08-19 18:23 来源:www.chinab4c.com 作者:ecshop专家
在ECSHOP电子商务系统中,往往需要将积分商城的产品调用到首页。也很简单。写一个ecshop函数exchange_get_goods()来负责调用积分商城的产品。通过模板来显示。
function exchange_get_goods($children, $size, $page)
{
$display = $GLOBALS['display'];
$where = "eg.is_exchange = 1 AND g.is_delete = 0 AND ".
"($children OR " . get_extension_goods($children) . ')';
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, eg.exchange_integral, ' .
'g.goods_type, g.goods_brief, g.goods_thumb , g.goods_img, eg.is_hot ' .
'FROM ' . $GLOBALS['ecs']->table('exchange_goods') . ' AS eg, ' .$GLOBALS['ecs']->table('goods') . ' AS g ' .
"WHERE eg.goods_id = g.goods_id AND $where ORDER BY g.goods_id desc";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
/* 处理商品水印图片 */
$watermark_img = '';
// if ($row['is_new'] != 0)
// {
// $watermark_img = "watermark_new_small";
// }
// elseif ($row['is_best'] != 0)
// {
// $watermark_img = "watermark_best_small";
// }
// else
if ($row['is_hot'] != 0)
{
$watermark_img = 'watermark_hot_small';
}
if ($watermark_img != '')
{
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if($display == 'grid')
{
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
else
{
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$row['goods_id']]['exchange_integral'] = $row['exchange_integral'];
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('exchange_goods', array('gid'=>$row['goods_id']), $row['goods_name']);
}
return $arr;
}
$children = get_children($cat_id);
exchange_get_goods($children,10,1);
$smarty -> assign('ext',exchange_get_goods($children,10,1));
以下是模板
<div class="goodsList">
<!--{foreach name=goods_list from=$goods_list item=goods}-->
<ul class="clearfix bgcolor"<!--{if $smarty.foreach.goods_list.index mod 2 eq 0}-->id=""<!--{else}-->id="bgcolor"<!--{/if}-->>
<li class="thumb"><a href="{$goods.url}"><img src="{$goods.goods_thumb}" alt="{$goods.goods_name}" /></a></li>
<li class="exchangeGoodName">
<a href="{$goods.url}">
<!-- {if $goods.goods_style_name} -->
<font class="f3">{$goods.goods_style_name}</font><br />
<!-- {else} -->
<font class="f3">{$goods.goods_name}</font><br />
<!-- {/if} -->
</a>
<!-- {if $goods.goods_brief} -->
{$lang.goods_brief}{$goods.goods_brief}<br />
<!-- {/if} -->
</li>
<li>
{$lang.exchange_integral}<font class="price">{$goods.exchange_integral}</font>
</li>
</ul>
<!--{/foreach}-->
</div>
通过调整PHP和模板。完成了ecshop调用积分商城的信息。
来源:中国B4C电子商务
最近更新
常用插件
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...