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
Merge remote-tracking branch 'origin/main' into 6-0-dev
Damian Legawiecee39a89e66a2
diff --cc CLAUDE.mdindex 143fb8b41e,782efc79c4..ca7babf8f5--- a/CLAUDE.md+++ b/CLAUDE.md@@@ -27,9 -27,9 +27,9 @@@ Active plans (6.0 target, work pending)- `6.0-tax-provider.md` — Per-Market TaxProvider, replaces TaxRate.adjust + Calculator; TaxRate gets direct country/state FKs (tax decoupled from Zone; Zone model dropped in 6.0 via `6.0-delivery-zones.md`)- `6.0-delivery-rate-provider.md` — Per-DeliveryMethod DeliveryRateProvider wrapping Stock::Estimator (calculators stay — 2026-07-27 reversal), `store_id` on ShippingMethod, enriched DeliveryRate (carrier/service/date/metadata)- `6.0-delivery-zones.md` — Zone → DeliveryZone with postal-code-range/prefix members (country-scoped); owns the full ~183-reference Zone consumer inventory; `Spree::Zone` dropped entirely by end of 6.0 (2026-07-27 — 6.0 is the breaking-change window)- - `6.0-rich-text-descriptions.md` — Drop ActionText storage, store HTML in text columns, sanitize on write, serve `description` + `description_html` in API (description_html serializer field shipped in 5.4)+ - `6.0-rich-text-descriptions.md` — Drop ActionText **entirely** at 6.0 (incl. CustomFields::RichText values + Order/User internal notes; gem dependency removed), store sanitized HTML in text columns, serve `field` + `field_html`, **write via `field_html`** (read/write symmetry). description_html serializer shipped 5.4; sanitizer shipped in **5.6.2** with a permissive-but-safe configurable allowlist + `sanitize_rich_text` step in the 5.5→5.6 upgrade manifest (decisions.md 2026-07-27/28), tightened to the Tiptap set at 6.0- `6.0-inventory-operations.md` — StockTransfer lifecycle (draft → ready_to_ship → in_transit → received with partial receive), new `Spree::PurchaseOrder` + `Spree::Supplier` (renamed from Vendor — `Spree::Vendor` is the marketplace seller, see decisions.md 2026-07-14) replacing today's "external receive" hack, variant + stock-location stock history panels. Consumes the typed-movement primitives from `6.0-typed-stock-movements.md`.-- `6.0-replace-taxons-with-categories.md` — Split Taxon into Category (hierarchy) + Collection (flat/rule-based). `Spree::Category < Spree::Taxon` alias + Category API surface shipped in 5.5; table rename + Collection pending.+- `6.0-replace-taxons-with-categories.md` — Split Taxon into Category (hierarchy) + Collection (flat/rule-based). **Shipped to 6-0-dev (PR #14302):** the Category surface (5.5–5.6) plus the 6.0 core — `spree_taxons`→`spree_categories` table rename + inheritance flip (`Spree::Category < Spree.base_class`, `Spree::Taxon` alias kept), the full `Collection` stack (model + rules + DB/Meilisearch manual sort + API), the taxon→category/collection data migration, and de-ruling Category. Pending (all 6.1): channel-aware `CollectionRules::AvailableOn` (ships interim now, rides with channels) + dropping `spree_taxon_rules`/`Taxonomy`. No brand feature in 6.0 — brands are modeled as a Category/Collection; `brand_taxon`/`brand_name` removed with `Taxonomy`.- `6.0-store-scoped-custom-field-definitions.md` — Add `store_id` + persisted `filter_key` to `Spree::MetafieldDefinition` (today global and computed), making uniqueness `(store_id, resource_type, filter_key)` with a DB index. Deferred from the 5.6 custom-field search/sort/filter work (schema change, not patch-safe). **Until then:** `filter_key` is a computed method — no Ransack predicates or `where`/`order` against it; definitions are global; uniqueness rests on a `CONCAT` validation with no index behind it.Multi-version plans (some phases shipped, some pending):diff --cc docs/plans/6.0-replace-taxons-with-categories.mdindex bf94440099,bd3b76b1f3..0e4ee5bb0b--- a/docs/plans/6.0-replace-taxons-with-categories.md+++ b/docs/plans/6.0-replace-taxons-with-categories.md@@@ -1,10 -1,10 +1,10 @@@# Replace Taxons with Categories & Add Collections-**Status:** API/serializer bridge shipped in 5.5 (`Spree::Category < Spree::Taxon` constant alias + `categories` controllers/serializers/associations); table rename + `Collection` split + rule engine pending in 6.0-**Target:** Spree 6.0 (5.5 ships the `Spree::Category` alias + Category API surface; 6.0 renames the table and adds `Collection`)-**Depends on:** API v3 conventions, ProductType plan (6.0-product-types.md)+**Status:** Shipped to `6-0-dev` (PR #14302, merged 2026-07-19). The Category read/write surface landed earlier (5.5–5.6); PR #14302 completed the 6.0 core: the `spree_taxons` → `spree_categories` table rename + inheritance flip (`Spree::Category < Spree.base_class`, `Spree::Taxon` retained as a deprecation alias), the full `Collection` stack (model + join + rules + DB/Meilisearch manual sort + API), the taxon→category/collection data-migration task, and de-ruling Category. **Remaining (all 6.1):** the channel-aware reimplementation of `CollectionRules::AvailableOn` — Phase 5, which ships now with an interim legacy-`available_on` `apply` and rides with `6.1-channels-catalogs-b2b.md`; and dropping `spree_taxon_rules` + `Spree::TaxonRule`/`TaxonRules::*` + the `Taxonomy` model (Phase 6). Nothing 6.0-blocking is left.+**Target:** Spree 6.0 (Category surface landed in 5.5–5.6; 6.0 renames the table, splits out `Collection`, and drops `Taxonomy`)+**Depends on:** API v3 conventions, ProductType plan (6.0-product-types.md), Rich Text Descriptions plan (6.0-rich-text-descriptions.md), Admin SPA plan (6.0-admin-spa.md — dashboard UI), Channels/Publications plan (6.0-channels-catalogs-b2b.md — the `CollectionRules::AvailableOn` rule's channel-aware implementation depends on its `available_on` → `ProductPublication#published_at` migration; see Migration Phase 5)**Author:** Damian + Claude- **Last updated:** 2026-07-20-**Last updated:** 2026-07-27++**Last updated:** 2026-07-28## Summary@@@ -622,63 -403,42 +622,69 @@@ Runs after the Phase 2 rename **and th```ruby# rake spree:migrate_taxons_to_categories_and_collections#-# For each Taxonomy:-# 1. Set store_id on all its root + descendant taxons (now categories)-# 2. If taxonomy is "Collections" (by name):-# - Move its automatic child taxons to spree_collections-# - Move their TaxonRules to CollectionRules-# - Move their Classifications to ProductCollections-# - Move manual child taxons to ProductCollections-# - Delete the taxonomy root category-# 3. For other taxonomies ("Categories", "Brands"):-# - Root category keeps the taxonomy name-# - Remove taxonomy_id column references-# 4. Drop taxonomy_id from categories+# For every store, using store_id (backfill first — spree:taxons:backfill_store_id):+# 1. Automatic categories (automatic: true OR any taxon_rules) -> Spree::Collection+# - copy their TaxonRules -> new CollectionRules (remap collection_id, rewrite STI type)+# Maps ALL types 1:1 — Tag, Sale, AND AvailableOn. AvailableOn's CollectionRule+# model ships in Phase 1 (interim legacy-column apply), so its rows migrate cleanly+# with value + match_policy preserved; they go channel-aware once Phase 5 reimplements apply.+# - copy their ProductCategories -> ProductCollections+# - copy columns + metadata + table translations; MOVE the ActionText description,+# ActiveStorage image/square_image, metafields, and friendly_id slugs onto the+# collection (else category.destroy purges/destroys them). Match both+# 'Spree::Taxon' and 'Spree::Category' record_type/sluggable_type (deploy window).+# (regardless of which taxonomy / name they lived under)+# then delete the automatic rows from spree_categories (one txn per category, idempotent)+# 2. Manual categories stay as Spree::Category (the nested-set tree, owned via store_id)+# - manual categories that happened to live under a "Collections" tree stay as+# categories; merchants re-file them as collections via the new UI+# (safe, reversible — no name-based guessing)+# 3. Sever the taxonomy structure from the survivors: drop taxonomy roots left+# childless after step 1 (keep non-empty roots as top-level categories), then+# null taxonomy_id on all remaining categories — they are store-owned now.+# The taxonomy_id COLUMN + spree_taxonomies + the Taxonomy model drop in 6.1.+# 4. Backfill stored class-name strings 'Spree::Taxon*' -> 'Spree::Category*'+# (Phase 3 renamed the classes and writes the new names; existing rows still+# hold the old ones, so migrate them here):+# - spree_metafields.resource_type+# - spree_metafield_definitions.resource_type+# - friendly_id_slugs.sluggable_type+# - active_storage_attachments.record_type (taxon image / square_image)+# - action_text_rich_texts.record_type (description — translates :description, backend: :action_text)+# - spree_promotion_rules.type (Promotion::Rules::Taxon -> Category, STI)+# Direct FK columns (taxon_id/category_id) and the pinned translation table+# need no change. Same rake run as above, so no additional upgrade window.+ # 5. Clean spree_product_type_categories (6.0-product-types.md): delete or-# re-point rows whose taxon moved to spree_collections or was a deleted++# re-point rows whose category moved to spree_collections or was a deleted+ # taxonomy root — otherwise dangling category_id FKs survive the split+#+# Handles both upgraded stores (may have localized/renamed standard trees) and+# new 5.5+ stores (arbitrary or zero taxonomies).```- **Status: implemented** as `spree/core/lib/tasks/categories_and_collections.rake` (spec: `spec/lib/tasks/categories_and_collections_spec.rb`). Each automatic category migrates in its own transaction — a partial failure rolls back and a re-run skips what's already gone, so the task is idempotent. Automatic categories with child categories are skipped (automatic taxons are leaves; the task refuses to destroy a subtree). After the automatic pass it severs the taxonomy structure (backfill store_id from taxonomy → drop childless taxonomy roots → null `taxonomy_id` on the rest), then runs the string backfills once for the surviving (manual) category rows.+ Also owned by this plan's rename wave: flip `Spree::ProductTypeCategory`'s+ `belongs_to :category, class_name: 'Spree::Taxon'` to `'Spree::Category'`+ (the product-types plan ships before this rename and cannot do it itself).-### Phase 3: Model renames + deprecation aliases++**Status: implemented** as `spree/core/lib/tasks/categories_and_collections.rake` (spec: `spec/lib/tasks/categories_and_collections_spec.rb`). Each automatic category migrates in its own transaction — a partial failure rolls back and a re-run skips what's already gone, so the task is idempotent. Automatic categories with child categories are skipped (automatic taxons are leaves; the task refuses to destroy a subtree). After the automatic pass it severs the taxonomy structure (backfill store_id from taxonomy → drop childless taxonomy roots → null `taxonomy_id` on the rest), then runs the string backfills once for the surviving (manual) category rows.+### Phase 5: Reintroduce channel-aware `AvailableOn` (after `6.0-channels-catalogs-b2b.md`)-- `Spree::Taxon` → `Spree::Category` (alias `Spree::Taxon = Spree::Category` for one release)-- `Spree::Taxonomy` → deprecated, no replacement-- `Spree::Classification` → `Spree::ProductCategory` (alias for one release)-- `Spree::TaxonRule` → `Spree::CollectionRule`-- `Spree::TaxonRules::*` → `Spree::CollectionRules::*`-- Update all serializers, controllers, services, factories, specs+Gated on the channels plan finishing the `available_on` → `ProductPublication#published_at` migration. Until then, `CollectionRules::AvailableOn` runs the interim legacy-column query shipped in Phase 1.++- **Reimplement `CollectionRules::AvailableOn#apply`** against `spree_product_publications.published_at` (join), replacing the raw `spree_products.available_on` query. Decide which channel a store-owned collection's availability rule evaluates against — the store's **default channel**, or any publication with `published_at` in the window — and document it (a collection has no channel of its own).+- **No data migration, no registry change** — `AvailableOn` is already registered (Phase 1) and its `CollectionRule` rows already carry the right `value`/`match_policy` from Phase 4; only `apply` changes.+- **Cross-plan ordering constraint (hard).** `CollectionRules::AvailableOn` is a reader of `spree_products.available_on`, which `6.0-channels-catalogs-b2b.md` Phase 3 ("6.0 cleanup") drops. This phase **must land before** that column drop — the channels plan's cleanup is blocked on this reimplementation.-### Phase 4: Cleanup (6.1)+### Phase 6: Cleanup (6.1)-- Remove all aliases and deprecation shims+- Remove all aliases and deprecation shims (incl. the `Spree::Taxon` alias and the `classification_count` `alias_attribute`)- Remove `taxonomy_id` column from categories-- Remove `spree_taxonomies` table+- Remove `spree_taxonomies` table + the `taxonomy_id` column + the `taxonomy_brands_name` locale key (brands out of scope — no replacement; `Product#brand_taxon`/`#brand_name` were already removed in 6.0/Phase 3)- Remove `automatic`, `rules_match_policy`, `sort_order` columns from categories (moved to collections)+- **Drop `spree_taxon_rules` + `Spree::TaxonRule` / `TaxonRules::*` + the `config.spree.taxon_rules` registry** (retained data-only through 6.0 so the Phase 4 data migration can read them; rows were copied to `spree_collection_rules`, and `CollectionRule` is net-new so there's no alias to keep)+- Remove the deprecated Ruby-level aliases kept through 6.0: the `taxons` and `classifications` method aliases on `Product`/`Category`/`Store`, the `taxon`/`taxon=` readers on the join models, and the rule's `taxons`/`taxon_ids`/`eligible_taxon_ids`/`taxon_ids_to_add` aliases+- Remove the deprecated **constant + service/job/queue aliases** kept through 6.0: `Spree::Taxon`, `Spree::Classification`, `Spree::PromotionRuleTaxon`, `Spree::Promotion::Rules::Taxon` (constant aliases + their load-time `Spree::Deprecation.warn`); the `Spree::Taxons::AddProducts`/`RemoveProducts`/`RegenerateProducts`, `Spree::Products::AutoMatchTaxons`/`AutoMatchTaxonsJob`/`TouchTaxonsJob` wrappers; and the `Spree.queues.taxons` singleton method+- Rename `spree_prototype_taxons` (with `6.0-product-types.md`), dropping the `foreign_key: :taxon_id` pin on `Category#prototype_taxons` (the `#taxon_rules` pin goes away with the `spree_taxon_rules` drop above)## Constraints on Current Work