Create a localized product

In the following code example, you localize a product for the languages that are available in your Sitefinity CMS project.

In the example below, you perform the following:

  1. Get an instance of the CatalogManager class.
  2. Get an instance of the EcommerceManager class.
  3. Using the CatalogManager, check whether a product with the same title already exists.
    If a product with the same name does exist, discontinue the execution of the method and return an empty Guid.
  4. Using the EcommerceManager, check whether the specified product type that you want to create already exists.
    If the product type does not exist, discontinue the execution of the method and return an empty Guid.
  5. Using the CatalogManager, check wheter a product with the same ID already exists. 
    If a product with the same ID does not exist, create the product by calling the CreateProduct method of the CatalogManager class. When calling the CreateProduct method, pass the product type that you want to create.
  6. Set the properties of the product objects.
    Passing the culture when setting the Title of the product ensures that the product is localized for that specific culture.
  7. Set the ApprovalWorkflowState to Published for the desired localized version by passing the culture.
  8. Save the changes.
  9. Publish the product by calling the MessageWorkflow of the WorkflowManager.
    This forces the new item to go through the Ecommerce module's workflow for creating products.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?