Search code examples
sap-commerce-cloudbackoffice

Change object identifier in hybris backoffice


I wanted to add an extension in backoffice, so that it is possible for non-programming people to add new objects (of defined types) to the database.

I've almost done it:

I defined two items: offer and tile (their relation is one to many)

What i achieved is there is a possibility to add a new offer in the backoffice. When you add it, and click to edit, you can also add a tile to this offer - either form drop-down list (if any tiles exist) or create a new tile, which will automatically be added to its table and realted to edited offer.

However, the representation of the drop-down list is unacceptable, see below:

screenshot from backoffice

as you can see, the identifier of an existing tile (within []) is its PK - which clearly is not a good identifier. I would like to inject there instead a value form one of tile's other attributes (which also is unique) so that someone could easily identify which tile to add.

Where is the mechanism responsible for it? How to override it. I tried to override toString method in the tile class, unfortunately to no avail


Solution

  • You need to customize the backoffice-config.xml for your custom Model. For your Tile model, you can use something like:

    <context merge-by="type" type="Tile" component="base">
        <y:base xmlns:y="http://www.hybris.com/cockpit/config/hybris">
            <y:labels>
                 <y:label>nameOfTile</y:label>
            </y:labels>
        </y:base>
    </context>