Skip to content

[Studio] Offer advanced relation fields for the Many-to-Many Relation data target - #702

Draft
alexbaat wants to merge 3 commits into
pimcore:2026.3from
alexbaat:bugfix/advanced-relation-target-attributes
Draft

alexbaat wants to merge 3 commits into
pimcore:2026.3from
alexbaat:bugfix/advanced-relation-target-attributes

Conversation

@alexbaat

@alexbaat alexbaat commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Bug

In the Studio Data Importer, fields of type Advanced Many-to-Many Relation and Advanced Many-to-Many Object Relation can never be selected as a mapping target. With a transformation result of dataObjectArray / assetArray the field select only lists the plain many-to-many fields — also when the data target type is Many-to-Many Relation, the one data target that writes advanced relations (ManyToManyRelation::getMergedDataArray() wraps the elements in ObjectMetadata / ElementMetadata).

Steps to reproduce

  1. Have a class with an Advanced Many-to-Many Object Relation field.
  2. In a Data Objects importer for that class, add a mapping whose pipeline results in dataObjectArray (e.g. Load Data Object → As Array).
  3. In the advanced mapping modal, choose the data target type Many-to-Many Relation and open the field select: the advanced relation field is missing.

Cause

The backend supports it already: GET /data-importer/data-type/class-attributes accepts loadAdvancedRelations, and TransformationDataTypeService::getPimcoreDataTypes() then replaces dataObjectArray / assetArray with advancedDataObjectArray / advancedAssetArray, which include the advanced relation types. The Studio UI never sends the flag, and it keeps the loaded class attributes in a map keyed only by transformation result type, so the data target type never influences which fields are offered.

Fix

The attributes map key now also depends on the data target type:

  • resolveAttrMapKey(transformationResultType, dataTargetType?) returns advancedRelations:<result type> for the manyToManyRelation data target with a dataObjectArray / assetArray result; every other combination keeps its existing key.
  • parseAttrMapKey() turns a key back into the request parameters (transformationResultType + loadAdvancedRelations), so the mapping step loader and the modal's on-demand fetch (useAutoRecalculateType) request exactly what the key stands for.
  • The consumers pass the data target type: useClassAttributes (field select in the modal), MappingItem (collapsed row title, now also part of the memo comparison) and the loader's watched key list, so switching a saved mapping's data target fetches the missing list.
  • Autofill suggestions skip the advanced keys: they are not transformation result types, and autofill only creates direct mappings, which cannot write advanced relations.

The direct data target keeps offering the plain relation fields only, which is correct — Direct passes the raw elements to the setter, which an advanced relation does not accept.

Notes

  • Source-only change: assets/studio has no jest/vitest setup, so there is no automated test to add; tsc --noEmit and ESLint pass. The built assets under src/Resources/public/studio/build/ are left to the automatic frontend build (the commit-build job is skipped for fork PRs).
  • Applied to a 2026.2.4 installation and rebuilt; verified there that the backend returns the advanced relation field only with loadAdvancedRelations=true.
  • Advanced relation metadata columns are still written empty (new ObjectMetadata($this->fieldName, [], $dataObject)); importing metadata values is out of scope here.

Tracking issue

Fixes pimcore/platform-version#536

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Attribute caching is not class-scoped, allowing stale advanced fields after changing the resolver class.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Enables advanced many-to-many relation fields as Studio mapping targets.

Changes:

  • Adds target-aware attribute-map keys and request parsing.
  • Fetches advanced relation attributes when required.
  • Excludes advanced-only keys from direct-mapping autofill.
File Description
types.ts Adds advanced attribute-key helpers.
compute-autofill-suggestions.ts Excludes advanced relation entries.
mapping-item.tsx Resolves attributes using target type.
mapping-item-with-filter.tsx Passes target type to mapping items.
use-mapping-step-loader.types.ts Renames the watched-key result.
use-mapping-step-loader.tsx Loads attributes using parsed map keys.
useClassAttributes.ts Selects target-specific attributes.
use-auto-recalculate-type.ts Fetches advanced attributes on demand.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

alexbaat and others added 3 commits September 30, 2026 09:01
… data target

The class attributes were only keyed by transformation result type and always
requested without loadAdvancedRelations, so advancedManyToMany(Object)Relation
fields never showed up in the target field select, whichever data target was
chosen. Attributes for the manyToManyRelation data target are now kept under a
separate map key and requested with loadAdvancedRelations=true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The class can be changed in the resolver step without saving. The mapping
step loader only fetched the attribute map keys that were missing, so entries
loaded for the previous class, e.g. its advanced relation fields, stayed in
use. The loader now tracks which class the map belongs to and reloads every
needed key when it changes, discarding results of a superseded class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jcPimcore
jcPimcore force-pushed the bugfix/advanced-relation-target-attributes branch from f1b1272 to e69c768 Compare September 30, 2026 07:05
@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


13 out of 14 committers have signed the CLA.
✅ (berfinyuksel)[https://github.com/berfinyuksel]
✅ (bluvulture)[https://github.com/bluvulture]
✅ (fashxp)[https://github.com/fashxp]
✅ (robertSt7)[https://github.com/robertSt7]
✅ (herbertroth)[https://github.com/herbertroth]
✅ (lukmzig)[https://github.com/lukmzig]
✅ (xIrusux)[https://github.com/xIrusux]
✅ (kingjia90)[https://github.com/kingjia90]
✅ (idaiv)[https://github.com/idaiv]
✅ (ValeriaMaltseva)[https://github.com/ValeriaMaltseva]
✅ (martineiber)[https://github.com/martineiber]
✅ (ellenico77)[https://github.com/ellenico77]
✅ (alexbaat)[https://github.com/alexbaat]
❌ @JochenCal
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@pimcore-deployments
pimcore-deployments marked this pull request as draft September 30, 2026 07:05
@pimcore-deployments

Copy link
Copy Markdown
Collaborator

🚫 CI & merge-readiness guardrail failed — this PR has been converted to draft.

A PR can only be merged when it has no conflicts with the base branch and all CI checks pass.

  • CI check not successful: cla-workflow / CLAAssistant (failure).

When fixed, press Ready for review to re-run the checks.

@jcPimcore
jcPimcore changed the base branch from 2026.2 to 2026.3 September 30, 2026 07:05
@sonarqubecloud

Copy link
Copy Markdown

@jcPimcore

Copy link
Copy Markdown
Contributor

Hello @alexbaat

Thanks for your contribution!

Since 2026.3 is released we do not maintain any 2026.2 version line anymore.
I rebased this PR onto 2026.3 now.

There is no todo coming with this on your side. Just an information.

Kind regards, Jochen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Studio Data Importer — Advanced Many-to-Many relation fields cannot be selected as mapping target

5 participants