Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Hydrate only manual collections on the product form

Damian Legawiec961c1b20ed9c
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
index 7542c19e98..6cee9fa92b 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
@@ -139,7 +139,11 @@ function productToFormValues(
description: product.description_html ?? '',
status: (product.status as ProductFormValues['status']) ?? 'draft',
category_ids: product.categories?.map((t) => t.id) ?? [],
- collection_ids: product.collections?.map((c) => c.id) ?? [],
+ // Manual membership only — this field is what the picker edits, and the
+ // API preserves automatic membership regardless of what it sends. Hydrating
+ // automatic collections here would render chips a merchant can remove to
+ // no effect.
+ collection_ids: product.collections?.filter((c) => !c.automatic).map((c) => c.id) ?? [],
tags: product.tags ?? [],
tax_category_id: product.tax_category_id ?? null,
product_type_id: product.product_type_id ?? null,