ecshop首页怎样在指定栏目显示指定商品和出售前十位的指定商品

比如车载导航栏目显示车载导航商品和车载导航售卖前十名的商品... 比如车载导航栏目显示车载导航商品和车载导航售卖前十名的商品 展开
 我来答
ecshop模板中心
2014-01-16 · TA获得超过1377个赞
知道大有可为答主
回答量:2046
采纳率:0%
帮助的人:1636万
展开全部
车贷导航商品可以放在一个可编辑区域里,后台设置一下商品列表就可以显示了
车载导航前十名的商品,要调用一个方法
在index.php中
$smarty->assign('top_goods12', get_top10(12)); // 12是你车载导航的ID

在模板中循环top_goods12

<!-- {foreach name=top_goods12 from=$top_goods item=goods}-->
<ul class="clearfix">
<img src="../images/top_{$smarty.foreach.top_goods.iteration}.gif" class="iteration" />
<!-- {if $smarty.foreach.top_goods.iteration<4}-->
<li class="topimg">
<a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="samllimg" /></a>
</li>
<!-- {/if} -->
<li {if $smarty.foreach.top_goods.iteration<4}class="iteration1"{/if}>
<a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name}</a><br />
{$lang.shop_price}<font class="f1">{$goods.price}</font><br />
</li>
</ul>
<!-- {/foreach} -->
ecmoban模板堂
2014-01-16 · TA获得超过770个赞
知道大有可为答主
回答量:2259
采纳率:66%
帮助的人:897万
展开全部
如何实现ecshop调用分类下销售排行
<meta http-equiv="Content-Type" content="text/html;
charset=gbk"><?php

function get_cats_top10($cat = ''){$sql = 'SELECT cat_id, cat_name '
.'FROM ' . $GLOBALS['ecs']->table('category') ."WHERE parent_id =
'$cat' ORDER BY sort_order ASC, cat_id ASC LIMIT 3";

$res = $GLOBALS['db']->getAll($sql);foreach ($res AS
$row){$cats =
get_children($row['cat_id']);$cat_arr[$row['cat_id']]['name'] =
mb_substr($row['cat_name'] , 0, 10 ,"gbk");$cat_arr[$row['cat_id']]['id'] =
$row['cat_id'];$where = !empty($cats) ? "AND ($cats) " : '';

switch ($GLOBALS['_CFG']['top10_time']){case 1: //
一年$top10_time = "AND o.order_sn >= '" . date('Ymd', gmtime() - 365 *
86400) . "'";break;case 2: // 半年$top10_time = "AND o.order_sn >=
'" . date('Ymd', gmtime() - 180 * 86400) . "'";break;case 3: //
三个月$top10_time = "AND o.order_sn >= '" . date('Ymd', gmtime() - 90 *
86400) . "'";break;case 4: // 一个月$top10_time = "AND o.order_sn >=
'" . date('Ymd', gmtime() - 30 * 86400) .
"'";break;default:$top10_time = '';}

$sql = 'SELECT g.goods_id, g.goods_name, g.goods_img, g.goods_thumb,
g.shop_price, g.promote_price, g.promote_start_date, g.promote_end_date,
SUM(og.goods_number) as goods_number ' .'FROM ' .
$GLOBALS['ecs']->table('goods') . ' AS g, '
.$GLOBALS['ecs']->table('order_info') . ' AS o, '
.$GLOBALS['ecs']->table('order_goods') . ' AS og ' ."WHERE
g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 $where $top10_time
" ;//判断是否启用库存,库存数量是否大于0if ($GLOBALS['_CFG']['use_storage'] ==
1){$sql .= " AND g.goods_number > 0 ";}$sql .= ' AND
og.order_id = o.order_id AND og.goods_id = g.goods_id ' ."AND o.order_status
= '" . OS_CONFIRMED . "' " ."AND (o.pay_status = '" . PS_PAYED . "' OR
o.pay_status = '" . PS_PAYING . "') " ."AND (o.shipping_status = '" .
SS_SHIPPED . "' OR o.shipping_status = '" . SS_RECEIVED . "') " .'GROUP BY
g.goods_id ORDER BY goods_number DESC, g.goods_id DESC LIMIT ' .
$GLOBALS['_CFG']['top_number'];

$arr = $GLOBALS['db']->getAll($sql);

foreach ($arr as
$row1){$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['short_name']
= $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row1['goods_name'],
$GLOBALS['_CFG']['goods_name_length']) :
$row1['goods_name'];$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['url']
= build_uri('goods', array('gid' => $row1['goods_id']),
$row1['goods_name']);$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['goods_img']
= get_image_path($row1['goods_id'],
$row1['goods_img']);$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['goods_thumb']
= get_image_path($row1['goods_id'],
$row1['goods_thumb']);$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['shop_price']
= price_format($row1['shop_price']);if ($row1['promote_price'] >
0){$promote_price = bargain_price($row1['promote_price'],
$row1['promote_start_date'],
$row1['promote_end_date']);$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['promote_price']
= $promote_price > 0 ? price_format($promote_price) :
'';}else{$cat_arr[$row['cat_id']]['children'][$row1['goods_id']]['promote_price']
= '';}}}return $cat_arr;}

$this->assign('top_goods_add' , get_cats_top10(0));//0代表顶级分类?>

<!-- {foreach name=top from=$top_goods_add item=goods}--><div
class="box"><div
class="box_2"><h3><span>{$goods.name}</span></h3><div
class="top10List clearfix"><!-- {foreach from=$goods.children
item=children name=top_goods}--><ul class="clearfix"><img
src="../images/top_{$smarty.foreach.top_goods.iteration}.gif" class="iteration"
/><!-- {if $smarty.foreach.top_goods.iteration<4}--><li
class="topimg"><a href="{$children.url}"><img
src="{$children.goods_thumb}" alt="{$children.name|escape:html}"
class="samllimg" /></a></li><!-- {/if}
--><li {if
$smarty.foreach.top_goods.iteration<4}class="iteration1"{/if}><a
href="{$children.url}"
title="{$children.name|escape:html}">{$children.short_name}</a><br
/>{$lang.shop_price}<font
class="f1">{$children.price}</font><br
/></li></ul><!--{/foreach}--></div></div></div><div
class="blank5"></div><!--{/foreach}-->
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式