Product Description Scenario

A calculated attribute can be used to automate the process of building dynamic product descriptions. Using existing attributes, and based on different product lines, in the example below we will generate a product description that is comprised of a basic 'stem' attribute, and concatenated with additional attributes.

Assumptions

  1. The Primary Product Hierarchy is organized so that product attributes may be placed on different product nodes in that hierarchy that correlate to a 'product line.'
  2. Up to three 'building' attributes are appended to a constant base (or 'stem') attribute to compose the complete product description.
  3. The following attribute values exist for the product lines.

Product Line

Pencils

Writing Pens

Product Family Title ('stem')

BIC® Atlantis®

BIC® Grip Rollers

Point Size (PointSize)

 

Fine

Point Size MM (PointSizeMM)

0.5

 

Ink Color (InkColor)

 

Blue

Package Qty (PkgQty)

 

10

Pencil Type (PencilType)

Mechanical

 

The screenshot below displays the attribute values used to compose the calculated product description for the product lines in workbench:

Results

The result of either solution 1 or solution 2 defined below are the same:

Solution Option 1

Approach

  1. Create three 'Qualifier' attributes that will reference and be made valid on the product nodes in the Primary Product Hierarchy. These attributes will hold the IDs of the attributes to be used to compose the final Product Description. In this case those attributes will have the ID of Q1, Q2, and Q3 (with names of Qualifier 1, 2, and 3).
  2. Place the qualifier attributes on the appropriate product line object type(s) and populate the values with the IDs of the attributes to use for the composed product description. For example, the pencils product line will have Q1 = PencilType, Q2 = PointSizeMM, Q3 = {empty}; and the writing pens product line will have Q1 = PointSize, Q2 = InkColor, Q3 = PkgQty

Value Template

The calculated attribute template includes a concatenation / if structure like this:

concatenate(value('ProductFamilyTitle')
,if(exact(value('Q1'),''),'',concatenate(', ',value(value('Q1'))))
,if(exact(value('Q2'),''),'',concatenate(', ',value(value('Q2'))))
,if(exact(value('Q3'),''),'',concatenate(', ',value(value('Q3')))))

Notes

  • The syntax value(value('Q1')) is used to get the value of the attribute ID pointed to by the attribute Q1 if that value is not blank. The same is repeated for Q2 and Q3.
  • The concatenate function takes into account skipping over empty Qualifier attribute values as well as empty values in the attributes to be used to build the product description.
  • This approach is not limited to only three attributes. As many Qualifier attributes can be used as are required by inserting an copy of the 'Q2' line before the 'Q3' line. Note that the 'Q3' row in the value template includes the final closing parenthesis and should not be duplicated.
  • This approach requires only one calculated attribute to satisfy the needs of every product line. A more labor intensive (not recommended) approach would be to create a calculated attribute using fixed attributes for each product line.
  • For the same result while simplifying the calculation and making it more readable, use variables to hold the values of each attribute, as shown below:
{GetQ1 := if(exact(value('Q1'),''),'',concatenate(', ',value(value('Q1')))),
GetQ2 := if(exact(value('Q2'),''),'',concatenate(', ',value(value('Q2')))),
GetQ3 := if(exact(value('Q3'),''),'',concatenate(', ',value(value('Q3')))),
stem := value('ProductFamilyTitle')
}
concatenate(stem,GetQ1,GetQ2,GetQ3)
  • When using auto-generated attribute IDs, if you prefer to display the name of the attribute in the Qualifiers attribute (for readability purposes), allow the qualifier values to include either name or id first, separating them with a delimiter character such as a colon (:). For example, if the Point Size attribute had an ID of 12734, and Ink Color an ID of 28276, and Package Quantity an ID of 47338, the qualifier values could allow for entries of 'Point Size:112734', 'Ink Color:28276', and 'Package Quantity:47338'. Then need to modify the value template to parse out the attribute ID from each qualifier entry, as demonstrated for Q1 below:
{GetID1 := trim(mid(value('Q1'),find(":",value('Q1'))+1,100)),
GetQ1 := if(exact(GetID1,''),'',concatenate(', ',value(GetID1))),
....
}
concatenate(stem,GetQ1,GetQ2,GetQ3)

Solution Option 2

Approach

Instead of having separate qualifier attributes for each element in the product description, a single attribute could be used with all the required Qualifier IDs separated by a pre-designated delimiter character such as a comma.

  1. Create one qualifier attribute with the ID of Qualifiers (name is also Qualifiers).
  2. Reference the Qualifiers attribute on the appropriate product line object type(s), make it valid, and populate the values with the IDs of the attributes to use for the composed product description, separated by a comma delimiter. For example, PointSize,InkColor,PkgQty and PointSizemm,PkgQty

Value Template

This formula requires that the spaces before and after the delimiter must be accommodated.

{qattrs := iterate(ESCAPESPLIT(',', '/', value('Qualifiers')), 'trim(item)'),
  vals := filter(iterate(qattrs, 'value(item)'), 'not(exact(item, ""))')
}
concatenate(value('ProductFamilyTitle')', ',  list(vals, ', '))

Considerations

  • This approach first builds a list (label is 'qattrs') from the entries found in the attribute 'Qualifiers', separated by a comma.
  • Then another list (label is 'vals') is formed by iterating through the qattrs list.
  • Finally the list 'vals' is converted to a text string (with a comma / space as the separator between values) and is prepended to the ProductFamilyTitle attribute value.