ClassProcess.php
1.06 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
<?php
namespace Plugin\DataProcess;
/**
* 分类数据处理类
*/
class ClassProcess
{
/**
* 处理品类数据
* @param $data
* @return array 处理之后的品类数据
*/
public static function getClassData($data)
{
$num = 1;
$classes = array();
foreach ($data as $k => $v){
$oneClass = array('name'=>$k, 'ca'=>array());
if($num === 1)
{
$oneClass['focus'] = true;
}
foreach ($v as $val) {
$item = array();
$item['name'] = $val['category_name'];
foreach ($val['sub'] as $value) {
$subitem = array();
$subitem['name'] = $value['category_name'];
$subitem['url'] = $value['category_id'];
$item['sub'][] = $subitem;
}
$oneClass['ca'][] = $item;
}
$num++;
$classes[] = $oneClass;
}
return $classes;
}
}