Problem/Motivation

The organization plumbing needs a known organization entity type: a default for sites without Group, something price lists, promotions, reports and commerce_b2b can target, and a test bed for the plumbing in core. Parent: #3638816: [META] Commerce 4.x roadmap.

Proposed resolution

Add an optional commerce_organization submodule (lifecycle: experimental, see #3638816: [META] Commerce 4.x roadmap): a thin reference module with no end-user behavior, no resolver, no membership and no access hooks.

  • Entity: commerce_organization implementing OrganizationInterface, fieldable, with base fields id, uuid, type, name, status, created, changed and remote_id.
  • remote_id: a multi-value commerce_remote_id field (provider + ID, getByProvider()), empty by default, so ERP and CRM sync modules have one known place for their IDs. First use of that field type as a base field.
  • Bundles: a commerce_organization_type config entity extending CommerceBundleEntityBase, so contrib can ship entity traits for organization types (commerce_b2b: payment terms, tax number). One type, default, shipped as optional config, like the default product and order types. Sites relabel it or add their own.
  • Administration: admin and per-bundle permissions through the entity permission provider, list builder, add/edit/delete forms, organization type UI with Field UI (manage fields, form and display per type).
  • Views: entity views data.
  • For contrib: a test trait to create organizations.

With only this module, organizations exist but orders referencing one are visible to admins only (fail-closed). Access is granted by the module that owns membership (commerce_b2b, a custom module, or a Group bridge). Group sites use the commerce_b2b_group bridge instead and do not install this module.

The order integration (Views relationship from the order, read-only organization on the admin order page, uninstall guard) comes with the organization_id field, in the next child issue.

Remaining tasks

  • Organization and organization type entities, default type, permissions, routes, admin UI, Views data, test trait
  • Kernel tests: CRUD for both entity types, remote_id, OrganizationInterface implemented

Data model changes

New entity types commerce_organization and commerce_organization_type, only when the submodule is installed.

Issue fork commerce-3641079

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jsacksick created an issue. See original summary.

jsacksick’s picture

Assigned: Unassigned » jsacksick

jsacksick’s picture

Status: Active » Closed (won't fix)

Closing: following the discussion in #3638816: [META] Commerce 4.x roadmap, the commerce_organization entity type moves out of core into commerce_b2b, as a submodule that keeps the commerce_organization machine name and IDs, so it could move back to core later without a data migration.

Core keeps the plumbing: OrganizationInterface, the organization_id field (#3641080: Add the organization_id base field to organization-owned entity types), and the organization entity type repository that discovers whichever module provides the organization entity type (commerce_b2b, a Group bridge or a custom entity). Core tests use commerce_organization_test.

The code from this MR (!810) will be carried over to commerce_b2b. Closing the MR.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.