您现在的位置:主页 > 程序应用 > ECShop >

ECShop首页完全调用指定分类商品id的解决方法新2备用网址hg622.com|首页吧亲测可用

来源:新2备用网址hg622.com|首页吧 责任编辑:Jzq8 发表时间:2013-10-30 点击:次

?首先,我们再在/includes/lib_goods.php下增加如下代码:这个代码可以加在最底部:

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;
}

ecshop首页调用指定分类商品

第二、在index.php增加以下代码

$smarty->assign('cat_id16_best_goods', index_get_cat_id_goods_best_list(16,8));

其中16是你调用的分类的id,这个分类可以是一级,也可以是二级。要注意有两个16

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
匿名?

今日头条

更多>>

推荐图文

  • ECshop地区列表设置教程
  • ECshop会员注册项设置
  • ECSHOP去掉版权copyright powered by ecshop 去掉商标志logo
  • ECshop验证码设置教程
  • ECshop配送方式设置教程
  • ECshop邮件服务器设置
  • ECshop自定义导航栏设置教程
  • ECShop首页完全调用指定分类商品id的解决方法新2备用网址hg622.com|首页吧亲测可用
  • ECshop首页主广告位管理
Alexa - 客户服务 - 联系方法 - 招聘信息 - 友情链接 - 网站地图 - TAG标签 - RSS订阅
Copyright ? 2013 JZQ8.COM. 新2备用网址hg622.com|首页吧|新2备用网址hg622.com|首页去吧 版权所有
冀ICP备09002514号
冀ICP备09002514号 网络报警 企业法人营业执照 中国互联网协会 支付宝付款 网银在线付款