Create product variations

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

  1. Get the catalog manager.
    Get an instance of the CatalogManager object.
  2. Get the specified product.
    Get an instance of the product that the variation will belong to. For more information, see For developers: Query products.
  3. Get the specified attribute value.
    Get an instance of the attribute value that the variation will be associated to.
  4. Create new product variation.
    To create new product variation, call the CreateProductVariation method of the manager.
  5. Set the properties of the ProductVariation instance.
    In this example the following properties are set:
    • AdditionalPrice
    • Parent
    • Sku 
    • IsActive
  6. Set the Variant property.
    To set the variant property, you must perform the following:
    1. Create an instance of the AttributeValuePair class.
    2. Set its AttributeId property to the ID of the attribute that the specified value belongs to. 
    3. Set the AttributeValueId to the ID of the specified attribute value.
    4. Create an instance of the JavaScriptSerializer class.
    5. Serialize the AttributeValuePair instance into a string.
    6. Set the Variant property of the variation to the serialized string.
  7. Create a product variation detail.
    To create a product variation detail, you must perform the following:
    1. Create a new instance of the ProductVariationDetail class by calling the CreateProductVariationDetail method of the manager. 
    2. Set the ProductAttributeParent to the instance of the attribute that the specified attribute value belongs to.
    3. Set the ProductAttributeValueParent to the instance of the specified attribute value.
    4. Set the ProductVariationParent to the instance of the product variation.
    5. Set the ProductVariationDetailParentId to Guid.Empty.
  8. Add the variation to the product.
    Add the instance of the product variation to the ProductVariations collection of the product.
  9. Save the changes.
    Save the changes to the catalog manager.
Here is a code example:


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?