Reuse attribute assigned values with the Data Load utility

We can use the Data Load utility to reuse assigned values for attributes when the same value is needed for multiple catalog entries. By reusing attribute assigned values across catalog entries, we can reduce the number of duplicate values that are created in the database.

If the site typically uses attributes with assigned values instead of attributes with predefined (allowed) values, many duplicate assigned values can exist for catalog entries since assigned values are not reused across catalog entries. The duplication of assigned values can cause the number of records in the ATTRVAL and ATTRVALDESC database tables to grow large, which can affect the performance of retrieving attribute information. For example, many catalog entries can have the same descriptive attribute Material with the same attribute value 100% Cotton. If the attribute uses assigned values, the value 100% Cotton is duplicated in the database for each catalog entry. If you use the Data Load utility to load the attribute values and reuse values, the utility creates only a single instance of the value. Alternatively to avoid duplicate assigned values and as a general best practice for using the attribute dictionary, use attributes with predefined values instead of attributes with assigned values whenever possible. Specifically, try to use attributes with predefined values when multiple catalog entries need the same attribute and value. If you do need to use attributes with assigned values, consider using the Data Load utility to load the catalog entry, attribute relationship, and assigned value information.

Note: If we use attributes with assigned values because attributes with predefined values display only 500 values in Management Center, as a best practice, use multiple attributes with predefined values instead. For instance, create separate attributes with predefined values for use within specific categories. For instance, we can create a Material attribute for each category. These attributes can all have the same name Material, but have different unique identifiers, such as material-shirts, material-shorts, and material-paints. By separating the predefined values into multiple instances of an attribute, the number of values for each attribute is reduced and business users can locate specific values easier. See Best practices for using the attribute dictionary.


Behavior changes when reusing assigned values

With the Data Load utility enabled to reuse assigned values, the behavior of the load process is different when we are creating, changing, or deleting assigned values.


Configuration property to enable and disable reusing assigned values

To enable or disable the reuse of assigned values, a new configuration property, shareAssignedAttributeValues is available for use with the CatalogEntryAttributeDictionaryAttributeMediator business object mediator. We can set the following values for this property:

To help demonstrate how to configure this property, the sample wc-loader-catalog-entry-AD-attribute-relationship.xml configuration file in the following directory is updated to include the property. We can use this file when loading you own data.

The following code demonstrates how to configure this property.

Another new configuration property is available to control the behavior when a business user updates or deletes an assigned value that is reused in Management Center. This KeepAssignedAttributeValueLocal configuration property is enabled by default and ensures that when business users update or delete an assigned value in Management Center, it does not affect other catalog entries that reuse the same assigned value. This KeepAssignedAttributeValueLocal configuration property is defined within the wc-business-object-mediator.xml file for configuring the business object mediators.

The following code shows this configuration, which is set for the CatalogEntryAttributeDictionaryAttributeMediator business object mediator.

We can set the following values for the property:


Example

Before you enable the Data Load utility to reuse assigned values, loading the following catalog entry and attribute with assigned value relationships loads duplicates of assigned values.

PartNumber AttributeIdentifier ValueIdentifier Value Usage Sequence
Shirt Material 100% Cotton Descriptive 1
Pants Material 100% Cotton Descriptive 1
Shorts Material 100% Cotton Descriptive 1

When you load this data into the database, each catalog entry uses the same attribute and attribute value information, but different attribute value records must be created for each value. Before you enable the reuse of values, you normally do not include the ValueIdentifier since the load process creates a new assigned value for each row. We can see these records by running the following SQL statement.

Where Material is the value of the AttributeIdentifier column. The following table shows the information that returns for the catalog entry and attribute relationship. These records include a different ATTRVAL_ID for each catalog entry and attribute relationship even though the actual value, 100% Cotton is the same.

CATENTRY_ID ATTR_ID ATTRVAL_ID Usage Sequence
19801 7000000000000000451 7000000000000008301 '2' 1
19802 7000000000000000451 7000000000000008302 '2' 1
19803 7000000000000000451 7000000000000008303 '2' 1

The different records for the same attribute and assigned value information includes duplicate attribute and assigned value relationship records in the ATTRVAL table. We can see these records by running the following SQL statement:

The following table shows the information that returns for these duplicate relationships.

ATTRVAL_ID ATTR_ID IDENTIFIER VALUSAGE
7000000000000008301 7000000000000000451 Cotton NULL
7000000000000008302 7000000000000000451 Cotton1 NULL
7000000000000008303 7000000000000000451 Cotton2 NULL

The duplicate assigned value records are stored in the ATTRVALDESC tables, which we can see by running the following SQL.

ATTRVAL_ID ATTR_ID Value
7000000000000008301 7000000000000000451 100% Cotton
7000000000000008302 7000000000000000451 100% Cotton
7000000000000008303 7000000000000000451 100% Cotton

When the Data Load utility is enabled to reuse assigned values, the same data is stored in the database differently. In your input file, we can include the same value identifier for different catalog entries without encountering an exception.

PartNumber AttributeIdentifier ValueIdentifier Value Usage Sequence
Shirt Material Cotton 100% Cotton Descriptive 1
Pants Material Cotton 100% Cotton Descriptive 1
Shorts Material Cotton 100% Cotton Descriptive 1

When the data loads, the catalog entry and attribute relationship can point to the same assigned value. We can see this change by running the following SQL statement.

CATENTRY_ID ATTR_ID ATTRVAL_ID Usage Sequence
19801 7000000000000000451 7000000000000008301 '2' 1
19802 7000000000000000451 7000000000000008301 '2' 1
19803 7000000000000000451 7000000000000008301 '2' 1

The ATTRVAL table now includes only a single record for the attribute and attribute value relationship and the ATTRVALDESC table includes only a single record for the assigned value.