收藏文章 楼主
版块:AB模板网   类型:普通   作者:AB模板网   查看:6520   回复:0   获赞:0   时间:2021-10-15 12:09:20
在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 代码如下   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- {if $category_related_random_goods} -->  <div class="box">         <h3>Related Products</h3>         <div>         <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}</a><br />         <!-- {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>         </div>  </div> <div class="blank5"></div> <!-- {/if} --> 样式可以自己定义 把category_related_random_goods.lbi文件复制到 /themes/你使用的模板/library/   文件夹里     3,ecshop找到  /themes/你使用的商城模板/goods.dwt  文件 加上   <!-- #BeginLibraryItem "/library/category_related_random_goods.lbi" --><!-- #EndLibraryItem -->   加在 <!-- #BeginLibraryItem "/library/goods_tags.lbi" --><!-- #EndLibraryItem -->   其他ecshop模块是同理的   PS: googs.php 里 ORDER BY rand() limit 12   这个代码 12 就是显示个数的

网站模板:https://www.jxmseo.com/list-89-1.html

本文转载于网络,如有侵权请联系删除


全站外链: TEC传感器 | 猫掌外链
 
回复列表
默认   热门   正序   倒序

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

网站公告

近期本站被人为恶意注册及发布垃圾帖,每一个发帖都会经过审核,一经发现违法或垃圾帖的用户,帖子将被删除或封号,请大家共同维护互联网环境,共创美好互联网未来。

详细的发帖规则请阅读:

《小猪外链网发帖规则》

《小猪外链网最新金币规则》

注:本站严禁发布灰色违禁违法内容,如发现立刻永久封号,如开通会员的概不退款。

Powered by 小猪外链网 7.12.1

©2015 - 2024 小猪SEO外链平台

备案号:浙ICP备17015142号

免责申明:本网站内容由平台入驻会员撰写,除创始人账号外,其他观点仅代表作者本人,不代表小猪外链网立场。如果内容涉及侵犯其他公司、团体的利益、请联系小猪SEO外链网客服举证删除

您的IP:3.147.46.58,2024-05-18 21:38:45,Processed in 0.13545 second(s).

各位站长请准守小猪SEO外链网的发帖规则,文明理性发言

外链优化

用户名:

粉丝数:

签名:

资料 关注 好友 消息
分享
已有0次打赏