ecshop调用指定栏目下的商品的方法
2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家
ecshop调用指定栏目下的商品,第一步 在ecshop系统目录文件找到includes/lib_goods.php 这个文件打开 在此页最底部加入以下函数代码 /** * 首页获取指定分类产品 * * @access public * @param string $cat_id53_best_goods * @param array $cat_id53_best_goods * @return array */ function index_get_cat_id_goods_best_list($cat_id = '', $num = '') { $sql = 'Select g.goods_id, g.cat_id,c.parent_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ". "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". "Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". $sql .= " AND (c.parent_id =" . $cat_id. " OR g.cat_id = " . $cat_id ." OR g.cat_id ". db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) .")"; $sql .= " LIMIT $num"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res AS $idx => $row) { $goods[$idx]['id'] = $row['article_id']; $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $goods; } 第二步 打开系统根目录下index.php文件加入如下代码 $smarty->assign('cat_id53_best_goods', index_get_cat_id_goods_best_list(53,9)); // 指定商品调用 其中53指的调用的栏目ID,9指的是调用商品的数量。 第三步 在首页模版中调用即可,如下 <!--{foreach from=$cat_id53_best_goods item=women}--> <li> <a href="{$women.url}" target="_blank"><img src="{$women.thumb}" alt="{$women.name|escape:html}" /></a> <span class="a_title"><a href="{$women.url}" title="{$women.name|escape:html}" target="_blank">{$women.short_style_name}</a></span> <div style="text-indent: 5px;">市场价 <span class="del">{$women.market_price}</span></div><div style="text-indent: 5px;"><span class="red">售 价 {$women.shop_price}</span></div></li> <!--{/foreach}--> 测试过,成功调用指定商品分类下的内容。 (责任编辑:chinab4c) |
最近更新
常用插件
- ecshop最小购买数量控制插
ecshop最小购买数量控制插件,这个插件主要是为我们提供一个十分方便...
- ecshop2.7.2生成虚拟订单2.
以前我们开发过ecshop下的虚拟订单,就是客户在访问的时候,会自动生...
- ecshop2.7.1邮件发送插件
ecshop2.7.1邮件发送插件:该插件主要的开发思想是源于ecshop短信发送系统...
- ecshop二次开发商品购买增
图片1香...
- ecshop没登陆情况下订单查
ecshop没登陆情况下订单查询插件,主要是针对ecshop在没有登陆的情况下...
ecshop热门问答
ecshop热门资料
ecshop全部商品
ecshop的
ecshop登入
ecshop深度
ecshop妹妹
ecshop三级下拉
ecshop图象
ecshopeachnet
ecshop深圳速汇通
ecshop激活码
ecshop求证
ecshopclothing
ecshop人防
ecshopgoogle翻译
ecshop增加
ecshop有色
ecshop字眼
ecshop后台进不去
ecshopiphone
ecshop漏洞补丁
ecshop倒序
ecshop受騙
ecshop优购IDC数据
ecshopEC浏览不正常
ecshop下载资源
ecshop163
ecshop购物车
ecshopmax
ecshop管理员密码
ecshopBaiduspider