yith-brand-migrator/test-plugin.php
2025-10-21 14:48:11 +08:00

39 lines
No EOL
1.3 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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";