Files
klz-cables.com/scripts/export-legacy-products-json.ts
Marc Mintel 02be8e59b2
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Failing after 1m53s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
feat: auto-opening brochure modal with mintel/mail delivery
- implemented BrochureDeliveryEmail template

- created AutoBrochureModal wrapper with 5s delay

- updated layout.tsx and BrochureCTA to use new success state

- added tests/brochure-modal.test.ts e2e test
2026-03-02 23:08:05 +01:00

75 lines
2.2 KiB
TypeScript

import * as fs from 'fs';
import * as path from 'path';
import { getPayload } from 'payload';
import configPromise from '@payload-config';
async function main() {
const payload = await getPayload({ config: configPromise });
const products: any[] = [];
for (const locale of ['en', 'de'] as const) {
const result = await payload.find({
collection: 'products',
locale: locale as any,
pagination: false,
});
for (const doc of result.docs) {
if (!doc.title || !doc.slug) continue;
const images: string[] = [];
if (doc.featuredImage) {
const url =
typeof doc.featuredImage === 'string'
? doc.featuredImage
: (doc.featuredImage as any).url;
if (url) images.push(url);
}
const categories = Array.isArray(doc.categories)
? doc.categories
.map((c: any) => ({ name: String(c.category || c) }))
.filter((c: any) => c.name)
: [];
const attributes: any[] = [];
if (Array.isArray((doc as any).content?.root?.children)) {
const ptBlock = (doc as any).content.root.children.find(
(n: any) => n.type === 'block' && n.fields?.blockType === 'productTabs',
);
if (ptBlock?.fields?.technicalItems) {
for (const item of ptBlock.fields.technicalItems) {
const label = item.unit ? `${item.label} [${item.unit}]` : item.label;
if (label && item.value) attributes.push({ name: label, options: [item.value] });
}
}
}
products.push({
id: doc.id,
name: doc.title,
shortDescriptionHtml: (doc as any).shortDescription || '',
descriptionHtml: '',
images,
featuredImage: images[0] || null,
sku: doc.slug,
slug: doc.slug,
translationKey: doc.slug,
locale,
categories,
attributes,
});
}
}
const outDir = path.join(process.cwd(), 'data/processed');
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true });
}
fs.writeFileSync(path.join(outDir, 'products.json'), JSON.stringify(products, null, 2));
console.log(`Exported ${products.length} products to data/processed/products.json`);
process.exit(0);
}
main();