How to create Localized String Collection

 Hybris has StringCollection OOTB


All the localized types are defined in {extensionName}-items.xml as maps. For example, localized:java.lang.String is defined in core-items.xml

Therefore, the best approach is to create a new maptype:

<maptypes>
    <maptype code="localized:StringCollection" argumenttype="Language" returntype="StringCollection" generate="false"/>
</maptypes>

Now the only thing that remains is to use the localized:StringCollection for the attribute that needs this type:

        <itemtype code="CustomCmsItemComponent" extends="SimpleCMSComponent"
                  autocreate="true" generate="true"
                  jaloclass="com.test.hybris.core.jalo.cms.CustomCmsItemComponent">
            <attributes>
                <attribute qualifier="localizedStringCollectionTest" type="localized:StringCollection">
                    <persistence type="property"/>
                </attribute>
            </attributes>
        </itemtype>

After building and updating the database I noticed that this solution works as expected.

Reference :https://stackoverflow.com/questions/52724713/how-to-create-localized-string-collection




Comments

Popular Posts