51可用代码模板网站

咨询热线:

181-1164-6936
  • 1
ECSHOP商城
当前位置:首页>实用代码>ECSHOP商城>

ecshop首页调用指定分类的热销、推荐、新货

时间:2017-08-10 13:52点击:
找到ecshop的includes/lib_goods.PHP,修改方法如下

以把SQL语句改一下,与category表关联即可将


    $sql =  'SELECT g.goods_id,g.goods_name, g.goods_name_style,
    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, ' .
再在



'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' .
下加一句
'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' .
然后将
    if (!empty($cats))
        {
            $sql .= " AND (" . $cats . " OR " . get_extension_goods($cats) .")";
        }

改为
    if (!empty($cats))
        {
            $sql .= " AND (c.parent_id =" . $cats. " OR " . get_extension_goods($cats) .")";
        }

这个是和分类表建立关联,调出商品所在分类的上级分类
然后在index.php中 smarty
$smarty->assign('chot_goods_35',   get_category_recommend_goods('hot','35'));     //指定分类下的热销商品
注意这个35是一级分类的ID,然后在模板中调用即可
<!--{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就可以了




51可用模板(代码)网站专为广大站长朋友提供精品模板与代码,同时免费提供网站收录。
本站域名: WWW.51KYDM.COM    联系方式:QQ:182468923    手机:18111646936
本站关键词:网站链接收录网址收录入口网站免费提交收录网站收录提交入口    网站地图
51可用模板
展开