feat: 产品搜索页

This commit is contained in:
2025-05-13 15:47:38 +08:00
parent e431dcd6d0
commit 2e29b169bf
3 changed files with 68 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ declare (strict_types = 1);
namespace app\index\model;
use app\common\model\ProductBaseModel;
use think\facade\Db;
use think\model\concern\SoftDelete;
/**
@@ -74,4 +75,10 @@ class ProductModel extends ProductBaseModel
{
$query->where('is_new', '=', (int)$stat);
}
// 关键词搜索
public function searchKeywordsAttr($query, string $keywords)
{
$query->whereRaw('BINARY spu LIKE "%' . $keywords . '%" OR BINARY name LIKE "%' . $keywords . '%" OR BINARY short_name LIKE "%' . $keywords . '%"');
}
}