← back to Flockedwallpaper
filter-true-flock.js
65 lines
const fs = require('fs');
console.log('🔍 Filtering for TRUE flocked products only...\n');
// Load current products
const allProducts = JSON.parse(fs.readFileSync('./flocked-products.json', 'utf8'));
console.log(`Total products currently: ${allProducts.length}`);
// Filter criteria: Must have FLOCKED or VELVET in productType, tags, or title
const flockedProducts = allProducts.filter(product => {
const title = (product.title || '').toLowerCase();
const productType = (product.productType || '').toLowerCase();
const tags = product.tags || [];
const tagsString = tags.join(' ').toLowerCase();
// Must contain "flock" or "velvet" somewhere
const hasFlockInType = productType.includes('flock');
const hasFlockInTags = tagsString.includes('flock');
const hasFlockInTitle = title.includes('flock');
const hasVelvetInTitle = title.includes('velvet');
const hasVelvetInType = productType.includes('velvet');
// Check if it's a flocked or velvet product
const isFlockOrVelvet = hasFlockInType || hasFlockInTags || hasFlockInTitle || hasVelvetInTitle || hasVelvetInType;
// Must NOT be just printed/regular wallpaper (unless it has flock in the type)
const isNotPrinted = !productType.includes('printed') || hasFlockInType;
const isNotGeneric = !['wallpaper', 'wallcoverings', 'complementary'].includes(productType.trim()) || hasFlockInType || hasFlockInTags;
return isFlockOrVelvet && isNotPrinted && isNotGeneric;
});
console.log(`True flocked products: ${flockedProducts.length}`);
console.log(`Removed: ${allProducts.length - flockedProducts.length} non-flocked items\n`);
// Show removed products
const removedProducts = allProducts.filter(p => !flockedProducts.includes(p));
console.log('📋 REMOVED PRODUCTS:');
console.log('='.repeat(80));
removedProducts.slice(0, 20).forEach((product, index) => {
console.log(`${index + 1}. ${product.title}`);
console.log(` Type: ${product.productType}`);
console.log(` SKU: ${product.primarySku}`);
console.log('');
});
if (removedProducts.length > 20) {
console.log(`... and ${removedProducts.length - 20} more removed\n`);
}
// Save filtered products
fs.writeFileSync('./flocked-products.json', JSON.stringify(flockedProducts, null, 2));
console.log(`\n✅ Saved ${flockedProducts.length} true flocked products to flocked-products.json`);
// Show product type breakdown
const typeCounts = {};
flockedProducts.forEach(p => {
typeCounts[p.productType] = (typeCounts[p.productType] || 0) + 1;
});
console.log('\n📊 Product Type Breakdown:');
Object.entries(typeCounts).sort((a, b) => b[1] - a[1]).forEach(([type, count]) => {
console.log(` ${type}: ${count}`);
});