Varyant detayları eklendi - hangi beden/renk hangi mağazada görünecek
Browse files
app.py
CHANGED
@@ -93,10 +93,11 @@ def get_realtime_stock(product_name):
|
|
93 |
else:
|
94 |
continue
|
95 |
|
96 |
-
# Ürünü ara - TÜM VARYANTLARI TOPLA
|
97 |
-
|
98 |
for product in products:
|
99 |
product_title = normalize_turkish(product.get('title', '')).lower()
|
|
|
100 |
|
101 |
# Tüm arama terimlerinin ürün başlığında olup olmadığını kontrol et
|
102 |
if all(term in product_title for term in search_terms):
|
@@ -106,20 +107,31 @@ def get_realtime_stock(product_name):
|
|
106 |
actual_stock = max(qty, stock) # İkisinden büyük olanı al
|
107 |
|
108 |
if actual_stock > 0:
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
110 |
total_stock += actual_stock
|
111 |
-
# break kaldırıldı - tüm varyantları toplamaya devam et
|
112 |
|
113 |
-
if
|
114 |
-
stock_info[warehouse_name] =
|
115 |
|
116 |
if not stock_info:
|
117 |
return f"{product_name}: Şu anda hiçbir mağazada stokta bulunmuyor."
|
118 |
|
119 |
-
# Minimal prompt oluştur
|
120 |
prompt_lines = [f"{product_name} stok durumu:"]
|
121 |
-
for warehouse,
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
prompt_lines.append(f"Toplam: {total_stock} adet")
|
124 |
|
125 |
return "\n".join(prompt_lines)
|
|
|
93 |
else:
|
94 |
continue
|
95 |
|
96 |
+
# Ürünü ara - TÜM VARYANTLARI TOPLA VE DETAYLARI KAYDET
|
97 |
+
warehouse_variants = []
|
98 |
for product in products:
|
99 |
product_title = normalize_turkish(product.get('title', '')).lower()
|
100 |
+
original_title = product.get('title', '')
|
101 |
|
102 |
# Tüm arama terimlerinin ürün başlığında olup olmadığını kontrol et
|
103 |
if all(term in product_title for term in search_terms):
|
|
|
107 |
actual_stock = max(qty, stock) # İkisinden büyük olanı al
|
108 |
|
109 |
if actual_stock > 0:
|
110 |
+
# Varyant detayını sakla (beden/renk bilgisi için)
|
111 |
+
variant_info = original_title.replace(product_name.upper(), '').strip()
|
112 |
+
if variant_info:
|
113 |
+
warehouse_variants.append(f"{variant_info}: {actual_stock}")
|
114 |
+
else:
|
115 |
+
warehouse_variants.append(f"{actual_stock} adet")
|
116 |
total_stock += actual_stock
|
|
|
117 |
|
118 |
+
if warehouse_variants:
|
119 |
+
stock_info[warehouse_name] = warehouse_variants
|
120 |
|
121 |
if not stock_info:
|
122 |
return f"{product_name}: Şu anda hiçbir mağazada stokta bulunmuyor."
|
123 |
|
124 |
+
# Minimal prompt oluştur - varyant detaylarıyla
|
125 |
prompt_lines = [f"{product_name} stok durumu:"]
|
126 |
+
for warehouse, variants in stock_info.items():
|
127 |
+
if isinstance(variants, list):
|
128 |
+
# Varyant detayları varsa
|
129 |
+
prompt_lines.append(f"- {warehouse}:")
|
130 |
+
for variant in variants:
|
131 |
+
prompt_lines.append(f" • {variant}")
|
132 |
+
else:
|
133 |
+
# Eski format (eğer hata olursa)
|
134 |
+
prompt_lines.append(f"- {warehouse}: {variants} adet")
|
135 |
prompt_lines.append(f"Toplam: {total_stock} adet")
|
136 |
|
137 |
return "\n".join(prompt_lines)
|