Brands.php
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace Product;
use Api\Yohobuy;
use Plugin\HelperSearch;
use LibModels\Web\Product\BrandData;
use Product\SearchModel;
/**
* 品牌首页模板数据模型
*
* @author Administrator
*/
class BrandsModel
{
/**
* 搜索品牌数据
* @param $condition array 搜索数据的条件
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options)
{
// 并行调用品牌相关接口并封装数据
$data = self::getBrandData($condition, $options);
//获取品牌系列数据
$adNav = self::getAdNav($options['brandId']);
$data['leftContent'][] = array('picLink' => $adNav);
//获取静态内容(eg:20141219-100447)
if($options['node']){
$nodeContent = HelperSearch::formatNodeContent($options['node']);
$data['leftContent'][]['picLink']['list'] = $nodeContent;
}
return $data;
}
//获取品牌系列数据
public static function getAdNav($brandId, $status = 1)
{
//调用接口获得数据
$advNav = BrandData::getFolderByBrand($brandId, $status);
$result = array();
if (isset($advNav['data']) && $advNav['code'] === 200) {
foreach ($advNav['data'] as $key => $value) {
$result['list'][$key]['href'] = '?folder_id=' . $value['id'];
$result['list'][$key]['src'] = $value['brand_sort_ico'];
}
$result['picTitle'] = '经典系列';
}
return $result;
}
/**
* 根据条件获取搜索数据
* @param array $customCondition
* @param array $customOptions
* @return array
*/
public static function getBrandData($customCondition = array(), $customOptions = array())
{
$urlList = array();
//获取$condition和$option 筛选条件和排序条件
$searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
// 组合搜索商品url
$urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
//组合搜索品牌url
$urlList['brand'] = HelperSearch::getBrandUrl($customOptions);
//组合获取品牌banner url
$urlList['banner'] = HelperSearch::getBannerUrl($customOptions);
//组合用户浏览记录url
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
//批量调接口
$result = Yohobuy::getMulti($urlList, array(), true);
//组织模板数据格式
$data = HelperSearch::getList($result, $searchCondition['options']);
return $data;
}
}