ecshop 首页调用指定分类下的销售排行

/*首页调用指定分类下的销售排行*/
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_brief, 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‘]);
    $cat_arr[$row[‘cat_id‘]][‘children‘][$row1[‘goods_id‘]][‘goods_name‘] = $row1[‘goods_name‘];
    $cat_arr[$row[‘cat_id‘]][‘children‘][$row1[‘goods_id‘]][‘goods_name‘] = $row1[‘goods_name‘];
    $cat_arr[$row[‘cat_id‘]][‘children‘][$row1[‘goods_id‘]][‘goods_brief‘] = $row1[‘goods_brief‘];
    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;
}
/*首页调用指定分类下的销售排行*/

模板调用处方法:

<!-- {foreach name=top from=$top_goods6 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}-->

ecshop 首页调用指定分类下的销售排行

时间: 2024-10-10 12:56:44

ecshop 首页调用指定分类下的销售排行的相关文章

ecshop首页调用指定商品分类下的商品品牌列表

转之--http://www.16css.com/ecshop/735.html 通过二次开发可以实现ECSHOP首页调用指定分类下的品牌列表. 第一步: 打开根目录下的index.php 在最后面 ?> 前面加入以下代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /** * 获得某个分类下的品牌 列表 * * @access  public * @param   int     $cat * @return 

ecshop首页调用指定分类下面的精品商品

1.首先在index.php页面加上这段代码: function index_get_cat_id_goods_best_list($cat_id, $num){    $sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, ' .                "promote_start_date, promote_end_date,

ectouch手机商城首页调用指定分类下的商品

ECTouch是国内市面上唯一开源的ECSHOP移动商城系统,为广大电商以最低的成本快速搭建移动商城.最近最一商城实例,手机版首页需要调用指定分类下的商品,ECtouch商城默认好像没有此调用方式,只能自己动手添加了. 方法如下: 1.打开mobile\include\apps\default\model\IndexModel.class.php 在最下面 } 之前添加以下代码 /**      * 获得指定分类下的商品      */      function assign_cat_good

ecshop首页调用某分类下的商品|assign_cat_goods()

ecshop首页调用分类下的商品其实很简单,也有模板设置那里可以设置,不过那个只可以用cat_goods.lib,不方便,所以我想看看怎么能简单的实现ecshop首页调用分类下的商品 只需要在index.php写上这么一句:assign_cat_goods(20,10); 其中20是分类id,10是调用的条数 assign_cat_goods这个函数是在includes/lib_goods.php里面的 然后就是ecshop模板里调用商品了 <!–{foreach from=$cat_goods

首页调用指定分类下子分类方法

模板首页一般都有分楼层显示的分类商品,每个楼层右上角会有该分类下小分类排列显示的: 以往有些模板这里都是静态显示的,需要客户手动依次修改,现在模板中心告诉您怎样修改成动态调用,只需修改一个id即可. 1.打开您的文件根目录下 includes/lib_goods.php 文件,在最后一行加入一个方法: function get_parent_id_tree($parent_id){$three_c_arr = array();$sql = 'SELECT count(*) FROM ' . $G

ecshop3 调用指定分类下推荐/热卖/新品商品,可指定调用数量

第一步:--------------------------------------------------------------------------------------/** * 取指定分类ID及类型的商品信息 * @access public * @param string $cat_id 分类ID * @param string $num 显示商品数量 * @param string $cat_type 显示商品类型 new新品,hot热销,best为精品,promote特价 *

ecshop调用指定分类热销-新品-精品

在模板页里首页写上代码: <?php$children = get_children(16);//此处为产品分类ID $smarty->assign( 'bestGoods16',get_category_recommend_goods('best', $children)); ?> 然后在模板文件里调用就行了. ecshop调用指定分类热销-新品-精品,布布扣,bubuko.com

ecshop调用指定商品分类下的商品

在系统目录文件找到includes/lib_goods.php  这个文件打开在此页最底部加入以下函数代码: /** * 首页获取指定分类产品 * * @access public * @param string $cat_id53_best_goods * @param array $cat_id53_best_goods * @return array */ function get_cat_id_goods_list($cat_id = '', $num = '') { $sql = 'S

EcShop首页显示特定分类的精品新品热销特价等推荐商品

EcShop首页显示特定分类的精品新品热销特价等推荐商品 很多大型的B2C商城都有特定分类专区,该分类下的[分类名称].[推荐子分类 或 推荐品牌].[大图片/推荐单品].[推荐商品].[促销商品].[推荐商品/热销排行]等,这是基于SEO及用户体验来开发的.ECSHOP虽然有类似的功能,并且推荐商品还分[精品].[新品].[热销]三类,但灵活性不是很好,首页第一次加载的时候,无论是[精品].[新品]还是[热销]都不能指定分类,只能不分类别地显示所有.即使是在分类的设置里面有[设置为首页推荐: