...
|
...
|
@@ -73,35 +73,35 @@ class SearchController extends AbstractAction |
|
|
'discount' => FILTER_VALIDATE_INT,
|
|
|
'gender' => FILTER_DEFAULT,
|
|
|
'p_d' => FILTER_DEFAULT,), false);
|
|
|
|
|
|
|
|
|
$query = isset($condition['query']) ? strtolower(trim($condition['query'])) : null;
|
|
|
|
|
|
|
|
|
// 标识用户是否有输入搜索内容
|
|
|
$haveQuery = $query !== null;
|
|
|
// 标识用户搜的是不是一级品类
|
|
|
$isQueryFirstClass = false;
|
|
|
// 标识用户搜的是不是二级品类
|
|
|
$isQuerySecondClass = false;
|
|
|
|
|
|
|
|
|
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框) */
|
|
|
if ($haveQuery) {
|
|
|
$domain = null;
|
|
|
$brandNames = Product\ListModel::getAllBrandNames();
|
|
|
|
|
|
|
|
|
do {
|
|
|
/* 精确查品牌域名 */
|
|
|
if (isset($brandNames[$query])) {
|
|
|
$domain = $query;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 精确查品牌名称 */
|
|
|
$domains = array_keys($brandNames, $query, true);
|
|
|
if (isset($domains[0])) {
|
|
|
$domain = $domains[0];
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 模糊查品牌域名 */
|
|
|
foreach ($brandNames as $key => $domains) {
|
|
|
if (strpos($key, $query) !== false) {
|
...
|
...
|
@@ -110,22 +110,22 @@ class SearchController extends AbstractAction |
|
|
}
|
|
|
}
|
|
|
} while (false);
|
|
|
|
|
|
|
|
|
// 清空变量做释放
|
|
|
$brandNames = array();
|
|
|
|
|
|
|
|
|
// 跳转到品牌商品列表页
|
|
|
if ($domain !== null) {
|
|
|
$url = Helpers::url('', array(
|
|
|
'from' => 'search',
|
|
|
'query' => $query,
|
|
|
'gender' => $condition['gender']
|
|
|
), $domain);
|
|
|
'from' => 'search',
|
|
|
'query' => $query,
|
|
|
'gender' => $condition['gender']
|
|
|
), $domain);
|
|
|
$this->go($url);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 判断是不是品类, 是品类加导航标题(不显示搜索框) */
|
|
|
if ($haveQuery) {
|
|
|
$classNames = Category\ClassModel::getClassNames();
|
...
|
...
|
@@ -137,30 +137,29 @@ class SearchController extends AbstractAction |
|
|
$isQueryFirstClass = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 精确查二级品类 */
|
|
|
$sorts = array_keys($classNames['second'], $query, true);
|
|
|
if (isset($sorts[0])) {
|
|
|
$isQuerySecondClass = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
while (false);
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
$classNames = array();
|
|
|
}
|
|
|
|
|
|
|
|
|
$data = array();
|
|
|
// 搜索是一级品类
|
|
|
if ($isQueryFirstClass) {
|
|
|
$this->setTitle('全部' . $query);
|
|
|
$this->setNavHeader('全部' . $query, true, SITE_MAIN);
|
|
|
}
|
|
|
}
|
|
|
// 搜索是二级品类
|
|
|
elseif ($isQuerySecondClass) {
|
|
|
$this->setTitle($query);
|
|
|
$this->setNavHeader($query, true, SITE_MAIN);
|
|
|
}
|
|
|
}
|
|
|
// 搜索其它内容
|
|
|
else {
|
|
|
if ($haveQuery) {
|
...
|
...
|
@@ -170,25 +169,29 @@ class SearchController extends AbstractAction |
|
|
$this->setTitle('搜索');
|
|
|
$this->setNavHeader('搜索', true, SITE_MAIN);
|
|
|
}
|
|
|
|
|
|
|
|
|
$data['goodListPage'] = true;
|
|
|
$data['goodList'] = $condition;
|
|
|
|
|
|
// 查询数据
|
|
|
$listData = SearchData::searchByCondition($condition);
|
|
|
// 处理返回的数据
|
|
|
if (!empty($listData['data']['brand'])) {
|
|
|
$brandData = $listData['data']['brand'];
|
|
|
$data['brandWay'] = array(
|
|
|
'url' => 'http://'. $brandData['brand_domain'] . SUB_DOMAIN,
|
|
|
'thumb' => Helpers::getImageUrl($brandData['brand_ico'], 75, 40),
|
|
|
'name' => $brandData['brand_name']
|
|
|
);
|
|
|
// 设置品牌默认值
|
|
|
$data['goodList']['brand'] = $brandData['id'];
|
|
|
$data['goodList'] += ListProcess::getListData($listData['data']);
|
|
|
if (!isset($condition['query'])) {
|
|
|
$data['goodList'] += Product\ListModel::getClassData($condition);
|
|
|
} else {
|
|
|
$listData = SearchData::searchByCondition($condition);
|
|
|
// 处理返回的数据
|
|
|
if (!empty($listData['data']['brand'])) {
|
|
|
$brandData = $listData['data']['brand'];
|
|
|
$data['brandWay'] = array(
|
|
|
'url' => 'http://' . $brandData['brand_domain'] . SUB_DOMAIN,
|
|
|
'thumb' => Helpers::getImageUrl($brandData['brand_ico'], 75, 40),
|
|
|
'name' => $brandData['brand_name']
|
|
|
);
|
|
|
// 设置品牌默认值
|
|
|
$data['goodList']['brand'] = $brandData['id'];
|
|
|
$data['goodList'] += ListProcess::getListData($listData['data']);
|
|
|
}
|
|
|
$listData = array();
|
|
|
}
|
|
|
$listData = array();
|
|
|
|
|
|
$this->_view->display('list', $data);
|
|
|
}
|
...
|
...
|
@@ -211,7 +214,7 @@ class SearchController extends AbstractAction |
|
|
'price' => FILTER_VALIDATE_INT,
|
|
|
'discount' => FILTER_DEFAULT,
|
|
|
'gender' => FILTER_DEFAULT,
|
|
|
'p_d' => FILTER_DEFAULT, ), false);
|
|
|
'p_d' => FILTER_DEFAULT,), false);
|
|
|
|
|
|
// 转换排序方式
|
|
|
$page = $this->get('page', 1);
|
...
|
...
|
@@ -232,15 +235,23 @@ class SearchController extends AbstractAction |
|
|
|
|
|
$data = array();
|
|
|
// 查询数据
|
|
|
$listData = SearchData::searchByCondition($condition, $order, $page);
|
|
|
// 处理返回的数据
|
|
|
if (isset($listData['data'])) {
|
|
|
if (isset($listData['data']['filter'])) {
|
|
|
unset($listData['data']['filter']);
|
|
|
if (!isset($condition['query'])) {
|
|
|
$data += Product\ListModel::getClassData($condition);
|
|
|
if (isset($data['filter'])) {
|
|
|
unset($data['filter']);
|
|
|
}
|
|
|
} else {
|
|
|
// 查询数据
|
|
|
$listData = SearchData::searchByCondition($condition, $order, $page);
|
|
|
// 处理返回的数据
|
|
|
if (isset($listData['data'])) {
|
|
|
if (isset($listData['data']['filter'])) {
|
|
|
unset($listData['data']['filter']);
|
|
|
}
|
|
|
$data = ListProcess::getListData($listData['data']);
|
|
|
}
|
|
|
$data = ListProcess::getListData($listData['data']);
|
|
|
$listData = array();
|
|
|
}
|
|
|
$listData = array();
|
|
|
|
|
|
if (empty($data)) {
|
|
|
echo ' ';
|
...
|
...
|
|