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 theCatalogManager, 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 whether 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.
    To ensure that the product is localized for a particular culture, create a using scope with an instance of the CultureRegion class and modify the Title inside this scope.
  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.

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?