Create product types

To create a product type, you must perform the following:

  1. Get instances of the following managers:
    • Ecommerce manager
    • Metadata manager
    • Catalog definition manager
  2. Get the initial count of product types.
  3. Create a new product type.
    To create a new product type, call the CreateProductType method of the manager.
  4. Set the properties of the product type.
    In the code example below the following properties are set:
    • Title
      Represents the display name of the product title.
    • TitlePlural
      Represents the plural display name of the product type.
    • ProductDeliveryType
      Represents how the products of this type are delivered.
      You can choose between Shippable, Downloadable, and Services.
  5. Create a dynamic type for the product type.
    The dynamic type allows you to customize each product type by adding custom fields to it. These fields are also applied to the products of this product type.
    To create a dynamic type, you must call the CreateProductTypePersistence method of the catalog manager and pass the instance of the product type, an instance of the metadata manager, and an output parameter for the name of the created dynamic type.
    For more information, see For developers: Custom fields of product types.
  6. Set the ClrType property of the product.
    To associate the product type with the dynamic type, set the ClrType property to the name of the dynamic type.
  7. Add a definition for the product type.
    The definition represents the visualization of the product type in the backend of the Products section. It lists the product types links on the page, which Sitefinity CMS displays when there are no products created.
    To add a definition for the product type, call the AddProductTypeDefinition method of the catalog definition manager. If the currently created item is the second in the list, you must adjust the definition for multiple product types. To do this, call the AdjustForMultipleProductTypes of the catalog definition manager and pass the already existing product type as an argument.
  8. Save the changes.
    Save the changes to the catalog manager and the metadata manager.
  9. Restart the product service host.
    To restart the product service host, call the RestartProductServiceHost static method of the ProductTypeResolver class.
Code example for creating a product type

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?

Next article

Query product types