fix: use Item.brand for eBay pricing match
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -326,27 +326,20 @@ def _upsert_system_pricing(manufacturer, model, pricing):
|
|||||||
|
|
||||||
|
|
||||||
def _update_item_market_data(manufacturer, model, pricing):
|
def _update_item_market_data(manufacturer, model, pricing):
|
||||||
|
clean_mfr = clean_manufacturer(manufacturer)
|
||||||
|
model_lower = model.lower()
|
||||||
|
|
||||||
|
# Match by brand (exact) + item_name (contains model)
|
||||||
items = frappe.get_all(
|
items = frappe.get_all(
|
||||||
"Item",
|
"Item",
|
||||||
filters={
|
filters={
|
||||||
"item_group": ["in", ["Laptop", "Desktop", "Tablet", "Phone", "Workstation"]],
|
"item_group": ["in", ["Laptop", "Desktop", "Tablet", "Phone", "Workstation"]],
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
|
"brand": clean_mfr,
|
||||||
},
|
},
|
||||||
fields=["name", "item_name", "brand"],
|
fields=["name", "item_name"],
|
||||||
)
|
)
|
||||||
clean_mfr = clean_manufacturer(manufacturer).lower()
|
|
||||||
model_lower = model.lower()
|
|
||||||
matched = None
|
matched = None
|
||||||
for item in items:
|
|
||||||
item_name_lower = (item.item_name or "").lower()
|
|
||||||
brand_lower = (item.brand or "").lower()
|
|
||||||
if model_lower in item_name_lower:
|
|
||||||
if clean_mfr in brand_lower or brand_lower in clean_mfr or clean_mfr in item_name_lower:
|
|
||||||
matched = item.name
|
|
||||||
break
|
|
||||||
elif matched is None:
|
|
||||||
matched = item.name
|
|
||||||
if not matched:
|
|
||||||
for item in items:
|
for item in items:
|
||||||
item_name_lower = (item.item_name or "").lower()
|
item_name_lower = (item.item_name or "").lower()
|
||||||
if model_lower in item_name_lower:
|
if model_lower in item_name_lower:
|
||||||
@@ -387,13 +380,15 @@ def _log_api_call(manufacturer, model, search_query, source, results_count, stat
|
|||||||
def run_batch(batch_size=10, source="auto", force=False):
|
def run_batch(batch_size=10, source="auto", force=False):
|
||||||
batch_size = int(batch_size) if batch_size != "all" else 999999
|
batch_size = int(batch_size) if batch_size != "all" else 999999
|
||||||
force = bool(force)
|
force = bool(force)
|
||||||
|
# Get unique models from Items that have serials
|
||||||
models = frappe.db.sql(
|
models = frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
SELECT DISTINCT manufacturer, model
|
SELECT DISTINCT i.brand as manufacturer, i.item_name as model
|
||||||
FROM `tabSerial No`
|
FROM `tabItem` i
|
||||||
WHERE manufacturer IS NOT NULL AND manufacturer != ''
|
INNER JOIN `tabSerial No` sn ON sn.item_code = i.name
|
||||||
AND model IS NOT NULL AND model != ''
|
WHERE i.brand IS NOT NULL AND i.brand != ''
|
||||||
ORDER BY creation DESC
|
AND i.disabled = 0
|
||||||
|
ORDER BY i.modified DESC
|
||||||
LIMIT %s
|
LIMIT %s
|
||||||
""",
|
""",
|
||||||
(batch_size,),
|
(batch_size,),
|
||||||
|
|||||||
Reference in New Issue
Block a user