Authored by 周少峰

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

@@ -232,6 +232,10 @@ class HelperSearch @@ -232,6 +232,10 @@ class HelperSearch
232 'thumb' => $val['default_images'], 232 'thumb' => $val['default_images'],
233 'name' => $val['product_name'], 233 'name' => $val['product_name'],
234 'salePrice' => $val['sales_price'], 234 'salePrice' => $val['sales_price'],
  235 + 'brand' => array(
  236 + 'url' => Helpers::url('', '', $val['brand_domain']),
  237 + 'name' => $val['brand_name']
  238 + ),
235 'isFew' => $isFew, 239 'isFew' => $isFew,
236 'skn' => $val['product_skn'], 240 'skn' => $val['product_skn'],
237 'showColBtn' => true, 241 'showColBtn' => true,
@@ -492,7 +496,7 @@ class HelperSearch @@ -492,7 +496,7 @@ class HelperSearch
492 $existName[] = $v['brand_name']; 496 $existName[] = $v['brand_name'];
493 } 497 }
494 if ($existBrandNum === 1){ 498 if ($existBrandNum === 1){
495 - $existName[]= substr($v['brand_name'], 0, 3).'...'; 499 + $existName[]= substr($v['brand_name'], 0, 4).'...';
496 } 500 }
497 $existBrandNum++; 501 $existBrandNum++;
498 } 502 }
@@ -547,9 +551,30 @@ class HelperSearch @@ -547,9 +551,30 @@ class HelperSearch
547 if (self::checkSearch('brand')) { 551 if (self::checkSearch('brand')) {
548 return array(); 552 return array();
549 } 553 }
550 - //品牌数量小于等于10,隐藏更多按钮  
551 - $result['showMulti'] = count($result['brandsShow']) > 1 ? true :false;  
552 - $result['showMore'] = count($result['brandsShow']) > 10 ? true :false; 554 + //品牌数量等于1,设置为已选中
  555 + $totalBrand = count($result['brandsShow']);
  556 + if ($totalBrand == 1) {
  557 + if (!in_array($totalBrand, $brandIds)) {
  558 + //设置已选中
  559 + self::$selected['brand'] = array(
  560 + 'name' => $result['brandsShow'][0]['name'],
  561 + 'href' => self::buildUrl($params, array('brand', $result['brandsShow'][0]['href']))
  562 + );
  563 + $result['default'][0]['checked'] = true;
  564 + }
  565 + if (self::$options['controller'] == 'Search') {
  566 + return array();
  567 + }
  568 + }
  569 + //品牌数量大于1小于10,显示多选
  570 + elseif ($totalBrand > 1 && $totalBrand < 10) {
  571 + $result['showMulti'] = true;
  572 + }
  573 + //品牌数量大于10,显示多选、更多按钮
  574 + else {
  575 + $result['showMulti'] = true;
  576 + $result['showMore'] = true;
  577 + }
553 return $result; 578 return $result;
554 } 579 }
555 /** 580 /**
@@ -1380,7 +1405,12 @@ class HelperSearch @@ -1380,7 +1405,12 @@ class HelperSearch
1380 $action = isset(self::$options['action']) ? strtolower(self::$options['action']) : ''; 1405 $action = isset(self::$options['action']) ? strtolower(self::$options['action']) : '';
1381 //列表页面 1406 //列表页面
1382 if ($controller == 'list' && $action == 'index') { 1407 if ($controller == 'list' && $action == 'index') {
1383 - $type = isset(self::$params['msort']) && self::$params['msort'] ? self::$params['msort'] : ''; 1408 + if (isset(self::$params['misort'])) {
  1409 + $type = self::$params['misort'];
  1410 + }
  1411 + elseif (isset(self::$params['msort'])) {
  1412 + $type = self::$params['msort'];
  1413 + }
1384 } 1414 }
1385 //新品到着 1415 //新品到着
1386 elseif ($controller == 'list' && $action == 'new') { 1416 elseif ($controller == 'list' && $action == 'new') {