PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC] ); $select = $pdo->prepare("SELECT uid, title, seotitle, seometa FROM tx_vitec_domain_model_product WHERE deleted = 0 AND slug = ?"); $update = $pdo->prepare("UPDATE tx_vitec_domain_model_product SET seotitle = ?, seometa = ?, tstamp = ? WHERE uid = ?"); $written = 0; foreach ($map as $slug => $meta) { $select->execute([$slug]); $product = $select->fetch(); if (!$product) { echo "FEHLT $slug - kein Produkt\n"; continue; } $newTitle = trim((string)$product['seotitle']) === '' ? trim((string)($meta['seotitle'] ?? '')) : (string)$product['seotitle']; $newMeta = trim((string)$product['seometa']) === '' ? trim((string)($meta['seometa'] ?? '')) : (string)$product['seometa']; $changes = []; if ($newTitle !== (string)$product['seotitle']) { $changes[] = 'seotitle'; } if ($newMeta !== (string)$product['seometa']) { $changes[] = 'seometa'; } if ($changes === []) { echo "ok {$product['title']} - beide Felder bereits gefuellt oder keine Daten\n"; continue; } printf("%s %s (uid %d): %s\n", $apply ? 'WRITE ' : 'plan ', $product['title'], $product['uid'], implode(' + ', $changes)); if ($apply) { $update->execute([$newTitle, $newMeta, time(), (int)$product['uid']]); } $written++; } printf("\n%d Produkt(e) %s.%s\n", $written, $apply ? 'geschrieben' : 'geplant', $apply ? ' Cache leeren: vendor/bin/typo3 cache:flush' : ' Mit --apply schreiben.');