HelperHome.php
2.43 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
<?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, $size = array())
{
$result = array();
foreach ($product as $key => $val) {
if (!empty($size)) {
$img = (isset($val['default_images']) && $val['default_images'])?Images::getImageUrl($val['default_images'], $size['width'], $size['height']) : '';
} else {
$img = (isset($val['default_images']) && $val['default_images'])?Images::getImageUrl($val['default_images'], 100, 100) : '';
// 强制对图片进行切图规则处理 redmine:12390
if (strpos($img, 'imageView')) {
$img = strstr($img, 'imageView', true) . 'imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/90';
}
}
$result[] = array(
'href' => Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['product_skc'], $val['cn_alphabet']),
'thumb' => $img,
'name' => $val['product_name'],
'price' => $val['sales_price'],
'productId' => $val['product_id'],
);
}
return $result;
}
}