Authored by 周少峰

仅剩下一个品牌设置为默认,搜索结果每个商品显示品牌,列表from参数设置

... ... @@ -232,6 +232,10 @@ class HelperSearch
'thumb' => $val['default_images'],
'name' => $val['product_name'],
'salePrice' => $val['sales_price'],
'brand' => array(
'url' => Helpers::url('', '', $val['brand_domain']),
'name' => $val['brand_name']
),
'isFew' => $isFew,
'skn' => $val['product_skn'],
'showColBtn' => true,
... ... @@ -492,7 +496,7 @@ class HelperSearch
$existName[] = $v['brand_name'];
}
if ($existBrandNum === 1){
$existName[]= substr($v['brand_name'], 0, 3).'...';
$existName[]= substr($v['brand_name'], 0, 4).'...';
}
$existBrandNum++;
}
... ... @@ -547,9 +551,30 @@ class HelperSearch
if (self::checkSearch('brand')) {
return array();
}
//品牌数量小于等于10,隐藏更多按钮
$result['showMulti'] = count($result['brandsShow']) > 1 ? true :false;
$result['showMore'] = count($result['brandsShow']) > 10 ? true :false;
//品牌数量等于1,设置为已选中
$totalBrand = count($result['brandsShow']);
if ($totalBrand == 1) {
if (!in_array($totalBrand, $brandIds)) {
//设置已选中
self::$selected['brand'] = array(
'name' => $result['brandsShow'][0]['name'],
'href' => self::buildUrl($params, array('brand', $result['brandsShow'][0]['href']))
);
$result['default'][0]['checked'] = true;
}
if (self::$options['controller'] == 'Search') {
return array();
}
}
//品牌数量大于1小于10,显示多选
elseif ($totalBrand > 1 && $totalBrand < 10) {
$result['showMulti'] = true;
}
//品牌数量大于10,显示多选、更多按钮
else {
$result['showMulti'] = true;
$result['showMore'] = true;
}
return $result;
}
/**
... ... @@ -1380,7 +1405,12 @@ class HelperSearch
$action = isset(self::$options['action']) ? strtolower(self::$options['action']) : '';
//列表页面
if ($controller == 'list' && $action == 'index') {
$type = isset(self::$params['msort']) && self::$params['msort'] ? self::$params['msort'] : '';
if (isset(self::$params['misort'])) {
$type = self::$params['misort'];
}
elseif (isset(self::$params['msort'])) {
$type = self::$params['msort'];
}
}
//新品到着
elseif ($controller == 'list' && $action == 'new') {
... ...