fix: improve product search robustness

- search-sheets: ne bloque plus sur l'absence d'ID Shopify en col A
- Shopify GraphQL: first:10 + match exact insensible à la casse au lieu de first:1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 17:54:56 +02:00
parent 920ec50402
commit 36447a5c8c
2 changed files with 27 additions and 19 deletions
+3 -2
View File
@@ -50,9 +50,10 @@ export async function GET(req: NextRequest) {
const refLower = ref.toLowerCase()
const ugsLower = ugs.toLowerCase()
const wordBoundary = new RegExp(`(^|[^a-z0-9])${ugsLower.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([^a-z0-9]|$)`)
const isMatch = ugs && shopifyId && wordBoundary.test(refLower)
// Ne requiert pas shopifyId pour le match UGS — ID peut être absent si produit externe
const isMatch = ugs && wordBoundary.test(refLower)
if (isMatch) {
if (isMatch && shopifyId) {
const title = (row[3] ?? '').trim()
if (!bestMatch || ugs.length > bestMatch.ugsLength) {
bestMatch = { shopifyId, title, ugsLength: ugs.length }