Authored by 周少峰

search api

... ... @@ -609,4 +609,20 @@ class SearchData
return Yohobuy::get(API_URL, $param);
}
public static function webSearchByCondition(array $condition, $isOnlyUrl = false) {
$result = array();
if(!empty($condition)) {
$param = Yohobuy::param();
$param['method'] = 'web.search.search';
$param += $condition;
$param['client_secret'] = Sign::getSign($param);
if($isOnlyUrl) {
return Yohobuy::httpBuildQuery(API_URL, $param);
}
$result = Yohobuy::get(API_URL, $param);
}
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -229,7 +229,7 @@ class InfoModel
$arr[$val['id']]=$val['src'];
}
if (!empty($productSkn)) {
$product = SearchData::searchElasticByCondition(array('query'=> implode(',', $productSkn)));
$product = SearchData::webSearchByCondition(array('query'=> implode(',', $productSkn), 'viewNum' => 100));
if (isset($product['data']['product_list'])) {
$result = self::formatProduct($product['data']['product_list'], $arr);
}
... ...
... ... @@ -66,7 +66,7 @@ class IndexModel
//新品上架
$productParam['new'] = 'Y';
$productParam['viewNum'] = 10;
$url['new'] = SearchData::getProductUrl($productParam);
$url['new'] = SearchData::webSearchByCondition($productParam, true);
//调用接口数据
$data = Yohobuy::getMulti($url);
//格式化数据
... ...