首页建站经验 ecshop网页模板商品页详情页添加同类随机商品

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

在ecshop商品页详情页添加同类随机商品,能起到更好的展示效果,美观的客户体验,加让系统更方便搜索引擎抓取。1,ecshop根目录下找到goods.php文件找到ecshop代码 $smarty->assign…

在ecshop商品页详情页添加同类随机商品,能起到更好的展示效果,美观的客户体验,加让系统更方便搜索引擎抓取。

1,ecshop根目录下找到goods.php文件

找到ecshop代码 $smarty->assign('properties', $properties['pro']); // 商品属性

在上面加代码 $smarty->assign('category_related_random_goods', category_related_random_goods($goods['cat_id'])); // 同分类随机商品

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

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

function category_related_random_goods($category_id)

{

$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(mp.user_price, g.shop_price * '$_SESSION[discount]') 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('goods') . ' AS g ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' 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($sql);

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

while ($row = $GLOBALS['db']->fetchRow($res))

{

$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'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];

$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);

$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);

$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);

$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);

$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);

if ($row['promote_price'] > 0)

{

$arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);

$arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']);

}

else

{

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

}

}

return $arr;

}

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

代码如下

Related Products

样式可以自己定义

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

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

加上

加在

其他ecshop模块是同理的

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

本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/jianzhan/jingyan/17772.html
上一篇使用XHGui来测试PHP性能的教程
下一篇 ecshop商品属性价格为0不显示出来
admin

作者: admin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部