如何在ecshop首页调用指定分类商品销售排行版 20
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏20(财富值+成长值)
2个回答
展开全部
ecshop我们的默认的排行榜,直接调用就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
胜天半子
2024-11-06 广告
2024-11-06 广告
胜天半子集团有限公司提供供应链一件代发API服务。我们拥有全品类对接供应链管理系统,API接口对接质量有保障,由专业团队负责。我们的服务包括自建商城、礼品商城等,提供海量货源,支持小家电、日用百货、美妆、食品等全品类商品一件代发。发货形式灵...
点击进入详情页
本回答由胜天半子提供
展开全部
比如你调用A分类商品销售排行榜,看下面代码
<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 " ;
//判断是否启用库存,库存数量是否大于0
if ($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}-->
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询