Merge branch 'fix/product-import-category-select' into main
Build and Push Medusa / Escaneo de Secretos (Gitleaks) (push) Successful in 22s
Build and Push Medusa / Construir y publicar Medusa (push) Successful in 16m51s

This commit is contained in:
devops committed 2026-09-04 04:35:28 +00:00
commit 093ae419d5
1 file changed
+13 -4
@@ -116,8 +116,13 @@ export async function POST(req: MedusaRequest<{ csv: string }>, res: MedusaRespo
stockLocationService.listStockLocations({}), stockLocationService.listStockLocations({}),
fulfillmentService.listShippingProfiles({}), fulfillmentService.listShippingProfiles({}),
salesChannelService.listSalesChannels({}), salesChannelService.listSalesChannels({}),
productService.listProductCategories({}), // select explicito -- sin el, name/title llegaban undefined (el
productService.listProductCollections({}), // default de estos module services no siempre trae todos los
// escalares, a diferencia de la capa HTTP del Admin API, confirmado
// en vivo: la ruta /admin/product-categories con fields=id,name si
// los trae completos).
productService.listProductCategories({}, { select: ["id", "name"] }),
productService.listProductCollections({}, { select: ["id", "title"] }),
]); ]);
const locationId = locations[0]?.id; const locationId = locations[0]?.id;
@@ -131,8 +136,12 @@ export async function POST(req: MedusaRequest<{ csv: string }>, res: MedusaRespo
return; return;
} }
const categoryByName = new Map(categories.map((c) => [c.name.toLowerCase().trim(), c.id])); const categoryByName = new Map(
const collectionByName = new Map(collections.map((c) => [c.title.toLowerCase().trim(), c.id])); categories.filter((c) => c.name).map((c) => [c.name.toLowerCase().trim(), c.id]),
);
const collectionByName = new Map(
collections.filter((c) => c.title).map((c) => [c.title.toLowerCase().trim(), c.id]),
);
const results: RowResult[] = []; const results: RowResult[] = [];