Product.CreateVariant

Ee797974.c++_on(en-US,CS.10).gifEe797974.vb_off(en-US,CS.10).gif

Use this method to create a new product variant of the current product. Only product specifc attributes will be set in the new variant.

Definition

Function CreateVariant(varProductVariantID As Variant) As Recordset

Parameters

varProductVariantID

A Variant that contains the unique ID of the product variant.

Return Values

If this method completes successfully, it returns a recordset that contains the properties for the variant.

Error Values

This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Constant Value Description
E_CAT_BLANK_VARIANT &H8898004F A blank value was specified for the VariantID.
E_CAT_CATALOG_DOESNT_SUPPORT_VARIANTS &H88980032 This catalog does not support product variants. This is determined when the catalog is created and cannot be changed.
E_CAT_INVALID_VARIANTID &H8898005C The VariantID exceeded 256 characters in length.
E_CAT_INVALIDVALUE_FOR_PROPERTY &H88980038 An invalid value was specified for one of the product properties.

This error can be due to:

  • One of the values in the recordset does not satisfy the requirements of the minimum value/maximum value attributes set for the properties.

  • An enumeration property has a value that is not defined in its list of legal values.

  • Strings exceed the maximum length defined for the property or are shorter than the minimum length.
E_CAT_INVALIDVALUE_FOR_VARIANTID &H8898004D An invalid value was specified for the VariantID.

This error can be due to the value of the VariantId being out of range.

E_CAT_NO_VARIANTS_UNDER_PRODUCT &H88980051 This product does not support variants. Variants cannot be created under a regular product.
E_CAT_PRODUCT_DOESNT_EXIST &H8898001E This product has been removed from the catalog.
E_CAT_VARIANT_EXISTS &H88980026 The specified variant already existed.

Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

The value and type of the varProductVariantID parameter must be valid for the property specified as the unique ID for product variants. This property, strProductVariantID, is specified when a catalog is created.

If the catalog created does not support variants, that is strProductVariantID was not specified on catalog creation, an error is returned.

Upon successful completion, the method returns an ActiveX Data Object (ADO) recordset that contains fields for all the properties defined for the new product-variant and an integer field named oid. The oid field is for internal use and should not be updated. The returned recordset is updateable, but disconnected. In order to modify the variant properties, pass this recordset to the SetVariantProperties method.

The product-variants inherit the properties that are present in the product definition. Values for non variant-specific product properties are propagated from the Product object down to the variants, but values for variant-specific properties must be explicitly set for each variant.

The variant ID value should be unique within the product family. There can be two product variants with same variant IDs within the same catalog, as long as they are in different product families and the unique Product identifier and the unique Variant identifier are different.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

Example

Set rsVariantProps = myProduct.CreateVariant("SKU4005XLA")

See Also

Product Object

Product.DeleteVariant

Product.SetVariantProperties


All rights reserved.