Showing
1 changed file
with
18 additions
and
11 deletions
@@ -197,11 +197,12 @@ class InfoModel | @@ -197,11 +197,12 @@ class InfoModel | ||
197 | foreach ($val['list'] as $k => $v) { | 197 | foreach ($val['list'] as $k => $v) { |
198 | $groupSkn[$key][] = $v['id']; | 198 | $groupSkn[$key][] = $v['id']; |
199 | $productSkn[] = $v['id']; | 199 | $productSkn[] = $v['id']; |
200 | + $arr[$v['id']]=$v['src']; | ||
200 | } | 201 | } |
201 | if (!empty($productSkn)) { | 202 | if (!empty($productSkn)) { |
202 | $product = SearchData::searchElasticByCondition(array('query' => implode(',', $productSkn))); | 203 | $product = SearchData::searchElasticByCondition(array('query' => implode(',', $productSkn))); |
203 | if (isset($product['data']['product_list'])) { | 204 | if (isset($product['data']['product_list'])) { |
204 | - $result[$key]['recos'] = array_slice(self::formatProduct($product['data']['product_list']), 0, 4); | 205 | + $result[$key]['recos'] = array_slice(self::formatProduct($product['data']['product_list'], $arr), 0, 4); |
205 | } | 206 | } |
206 | } | 207 | } |
207 | } | 208 | } |
@@ -218,11 +219,12 @@ class InfoModel | @@ -218,11 +219,12 @@ class InfoModel | ||
218 | $result = $productSkn = array(); | 219 | $result = $productSkn = array(); |
219 | foreach ($goods as $key => $val) { | 220 | foreach ($goods as $key => $val) { |
220 | $productSkn[] = $val['id']; | 221 | $productSkn[] = $val['id']; |
222 | + $arr[$val['id']]=$val['src']; | ||
221 | } | 223 | } |
222 | if (!empty($productSkn)) { | 224 | if (!empty($productSkn)) { |
223 | $product = SearchData::searchElasticByCondition(array('query'=> implode(',', $productSkn))); | 225 | $product = SearchData::searchElasticByCondition(array('query'=> implode(',', $productSkn))); |
224 | if (isset($product['data']['product_list'])) { | 226 | if (isset($product['data']['product_list'])) { |
225 | - $result = self::formatProduct($product['data']['product_list']); | 227 | + $result = self::formatProduct($product['data']['product_list'], $arr); |
226 | } | 228 | } |
227 | } else { | 229 | } else { |
228 | return array(); | 230 | return array(); |
@@ -330,22 +332,27 @@ class InfoModel | @@ -330,22 +332,27 @@ class InfoModel | ||
330 | * @param $product | 332 | * @param $product |
331 | * @return arr | 333 | * @return arr |
332 | */ | 334 | */ |
333 | - public static function formatProduct($product) | 335 | + public static function formatProduct($product, $arr) |
334 | { | 336 | { |
335 | $result = array(); | 337 | $result = array(); |
338 | + foreach ($arr as $k => $v) { | ||
336 | foreach ($product as $key => $val) { | 339 | foreach ($product as $key => $val) { |
337 | - if (empty($val['default_images'])) { | ||
338 | - $val['default_images'] = $val['goods_list'][0]['images_url']; | ||
339 | - } | ||
340 | - $result[$key]['thumb'] = Images::getImageUrl($val['default_images'],235,314); | ||
341 | - $result[$key]['name'] = $val['product_name']; | 340 | + $goods = array(); |
341 | + $goods['thumb'] = Images::getImageUrl($val['default_images'],235,314); | ||
342 | + $goods['name'] = $val['product_name']; | ||
342 | //市场价不等于售价时显示 | 343 | //市场价不等于售价时显示 |
343 | if ($val['market_price'] != $val['sales_price']) { | 344 | if ($val['market_price'] != $val['sales_price']) { |
344 | - $result[$key]['marketPrice'] = $val['market_price']; | 345 | + $goods['marketPrice'] = $val['market_price']; |
346 | + } | ||
347 | + $goods['salePrice'] = $val['sales_price']; | ||
348 | + $goods['url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['goods_id'], $val['cn_alphabet']);; | ||
349 | + if ($k == $val['product_skn']) { | ||
350 | + $goods['thumb'] = Images::getImageUrl($v,235,314); | ||
351 | + $result[] = $goods; | ||
345 | } | 352 | } |
346 | - $result[$key]['salePrice'] = $val['sales_price']; | ||
347 | - $result[$key]['url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['goods_id'], $val['cn_alphabet']);; | ||
348 | } | 353 | } |
354 | + } | ||
355 | + | ||
349 | return $result; | 356 | return $result; |
350 | } | 357 | } |
351 | 358 |
-
Please register or login to post a comment