Adding Properties to the Product Type – an Overview

Objective

After completing this lesson, you will be able to explain the process and benefits of adding properties to products using the type system.

Add Properties by Extending the Type System

SAP Commerce Cloud stores all its products in a database. The attributes that are stored, such as ID, name, summary, and so on, are defined in a type named Product. Any product item like a particular type of car is based on the Product type definition and therefore includes all the attributes defined in the type. Of course, the value of many of these attributes will be different for each item.

Note

Since modification of the type system is a developer task, we only cover the basics here. Before new properties appear in the Product Cockpit, SAP Commerce needs to be rebuilt, redeployed, and updated. 

If a developer decides that a new property applies to all products on the website, they will add it to the Product type. However, most new properties apply only to a subset of products, and the developer will typically extend the root type Product with a child type, which inherits all the properties of their Product parent type, and add the new properties to the child type. 

For example, the child type Car might add the property hp (indicating the car’s horsepower). All items (also known as instances) of type Car will have the property hp in addition to all the properties of type Product. Conversely, regular products and other child types, for whom this property doesn’t make sense, won’t have it.

Remember: Each car item will likely end up with a different value for the hp property.

Let's expand on this example: Type Product is extended by type Car, which itself is then extended by Sedan and Sports Car. For illustration purposes, each of these three subtypes adds a single property:

Diagram shows the Classification hierarchical structure using classifying categories.

Create and Add Product Instances to Categories on the Website

After the types are defined, let's have a look at our website with categories:

The Cars R Us site defines the categories Racing, Taxi, Delivery, and Dealership.

Diagram shows a catalog of an example of a root category with four product subcategories.

We create three instances of type Sedan, which we place in the Taxi, Delivery, and Dealership categories. We then create two instances of type SportsCar, which we place in the Racing and Dealership categories.

The following diagram describes all the entities involved:

Diagram shows the conventional way of adding properties to a content item, such as a product, to extend the base item type, adding properties in each derived type. From top to bottom: 1. A type hierarchy with Product at its root. 2. Car extends Product, adding the hp property. 3. Sedanextends Car, adding the property passengers. 4. Sportscaralso extends Car and adds on engineMod property to denote engine modifications. 5. Our catalog has the Cars R Us root category with four product subcategories. 6. Finally, we have cars available under each sub category Racing and Dealership offer sports cars; the others are sedans.

Log in to track your progress & complete quizzes