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_organizationimplementingOrganizationInterface, fieldable, with base fields id, uuid, type, name, status, created, changed andremote_id. - remote_id: a multi-value
commerce_remote_idfield (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_typeconfig entity extendingCommerceBundleEntityBase, 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,OrganizationInterfaceimplemented
Data model changes
New entity types commerce_organization and commerce_organization_type, only when the submodule is installed.
Issue fork commerce-3641079
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
Comment #2
jsacksick commentedComment #4
jsacksick commentedClosing: following the discussion in #3638816: [META] Commerce 4.x roadmap, the
commerce_organizationentity type moves out of core into commerce_b2b, as a submodule that keeps thecommerce_organizationmachine name and IDs, so it could move back to core later without a data migration.Core keeps the plumbing:
OrganizationInterface, theorganization_idfield (#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 usecommerce_organization_test.The code from this MR (!810) will be carried over to commerce_b2b. Closing the MR.