Nov
24

ECSHOP获得指定栏目最新的商品列表     2009

 11:34    563    0   noel Ecshop/Ecmall/Smarty 不指定 | |
ECSHOP获得指定栏目最新的商品列表

/**
* 获得指定栏目最新的商品列表。
*
* @access  private
* @return  array
*/
function index_get_class_goods($cat_aid, $cat_num)
{


   $sql = "SELECT goods_id  FROM " .$GLOBALS['ecs']->table('goods'). "WHERE (cat_id = ".$cat_aid." OR goods_id in (".good_cat_id($cat_aid).") ) and is_on_sale = 1 order by `last_update` desc LIMIT " . $cat_num;
    $res = $GLOBALS['db']->getAll($sql);
    $arr = array();
    foreach ($res AS $idx => $row)
    {
        $arr[$idx]['id']          = $row['goods_id'];
        $arr[$idx]['url']     = build_uri('goods', array('gid' => $row['goods_id']));
    }
    return $arr;
}

function good_cat_id($cat_aid){
$sql = "SELECT goods_id  FROM " .$GLOBALS['ecs']->table('goods_cat'). " WHERE cat_id = ".$cat_aid;
    $res = $GLOBALS['db']->getAll($sql);
      $arr = array();
    foreach ($res AS $row)
    {
        $arr[] = $row['goods_id'];

    }

  $ck_explode=implode(',',$arr);
  return $ck_explode;
  }

$smarty->assign(’shop_notice’, $_CFG['shop_notice']); // 商店公告
加上
$smarty->assign(’news_goods’, index_get_class_goods(18,4)); // 新品快递
$smarty->assign(’design_recommend’, index_get_class_goods(35,4)); // 设计师推荐

指定函数定义放到HTML里就可以了

作者:noel@ECMall Ecmall二次开发 - PHP技术-
地址:http://www.laohucheng.com/post/408/
版权所有©转载时必须以链接形式注明作者和原始出处及本声明!

Tags: 引用(0)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我