|
@@ -70,7 +70,7 @@ class InfoModel |
|
@@ -70,7 +70,7 @@ class InfoModel |
70
|
{
|
70
|
{
|
71
|
$result = array();
|
71
|
$result = array();
|
72
|
//推荐商品列表
|
72
|
//推荐商品列表
|
73
|
- $goods = array();
|
73
|
+ $goods = $goodsGroup = array();
|
74
|
$result['pathNav'] = self::getCenterCrumb($article['article_title'], $channel);
|
74
|
$result['pathNav'] = self::getCenterCrumb($article['article_title'], $channel);
|
75
|
//文章头部信息
|
75
|
//文章头部信息
|
76
|
$result['header']['title'] = $article['article_title'];
|
76
|
$result['header']['title'] = $article['article_title'];
|
|
@@ -88,10 +88,12 @@ class InfoModel |
|
@@ -88,10 +88,12 @@ class InfoModel |
88
|
if (isset($data['contents']) && !empty($data['contents'])) {
|
88
|
if (isset($data['contents']) && !empty($data['contents'])) {
|
89
|
foreach ($data['contents'] as $key => $val) {
|
89
|
foreach ($data['contents'] as $key => $val) {
|
90
|
foreach ($val as $type => $con) {
|
90
|
foreach ($val as $type => $con) {
|
91
|
- if ($type != 'goods') {
|
|
|
92
|
- $result['content'][] = is_callable("self::$type") ? self::$type($con['data']) : '';
|
|
|
93
|
- } else {
|
91
|
+ if ($type === 'goods') {
|
94
|
$goods = array_merge_recursive($goods, self::goods($con['data']));
|
92
|
$goods = array_merge_recursive($goods, self::goods($con['data']));
|
|
|
93
|
+ } elseif ($type === 'goodsGroup') {
|
|
|
94
|
+ $goodsGroup = array_merge_recursive($goodsGroup, self::goodsGroup($con['data']));
|
|
|
95
|
+ } else {
|
|
|
96
|
+ $result['content'] = is_callable("self::$type") ? self::$type($con['data']) : '';
|
95
|
}
|
97
|
}
|
96
|
}
|
98
|
}
|
97
|
}
|
99
|
}
|
|
@@ -99,6 +101,9 @@ class InfoModel |
|
@@ -99,6 +101,9 @@ class InfoModel |
99
|
if (!empty($goods)) {
|
101
|
if (!empty($goods)) {
|
100
|
$result['content'][] = array('relatedReco'=>array('recos'=>$goods));
|
102
|
$result['content'][] = array('relatedReco'=>array('recos'=>$goods));
|
101
|
}
|
103
|
}
|
|
|
104
|
+ if (!empty($goodsGroup)) {
|
|
|
105
|
+ $result['content']['relatedReco'] = $goodsGroup;
|
|
|
106
|
+ }
|
102
|
//赞、收藏
|
107
|
//赞、收藏
|
103
|
if (isset($data['baseInfo']) && !empty($data['baseInfo'])) {
|
108
|
if (isset($data['baseInfo']) && !empty($data['baseInfo'])) {
|
104
|
$result['userInfo']['isLike'] = $data['baseInfo']['isPraise'] == 'Y' ? true : false;
|
109
|
$result['userInfo']['isLike'] = $data['baseInfo']['isPraise'] == 'Y' ? true : false;
|
|
@@ -182,20 +187,21 @@ class InfoModel |
|
@@ -182,20 +187,21 @@ class InfoModel |
182
|
*/
|
187
|
*/
|
183
|
public static function goodsGroup($goodsGroup)
|
188
|
public static function goodsGroup($goodsGroup)
|
184
|
{
|
189
|
{
|
185
|
- $result = $groupSkn = $productSkn = array();
|
190
|
+ $result = $groupSkn = array();
|
186
|
foreach ($goodsGroup as $key => $val) {
|
191
|
foreach ($goodsGroup as $key => $val) {
|
187
|
if (!isset($val['list']) || empty($val['list'])) {
|
192
|
if (!isset($val['list']) || empty($val['list'])) {
|
188
|
continue;
|
193
|
continue;
|
189
|
}
|
194
|
}
|
|
|
195
|
+ $productSkn = array();
|
190
|
foreach ($val['list'] as $k => $v) {
|
196
|
foreach ($val['list'] as $k => $v) {
|
191
|
$groupSkn[$key][] = $v['id'];
|
197
|
$groupSkn[$key][] = $v['id'];
|
192
|
$productSkn[] = $v['id'];
|
198
|
$productSkn[] = $v['id'];
|
193
|
}
|
199
|
}
|
194
|
- }
|
|
|
195
|
- if (!empty($productSkn)) {
|
|
|
196
|
- $product = SearchData::searchElasticByCondition(array('query' => implode(',', $productSkn)));
|
|
|
197
|
- if (isset($product['data']['product_list'])) {
|
|
|
198
|
- $result['relatedReco']['recos'] = array_slice(self::formatProduct($product['data']['product_list']), 0, 4);
|
200
|
+ if (!empty($productSkn)) {
|
|
|
201
|
+ $product = SearchData::searchElasticByCondition(array('query' => implode(',', $productSkn)));
|
|
|
202
|
+ if (isset($product['data']['product_list'])) {
|
|
|
203
|
+ $result[$key]['recos'] = array_slice(self::formatProduct($product['data']['product_list']), 0, 4);
|
|
|
204
|
+ }
|
199
|
}
|
205
|
}
|
200
|
}
|
206
|
}
|
201
|
return $result;
|
207
|
return $result;
|