Danny Krämer
Philosopher gone Frontend Developer

SAP Commerce: Change Nested Editor in Backoffice config

Written by Danny Krämer

Published on: 18.07.2024

Editing Custom Fields in the Backoffice

Recently, I created a custom CMS component and for that, I created a new type for localized maps. Out of the box, the SAP Commerce Backoffice is able to display and edit maps, but if those maps are localized (so you have one map for each language), the Backoffice just does not know which editor to show.

Of course, you could just write a completely new widget to edit the field, but that would actually be a bit overkill for this use case because we already have an editor for localized fields and an editor for maps; we just have to fuse them somehow. Luckily, in the SAP Help, there is a description of exactly this case. You can find it here:  SAP Help Nested Editors

But as I was struggling a bit to get it right and I found the documentation a bit confusing and short, here are some extra things to consider.

Troubleshooting the Process

Example

So here is my final code example:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://www.hybris.com/cockpit/config">
    <context merge-by="type" parent="SimpleCMSComponent" type="CustomComponent" component="editor-area" module="myextension">
    <editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
        <editorArea:tab name="hmc.properties">
            <editorArea:section name="hmc.essential">
                <editorArea:attribute editor="com.hybris.cockpitng.editor.localized(com.hybris.cockpitng.editor.defaultmap)" qualifier="dynamicFields"/>
                <editorArea:attribute qualifier="htmlMarkup" />
            </editorArea:section>
        </editorArea:tab>
    </editorArea:editorArea>
</context>
</config>

As you can see, I just nested the localized editor with the default map editor and moved the fields to the properties tab in an essential section.

sap commerce

backoffice

config