AppleBud
AppleBud

Reputation: 1541

How to declare an attribute of type "HybrisEnumValue" in items.xml in Hybris?

I have a use case where I am trying to declare a new itemtype with an attribute of type HybrisEnumValue inside items.xml. However, when I try to do an ant build, I always get a build error on this attribute - error due to missing type HybrisEnumValue.

This is my Items.xml entry :

 <itemtype code="xyz" generate="true" autocreate="true">
        <deployment table="xyz" typecode="1"/>
        <attributes>
            <attribute type="HybrisEnumValue" qualifier="def">
                <persistence type="property"/>
                <modifiers read="true" write="true" search="true" optional="true" />
            </attribute>

        </attributes>
    </itemtype>

Upvotes: 2

Views: 3131

Answers (1)

Free-Minded
Free-Minded

Reputation: 5430

HybrisEnumValue is not a Type, its actually a interface which you can't define in items.xml as a object type.

To define enumValue in your model, you need to first define your enum values using enumtype tag.

<enumtype generate="true" code="ColorEnum" autocreate="true"
        dynamic="true">
        <value code="BLACK" />
        <value code="BLUE" />
        <value code="BROWN" />
        <value code="GREEN" />
</enumtype>

Its your choice to either make your enumType dynamic or not. Dynamic means you can add values at runtime as well. Make sure your define enumType above your itemType.

Check here EnumType

Now define your enumType in your model like this ..

<itemtype code="xyz" generate="true" autocreate="true">
    <deployment table="xyz" typecode="1"/>
    <attributes>
        <attribute type="ColorEnum" qualifier="color">
            <persistence type="property"/>
            <modifiers read="true" write="true" search="true" optional="true" />
        </attribute>

    </attributes>
</itemtype>

Do ant all and it will generate ColorEnum.java which actually implements HybrisEnumValue.

Upvotes: 3

Related Questions