ECSHOP首页调用指定分类推荐商品/热卖商品/新品商品

ECSHOP网站首页调用最新商品、热门商品、推荐商品默认都是调用全部商品分类的。

通过以下方法可以调用指定分类下的热门、推荐、最新商品。

1、打开ecshop的includes/lib_goods.php

查找:

1
2
$sql =  'SELECT g.goods_id,g.goods_name, g.goods_name_style,
g.market_price, g.shop_price AS org_price, g.promote_price, ' .

修改为:

1
$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, ' .

继续查找:

1
'LEFT JOIN ' . $GLOBALS [ 'ecs' ]->table( 'brand' ) . ' AS b ON b.brand_id = g.brand_id ' .

在下面增加一句:

1
'LEFT JOIN ' . $GLOBALS [ 'ecs' ]->table( 'category' ) . ' AS c ON c.cat_id = g.cat_id ' .

再查找:

1
2
3
4
if (! empty ( $cats ))
     {
         $sql .= " AND (" . $cats . " OR " . get_extension_goods( $cats ) . ")" ; ECSHOP模板http: //www.ecshop520.com
     }

修改为:

1
2
3
4
if (! empty ( $cats ))
     {
         $sql .= " AND (c.parent_id =" . $cats . " OR " . get_extension_goods( $cats ) . ")" ;
     }

这个是和分类表建立关联,调出商品所在分类的上级分类

2、然后在index.php中增加下面代码:

1
$smarty ->assign( 'chot_goods_35' ,   get_category_recommend_goods( 'hot' , '35' ));     //指定分类下的热销商品

注意这个35是一级分类的ID,然后在模板中调用即可

1
2
3
4
5
6
7
8
9
10
11
12
<!--{ foreach from= $chot_goods_35 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 }-->

同理,新品,推荐都可以调,只要把hot改为new 或者best就可以了

转载于:https://www.cnblogs.com/wpindesign/p/3654965.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值