Import product photos from live sites; link downloads and SEO meta to products
- vitec:import-product-images: attach staged photos (fileadmin/user_upload/ products/<slug>/, 116 files harvested from vitec.com and datapath.co.uk carousels) to image-less products via FAL/DataHandler; fill-up only. fix_image_reference_fieldname.php repairs the first run's references (TCA field is productimage, not the JSON key images) - vitec:link-product-downloads: match the download records imported on 2026-08-06 to products by title (doc-type/brand/role suffix stripping, alias table for live-site naming deviations, series rules for g45xx/e38xx/ chassis docs); 55 unique-match links added, add-only, idempotent - SEO meta: seo_meta_vitec.json + apply_seo_meta.php fill empty seotitle/ seometa from the live vitec.com product pages (11 products, fill-up only)"
This commit is contained in:
59
migrations/fix_image_reference_fieldname.php
Normal file
59
migrations/fix_image_reference_fieldname.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* One-shot repair (2026-09-04): the first vitec:import-product-images run
|
||||
* wrote its sys_file_reference rows with fieldname 'images' - the JSON key -
|
||||
* but the TCA field (and everything that queries it) is 'productimage'.
|
||||
* Re-files those references and refreshes the products' inline counter.
|
||||
*
|
||||
* Usage: php migrations/fix_image_reference_fieldname.php
|
||||
*/
|
||||
|
||||
$root = null;
|
||||
$dir = __DIR__;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
if (is_file($dir . '/config/system/settings.php')) {
|
||||
$root = $dir;
|
||||
break;
|
||||
}
|
||||
$dir = dirname($dir);
|
||||
}
|
||||
if ($root === null) {
|
||||
exit("Could not locate project root above " . __DIR__ . "\n");
|
||||
}
|
||||
|
||||
$settings = require $root . '/config/system/settings.php';
|
||||
$db = $settings['DB']['Connections']['Default'];
|
||||
$pdo = new PDO(
|
||||
sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8mb4', $db['host'] ?? 'localhost', $db['port'] ?? 3306, $db['dbname'] ?? ''),
|
||||
$db['user'] ?? '',
|
||||
$db['password'] ?? '',
|
||||
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
||||
);
|
||||
|
||||
$wrong = (int)$pdo->query(
|
||||
"SELECT COUNT(*) FROM sys_file_reference
|
||||
WHERE deleted = 0 AND tablenames = 'tx_vitec_domain_model_product' AND fieldname = 'images'"
|
||||
)->fetchColumn();
|
||||
echo "Misfiled references (fieldname 'images'): $wrong\n";
|
||||
|
||||
if ($wrong > 0) {
|
||||
$pdo->exec(
|
||||
"UPDATE sys_file_reference SET fieldname = 'productimage'
|
||||
WHERE deleted = 0 AND tablenames = 'tx_vitec_domain_model_product' AND fieldname = 'images'"
|
||||
);
|
||||
echo "Re-filed to 'productimage'.\n";
|
||||
}
|
||||
|
||||
$updated = $pdo->exec(
|
||||
"UPDATE tx_vitec_domain_model_product p
|
||||
SET p.productimage = (
|
||||
SELECT COUNT(*) FROM sys_file_reference r
|
||||
WHERE r.deleted = 0 AND r.uid_foreign = p.uid
|
||||
AND r.tablenames = 'tx_vitec_domain_model_product' AND r.fieldname = 'productimage'
|
||||
)
|
||||
WHERE p.deleted = 0"
|
||||
);
|
||||
echo "Inline counters refreshed on $updated product(s). Flush the cache: vendor/bin/typo3 cache:flush\n";
|
||||
Reference in New Issue
Block a user