ECSHOP调用指定分类以及子分类下推荐商品(指定best,cat_id,number)
2013-03-21 11:03
423 查看
函数保存在include/lib_goods.php文件,调用了ecshop自带的函数get_children($cat_id)调用指定分类下所有子分类的id,该函数在文件include/lib_common.php文件内;
具体代码如下:
gategory.php文件调用:
gategory.dwt文件调用:
具体代码如下:
/** * 获得指定分类下的推荐商品 * sun04zh3-20130321 * @access public * @param string $type 推荐类型,可以是 best, new, hot, promote * @param string $cats 分类的ID * @param integer $num 显示的产品数量 * @return array */ function get_category_recommend_goods_cat_id($type = '',$cat_id, $num) { $sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_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 ' . "Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND ".get_children($cat_id); switch ($type) { case 'best': $sql .= ' AND g.is_best = 1'; break; case 'new': $sql .= ' AND g.is_new = 1'; break; case 'hot': $sql .= ' AND g.is_hot = 1'; break; case 'promote': $time = gmtime(); $sql .= " AND is_promote = 1 AND promote_start_date <= '$time' AND promote_end_date >= '$time'"; break; } $sql .=" LIMIT $num"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res AS $idx => $row) { $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; }
gategory.php文件调用:
$smarty->assign('best_goods_rmb', get_category_recommend_goods_cat_id('best',8 ,8));
gategory.dwt文件调用:
<meta http-equiv="Content-Type" content="text/html; charset=GBK"> <!-- {if $best_goods_rmb} --> <!--{foreach from=$best_goods_rmb item=rmb}--> <li><a href="{$rmb.url}"><img src="{$rmb.thumb}" alt="{$rmb.name|escape:html}" width="150" height="123" /></a><p><a href="{$rmb.url}" title="{$rmb.name|escape:html}">{$rmb.short_style_name}</a></p><em><!-- {if $rmb.promote_price neq ""} -->{$rmb.promote_price}<!-- {else}-->{$rmb.shop_price}<!--{/if}--></em></li> <!--{/foreach}--> <!-- {/if} -->
相关文章推荐
- ECSHOP首页调用指定分类推荐商品/热卖商品/新品商品
- ecshop首页调用指定分类下商品
- ecshop二次开发之首页调用指定分类下的商品
- ecshop调用指定ID分类下的文章列表(指定分类下的文章)
- ecshop 调用指定分类的推荐,热卖,新品
- ECSHOP首页调用指定分类下的商品
- ecshop调用指定分类ID的下级分类
- ecshop首页调用指定分类下面的精品商品
- ECSHOP首页调用指定分类下的商品
- Ecshop模板在首页调用指定分类的热销、推荐、新品商品
- ecshop 首页调用全部分类树 并且分类下的品牌 &调用商品分类指定分类下级分类
- 如何在ecshop首页调用指定分类的热销、推荐、新
- ecshop首页调用指定分类下的推荐、热卖、新品
- ecshop调用指定商品分类下固定条数的商品品牌列表
- ECSHOP首页调用指定扩展分类商品
- ecshop首页调用指定商品分类下的商品品牌列表
- ecshop首页调用某分类下的商品|assign_cat_goods()
- ecshop首页调用某分类下的商品|assign_cat_goods()
- ecshop怎么全局调用指定文章二级分类(注意是文章分类不是二级商品分类)
- ecshop调用指定商品文章