Skip out-of-stock products in XML generation: Added logic to exclude products that are not available from the generated XML, improving the accuracy of product listings for SEO purposes.

This commit is contained in:
sebseb7
2025-07-19 06:25:57 +02:00
parent 7eb70abb22
commit b602444066

View File

@@ -414,6 +414,12 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => {
// Generate availability
const availability = product.available ? "in stock" : "out of stock";
// Skip products that are out of stock
if (!product.available) {
skippedCount++;
return;
}
// Generate price (ensure it's a valid number)
const price = product.price && !isNaN(product.price)
? `${parseFloat(product.price).toFixed(2)} ${config.currency}`