...
|
...
|
@@ -59,35 +59,49 @@ class HelperSearch |
|
|
self::$options = $options;
|
|
|
unset(self::$params['/']);
|
|
|
unset(self::$params['page']);
|
|
|
self::$filter = $data['product']['filter'];
|
|
|
self::$filter = isset($data['product']['filter']) ? $data['product']['filter'] : array();
|
|
|
//产品列表
|
|
|
$result['goods'] = self::getProductList($data['product']['product_list'], $options['imgSize']);
|
|
|
$result['goods'] = isset($data['product']['product_list']) ? self::getProductList($data['product']['product_list'], $options['imgSize']) : array();
|
|
|
//总页数
|
|
|
$result['page_total'] = $data['product']['page_total'];
|
|
|
self::$pageTotal = $data['product']['page_total'];
|
|
|
$result['page_total'] = isset($data['product']['page_total']) ? $data['product']['page_total'] : '';
|
|
|
self::$pageTotal = $result['page_total'];
|
|
|
//当前页
|
|
|
$result['page'] = $data['product']['page'];
|
|
|
$result['page'] = isset($data['product']['page']) ? $data['product']['page'] : '';
|
|
|
self::$page = $result['page'];
|
|
|
//筛选条件
|
|
|
$result['filters'] = self::filter();
|
|
|
$result['filters'] = isset($data['product']['filter']) ? self::filter() : array();
|
|
|
//排序方式、显示数量等其他选项
|
|
|
$result['opts'] = self::getOpts();
|
|
|
$result['opts'] = isset($data['product']['filter']) ? self::getOpts() : array();
|
|
|
//下一页
|
|
|
if (isset($data['product']['page_total'])) {
|
|
|
$result['hasNextPage'] = self::next($data['product']['page_total']);
|
|
|
}
|
|
|
//全部折扣
|
|
|
$result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array();
|
|
|
//分类条件
|
|
|
$result['filters']['sort'] = isset($data['sort']) ? self::searchSort($data['sort']['sort']) : array();
|
|
|
if (isset($data['discount']['discount']) && !empty($data['discount']['discount'])) {
|
|
|
$result['leftContent'][]['allDiscount'] = self::getDiscount($data['discount']['discount']);
|
|
|
}
|
|
|
//分类条件(搜索页面)
|
|
|
if (isset($data['sort']['sort'])) {
|
|
|
//分类条件(搜索页面)
|
|
|
if (isset($options['controller']) && $options['controller'] != 'Search') {
|
|
|
$result['filters']['sort'] = self::searchSort($data['sort']['sort']);
|
|
|
}else{
|
|
|
//左侧分类分类
|
|
|
$result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array();
|
|
|
$result['leftContent'][]['allSort'] = self::groupSort($data['sort']['sort']);
|
|
|
}
|
|
|
}
|
|
|
//一周新品上架
|
|
|
$result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array();
|
|
|
if (isset($data['recent']['recent']) && !empty($data['recent']['recent'])) {
|
|
|
$result['leftContent'][]['newSales'] = self::recentShelve($data['recent']['recent']);
|
|
|
}
|
|
|
//品牌banner
|
|
|
$result['brandBanner'] = isset($data['brand']) ? self::getBannerFormat($data['brand'], $options['brandBanner']) : array();
|
|
|
//总记录数
|
|
|
$result['totalCount'] = $data['product']['total'];
|
|
|
//品牌店铺信息
|
|
|
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
|
|
|
if (isset($data['shop']) && !empty($data['shop'])) {
|
|
|
$result['shopEntry'] = self::shop($data['shop'], $data['sort']['sort']);
|
|
|
}
|
|
|
//分页
|
|
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
|
|
//浏览记录
|
...
|
...
|
@@ -117,6 +131,9 @@ class HelperSearch |
|
|
{
|
|
|
$params = self::$params;
|
|
|
$goods = array();
|
|
|
if (empty($product)) {
|
|
|
return $goods;
|
|
|
}
|
|
|
foreach($product as $key => $val){
|
|
|
//NEW
|
|
|
$isNew = $val['is_new'] == 'Y' ? true : false;
|
...
|
...
|
@@ -306,9 +323,6 @@ class HelperSearch |
|
|
{
|
|
|
$result = array();
|
|
|
$options = self::$options;
|
|
|
if (!isset($options['controller']) || $options['controller'] != 'Search') {
|
|
|
return $result;
|
|
|
}
|
|
|
$params = self::$params;
|
|
|
foreach ($sort as $key => $val) {
|
|
|
$result[$key]['id'] = $val['sort_id'];
|
...
|
...
|
@@ -361,7 +375,6 @@ class HelperSearch |
|
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
|
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
|
|
$brand = $filter['brand'];
|
|
|
// print_r($filter); exit;
|
|
|
//已选中品牌数量
|
|
|
$existBrandNum = 0;
|
|
|
//已选中品牌标签名
|
...
|
...
|
@@ -427,15 +440,20 @@ class HelperSearch |
|
|
if ($key && !in_array($key, $index_key) && !is_numeric($key)) {
|
|
|
$index['index'] = strtolower(($key));
|
|
|
$index['name'] = $key;
|
|
|
$result['brandIndex'][] = $index;
|
|
|
$index_key[] = $index;
|
|
|
}
|
|
|
if ($key && !in_array($key, $index_key) && is_numeric($key) && count($result['brandIndex']) === 1) {
|
|
|
$index['index'] = '0-9';
|
|
|
$index['name'] = '0~9';
|
|
|
$result['brandIndex'][] = $index;
|
|
|
}
|
|
|
if (is_array($val)) {
|
|
|
foreach ($val as $v) {
|
|
|
$result['brandsShow'][] = $v;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$result['brandIndex'] = array_merge($result['brandIndex'], $index_key);
|
|
|
unset($brandList);
|
|
|
}
|
|
|
//搜索页已选中,返回空
|
...
|
...
|
@@ -952,9 +970,6 @@ class HelperSearch |
|
|
public static function getDiscount(array $list = array())
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (empty($list)) {
|
|
|
return array();
|
|
|
}
|
|
|
$query = array();
|
|
|
$total = 0;
|
|
|
foreach ($list as $k => $v) {
|
...
|
...
|
@@ -1141,7 +1156,7 @@ class HelperSearch |
|
|
if (isset($options['controller']) && $options['controller'] == 'Search' && isset($param['query'])) {
|
|
|
self::$listNav[1] = array(
|
|
|
'href' => '',
|
|
|
'name' => "‘".$param['query']."’ 共".$total."个结果"
|
|
|
'name' => '搜索“<span id="nav_keyword">'.$param['query'].'</span>”共<span id="nav_keyword_count">'.$total.'</span>个结果'
|
|
|
);
|
|
|
}else{
|
|
|
self::$listNav[1] = array(
|
...
|
...
|
|