This commit is contained in:
2026-05-06 23:19:35 +02:00
parent 34e6b6373f
commit b1b5e416ba
16 changed files with 1448 additions and 65 deletions

View File

@@ -440,18 +440,36 @@ class XmlFeedImporter
}
else
{
$insert_stmt -> execute( [
':client_id' => $client_id,
':offer_id' => $item['offer_id'],
':title' => $title,
':description' => $desc,
':custom_label_1' => $cl1,
':price' => $price,
] );
$inserted_count++;
if ( $is_debug_offer )
try
{
$report['debug_offer']['inserted'] = true;
$insert_stmt -> execute( [
':client_id' => $client_id,
':offer_id' => $item['offer_id'],
':title' => $title,
':description' => $desc,
':custom_label_1' => $cl1,
':price' => $price,
] );
$inserted_count++;
if ( $is_debug_offer ) $report['debug_offer']['inserted'] = true;
}
catch ( \PDOException $pe )
{
// 1062 = race condition z UNIQUE KEY (client_id, offer_id) - aktualizuj zamiast wstawiac
if ( strpos( (string) $pe -> getMessage(), '1062' ) === false ) throw $pe;
$existing_id = (int) $pdo -> query( 'SELECT id FROM products WHERE client_id = ' . (int) $client_id . ' AND offer_id = ' . $pdo -> quote( (string) $item['offer_id'] ) . ' LIMIT 1' ) -> fetchColumn();
if ( $existing_id > 0 )
{
$update_stmt -> execute( [
':title' => $title,
':description' => $desc,
':custom_label_1' => $cl1,
':price' => $price,
':id' => $existing_id,
] );
$updated_count++;
if ( $is_debug_offer ) $report['debug_offer']['updated_via_race_fallback'] = true;
}
}
}
}