SamiKoen commited on
Commit
3dd7ea5
·
verified ·
1 Parent(s): 24d840d

XML stokta olmayan ürünler için de fiyat bilgisi saklanacak

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -323,8 +323,21 @@ if root is not None:
323
  product_info.append("") # Boş resim URL'si
324
 
325
  else:
326
- # Stokta olmayan ürün için sadece stok durumu
327
- product_info = [stock_amount]
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
  products.append((name, product_info, full_name))
330
 
@@ -498,8 +511,13 @@ def chatbot_fn(user_message, history, image=None):
498
  break
499
  for product_info in products:
500
  if word in product_info[0] or word in product_info[2].lower():
501
- if product_info[1][0] == "stokta":
502
- normal_price = f"\\nFiyat: {product_info[1][1]} TL"
 
 
 
 
 
503
 
504
  rebate_price = ""
505
  discount_info = ""
 
323
  product_info.append("") # Boş resim URL'si
324
 
325
  else:
326
+ # Stokta olmayan ürün için de fiyat bilgilerini sakla (API için gerekli)
327
+ # Normal fiyat bilgisini al
328
+ price_elem = item.find('priceTaxWithCur')
329
+ price_str = price_elem.text if price_elem is not None and price_elem.text else "Fiyat bilgisi yok"
330
+
331
+ # Ürün URL'si
332
+ product_url_elem = item.find('productLink')
333
+ product_url = product_url_elem.text if product_url_elem is not None and product_url_elem.text else ""
334
+
335
+ # Resim URL'si
336
+ image_elem = item.find('picture1Path')
337
+ image_url = image_elem.text if image_elem is not None and image_elem.text else ""
338
+
339
+ # Stokta olmayan ürün için de tüm bilgileri sakla
340
+ product_info = [stock_amount, price_str, product_url, "", "", "", image_url]
341
 
342
  products.append((name, product_info, full_name))
343
 
 
511
  break
512
  for product_info in products:
513
  if word in product_info[0] or word in product_info[2].lower():
514
+ # API'den stok alındıysa veya ürün stokta ise bilgileri al
515
+ if has_stock_from_api or product_info[1][0] == "stokta":
516
+ # Fiyat bilgisi varsa al
517
+ if len(product_info[1]) > 1 and product_info[1][1]:
518
+ normal_price = f"\\nFiyat: {product_info[1][1]} TL"
519
+ else:
520
+ normal_price = ""
521
 
522
  rebate_price = ""
523
  discount_info = ""