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.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. 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?