HelperHome.php
1.84 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
<?php
namespace WebPlugin;
use WebPlugin\Paging;
use WebPlugin\Helpers;
use LibModels\Web\Product\BrandData;
use Configs\ChannelConfig;
/**
* 搜索辅助类
*/
class HelperHome
{
/**
* 格式化喜欢的品牌
* @param $brandInfo
* @param int $i
* @return array
*/
public static function formatFavBrand($brandInfo, $i = 10)
{
//取前20个热销品牌
$hotBrands = array();
if ($brandInfo) {
foreach ($brandInfo as $value) {
if (isset($value['is_hot']) && $value['is_hot'] == 'Y') {
$hotBrands[] = array(
'href' => Helpers::url('', '', $value['brand_domain']),
'logo' => Images::getSourceUrl($value['brand_ico'], 'brandLogo'),
'name' => $value['brand_name'],
);
$i--;
}
if ($i <= 0) {
break;
}
}
}
return $hotBrands;
}
/**
* 格式化新品上架数据(个人中心)
* @param $product
* @return array
*/
public static function formatNew($product)
{
$result = array();
foreach ($product as $key => $val) {
$result[] = array(
'href' => Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['product_skc'], $val['cn_alphabet']),
'thumb' => (isset($val['default_images']) && $val['default_images'])?Images::getImageUrl($val['default_images'], 400, 500) : '',
'name' => $val['product_name'],
'price' => $val['sales_price'],
'productId' => $val['product_id'],
);
}
return $result;
}
}