ecshop网页模板商品页详情页添加同类随机商品

2021-06-21 作者:未知   |   浏览(

加上

!-- #BeginLibraryItem /library/category_related_random_goods.lbi --!-- #EndLibraryItem --

1,ecshoh3根目录下找到goods.h3hh3文件

找到ecshop代码 $smarty-assign; // 商品的基本属性

在上面加代码 $smarty-assign); // 同分类随机产品

再在ecshop最底部添加上 随机相同种类产品的函数, 以下代码

/*同分类下随机推荐产品*/

function category_related_random_goods

{

$where = g.is_on_sale = 1 AND g.is_alone_sale = 1 AND .

g.is_delete = 0 AND g.cat_id=$category_id ;

$sql = SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, .

IFNULL AS shop_price, g.promote_price, g.goods_type, .

g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img .

FROM . $GLOBALS[ecs]-table . AS g .

LEFT JOIN . $GLOBALS[ecs]-table . AS mp .

ON mp.goods_id = g.goods_id AND mp.user_rank = $_SESSION[user_rank] .

WHERE $where ORDER BY rand limit 12;

$res = $GLOBALS[db]-query;

$arr = array;//www.zuimoban.com

while )

{

$arr[$row[goods_id]][goods_id] = $row[goods_id];

$arr[$row[goods_id]][goods_name]= $row[goods_name];

$arr[$row[goods_id]][short_name]= $GLOBALS[_CFG][goods_name_length] 0 ?

sub_str : $row[goods_name];

$arr[$row[goods_id]][goods_thumb] = get_image_path;

$arr[$row[goods_id]][goods_img]= get_image_path;

$arr[$row[goods_id]][market_price] = price_format;

$arr[$row[goods_id]][shop_price]= price_format;

$arr[$row[goods_id]][url] = build_uri, $row[goods_name]);

if

{

$arr[$row[goods_id]][promote_price] = bargain_price;

$arr[$row[goods_id]][formated_promote_price] = price_format;

}

else

{

$arr[$row[goods_id]][promote_price] = 0;

}

}

return $arr;

}

2,新建ecshoh3模板文件 category_related_random_goods.lbi

代码如下

meta http-equiv=Content-Type content=text/html; charset=utf-8

!-- {if $category_related_random_goods} --

p class=box

h3Related Products/h3

p

ul

!--{foreach from=$category_related_random_goods item=category_related_random_goods_data}--

li class=li1 style=float:left; margin-bottom:20px;a href={$category_related_random_goods_data.url}img src={$category_related_random_goods_data.goods_thumb} alt={$category_related_random_goods_data.goods_name}//a/li

li class=li2 style=float:left; margin-bottom:20px;a href={$category_related_random_goods_data.url} title={$category_related_random_goods_data.goods_name}{$category_related_random_goods_data.short_name}/abr /

!-- {if $category_related_random_goods_data.promote_price neq 0} --

{$lang.promote_price}font class=f1{$category_related_random_goods_data.formated_promote_price}/font

!-- {else} --

{$lang.shop_price}font class=f1{$category_related_random_goods_data.shop_price}/font

!-- {/if} --/li

!--{/foreach}--

/ul

/p

/p

p class=blank5/p

!-- {/if} --

其他ecshoh3模块是同理的

PS: googs.php 里 ORDER BY rand limit 12这个代码 12 就是显示个数的

样式可以自己概念

把category_related_random_goods.lbi文件复制到 /themes/你用的模板/library/文件夹里

3,ecshop找到 /themes/你用的商城模板/goods.dwt 文件

加在 !-- #BeginLibraryItem /library/goods_tags.lbi --!-- #EndLibraryItem --

在ecshop产品页详情介绍页添加相同种类随机产品,能起到更好的展示成效,美观的顾客体验,加让系统更便捷搜索引擎抓取。