Neue Fotos für Linden-, Sommerblüten- und Sonnenblumenhonig

Frühstücks- und Outdoor-Aufnahme, ohne Studio; Frühstück ist das Hauptbild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
torbinus
2026-11-05 12:11:02 +01:00
parent 288527aa18
commit 22d3e25fe2
8 changed files with 61 additions and 0 deletions
@@ -0,0 +1,6 @@
import neueHonigbilder from "../scripts/set-neue-honigbilder";
/** Läuft einmal beim Deploy (medusa db:migrate), wie die Kerzenbilder. */
export default async function ({ container }: any) {
await neueHonigbilder({ container });
}
@@ -0,0 +1,55 @@
/**
* Fotos für Lindenhonig, Sommerblütenhonig und Sonnenblumenhonig.
*
* npx medusa exec ./src/scripts/set-neue-honigbilder.ts
*
* Nur die Frühstücks- und die Outdoor-Aufnahme, ohne Studio. Die Frühstücks-
* aufnahme wird das Hauptbild. Vorhandene Bilder bleiben dahinter erhalten.
*
* Die Dateien liegen im Frontend (public/images/produkte) und kommen mit dem
* Frontend-Image mit — wie die Kerzenbilder.
*
* Wiederholbar: Was schon dran ist, wird nicht doppelt angehängt.
*/
import { updateProductsWorkflow } from "@medusajs/core-flows";
const SORTEN = [
{ datei: "linde", handle: "lindenhonig-aus-hamburg" },
{ datei: "sommer", handle: "sommerblutenhonig-aus-hamburg" },
{ datei: "sonnenblume", handle: "sonnenblumenhonig-aus-der-harzregion" },
];
const PFAD = (aufnahme: string, sorte: string) => `/images/produkte/produkt-${aufnahme}-${sorte}-250g.jpg`;
export default async function ({ container }: any) {
const query = container.resolve("query");
const logger = container.resolve("logger");
for (const sorte of SORTEN) {
const { data } = await query.graph({
entity: "product",
fields: ["id", "title", "images.url", "images.rank"],
filters: { handle: sorte.handle },
});
const produkt = data?.[0];
if (!produkt) {
logger.warn(`Kein Produkt mit Handle ${sorte.handle}.`);
continue;
}
const neu = [PFAD("fruehstueck", sorte.datei), PFAD("outdoor", sorte.datei)];
const bisher = [...(produkt.images ?? [])]
.sort((a: any, b: any) => (a.rank ?? 0) - (b.rank ?? 0))
.map((i: any) => i.url)
.filter((url: string) => !neu.includes(url));
const bilder = [...neu, ...bisher];
await updateProductsWorkflow(container).run({
input: {
selector: { id: produkt.id },
update: { thumbnail: neu[0], images: bilder.map((url) => ({ url })) },
} as any,
});
logger.info(`${produkt.title}: ${bilder.length} Bilder, Hauptbild Frühstück.`);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 KiB