2KB项目,专业的源码交易网站 帮助 收藏 每日签到

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

  • 时间:2019-01-31 02:15 编辑:2KB 来源:2KB.COM 阅读:320
  • 扫一扫,手机访问
  • 分享
摘要: 在ecshop商品页详情页添加同类随机商品,能起到更好的展示效果,美观的客户体验,加让系统更方便搜索引擎抓取。   1,ecshop根目录下找到goods.php文件 找到ecshop代码  $smarty->assign('properties'
在ecshop商品页详情页添加同类随机商品,能起到更好的展示效果,美观的客户体验,加让系统更方便搜索引擎抓取。   1,ecshop根目录下找到goods.php文件 找到ecshop代码  $smarty->assign(&#39;properties&#39;,          $properties[&#39;pro&#39;]);                              // 商品属性 在上面加代码 $smarty->assign(&#39;category_related_random_goods&#39;,       category_related_random_goods($goods[&#39;cat_id&#39;])); // 同分类随机商品   再在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 = &#39;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, &#39; .                 "IFNULL(mp.user_price, g.shop_price * &#39;$_SESSION[discount]&#39;) AS shop_price, g.promote_price, g.goods_type, " .                 &#39;g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img &#39; .             &#39;FROM &#39; . $GLOBALS[&#39;ecs&#39;]->table(&#39;goods&#39;) . &#39; AS g &#39; .             &#39;LEFT JOIN &#39; . $GLOBALS[&#39;ecs&#39;]->table(&#39;member_price&#39;) . &#39; AS mp &#39; .                 "ON mp.goods_id = g.goods_id AND mp.user_rank = &#39;$_SESSION[user_rank]&#39; " .             "WHERE $where ORDER BY rand() limit 12";     $res = $GLOBALS[&#39;db&#39;]->query($sql);     $arr = array();//www.zuimoban.com     while ($row = $GLOBALS[&#39;db&#39;]->fetchRow($res))     {         $arr[$row[&#39;goods_id&#39;]][&#39;goods_id&#39;]     = $row[&#39;goods_id&#39;];         $arr[$row[&#39;goods_id&#39;]][&#39;goods_name&#39;]   = $row[&#39;goods_name&#39;];         $arr[$row[&#39;goods_id&#39;]][&#39;short_name&#39;]   = $GLOBALS[&#39;_CFG&#39;][&#39;goods_name_length&#39;] > 0 ?             sub_str($row[&#39;goods_name&#39;], $GLOBALS[&#39;_CFG&#39;][&#39;goods_name_length&#39;]) : $row[&#39;goods_name&#39;];         $arr[$row[&#39;goods_id&#39;]][&#39;goods_thumb&#39;]  = get_image_path($row[&#39;goods_id&#39;], $row[&#39;goods_thumb&#39;], true);         $arr[$row[&#39;goods_id&#39;]][&#39;goods_img&#39;]    = get_image_path($row[&#39;goods_id&#39;], $row[&#39;goods_img&#39;]);         $arr[$row[&#39;goods_id&#39;]][&#39;market_price&#39;] = price_format($row[&#39;market_price&#39;]);         $arr[$row[&#39;goods_id&#39;]][&#39;shop_price&#39;]   = price_format($row[&#39;shop_price&#39;]);         $arr[$row[&#39;goods_id&#39;]][&#39;url&#39;]          = build_uri(&#39;goods&#39;, array(&#39;gid&#39;=>$row[&#39;goods_id&#39;]), $row[&#39;goods_name&#39;]);         if ($row[&#39;promote_price&#39;] > 0)         {             $arr[$row[&#39;goods_id&#39;]][&#39;promote_price&#39;] = bargain_price($row[&#39;promote_price&#39;], $row[&#39;promote_start_date&#39;], $row[&#39;promote_end_date&#39;]);             $arr[$row[&#39;goods_id&#39;]][&#39;formated_promote_price&#39;] = price_format($arr[$row[&#39;goods_id&#39;]][&#39;promote_price&#39;]);         }         else         {             $arr[$row[&#39;goods_id&#39;]][&#39;promote_price&#39;] = 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 就是显示个数的


2KB项目(www.2kb.com,源码交易平台),提供担保交易、源码交易、虚拟商品、在家创业、在线创业、任务交易、网站设计、软件设计、网络兼职、站长交易、域名交易、链接买卖、网站交易、广告买卖、站长培训、建站美工等服务

  • 全部评论(0)
资讯详情页最新发布上方横幅
最新发布的资讯信息
【计算机/互联网|】Nginx出现502错误(2020-01-20 21:02)
【计算机/互联网|】网站运营全智能软手V0.1版发布(2020-01-20 12:16)
【计算机/互联网|】淘宝这是怎么了?(2020-01-19 19:15)
【行业动态|】谷歌关闭小米智能摄像头,因为窃听器显示了陌生人家中的照片(2020-01-15 09:42)
【行业动态|】据报道谷歌新闻终止了数字杂志,退还主动订阅(2020-01-15 09:39)
【行业动态|】康佳将OLED电视带到美国与LG和索尼竞争(2020-01-15 09:38)
【行业动态|】2020年最佳AV接收机(2020-01-15 09:35)
【行业动态|】2020年最佳流媒体设备:Roku,Apple TV,Firebar,Chromecast等(2020-01-15 09:31)
【行业动态|】CES 2020预览:更多的流媒体服务和订阅即将到来(2020-01-08 21:41)
【行业动态|】从埃隆·马斯克到杰夫·贝佐斯,这30位人物定义了2010年代(2020-01-01 15:14)
联系我们

Q Q: 7090832

电话:400-0011-990

邮箱:7090832@qq.com

时间:9:00-23:00

联系客服
商家入住 服务咨询 投拆建议 联系客服
0577-67068160
手机版

扫一扫进手机版
返回顶部