Create products

To create a product, you must perform the following:

  1. Get an instance of the CatalogManager object.
  2. Check if the product already exists.
    To check if the product already exists, make a query for a product with the same name and check if it returns null.
  3. Get the product type.
    Get an instance of the product type that the product is associated with. You cannot create product without specifying its product type.
  4. Create a new product.
    To create a new product type, call the CreateProduct method of the manager and pass the CLR product type as an argument.
  5. Set the properties of the product.
    You must set at least the following properties:
    • Title
    • IsActive
    • Sku
    • UrlName
    • ClrType
  6. Set the status of the product.
    Set the Status property of the product to GenericContent.Model.ContentLifecycleStatus.Master.
    This is the master version of the product, which you use when you modify the product. When you publish the product, you are creating a live version. For more information, see For developers: Content lifecycle.
  7. Recompile the URLs of the product.
    To recompile the URLs of the product, call RecompileItemUrls and pass the product as an argument.
  8. Save the changes to the catalog manager.
  9. Publish the product.
    To publish the product, call the MessageWorkflow method of the WorkflowManager class and pass the required arguments as shown in the example below.
    This creates a live version of the product that is displayed in the frontend.
  • Code example: Create a product

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 products