您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop商城调用指定分类新品商品/热门商品/推荐商品可设置商品数量
易堃登2024-04-25Ecshop商城教程已有人查阅
导读ECSHOP商城任何页面调用显示指定分类下新品商品/热门商品/推荐商品可设置商品数量步: 打开你要显示文件例如index.php首页 goods.php
ECSHOP商城任何页面调用显示指定分类下新品商品/热门商品/推荐商品可设置商品数量
第一步: 打开你要显示文件例如index.php首页 goods.php商品页面 category.php分类页面
/**
* 取指定分类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; }
?>
第2步:打开你要显示文件例如index.php首页 goods.php商品页面 category.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
打开你要显示文件例如index.dwt首页 goods.dwt商品页面 category.dwt分类页面 增加:
<!--{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}-->
本文标签:
很赞哦! ()
相关教程
图文教程
ecshop验证码不显示的解决方法
知道大家注意到了没有,ECSHOP的验证码设置有一个BUG,那就是 “用户登录”和“发表评论”的验证码设置是相冲突的。
ecshop返回顶部按钮代码样式写法实例
打开模板,底部模板文件 library/page_footer.lbi在之后加入以下代码:再在模板CSS文件里加入CSS,并把下面的图片,另存为:scroll.png
ecshop表单在火狐浏览器下无法刷新重置的修复方法
这个问题不是ecshop系统独有的,其他所有涉及到表单的页面都会出现类似问题:问题现象为:在火狐浏览器下,ECSHOP表单无法刷新重置。
ecshop用户协议字体颜色怎么修改
ECSHOP用户协议模板文件article_pro.dwt这里《用户协议》的颜 在哪里改?找到languages\zh_cn\user.php
相关源码
-
(自适应响应式)工业机床工程农业机械设备网站源码下载框架适用于工程机械、机床设备等工业领域。通过模块调整可快速转型为农业机械、物流设备展示系统。预留7种工业产品展示模板。查看源码 -
自适应响应式绿色装修公司定制家居类pbootcms网站下载(自适应手机端)响应式全屋装修定制家居类网站pbootcms模板 绿色装修公司网站源码下载PbootCMS内核开发的网站模板,该模板适用于装修定制网站、装查看源码 -
(自适应响应式)化妆美容口红唇膏化妆品模板pbootcms源码下载基于PbootCMS开发的响应式模板,为化妆品品牌、美容机构打造,通过优雅的视觉呈现提升产品展示效果与品牌调性。采用时尚杂志排版风格,色卡系统规范产品展示。微交互动画增强用户体验,智能推荐算法提升产品关联展示效果。查看源码 -
(自适应)家政保洁保姆打扫卫生清灰服务pbootcms模板免费下载采用手工编写的DIV+CSS架构,代码结构清晰无冗余,加载速度优异。响应式设计适配各类终端设备,保障手机、平板、电脑端的一致浏览体验。查看源码 -
响应式帝国cms7.5NBA黑色体育资讯模板下载本模板为体育新闻媒体、报道机构设计,采用帝国CMS7.5内核开发,具备完整的资讯发布、体育日历、数据展示功能。响应式布局确保在手机端呈现实时资讯和图文内容查看源码 -
(自适应响应式)水墨风白酒酿制酒业酒文化酒类产品网站源码下载本模板基于PbootCMS内核开发,为酒类企业打造的水墨风响应式网站解决方案。采用传统东方美学设计语言,呈现白酒文化底蕴,自适应移动端展示效果,数据实时同步更新,助力酒企建立专业数字化形象。查看源码
| 分享笔记 (共有 篇笔记) |
