feat(search-by-product): extend order search to include product names

Added EXISTS subquery on order_items.original_name to the search filter
in OrdersRepository::buildPaginateFilters(). Users can now find orders
by typing a product name in the search field. Updated search placeholder
to reflect the new capability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 09:14:40 +02:00
parent 24df01cfde
commit aadf98bc80
8 changed files with 249 additions and 11 deletions

View File

@@ -95,13 +95,14 @@ final class OrdersRepository
$search = trim((string) ($filters['search'] ?? ''));
if ($search !== '') {
$where[] = '(o.source_order_id LIKE :s1 OR o.external_order_id LIKE :s2 OR o.customer_login LIKE :s3 OR a.name LIKE :s4 OR a.email LIKE :s5)';
$where[] = '(o.source_order_id LIKE :s1 OR o.external_order_id LIKE :s2 OR o.customer_login LIKE :s3 OR a.name LIKE :s4 OR a.email LIKE :s5 OR EXISTS (SELECT 1 FROM order_items oi_s WHERE oi_s.order_id = o.id AND oi_s.original_name LIKE :s6))';
$searchVal = '%' . $search . '%';
$params['s1'] = $searchVal;
$params['s2'] = $searchVal;
$params['s3'] = $searchVal;
$params['s4'] = $searchVal;
$params['s5'] = $searchVal;
$params['s6'] = $searchVal;
}
$source = trim((string) ($filters['source'] ?? ''));