/* 调查 */ $vote = get_vote(); if (!empty($vote)) { $smarty->assign('vote_id', $vote['id']); $smarty->assign('vote', $vote['content']); } $smarty->assign('best_goods', get_category_recommend_goods('best', $children, $brand, $price_min, $price_max, $ext)); $smarty->assign('promotion_goods', get_category_recommend_goods('promote', $children, $brand, $price_min, $price_max, $ext)); $smarty->assign('hot_goods', get_category_recommend_goods('hot', $children, $brand, $price_min, $price_max, $ext)); $smarty->assign('new_goods', get_category_recommend_goods('new', $children, $brand, $price_min, $price_max, $ext)); $count = get_cagtegory_goods_count($children, $brand, $price_min, $price_max, $ext); $max_page = $count > 0 ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = category_get_goods($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order); if ($display == 'grid') { if (count($goodslist) % 2 != 0) { $goodslist[] = array(); } } $smarty->assign('goods_list', $goodslist); $smarty->assign('category', $cat_id); $smarty->assign('script_name', 'category'); $smarty->assign('cat_name_curr', $cat['cat_name']); $smarty->assign('condition', $condition); $smarty->assign('brand_have_logo', $brand_have_logo); $smarty->assign('filter_attr_count', count($all_attr_list)); $filter = isset($_REQUEST['filter']) ? intval($_REQUEST['filter']) : 0; assign_pager('category', $cat_id, $count, $size, $sort, $order, $page, '', $brand, $price_min, $price_max, $display, $filter_attr_str, '', '', $filter); // 分页
assign_template_supplier(); $position = assign_ur_here(); //$hereinfo = get_categories_tree($cat_id); //$ur_here = "<a href='supplier.php?suppId=".$_GET['suppId']."'>店铺首页</a> <code>></code> <a href='".$hereinfo[$cat_id]['url']."'>".$hereinfo[$cat_id]['name']."</a>"; $smarty->assign('page_title', $position['title']); // 页面标题 //$smarty->assign('ur_here', $ur_here); // 当前位置 $smarty->assign('categories', get_categories_tree_supplier()); // 分类树 $children = get_children_supplier($cat_id); $count = get_cagtegory_goods_count($children); $max_page = $count > 0 ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = category_get_goods($children, $size, $page); if ($display == 'grid') { if (count($goodslist) % 2 != 0) { $goodslist[] = array(); } } assign_pager('supplier', $cat_id, $count, $size, '', '', $page, '', '', '', '', $display, ''); // 分页 $smarty->assign('goods_list', $goodslist); assign_dynamic('category'); } $smarty->display('category.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */ /**
// 页面标题 //$smarty->assign('ur_here', $ur_here); // 当前位置 $smarty->assign('categories', get_categories_tree_supplier()); // 分类树 $s_value = get_search_price($price); $children = get_cattype_supplier($cat_id, $keywords); if ($children === false) { ecs_header("Location: supplier.php?suppId=" . $_GET['suppId']); exit; } $count = get_cagtegory_goods_count($children, $keywords, $s_value); $max_page = $count > 0 ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = category_get_goods($children, $size, $page, $keywords, $s_value, $sort, $order); if ($display == 'grid') { if (count($goodslist) % 2 != 0) { $goodslist[] = array(); } } assign_pager('supplier', $cat_id, $count, $size, $sort, $order, $page, $keywords . "&price=" . $price, '', '', '', $display, ''); // 分页 $smarty->assign('goods_list', $goodslist); assign_dynamic('search'); } $smarty->display('search.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */ /**
public function search () { /** * 参数描述: * @var id 分类id. * @var page 当前页. * @var brand 品牌id. * @var price_max 最高价格. * @var price_min 最低价格. * @var order 排序方式. @enum.<'ASC', 'DESC'> * @var sort 排序字段.@enum.<'goods_id', 'shop_price', 'last_update'> * @var filter_attr table goods_attr 中goods_attr_id使用"."连接。例如9.10.11 */ global $_CFG,$ecs,$db; $cat_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if (!$cat_id) { $result = rpcLang('category.php', 'goodslist_failure'); jsonExit("{\"status\":\"$result\"}"); } $cat = get_cat_info($cat_id); // 获得分类的相关信息 if (empty($cat)) { $result = rpcLang('category.php', 'search_cat_failure'); jsonExit("{\"status\":\"$result\"}"); } $page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; // $size = isset($_CFG['page_size']) && intval($_CFG['page_size']) > 0 ? intval($_CFG['page_size']) : 1; $size = 10; //品牌筛选. $brand = isset($_REQUEST['brand']) && intval($_REQUEST['brand']) > 0 ? intval($_REQUEST['brand']) : 0; //价格区间 $price_max = isset($_REQUEST['price_max']) && intval($_REQUEST['price_max']) > 0 ? intval($_REQUEST['price_max']) : 0; $price_min = isset($_REQUEST['price_min']) && intval($_REQUEST['price_min']) > 0 ? intval($_REQUEST['price_min']) : 0; //属性筛选.格式1.2.3 / attr_id使用.分割 $filter_attr_str = isset($_REQUEST['filter_attr']) ? htmlspecialchars(trim($_REQUEST['filter_attr'])) : '0'; $filter_attr_str = urldecode($filter_attr_str); $filter_attr = empty($filter_attr_str) ? '' : explode('.', trim($filter_attr_str)); /* 排序、方式及类型 */ $default_sort_order_method = $_CFG['sort_order_method'] == '0' ? 'DESC' : 'ASC'; $default_sort_order_type = $_CFG['sort_order_type'] == '0' ? 'goods_id' : ($_CFG['sort_order_type'] == '1' ? 'shop_price' : 'last_update'); $sort = (isset($_REQUEST['sort']) && in_array(trim(strtolower($_REQUEST['sort'])), array('goods_id', 'shop_price', 'last_update'))) ? trim($_REQUEST['sort']) : $default_sort_order_type; $order = (isset($_REQUEST['order']) && in_array(trim(strtoupper($_REQUEST['order'])), array('ASC', 'DESC'))) ? trim($_REQUEST['order']) : $default_sort_order_method; $children = get_children($cat_id); //属性筛选 $ext = ''; if (!empty($filter_attr)) { $ext_sql = "SELECT DISTINCT(b.goods_id) FROM " . $ecs->table('goods_attr') . " AS a, " . $ecs->table('goods_attr') . " AS b " . "WHERE "; $ext_group_goods = array(); foreach ($filter_attr AS $k => $v)// 查出符合所有筛选属性条件的商品id */ { if (!is_numeric($v) || $v == 0) continue; $sql = $ext_sql . "b.attr_value = a.attr_value AND a.goods_attr_id = " . $v; $ext_group_goods = $db->getColCached($sql); $ext .= ' AND ' . db_create_in($ext_group_goods, 'g.goods_id'); } } $count = get_cagtegory_goods_count($children, $brand, $price_min, $price_max, $ext); $max_page = ($count> 0) ? ceil($count / $size) : 1; if ($page > $max_page) $page = $max_page; $goodslist = category_get_goods($children, $brand, $price_min, $price_max, $ext, $size, $page, $sort, $order); if (!$goodslist) { $goodslist = rpcLang('category.php', 'goodslist_empty'); } $goodslist = array_values($goodslist); $pager = get_pager('category.php', $_GET, $count, $page, $size); //print_r(array('goods_list'=>$goodslist, 'pager'=>$pager));exit; jsonExit(array('goods_list'=>$goodslist, 'pager'=>$pager)); }
$smarty->assign('page_title', $position['title']); // 页面标题 //$smarty->assign('ur_here', $ur_here); // 当前位置 $smarty->assign('categories', get_categories_tree_supplier()); // 分类树 $children = get_cattype_supplier($cat_id, $keywords); if ($children === false) { ecs_header("Location: supplier.php?suppId=" . $_GET['suppid']); exit; } $count = get_cagtegory_goods_count($children, $keywords); $max_page = $count > 0 ? ceil($count / $size) : 1; if ($page > $max_page) { $page = $max_page; } $goodslist = category_get_goods($children, $size, $page, $keywords); if ($display == 'grid') { if (count($goodslist) % 2 != 0) { $goodslist[] = array(); } } assign_pager('supplier', $cat_id, $count, $size, '', '', $page, $keywords, '', '', '', $display, ''); // 分页 $smarty->assign('goods_list', $goodslist); assign_dynamic('category'); } $smarty->display('category.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */ /**