10
2020
05

ecshop首页调用指定商品分类下推荐热销最新商品

其实这个在ecshop中预留这个函数,不知道是不是开发者特意留下,但不想让所有人知道而已,函数在includes/lib_goods.php里面。

下面开始教你如何添加指定分类的下热销产品:

1.在首页index.php中找到

/* 页面中的动态内容 */

assign_dynamic('index');

2.在上面添加如下代码

$children = get_children(1);

$smarty->assign('index_hot_goods_1', get_category_recommend_goods("hot", $children)); // 热销商品

其中分类编号1,根据你想调用分类而填写

如果是最新产品就再加上

$children = get_children(1);

$smarty->assign('index_new_goods_1', get_category_recommend_goods("new", $children)); // 最新商品

若果是精品产品

$children = get_children(1);

$smarty->assign('index_best_goods_1', get_category_recommend_goods("best", $children)); // 精品商品

3.然后再模板库文件中新建index_hot_goods_1.lbi。文件内容如下:

<!--{foreach from=$index_hot_goods_1 item=goods}-->

<li><a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="goodsimg" border="0" width="160" height="200" /></a>

<h1><a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name|escape:html}</a></h1>

<!-- {if $goods.promote_price neq ""} -->

<span>一口价 <b>{$goods.promote_price}</b></span>

<!-- {else}-->

<span>一口价 <b>{$goods.shop_price}</b></span>

<!--{/if}-->

</li>

<!--{/foreach}-->

4.然后在首页模板index.dwt中调用index_hot_goods_1.lbi。

<!-- #BeginLibraryItem "/library/index_hot_goods_19.lbi" --><!-- #EndLibraryItem -->

5.如果有多个分类要调用,可以重复1-3的步骤

至于每个调用的商品的数量 ,在后台》》模板设置》》

原文链接:https://www.qiquanji.com/post/8253.html

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

微信扫码关注

更新实时通知

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。