Adding an attribute dictionary attribute usage type
Attribute dictionary attributes have two predefined usage types: Predefined allowed value attributes and assigned value attributes. If the predefined attribute usage types are insufficient to meet your business requirements, you can create custom attribute usage types. To create custom usage types, you will need to create a custom business object mediator and catalog properties, and add the usage field in the Management Center. When assigning an attribute to a catalog entry, you will need to select the custom usage type from the drop down list for usage type.
Procedure
- Go to WC/xml/config.
- In the WC/xml/config folder, create a com.ibm.commerce.catalog-ext folder, if one does not exist.
- Inside the com.ibm.commerce.catalog-ext folder, create a wc-business-object-mediator.xml file. This xml file will define the mapping of the Usage column for the CATENTRATTR table for use as user data.
- Open the wc-business-object-mediator.xml file
for editing. Add the following XML code to the file to map the usage
column:
<_config:BusinessObjectMediatorConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-business-object-mediator.xsd" xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"> <_config:object logicalType="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType" physicalType="com.ibm.commerce.catalog.facade.server.entity.datatypes.CatalogEntry"> <_config:property-mapping logicalType="com.ibm.commerce.catalog.facade.datatypes.CatalogAttributeType" physicalType="com.ibm.commerce.catalog.facade.server.entity.datatypes.CatalogEntryAttributeRelation"> <_config:userDataProperty logicalPropertyName="usage" physicalPropertyName="usage"/> </_config:property-mapping> </_config:object> </_config:BusinessObjectMediatorConfiguration>
- Add the properties to customize the Catalog properties
file.
- Go to LOBTools/src.
- Create the package com.mycompany.commerce.catalog.client.lobtools.properties.
- In the package create the properties file CatalogLOB.properties.
- In the properties file, add the following properties:
attributeUsageType1=Defining attributeUsageType2=Descriptive attributeUsageTypeA=A attributeUsageTypeB=B attributeUsageTypeC=C
- Extend the catalog management resource bundle.
- Create the folder mycompany under LOBTools/WebContent/WEB-INF/src/lzx.
- Create the folder catalog under LOBTools/WebContent/WEB-INF/src/lzx/mycompany.
- Create the file extCatalogManagementResourceBundle.lzx under LOBTools/WebContent/WEB-INF/src/lzx/mycompany/catalog.
- In the extCatalogManagementResourceBundle.lzx file,
extend the resource bundle by adding the following code:
<library> <class name="extCatalogResourceBundle" extends="wcfResourceBundle" baseName="com.mycompany.commerce.catalog.client.lobtools.properties.CatalogLOB"> <wcfResourceBundleKey name="attributeUsageType1"/> <wcfResourceBundleKey name="attributeUsageType2"/> <wcfResourceBundleKey name="attributeUsageTypeA"/> <wcfResourceBundleKey name="attributeUsageTypeB"/> <wcfResourceBundleKey name="attributeUsageTypeC"/> </class> <extCatalogResourceBundle id="extCatalogResources"/> </library>
- Go to LOBTools/WebContent/WEB-INF/src/lzx/commerce/catalog/CatalogExtensionsLibrary.lzx. Add
the following code.
<library> <!-- File to add customer libraries --> <include href="../../mycompany/catalog/extCatalogManagementResourceBundle.lzx"/> </library>
- Add the usage field in the Management Center object.
- Go to the LOBTools/WebContent/config/commerce/catalog/objectDefinitions/ directory.
- Open AttributeDictionaryCommonObjectDefinition.def for editing.
- Under the object definitions:
- catBaseCatalogEntryReferenceDescriptiveAttributeDictionaryAttributeWithAllowedValues
- catBaseCatalogEntryReferenceDescriptiveAttributeDictionaryAttributeWithAssignedValues
<PropertyDefinition displayName="${catalogResources.attributeUsagePrompt}" maximumSize="254" propertyName="xrel_usage" required="true"> <PropertyValue displayName="${extCatalogResources.attributeUsageType2}" value="2"/> <PropertyValue displayName="${extCatalogResources.attributeUsageTypeA}" value="A"/> <PropertyValue displayName="${extCatalogResources.attributeUsageTypeB}" value="B"/> <PropertyValue displayName="${extCatalogResources.attributeUsageTypeC}" value="C"/> </PropertyDefinition>
- Go to the LOBTools/WebContent/config/commerce/catalog/listViewDefinitions/ directory.
- Open CatalogEntryAttrDictDescriptiveAttributeGrid.def for editing.
- Insert the line:
<GridComboBox editable="true" languageSensitive="false" name="xrel_usage" propertyName="xrel_usage" text="${catalogResources.attributeUsagePrompt}" visible="true" width="120"/>
after the line:<GridComboBox editable="false" enableFilter="true" name="attrDataType" objectPath="AttributeDictionaryAttributes" propertyName="attrDataType" required="true" text="${catalogResources.attributeDataType_ColumnHeader}" visible="true" width="130"/>
- Right-click on project LOBTools. Click Build OpenLazlo Project to run the build process.
- Restart the server.