поиск+доставка

This commit is contained in:
Alisa
2026-06-07 13:12:42 +03:00
parent 65d182b4af
commit ee753429e2
20 changed files with 3429 additions and 91 deletions
+17
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Repositories;
use App\Services\PriceTierService;
use App\Services\SmartSearchService;
final class ProductRepository extends BaseRepository
{
@@ -51,6 +52,22 @@ final class ProductRepository extends BaseRepository
return (int) $statement->fetchColumn();
}
/**
* @return array{products: array<int, array<string, mixed>>, total: int}
*/
public function searchCatalog(string $query, int $limit = 48, int $offset = 0, bool $includeHidden = false): array
{
$limit = max(1, min($limit, 5000));
$offset = max(0, $offset);
$products = $this->catalogPreview(5000, 0, $includeHidden);
$rankedProducts = (new SmartSearchService())->rankProducts($query, $products);
return [
'products' => array_slice($rankedProducts, $offset, $limit),
'total' => count($rankedProducts),
];
}
/**
* @return array<int, array<string, mixed>>
*/