Authored by yyq

web skc @ by yangyang

... ... @@ -197,11 +197,12 @@ class InfoModel
foreach ($val['list'] as $k => $v) {
$groupSkn[$key][] = $v['id'];
$productSkn[] = $v['id'];
$arr[$v['id']]=$v['src'];
}
if (!empty($productSkn)) {
$product = SearchData::searchElasticByCondition(array('query' => implode(',', $productSkn)));
if (isset($product['data']['product_list'])) {
$result[$key]['recos'] = array_slice(self::formatProduct($product['data']['product_list']), 0, 4);
$result[$key]['recos'] = array_slice(self::formatProduct($product['data']['product_list'], $arr), 0, 4);
}
}
}
... ... @@ -218,11 +219,12 @@ class InfoModel
$result = $productSkn = array();
foreach ($goods as $key => $val) {
$productSkn[] = $val['id'];
$arr[$val['id']]=$val['src'];
}
if (!empty($productSkn)) {
$product = SearchData::searchElasticByCondition(array('query'=> implode(',', $productSkn)));
if (isset($product['data']['product_list'])) {
$result = self::formatProduct($product['data']['product_list']);
$result = self::formatProduct($product['data']['product_list'], $arr);
}
} else {
return array();
... ... @@ -330,22 +332,27 @@ class InfoModel
* @param $product
* @return arr
*/
public static function formatProduct($product)
public static function formatProduct($product, $arr)
{
$result = array();
foreach ($arr as $k => $v) {
foreach ($product as $key => $val) {
if (empty($val['default_images'])) {
$val['default_images'] = $val['goods_list'][0]['images_url'];
}
$result[$key]['thumb'] = Images::getImageUrl($val['default_images'],235,314);
$result[$key]['name'] = $val['product_name'];
$goods = array();
$goods['thumb'] = Images::getImageUrl($val['default_images'],235,314);
$goods['name'] = $val['product_name'];
//市场价不等于售价时显示
if ($val['market_price'] != $val['sales_price']) {
$result[$key]['marketPrice'] = $val['market_price'];
$goods['marketPrice'] = $val['market_price'];
}
$goods['salePrice'] = $val['sales_price'];
$goods['url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['goods_id'], $val['cn_alphabet']);;
if ($k == $val['product_skn']) {
$goods['thumb'] = Images::getImageUrl($v,235,314);
$result[] = $goods;
}
$result[$key]['salePrice'] = $val['sales_price'];
$result[$key]['url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['goods_id'], $val['cn_alphabet']);;
}
}
return $result;
}
... ...