Category Affinity Enricher

Overview

A consumer's affinity for a category can be indicated by a number of consumer actions, not all of which are currently used in the current version of this enricher:

  • Viewing all products of a category
  • Adding a product of this category to his/her shopping cart
  • Purchasing or returning a product of a category

The current version of the Category Affinity Enricher reacts on a category view event and then creates HAS_AFFINITY relations and Affinity nodes.

The HAS_AFFINITY relations are between these nodes:

  • commerce/Session and commerce/Category
  • core/Profile and commerce/Category

If the relations exist, the property viewCount is increased on both of them. In addition, on every view, the affinity property of both relations is recalculated by the formula log10(viewCount).

The commerce/CategoryAffinity nodes have an ID in the format CATEGORY_[hash_value] where hash_value is calculated based on category's ID and user profile's ID.

Besides the ID, a CategoryAffinity node has the following properties:

  • affinity: A numerical representation of the consumer's affinity for the category.
  • categoryViewCount: The number of times the consumer has viewed the respective category page.
  • updated: Timestamp when this category view took place. The value is a UTC date and time in ISO 8601 format, such as: yyyy-MM-dd'T'HH:mm:ss.SSSZ.

This enricher establishes a core/HAS relationship between a Profile node and the CategoryAffinity node, and a commerce/TO relationship between the CategoryAffinity node and the Category node.


Events

The category view event, stored in the Context service, triggers the Category Affinity Enricher.

Triggered by SchemaPayload schemaPayload example
context/commerce/CategoryViewSchema{'eventType': 'CategoryDetailPageViewEvent','payload': {'sessionId':'someSessionId','action':'viewcategory','_pkc':'Shoes','user':'someUser','tenant':'someTenant','data':[{'categoryName':'someCategory'}],'cvar':[{'1':['cart_id','789']},{'5':['_pkc','Shoes']}]} }

The Category Affinity Enricher draws an edge between the Profile node and a CategoryAffinity node, and between a CategoryAffinity node and a Category node and draws an edge between the Session node and the Profile node in the graph database, as shown in the graph database. The affinity property of the CategoryAffinity node is a positive number representing the intensity of a user's affinity towards a category. The categoryViewCount property is a positive integer representing the total number of category views across all sessions for this profile. For more information, see the Secure Graph service documentation.

Node or Relationproperties
nodes/core/Profile
nodes/commerce/CategoryAffinityaffinity, categoryViewCount
nodes/commerce/Category
relations/core/Profile/commerce/CategoryAffinity/core/HAS
relations/commerce/CategoryAffinity/commerce/Category/commerce/TO
nodes/commerce/Session
relations/commerce/Session/commerce/Category/commerce/HAS_AFFINITYaffinity, viewCount
relations/core/Profile/commerce/Category/commerce/HAS_AFFINITYaffinity, viewCount


Metamodel

Enrichers react to one or more schema events. A schema event references a context, a node, an edge, or a property; for example, a keyword search context, the creation of a new category node, the update of an edge between category and cart nodes, or the update of an edge property. In response to a triggering schema, the enricher retrieves the complete event data from the Context service, enriches this data, and updates the graph accordingly. Enrichers can only affect their declared schemas in the graph.

The following interactive graphic displays the schemas that invoke this enricher and the schemas the enricher can affect in the graph.

To zoom in and out of the image, use the scroll wheel on your mouse. To pan the image, click on the background and drag.



Scopes

Scopes are strings that represent permission to access specific resources and/or operations. For example, a scope string may represent permission to write data to a data repository.

You must provide a proper scope that enables users to perform certain operations. The scopes should be granted in an access token from the OAuth 2.0 service. For more information about the authorization and authentication used in SAP Hybris services, and also about the scopes in general, see:

###Scopes hybris.profile_graph_view: Use this scope to view data in the graph.

hybris.profile_graph_manage: Use this scope to update data in the graph.

hybris.profile_consent_manage: Use this scope to read and update user consents.


Glossary

TermDescription
authorizationThe process of determining whether a given microservice has permission to gain consent.
consentPermission to access (read, write) specific profile data, for example, permission to read/write age estimation or physical address. A consumer and a tenant can grant and revoke consent for subsets of their respective data.
consent classA string alias, defined by developers, that references a set of profile data (also called "schemas") for which consent can be granted and revoked. This string is exposed to users (consumers and tenants) as a reference through which they control consent. For example, the Consent Class "Purchases" might reference a set of data that includes items purchased, purchase dates, and purchase prices. Toggling consent for "Purchase" would enable and disable consent for that entire set of data.
consent referenceA unique, randomized string that serves as a passcode to decrypt data associated with one or more schemas. Various service calls require a consent reference. For example:
consumerThe end user whose actions yield profile data in the graph. A profile describes a single consumer.
contextData that affects the state of the graph. This data can be collected from consumer-triggered events or from third-party sources such as weather stations.
Context AdapterA microservice that receives data and, optionally, adapts it for entry into the graph. For example, a context adapter can adapt address data by adding a ZIP code and normalizing the street labels (for example, changing "St" to "Street"). The Context Adapter then passes the data through the Context service, which caches it so that enrichers can subsequently persist the data in the graph.
context repositoryA temporary cache for adapted context data, before it is further processed by enrichers and persisted in the graph.
context serviceAn internal microservice that manages the insertion of, and the retrieval of, context data in the Context Repository.
encryption keyA unique, randomized string used to encrypt and decrypt specific data in the graph. Each data element is encrypted with a different encryption key. Decryption, using this key, is required to access, view, and alter the data.
enricherA microservice that retrieves data from the Context Repository and/or Graph, possibly alters or extends it, and then persists data in the graph. An enricher can interpret data points, or sets of data points, to yield new data to persist. For example, an enricher can interpret purchasing data and contemporaneous weather station data to yield new data indicating that the consumer is a rainy-day shopper.
graphThe database that stores profile data as nodes, edges, and properties, and allows semantic queries. For example, the graph can represent a consumer"s shoe order as follows:
identityOne of many independent units of data used to identify a unique profile, such as an email address, browser type, or version.
profileTechnical definition: Data in the graph that is associated with a single consumer and is interdependent (in other words, it can be traversed through node-edge relationships).
schemaA string representation of a path in the graph that represents an abstraction, rather than a concrete instance, of a particular data structure. Schemas are used to define graph read/write permissions for SAP Hybris Profile microservices. A microservice must explicitly register one or more schemas representing the graph structure(s) it intends to access and alter. A schema has one of the following two forms:
tenantA registered entity with a shared commercial goal that subscribes to SAP Hybris Profile services and packages to reach that goal. A tenant can also develop and contribute enrichers and context adapters to the SAP Hybris Profile suite. Within YaaS, a tenant is a project.


  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.