yith-brand-migrator/test-plugin.php

39 lines
1.3 KiB
PHP
Raw Normal View History

2025-10-21 14:48:11 +08:00
<?php
define('WP_USE_THEMES', false);
require_once('/Users/feibisi-studio/Local Sites/mall/app/public/wp-load.php');
echo "=== YITH 品牌数据状态检查 ===\n\n";
global $wpdb;
echo "🔗 数据库连接状态: ";
if ($wpdb->last_error) {
echo "❌ 连接失败: " . $wpdb->last_error . "\n";
exit(1);
} else {
echo "✅ 连接正常\n";
}
$yith_brands = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->terms} t
INNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id
WHERE tt.taxonomy = 'yith_product_brand'");
$native_brands = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->terms} t
INNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id
WHERE tt.taxonomy = 'product_brand'");
echo "\n📊 当前数据统计:\n";
echo " YITH 品牌数量: " . ($yith_brands ?: 0) . "\n";
echo " 原生品牌数量: " . ($native_brands ?: 0) . "\n\n";
if ($yith_brands > 0) {
echo "🔄 检测到 YITH 品牌数据,可以执行迁移\n";
echo " 运行命令: php migrate-script.php\n";
} elseif ($native_brands > 0) {
echo "✅ 检测到原生品牌数据,迁移已完成\n";
echo " 如需回滚: php rollback-script.php\n";
} else {
echo " 未检测到任何品牌数据\n";
}
echo "\n=== 检查完成 ===\n";