Implement product filtering based on excluded terms: Added logic to skip products with specific terms in their title or description during XML generation in feeds.cjs, enhancing content management for SEO purposes.
This commit is contained in:
@@ -316,6 +316,27 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip products with excluded terms in title or description
|
||||
const productTitle = (product.name || "").toLowerCase();
|
||||
const productDescription = (product.description || "").toLowerCase();
|
||||
|
||||
const excludedTerms = {
|
||||
title: ['canna', 'hash', 'marijuana'],
|
||||
description: ['cannabis']
|
||||
};
|
||||
|
||||
// Check title for excluded terms
|
||||
if (excludedTerms.title.some(term => productTitle.includes(term))) {
|
||||
skippedCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check description for excluded terms
|
||||
if (excludedTerms.description.some(term => productDescription.includes(term))) {
|
||||
skippedCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip products without GTIN
|
||||
if (!product.gtin || !product.gtin.toString().trim()) {
|
||||
skippedCount++;
|
||||
|
||||
Reference in New Issue
Block a user