首页怎样挪用一级,二级分类的热销,佳构,新品商品

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

首页怎样挪用一级,二级分类的热销,佳构,新品商品
在includes/lib_goods.php中有如下函数
function get_category_recommend_goods($type = '', $cats = '', $brand = 0, $min =0,$max = 0, $ext='')
{

}
找到如下代码

$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,g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .

查询出g.cat_id是商品的分类ID,然后把

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

改为

if (!empty($cats))
{
$sql .= " AND (g.cat_id =" . $cats. " OR " . get_extension_goods($cats) .")";
}

加个限定,将ID为$cats的全部热销查询出来,也就是你要指定的分类ID下的热销商品然后在index.php中找到

$smarty->assign('best_goods',get_recommend_goods('best')); // 保举商品
$smarty->assign('new_goods', get_recommend_goods('new'));// 最新商品
$smarty->assign('hot_goods', get_recommend_goods('hot'));// 热门文章

在下面加一句
http://xinaoboyu161.com
http://dafbaba4261.com
http://dafengsylc541.com

$smarty$smarty->assign('chot_goods_16',get_category_recommend_goods('hot','16'));

上面的16就是二级分类的id,hot就是热点商品,假如想改成保举,佳构等就把hot改成响应的就是

最后在模板index.dwt中响应位置加上

<!–{foreach from=$chot_goods_16 item=goods}–>
<div class="bb1_da pl15 pr15 pt15 pb10 adjust">
<div class="left b1"><a target="_blank" href="{$goods.url}"><img alt="{$goods.name|escape:html}" src="{$goods.thumb}" width="60" height="60" /></a></div>
<div class="left pl5 div140 lin16">
<div><a title="{$goods.name|escape:html}" target="_blank" href="{$goods.url}">{$goods.name|escape:html}</a></div>
<div class="f_delline">市场价:{$goods.market_price}</div>
<div class="f_red">无忧康价:{$goods.shop_price}</div>
<div class="f_orange">售出:{$goods.goods_number}</div>
</div>
</div>
<!–{/foreach}–>

回答:
不回不行了,因为楼猪太有才了~












简象生活@唯美实用主义全球精选~http://joy**.taobao.com

不错 ecshop论坛又活了可以学习了多谢 多谢