Neue Fotos für Doppelbärchen, Waffeln, Lakritz und Bonbons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -0,0 +1,6 @@
|
|||||||
|
import snackbilder from "../scripts/set-snackbilder";
|
||||||
|
|
||||||
|
/** Läuft einmal beim Deploy (medusa db:migrate). */
|
||||||
|
export default async function ({ container }: any) {
|
||||||
|
await snackbilder({ container });
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* Neue Fotos für Honig-Doppelbärchen, Honigwaffeln, Honig-Lakritz und Honig-Bonbons.
|
||||||
|
*
|
||||||
|
* npx medusa exec ./src/scripts/set-snackbilder.ts
|
||||||
|
*
|
||||||
|
* Ersetzt die bisherigen Bilder ganz. Hauptbild ist die Packung auf
|
||||||
|
* Elfenbein, dahinter die Szenen mit Packung und der Teller.
|
||||||
|
* Die Dateien liegen im Frontend (public/images/produkte).
|
||||||
|
*
|
||||||
|
* Wiederholbar.
|
||||||
|
*/
|
||||||
|
import { updateProductsWorkflow } from "@medusajs/core-flows";
|
||||||
|
|
||||||
|
const SNACKS = [
|
||||||
|
{ handle: "gummibarchen", datei: "doppelbaerchen", szenen: ["wohnzimmer"] },
|
||||||
|
{ handle: "honigwaffeln", datei: "honigwaffeln", szenen: ["tisch"] },
|
||||||
|
{ handle: "honig-lakritze", datei: "honig-lakritz", szenen: ["wohnzimmer"] },
|
||||||
|
{ handle: "honig-bonbons", datei: "honig-bonbons", szenen: ["tisch", "unterwegs"] },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default async function ({ container }: any) {
|
||||||
|
const query = container.resolve("query");
|
||||||
|
const logger = container.resolve("logger");
|
||||||
|
|
||||||
|
for (const snack of SNACKS) {
|
||||||
|
const { data } = await query.graph({ entity: "product", fields: ["id", "title"], filters: { handle: snack.handle } });
|
||||||
|
const produkt = data?.[0];
|
||||||
|
if (!produkt) {
|
||||||
|
logger.warn(`Kein Produkt mit Handle ${snack.handle}.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const bilder = ["studio", ...snack.szenen, "teller"].map((a) => `/images/produkte/produkt-${a}-${snack.datei}.jpg`);
|
||||||
|
await updateProductsWorkflow(container).run({
|
||||||
|
input: {
|
||||||
|
selector: { id: produkt.id },
|
||||||
|
update: { thumbnail: bilder[0], images: bilder.map((url) => ({ url })) },
|
||||||
|
} as any,
|
||||||
|
});
|
||||||
|
logger.info(`${produkt.title}: ${bilder.length} neue Bilder.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 248 KiB |
|
After Width: | Height: | Size: 229 KiB |
|
After Width: | Height: | Size: 250 KiB |
|
After Width: | Height: | Size: 332 KiB |
|
After Width: | Height: | Size: 371 KiB |
|
After Width: | Height: | Size: 364 KiB |
|
After Width: | Height: | Size: 406 KiB |
|
After Width: | Height: | Size: 266 KiB |
|
After Width: | Height: | Size: 233 KiB |
|
After Width: | Height: | Size: 293 KiB |
|
After Width: | Height: | Size: 262 KiB |
|
After Width: | Height: | Size: 275 KiB |