get_var("SELECT COUNT(*) FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'yith_product_brand'"); $native_count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'product_brand'"); echo "📊 当前数据统计:\n"; echo " YITH 品牌数量: " . ($yith_count ?: 0) . "\n"; echo " 原生品牌数量: " . ($native_count ?: 0) . "\n\n"; if ($native_count > 0) { $brands = $wpdb->get_results(" SELECT t.name, t.slug, tt.count FROM {$wpdb->terms} t INNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'product_brand' ORDER BY tt.count DESC LIMIT 10 "); echo "🏷️ 前10个原生品牌:\n"; foreach ($brands as $brand) { echo " - " . $brand->name . " (" . $brand->count . "个产品)\n"; } $relationships = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->term_relationships} tr INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'product_brand' "); $meta_count = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->termmeta} tm INNER JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.taxonomy = 'product_brand' "); echo "\n🔗 产品-品牌关联数量: " . $relationships . "\n"; echo "📝 品牌元数据记录: " . $meta_count . "\n"; } echo "\n=== 验证完成 ===\n";