Feature lookup rules dynamically display asset properties of a related asset on an asset page, without storing the data in the displayed asset. For example, on product pages that belong to a Product family, Product series, Product edition, or Product set.


Target groups

  • Solution developers
  • Solution administrators

Context

Feature lookup rule assets contain a rule set to look up assigned features in defined paths.

Prerequisites

None

Introduction

In asset structures that represent classification systems, or that are variants of the same original asset, it can be helpful or necessary to display asset properties across relations and paths without inheriting them to the target asset. For example, in PIM systems, Product families store additional features that are only required in the Product family context, but not in the Product. However, for users, it is helpful to see all the properties in one place on a Product asset page.

Feature lookup displays asset properties across asset relations but does not store the looked-up data in the target assets. Feature lookup keeps the asset data model consistent and does not add unnecessary data to an asset.

Note: Inline editing is not possible for looked up feature values. As the feature value information is not stored in the target asset, it is not possible to edit the feature values with the inline edit function.

To configure a Feature lookup, censhare uses a Feature lookup rule asset. The asset contains an XSL stylesheet. The stylesheet defines across which asset relations and paths a feature is looked up. To setup a feature lookup, the desired Feature asset must be assigned to the Feature lookup rule.

Features can be looked up over direct and indirect relations. The looked-up feature is only shown in the target asset, not in the intermediate assets. For example, if a feature is looked up in the root Product category, the feature is displayed only in the Product (target asset), but not in the Product categories between the root category and the product.

The Feature lookup can be stopped on the target asset or overwritten with a new value. If the Feature lookup is stopped, censhare adds a Lookup stop feature to the target asset. The value of the Lookup stop feature references the looked-up feature. If the looked-up feature is overwritten, the feature itself is added to the target asset with the new value.

The following graphic shows the schema of feature lookup:

The root Product category (1) contains a feature called "Former category". This is an informative feature and therefore not required in the product data. With a Feature lookup, the "Former category" feature is looked up and displayed in Product asset pages (4). The looked-up feature is not stored in the Product asset, nor does it appear in the intermediate child Product categories (2,3).

Technical implementation

Feature lookup uses the following principles:

Feature lookup rules

The asset type Module / Feature lookup rule contains the definition of paths and prioritization in an XSL stylesheet. The censhare standard solution is delivered with the Feature lookup rule Product variants, families, categories. This Feature lookup rule can be used without further configuration. The following code examples are taken from this Feature lookup rule. You can create your own rules based on this example. The code is taken from the asset with the resource key censhare:feature-inheritance-rule.product-variants-families-categories:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:cs="http://www.censhare.com/xml/3.0.0/xpath-functions"
                xmlns:csc="http://www.censhare.com/censhare-custom"
                exclude-result-prefixes="cs csc">

 <xsl:template match="/asset">
  <xsl:variable name="asset" select="."/>

<!-- 1. priority: original asset of variant and recursive their variant originals -->
  <xsl:if test="$asset/parent_asset_rel[starts-with(@key, 'variant.')]">
   <path description="Variant originals">
    <xsl:copy-of select="csc:getVariantRelatedParentAssets($asset)"/>
   </path>
  </xsl:if>

<!-- 2. priority: product family -->
  <xsl:if test="$asset/parent_asset_rel[@key='user.product-family.']">
   <path description="Product families and recursive their product families">
    <xsl:copy-of select="csc:getRelatedParentAssets($asset, 'user.product-family.')"/>
   </path>
  </xsl:if>

<!-- 3. priority: product categories (assigned categories and recursive their parent categories) --> 
  <xsl:variable name="assetRefs"
                select="$asset/asset_feature[@feature='censhare:product.category']"/>
  <xsl:if test="$assetRefs">
   <path description="product categories and recursive their parent categories">
    <xsl:for-each select="$assetRefs">
     <xsl:variable name="originalAsset" select="cs:get-asset(@value_asset_id)"/>

<!-- add parent product categories -->
      <xsl:copy-of select="csc:getRelatedParentAssets($originalAsset, 'user.product-category-hierarchy.')"/>

<!-- add own asset -->
     <xsl:copy-of select="$originalAsset"/>
    </xsl:for-each>
   </path>
  </xsl:if>
 </xsl:template>

<!-- get recursive variant related parent assets of given asset -->
  <xsl:function name="csc:getVariantRelatedParentAssets" as="element(asset)*">
   <xsl:param name="asset" as="element(asset)"/>
    <xsl:for-each select="$asset/parent_asset_rel[starts-with(@key, 'variant.')]">
     <xsl:variable name="originalAsset" select="cs:get-asset(@parent_asset)"/>

<!-- add parent variant assets -->
  <xsl:copy-of select="csc:getVariantRelatedParentAssets($originalAsset)"/>

<!-- add own asset -->
  <xsl:copy-of select="$originalAsset"/>
   </xsl:for-each>
  </xsl:function>

<!-- get recursive related parent assets of given asset and relation key -->
  <xsl:function name="csc:getRelatedParentAssets" as="element(asset)*">
   <xsl:param name="asset" as="element(asset)"/>
   <xsl:param name="relationKey"/>
   <xsl:for-each select="$asset/parent_asset_rel[@key=$relationKey]">
    <xsl:variable name="originalAsset" select="cs:get-asset(@parent_asset)"/>

<!-- add parent assets -->
    <xsl:copy-of select="csc:getRelatedParentAssets($originalAsset, $relationKey)"/>

<!-- add own asset -->
    <xsl:copy-of select="$originalAsset"/>
  </xsl:for-each>
 </xsl:function>
</xsl:stylesheet>
XML

To enable feature lookup, add a reference of the Feature lookup rule to the desired Feature asset (feature ID: censhare:feature.lookup-rule).

Feature lookup paths

You can look up features along paths. A path consists of a cascade of asset relations. To build a path, specify the relation type and the direction (parent or child relation). In the example above, two lookup paths are implemented:

  • csc:getVariantRelatedParentAssets looks up all parent assets of an asset variant. The looked-up feature is retrieved from the original asset.

  • csc:getRelatedParentAssets looks up all parent assets of either a Product family hierarchy or a Product category hierarchy. The respective asset relation key must be passed to the function from the target asset. For details, see the following section.

To lookup features in child direction relations, you must add a function csc:getRelatedChildAssets and set the respective attributes.

Feature lookup prioritization

In the example above, a three-stage prioritization is implemented.

  1. First, the Feature lookup rule checks if the target asset is an asset variant and looks up the assigned features in the original source (parent assets in a variant relation).

  2. Next, the Feature lookup rule checks if the target asset is part of a Product family and looks up the assigned features in the parent Product family. If a Product family hierarchy exists, the feature is looked up in the root Product family.

  3. Finally, the Feature lookup rule checks if the target asset is placed in a Product categoryand looks up the assigned features in the parent Product category. If a Product category hierarchy exists, the feature is looked up in the root Product category.

In the second and third stages, the relation type must be specified and passed to the lookup path. To look up features in other asset structures, add a new code snippet in the desired prioritization. For example, to look up features from a Product set, or a Product edition.

If a looked-up feature occurs in two or more looked up paths, the feature value from the path with the higher priority is retrieved and displayed in the target asset.

Feature lookup stops

Looked-up features can be disabled with a Feature lookup stop. If a user clicks Stop lookup in the dialog, censhare adds a Feature lookup stop to the target asset:

<asset_feature asset_id="12345"
               feature="censhare:feature.lookup-stop-feature-key"
               value_string="censhare:product.ean"/>
XML

The value of the Feature lookup stop contains the ID of the originally looked up feature.

Result

You can create your own Feature lookup rules and apply them to your asset structures, product classifications, etc. To enable feature lookup, add a reference of the Feature lookup rule to the desired Feature asset (feature ID: censhare:feature.lookup-rule).