Definitions

Definitions are the foundation for flexible data in Ucommerce

A lot of the business objects in Ucommerce are based on definitions, which are also referred to as dynamic entities. This article will cover how to work with definitions to make your store more flexible.

Dynamic entities includes (but are not limited to):

  • Stores

  • Catalogs

  • Categories

  • Products

  • Promotions

  • Payment methods

  • Shipping methods

  • Orders/Carts

What Are Definitions?

The idea behind definitions is to enable saving additional information, tailored to your specific needs, for each entity.

Consider the following scenario: You sell shirts and shoes in the store. To do that you need information about sizes and colors on your products.

The solution is simple - Ucommerce supports definitions, to which new fields can be added to store the information you need. You might already be familiar with the concept of Document Types in Umbraco or Templates in Sitecore. A definition in Ucommerce is basically the same thing, but for e-commerce.

Definition Fields

Definitions have a list of fields, which are available to the store manager to maintain in the back office. For the shirts definition you can have two fields available: Color and Size. For the shoe definition you can have one field available: Size.

Each field has a number of configuration options, which influence the look and functionality in the back office UI. They will be covered in detail in the next sections.

Multilingual Fields

If you need to maintain the data of the field in multiple languages, you can mark the field as being multilingual. This will allow you to define a value per language configured.

Display on Site

A true/false value which is set on the field to indicate whether to display the field on the website. If set to false, the field will not be part of the search index.

Render in Editor

Sometimes you need data you don’t want the back office user to edit. Setting this property to false will exclude the field from the back office UI, effectively making the field accessible via code only.

Data Type

Each field has an associated data type, which determines the editor for the particular field, e.g. a checkbox, text box, date picker, etc. Ucommerce comes with a number of built-in data types such as ShortText, LongText, Number, Boolean, Enum, and Image. Enum is a special type that enables you to predefine a list of values for the back office user to select from, e.g. colors or sizes. Basically data with a finite number of options to choose from.

Validation Expression

A data type can have a validation expression associated with it to validate user input when editing in the back office. A validation expression is a standard regular expression evaluated whenever a field of the given type is saved.

Variant property (products only)

When creating a definition field on a product, you can decide whether it is a variant field, or not. This will change the definition field from appearing on the parent product, or on the product variant.

Composable Definitions

A definition can inherit from other definitions, which enable you to build your definitions in a composable way. Add fields, which are common across multiple definitions, in a single definition and reuse it as a parent for other definitions, e.g. SEO information is something you want to store on all products and categories regardless of their various definitions so the shirts, shoes, and accessories definitions all inherit from the SEO definition.

The result is less work when defining new fields as shared fields can be added once and "mixed" in with the relevant definitions.

Ucommerce supports inheritance from multiple parents, which means a single definition may inherit from multiple other definitions, e.g. the Shoe definition might inherit fields from both the SEO and Footwear definition.

Last updated