第一步:
--------------------------------------------------------------------------------------
/**
* 取指定分类ID及类型的商品信息
* @access public
* @param string $cat_id 分类ID
* @param string $num 显示商品数量
* @param string $cat_type 显示商品类型 new新品,hot热销,best为精品,promote特价
* @param auther 邓士鹏(自定义函数)
* @return array
*/
function index_get_cat_id_goods_list($cat_id = '', $num = '',$cat_type='')
{
$sql = 'Select g.goods_id, g.cat_id,c.parent_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
"promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " .
"g.is_best, g.is_new, g.is_hot, g.is_promote " .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
$sql .= " AND (c.parent_id =" . $cat_id. " or g.cat_id = " . $cat_id ." or g.cat_id ". db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) .")";
if($cat_type!=''){
$sql .=" and is_".$cat_type."=1";
}else{
$sql .=" and is_best=0 and is_new=0 and is_hot=0 and is_promote=0";
}
$sql .= " order by g.goods_id desc LIMIT $num";
$res = $GLOBALS['db']->getAll($sql);
$goods = array();
foreach ($res AS $idx => $row)
{
$goods[$idx]['id'] = $row['article_id'];
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb'];
$goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img'];
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $goods;
} ?>
--------------------------------------------------------------------------------------

第二步:

打开根目录的 index.php 文件,在适当位置添加以下代码:

比如在

$smarty->assign('shop_notice',     $_CFG['shop_notice']);       // 商店公告
--------添加
// new新品,hot热销,best为精品,promote特价
$smarty->assign('cat_id1_new_goods', index_get_cat_id_goods_list(1,10));
$smarty->assign('cat_id1_hot_goods', index_get_cat_id_goods_list(1,10,'hot'));
$smarty->assign('cat_id1_hot_goods', index_get_cat_id_goods_list(1,10,'promote'));
$smarty->assign('cat_id1_hot_goods', index_get_cat_id_goods_list(1,10,'best'));

根据自己的需要添加多条。

其中,1为分类ID,10为调用的数量。

如果不限制商品分类,分类ID可填 0

注:如果需要在 分类页调用,则在 category.php 文件中添加。

如果需要在 商品详情页调用,则在 good.php 文件中添加。

==================================================

<!--{foreach name=cat_id1_hot_goods from=$cat_id1_hot_goods item=goods}-->
<div style="padding-top: 8px;" class="new-tr">
<a target="_blank" href="{$goods.url}"><img width="116" height="130" border="0" alt="{$goods.name|escape:html}" src="{$goods.thumb}"></a>
<div class="right">
<a target="_blank" href="{$goods.url}">{$goods.name|escape:html}</a><br>
<span style="color: rgb(102, 102, 102); text-decoration: line-through;">市场价:{$goods.market_price}</span><br>
特卖价:<span style="color: rgb(255, 0, 0);">{$goods.shop_price}</span><br>
<span class="font-gmm"><a href="javascript:addToCart({$goods.id})">立即抢购</a></span>
</div>
<span class="new-line"></span>
</div>
<!--{/foreach}-->
												

ecshop3 调用指定分类下推荐/热卖/新品商品,可指定调用数量的更多相关文章

  1. ecshop 调用指定分类的推荐,热卖,新品

    未测试 1.includes/lib_goods.php文件.把SQL语句改一下,与category表关联即可 将 $sql = 'SELECT g.goods_id,g.goods_name, g. ...

  2. EcShop调用显示指定分类下的子分类方法

    ECSHOP首页默认的只有全部分类,还有循环大类以及下面小类的代码,貌似没有可以调用显示指定大类下的子分类代码.于是就有这个文章的产生了,下面由夏日博客来总结下网站建设过程中ECSHOP此类问题的网络 ...

  3. dedecms如何随机调用指定分类下的文章到网站首页

    dedecms是全静态的,有时会因为其他事情好几天没写文章推荐到首页,那样对se不是很友好.原本ytkah是想在网站首页上半部分调用几篇id从200到500的文章随机展示的,这样每次更新首页给se的赶 ...

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

    /*首页调用指定分类下的销售排行*/ function get_cats_top10($cat = '') { $sql = 'SELECT cat_id, cat_name ' . 'FROM ' ...

  5. ECSHOP首页调用指定分类下的商品

    转:http://bbs.ecshop.com/thread-1123207-1-1.html 调用某个分类下的商品,方法有很多种的,不过都需要先在后台设置模板那里设置显示和显示条数, 然后在需要调用 ...

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

    ecshop首页调用分类下的商品其实很简单,也有模板设置那里可以设置,不过那个只可以用cat_goods.lib,不方便,所以我想看看怎么能简单的实现ecshop首页调用分类下的商品 只需要在inde ...

  7. Laravel 实现指定用户下的设备分页(与查询指定分类下的文章原理相同)

    <?php //控制器 namespace App\Http\Controllers\Api\User; use App\Http\Controllers\Controller; use Ill ...

  8. thinkphp 查询指定分类下的文章

    $list = $Dao->query("SELECT xp_wztj.bt,xp_wztj.time,xp_wztj.gjz,xp_wztj.wz,xp_wzfl.name FROM ...

  9. Linux下如何遍历指定目录下的所有文件并删除指定天数之前创建的文件

    脚本内容如下: #!/bin/bash function delete_file { days=$[$-] for i in `find $dir -type f -ctime +$days` do ...

随机推荐

  1. android自带的处理Bitmap out Memory 的处理,我仅仅是改变了些写法成为自己用的东西

    每天上万次的启动载入证明这个载入是不错的; 第三方的载入框架非常多,推荐使用成熟框架,比方大家都知道的ImageLoad等, 这里的仅仅供学习; 我也曾在一个菜谱的项目里写过载入手机相冊图片的,只是当 ...

  2. SharePoint 2013 Silverlight中使用Netclient对象模型

    1.创建Silverlight时,选择Silverlight 4.不要选择版本号5,试了非常久版本号5都调用不了,自己也不知道什么原因.谷歌也没找到答案.后来尝试版本号4,能够调用. 至于Host t ...

  3. ZOJ 2314 无源汇可行流(输出方案)

    Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge The terrorist group leaded by a ...

  4. 【专题】概率期望DP

    11.22:保持更新状态:主要发一些相关的题目和个人理解 (P.S.如果觉得简单,可以直接看后面的题目) upd 11.30 更完了 [NO.1] UVA12230 Crossing Rivers  ...

  5. VS2015 右侧导航插件地址

    右侧导航插件: https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProductivityPowe ...

  6. 35个jquery小技巧

    1. 禁止右键点击 ? 1 2 3 4 5 $(document).ready(function(){     $(document).bind("contextmenu",fun ...

  7. css样式变 及实际用法

    <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Con ...

  8. 大白话理解cookie

    HTTP协议是一个无状态的协议,服务器无法区分出两次请求是否发送自同一服务器. 需要通过会话控制来解决这个问题,会话控制主要有两种方式Cookie 和 Session. Cookie就是一个头,Coo ...

  9. C#调用Java的WebService出现500 服务器错误

    最近在用C#调用Java写的WebService时,发现老是返回500 服务器错误,到底什么原因一直找不出来, 后来google了以后,找到国外的http://stackoverflow.com站点已 ...

  10. 使用Ajax验证用户名

    Ajax是一项很重要的技术,下面简要举个例子,来解释如何使用Ajax.步骤如下:使用Ajax验证用户名使用文本框的onBlur事件 使用Ajax技术实现异步交互创建XMLHttpRequest对象通过 ...