在ecshop首页调用指定分类的推荐、热卖和新品-站长杂谈下载

在ecshop首页调用指定分类的推荐、热卖和新品

开通本站Svip会员,全站资源免费下
大家都知道ECSHOP首页的推荐、热卖和新品三个板块的商品都是从所有商品里读取出来的。
; y- ?6 [8 j+ I3 V' I+ K1 Z如果我想“在ecshop首页调用指定分类的推荐、热卖和新品?”该怎么办呢,4 X+ u( t1 C% n' Z8 D% p7 {5 }2 @5 L. H
下面教你一种方法.
找到ecshop的includes/lib_goods.php,: T  M1 ?' J3 O; Z* Q) r- Y
把SQL语句改一下,与category表关联即可
$sql =  'SELECT g.goods_id,g.goods_name, g.goods_name_style,
' t' j* d9 T+ b6 t  O1 e$ p, ^g.market_price, g.shop_price AS org_price, g.promote_price, ' .
修改为
$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, ' .
继续找到
7 j: ~9 @# `6 f'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' .
在它下面加一句
2 l# y: ^. m7 Q7 |* N3 `7 L+ C'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' .
然后将
7 b& m' K5 u2 Z1 T5 e+ Lif (!empty($cats)), z# t: D3 q8 y) W6 _/ Q" q3 u5 c
    {
6 {! X0 V5 j6 ^+ C$ K. J$ \        $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) .")";
2 S) F: `1 H  E2 U  X    }
改为
# f2 J  k% c; j' c' a' K8 F$ Zif (!empty($cats))
8 W% T  _' S+ s( j' k4 u) `/ x    {, Q9 C( m; f, t# K+ R3 z
        $sql .= " AND (c.parent_id =" . $cats. " OR " . get_extension_goods($cats) .")";
/ G: r- T) g, |9 I7 ^+ [    }
这个是和分类表建立关联,调出商品所在分类的上级分类1 l. K7 {. z9 I7 R4 w/ b
然后在index.php中增加下面代码$ g) q- y9 e/ n6 L- @
$smarty->assign('chot_goods_35',   get_category_recommend_goods('hot','35'));     //指定分类下的热销商品
注意这个35是一级分类的ID,然后在模板中调用即可
. d  @  q* }2 W/ P4 u<!--{foreach from=$chot_goods_35 item=goods}-->
) M- Z" N6 ~/ V1 P$ U: ?& \/ [         <div style="padding-top: 8px;" class="new-tr">
1 ~6 {( A; A0 i           <a target="_blank" href="{$goods.url}"><img width="116" height="130" border="0" alt="{$goods.name|escape:html}" src="{$goods.thumb}"></a>
) `+ H' P- U% N, A) N          <div class="right">0 h  C- i+ n( e( j# L/ b
          <a target="_blank" href="{$goods.url}">{$goods.name|escape:html}</a><br>7 ]" o1 ~5 t9 D% P. k; @
          <span style="color: rgb(102, 102, 102); text-decoration: line-through;">市场价:{$goods.market_price}</span><br>
6 A8 i* v9 ~% q6 [' c  W) O6 C          特卖价:<span style="color: rgb(255, 0, 0);">{$goods.shop_price}</span><br>
7 |6 Y8 y9 c9 x; P; u3 u          <span class="font-gmm"><a  href="javascript:addToCart({$goods.id})">立即抢购</a></span>. K9 M. t: |- J) S
          </div>7 s( t4 H  I3 f: W: a# I$ j
          <span class="new-line"></span># s1 w: x$ ~  J6 P$ A& n% O
          </div>
2 Q- g) }8 }4 v, J           <!--{/foreach}-->) N* `& ]( z2 ]- Q8 I" x- W
同理,新品,推荐都可以调,只要把hot改为new 或者best就可以了
8 n& D# O7 h: }( f

全部评论 0

您需要登录后才可以回帖 立即登录
登录
0
0
0
返回顶部