Adding Properties to the Product Type – an Overview

Objective

After completing this lesson, you will be able to outline how the type system can be used to add attributes to products.

Adding Properties by Extending the Type System

In this lesson, we'll show you how to add properties (also called attributes) to a product. For example, how to make sure a product has a description or a color associated with it.

To understand how this is done in SAP Commerce Cloud, we need to give you a very brief introduction to types. If you’re a consultant or developer taking this course, remember types, as you’ll see them a lot. Their utility goes far beyond what we discuss here, but for the business users among you, we’ll give a very simplified introduction.

What is a Type?

With that said, what is a type?

Almost everything you see in SAP Commerce Cloud is based on a type. Products, users, orders, tickets, and the list goes on.

For our purposes in this course, think of types as the template on which you’ll base your product. A developer creates types during SAP Commerce Cloud implementation. When a product manager clicks the "Create" button to add a new product, the product’s properties are determined by the type it's based on. For example, a name, an identifier, and a description. The new product is called an item and has the same properties as all other products based on that type – of course, you’ll set different property values for each item.

Let’s look at a simplified example. Say you work for Cars R Us, a company that sells cars. A developer could create a simple type for cars with a single property, hp (horsepower).

Note

A type that is used to create items is technically called an itemtype, as you‘ll see in the following image. But don’t worry, you don't need to remember anything about the code, it's only for visualization.

This image shows a simplified example XML file that is used to create an itemtype, which can be used to create an item car with the attribute hp.

Any type can have other types created under it in a hierarchy. These other types are called subtypes, and they inherit the properties of their parent type. Let’s introduce the type "Product' to hold basic attributes such as description, article number, and so on. The type "Car' extends "Product," gaining all attributes from it and adding its own attribute, "hp."

Again, don’t worry about the simplified code here, but it may help you understand how the different types are linked.

This image shows how a parent type Product can be extended by a child type car, using an example XML and a diagram representing what is in the simplified XML snippet.

Of course, there are likely more different kinds of cars to be added to the product catalog. So, more types can be created to add different properties to different kinds of cars. Each can be created as a subtype of another type and inherit all properties from the parent type.

A possible setup may be something like this:

  1. The basic type for all products that contains the properties "name," "identifier," and so on.
  2. Our "car" type with the property "hp."
  3. Sub-types for sedans and sports cars with properties for the number of passengers and engine modifications, respectively.
This diagram shows the hierarchical inheritance structure of types. Product is the root type, derived by Car, which in turn has Sedan and SportsCar as sub-types (also known as children).

Create and Add Product Items 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.

This diagram shows product catalog with the Cars R Us root category, containing three product subcategories.

Note

The type defines the properties that exist, including those inherited from parent types. An item serves as the "physical representation" of a type. For instance, each item of the type SportsCar shares the same attributes, even if you create thousands of them – they only differ in the values of those attributes.

We create two Sedan items, placing them in the Delivery and Dealership categories. Then, we create two SportsCar items, which we categorize under Racing and Dealership.

The following diagram describes all the entities involved:

This diagram shows the conventional way to add properties to a content item, such as a product, to extend the base item type by adding properties in each derived type. In one example, a product (or item) DeLorean is placed in a Dealership category and inherits hp and engine mod as attributes. Further examples show the same principle.

Summary

  • Type definitions play a major role in SAP Commerce Cloud.
  • Items, such as Products, derive their properties from the type on which they're based.
  • Items of the same type share the same properties, but with different values.
  • Development work is necessary to change a type definition.
  • Sub-types extend parent types to inherit their properties.