Files
PriceUpdaterAppv2/debug-tags.js
Spencer Grimes 1e6881ba86 Initial commit: Complete Shopify Price Updater implementation
- Full Node.js application with Shopify GraphQL API integration
- Compare At price support for promotional pricing
- Comprehensive error handling and retry logic
- Progress tracking with markdown logging
- Complete test suite with unit and integration tests
- Production-ready with proper exit codes and signal handling
2025-08-05 10:05:05 -05:00

90 lines
2.8 KiB
JavaScript

#!/usr/bin/env node
/**
* Debug script to list all product tags in the Shopify store
* This helps identify why the main script might not be finding products
*/
const ProductService = require("./src/services/product");
const { getConfig } = require("./src/config/environment");
async function debugTags() {
try {
console.log("🔍 Debug: Analyzing product tags in your Shopify store...\n");
// Load configuration
const config = getConfig();
console.log(`Store: ${config.shopDomain}`);
console.log(`Looking for tag: "${config.targetTag}"`);
console.log("─".repeat(50));
// Create product service
const productService = new ProductService();
// Fetch products and analyze tags
const products = await productService.debugFetchAllProductTags(100);
// Check if the target tag exists (case-insensitive search)
const targetTag = config.targetTag.toLowerCase();
const matchingProducts = products.filter((product) => {
if (!product.tags || !Array.isArray(product.tags)) return false;
return product.tags.some((tag) => tag.toLowerCase().includes(targetTag));
});
console.log("\n📊 Analysis Results:");
console.log(`Total products analyzed: ${products.length}`);
console.log(
`Products with target tag "${config.targetTag}": ${matchingProducts.length}`
);
if (matchingProducts.length > 0) {
console.log("\n✅ Found products with matching tags:");
matchingProducts.forEach((product) => {
const matchingTags = product.tags.filter((tag) =>
tag.toLowerCase().includes(targetTag)
);
console.log(
` - "${product.title}" has tags: [${matchingTags.join(", ")}]`
);
});
} else {
console.log("\n❌ No products found with the target tag.");
console.log("\n💡 Suggestions:");
console.log("1. Check if the tag name is spelled correctly");
console.log("2. Tags are case-sensitive - try different capitalization");
console.log(
"3. Check if products actually have this tag in Shopify admin"
);
console.log(
"4. Try a partial match - maybe the tag has additional words"
);
// Show similar tags
const allTags = new Set();
products.forEach((product) => {
if (product.tags && Array.isArray(product.tags)) {
product.tags.forEach((tag) => allTags.add(tag));
}
});
const similarTags = Array.from(allTags).filter(
(tag) =>
tag.toLowerCase().includes("summer") ||
tag.toLowerCase().includes("sale") ||
tag.toLowerCase().includes(targetTag.split("-")[0]) ||
tag.toLowerCase().includes(targetTag.split("-")[1] || "")
);
if (similarTags.length > 0) {
console.log(`\n🔍 Similar tags found: [${similarTags.join(", ")}]`);
}
}
} catch (error) {
console.error("❌ Debug failed:", error.message);
process.exit(1);
}
}
// Run the debug function
debugTags();