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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Stop sellers writing the marketplace's tag vocabulary
Damian Legawiec494cc4e61a1e
diff --git a/docs/plans/6.0-seller-product-submission.md b/docs/plans/6.0-seller-product-submission.mdindex 729af82e42..eb88e70c9e 100644--- a/docs/plans/6.0-seller-product-submission.md+++ b/docs/plans/6.0-seller-product-submission.md@@ -54,18 +54,35 @@ drift.resource with no seller audience.** Which channels carry a product ismarketplace merchandising, not a seller's to set.-7. **Custom field *values* are seller-writable; *definitions* are not.**+7. **A seller files a product into the marketplace's groupings; they do not+ extend them.** `category_ids` and `collection_ids` are writable — filing a+ product is part of maintaining it, which is why the operator's own endpoint+ permits them under `write_products` rather than `write_collections`. The+ categories and collections themselves are read-only pickers.++ **Tags are not writable at all.** They are tenanted to the store+ (`acts_as_taggable_tenant :store_id`), so a seller typing a new one adds a+ term to the marketplace's shared vocabulary rather than labelling their own+ product. Verified against both marketplace platforms we looked at: Mercur's+ vendor API exposes categories, collections, tags, types and attributes as+ GET-only, with a single `POST /vendor/product-categories/:id/products` to+ place a seller's own products into an existing category; Mirakl's category+ tree and attribute schema are operator-only imports that sellers map onto.+ The legacy `spree_multi_vendor` gem took the same line+ (`cannot :manage_tags`, taxonomy `index`/`show` only).++8. **Custom field *values* are seller-writable; *definitions* are not.**`Spree::CustomField` stays on `products`; `Spree::MetafieldDefinition`is operator-only, and the seller panel renders the definitions it is givenwithout the "add a definition" affordance.-8. **The product form cards live in `@spree/dashboard-ui`**, headless and+9. **The product form cards live in `@spree/dashboard-ui`**, headless andgeneric over the record type — data by props, no SDK import, no providerimport. `MediaCard`'s one `adminClient.media.list` call becomes an injectedprop. This is what makes "the same as in dashboard" true by constructionrather than by discipline.-9. **No JSON preview on the seller panel.** It is an opt-in prop on the page+10. **No JSON preview on the seller panel.** It is an opt-in prop on the pageshell; the seller form omits it.## Design Detailsdiff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.tsindex 345351e1a0..80dc702727 100644--- a/packages/dashboard-core/src/api-client.ts+++ b/packages/dashboard-core/src/api-client.ts@@ -148,6 +148,14 @@ export interface PanelApiClient {mediaLibrary?: {list(params?: Record<string, unknown>): Promise<{ data: PanelMediaRecord[] }>}+ /**+ * The store's tag vocabulary. Operator-only: tags are tenanted to the store+ * (`acts_as_taggable_tenant :store_id`), so a seller typing a new one would+ * be writing into the marketplace's own namespace.+ */+ tags?: {+ list(params?: Record<string, unknown>): Promise<{ data: Array<{ name: string }> }>+ }}export interface PanelDeliveryProfile extends PanelNamedRecord {diff --git a/packages/dashboard-core/src/components/tag-combobox.tsx b/packages/dashboard-core/src/components/tag-combobox.tsxindex dc18aaa472..f01abf1f63 100644--- a/packages/dashboard-core/src/components/tag-combobox.tsx+++ b/packages/dashboard-core/src/components/tag-combobox.tsx@@ -13,7 +13,7 @@ import {import { useQuery } from '@tanstack/react-query'import { useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'-import { adminClient } from '../client'+import { getApiClient } from '../api-client'import { useAuth } from '../hooks/use-auth'import type { TaggableType } from '../lib/table-registry'@@ -36,10 +36,14 @@ export function TagCombobox({const [inputValue, setInputValue] = useState('')const { isAuthenticated } = useAuth()+ // Through the registered client, so a panel without a tag vocabulary+ // simply has none rather than calling an API it holds no key for.+ const tagsClient = getApiClient().tags+const { data } = useQuery({- queryKey: ['admin-tags', taggableType],- queryFn: () => adminClient.tags.list({ taggable_type: taggableType }),- enabled: isAuthenticated,+ queryKey: ['panel-tags', taggableType],+ queryFn: () => tagsClient?.list({ taggable_type: taggableType }),+ enabled: isAuthenticated && Boolean(tagsClient),staleTime: 60_000,})diff --git a/packages/dashboard-core/src/products/product-form-cards.tsx b/packages/dashboard-core/src/products/product-form-cards.tsxindex 44bc806dbb..65473e76f1 100644--- a/packages/dashboard-core/src/products/product-form-cards.tsx+++ b/packages/dashboard-core/src/products/product-form-cards.tsx@@ -1030,20 +1030,24 @@ export function CategorizationCard({ form }: FormCardProps) {</span></Field>- <Field>- <FieldLabel>{t('admin.fields.product.tags.label')}</FieldLabel>- <Controller- name="tags"- control={form.control}- render={({ field }) => (- <TagCombobox- taggableType="Spree::Product"- value={field.value ?? []}- onChange={field.onChange}- />- )}- />- </Field>+ {/* Tags are the store's own vocabulary, so only a panel that manages+ it offers the field (docs/plans/6.0-multi-vendor-marketplace.md). */}+ {getApiClient().tags && (+ <Field>+ <FieldLabel>{t('admin.fields.product.tags.label')}</FieldLabel>+ <Controller+ name="tags"+ control={form.control}+ render={({ field }) => (+ <TagCombobox+ taggableType="Spree::Product"+ value={field.value ?? []}+ onChange={field.onChange}+ />+ )}+ />+ </Field>+ )}</CardContent></Card>)diff --git a/packages/dashboard/src/api-client-setup.ts b/packages/dashboard/src/api-client-setup.tsindex 6cca25fbbf..f03ab6ff2e 100644--- a/packages/dashboard/src/api-client-setup.ts+++ b/packages/dashboard/src/api-client-setup.ts@@ -42,4 +42,7 @@ setApiClient({deliveryProfiles: { list: (params) => adminClient.deliveryProfiles.list(params) },deleteProductMedia: (productId, mediaId) => adminClient.products.media.delete(productId, mediaId),mediaLibrary: { list: (params) => adminClient.media.list(params) },+ tags: {+ list: (params) => adminClient.tags.list(params as { taggable_type: string; q?: string }),+ },})diff --git a/packages/seller-dashboard/src/pages/product.tsx b/packages/seller-dashboard/src/pages/product.tsxindex 0772b55bf5..504abc6390 100644--- a/packages/seller-dashboard/src/pages/product.tsx+++ b/packages/seller-dashboard/src/pages/product.tsx@@ -93,7 +93,6 @@ export function ProductPage({ mode }: { mode: 'new' | 'edit' }) {product_type_id: values.product_type_id ?? undefined,category_ids: values.category_ids,collection_ids: values.collection_ids,- tags: values.tags,custom_fields: values.custom_fields,// Both lists are the whole intent: anything the seller removed is// absent here, which is what tells the API to drop it.diff --git a/spree/api/app/controllers/spree/api/v3/seller/products_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/products_controller.rbindex 5ca58e7f26..3cb2df5900 100644--- a/spree/api/app/controllers/spree/api/v3/seller/products_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/seller/products_controller.rb@@ -76,7 +76,16 @@ module Spree:name, :description, :slug,:meta_title, :meta_description, :meta_keywords,:product_type_id,- tags: [],+ # Filing a product into the marketplace's existing groupings is+ # part of maintaining the product, which is why the operator's+ # endpoint permits these under `write_products` too. Creating a+ # category or collection remains the operator's.+ #+ # `tags` is deliberately absent: they are the store's own+ # vocabulary (`acts_as_taggable_tenant :store_id`), so a seller+ # typing a new one writes into the marketplace's namespace rather+ # than onto their product+ # (docs/plans/6.0-multi-vendor-marketplace.md).category_ids: [],collection_ids: [],metadata: {},diff --git a/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rbindex e03f77a229..45e85c5ce1 100644--- a/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rb@@ -221,6 +221,16 @@ RSpec.describe Spree::Api::V3::Seller::ProductsController, type: :controller doexpect(mine.reload.media.map(&:alt)).to include('A lamp')end+ # Tags are tenanted to the store, so a seller writing one would be adding+ # a term to the marketplace's own vocabulary rather than labelling their+ # product (docs/plans/6.0-multi-vendor-marketplace.md).+ it 'ignores tags' do+ patch :update, params: { id: mine.prefixed_id, tags: ['seller-coined'] }, as: :json++ expect(response).to have_http_status(:ok)+ expect(mine.reload.tag_list).to be_empty+ end+it 'files the product under a category' dopatch :update, params: { id: mine.prefixed_id, category_ids: [category.prefixed_id] }, as: :json