提交 ec664a54 编写于 作者: T Terry

搜索功能:新增sku精准搜索

上级 efbe92a1
......@@ -219,6 +219,14 @@ class MongoSearch extends Service implements SearchInterface
*/
protected function actionGetSearchProductColl($select, $where, $pageNum, $numPerPage, $product_search_max_count)
{
// 先进行sku搜索,如果有结果,说明是针对sku的搜索
$searchText = $where['$text']['$search'];
$productM = Yii::$service->product->getBySku($searchText);
if ($productM) {
$collection['coll'][] = $productM;
$collection['count'] = 1;
} else {
$filter = [
'pageNum' => $pageNum,
'numPerPage' => $numPerPage,
......@@ -228,8 +236,9 @@ class MongoSearch extends Service implements SearchInterface
];
//var_dump($filter);exit;
$collection = $this->fullTearchText($filter);
}
$collection['coll'] = Yii::$service->category->product->convertToCategoryInfo($collection['coll']);
//var_dump($collection);
return $collection;
}
......
......@@ -132,6 +132,13 @@ class XunSearch extends Service implements SearchInterface
protected function fullTearchText($select, $where, $pageNum, $numPerPage, $product_search_max_count)
{
$searchText = $where['$text']['$search'];
$productM = Yii::$service->product->getBySku($searchText);
$productIds = [];
if ($productM) {
$productIds[] = $productM['_id'];
} else {
$XunSearchQuery = $this->_searchModel->find()->asArray();
$XunSearchQuery->fuzzy($this->fuzzy);
$XunSearchQuery->synonyms($this->synonyms);
......@@ -169,6 +176,7 @@ class XunSearch extends Service implements SearchInterface
}
$productIds = array_slice($productIds, $offset, $limit);
}
if (!empty($productIds)) {
$query = $this->_productModel->find()->asArray()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册