Product3.CreateVariant Method (PIA)
Use this method to create a new product variant of the current product. Only product-specific attributes will be set in the new variant.
Definition
[Visual Basic .NET]
Imports Microsoft.CommerceServer.Interop.Catalog
Imports ADODB26Lib ' for _Recordset
…
Public Function CreateVariant(varProductVariantID As Object) As _Recordset
[C#]
using Microsoft.CommerceServer.Interop.Catalog;
using ADODB26Lib; //For _Recordset
…
public _Recordset CreateVariant(objectvarProductVariantID);
Parameters
[Visual Basic .NET]
- varProductVariantID
An Object that contains the unique ID of the product variant.
[C#]
- varProductVariantID
An object that contains the unique ID of the product variant.
Return Values
[Visual Basic .NET] If this method completes successfully, it returns a _Recordset interface to a Recordset that contains the properties for the object.
[C#] This method returns a _Recordset interface to a Recordset object used to return the product variant.
Exceptions
This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.
The following table shows the custom COM errors that a COMException can wrap.
Constant | Value | Description |
---|---|---|
E_CAT_VC_NOT_A_SUPPLIER_CATALOG | [C#] 0x889800F9 [Visual Basic .NET] &H889800F9 |
Invalid catalog type. This API can only be called on a base catalog. |
E_CAT_CATALOG_DOESNT_SUPPORT_VARIANTS | [C#] 0x88980032 [Visual Basic .NET] &H88980032 |
This catalog does not support variants. To support variants, a catalog must be created with a variant identifier. |
E_CAT_NO_VARIANTS_UNDER_PRODUCT | [C#] 0x88980051 [Visual Basic .NET] &H88980051 |
You cannot create a variant under a regular product. Variants can be created under product families only. |
E_CAT_INVALID_PARAMETER | [C#] 0x889800B6 [Visual Basic .NET] &H889800B6 |
The input parameter <parameter number> is invalid. |
E_CAT_INVALID_VARIANTID | [C#] 0x8898005C [Visual Basic .NET] &H8898005C |
The value you specified for the VariantID exceeds the maximum allowed length of 256 characters. |
E_CAT_INVALIDVALUE_FOR_VARIANTID | [C#] 0x8898004D [Visual Basic .NET] &H8898004D |
The value you specified for the VariantID is either out of range or does not satisfy the Min/Max condition. |
E_CAT_BLANK_VARIANT | [C#] 0x8898004F [Visual Basic .NET] &H8898004F |
You have specified a blank value for the VariantID. A variant cannot be created with a blank value. |
E_CAT_VC_INVALID_VARIANT_ID | [C#] 0x889800FC [Visual Basic .NET] &H889800FC |
The value you specified for the VariantID exceeds the maximum allowed length of 348 characters. |
E_CAT_VARIANT_EXISTS | [C#] 0x88980026 [Visual Basic .NET] &H88980026 |
The product variant you specified already exists. |
E_CAT_PRODUCT_DOESNT_EXIST | [C#] 0x8898001E [Visual Basic .NET] &H8898001E |
The product you specified does not exist. |
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 Objects (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. 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 the same variant ID within the same catalog, as long as they are in different product families.
[Visual Basic .NET]
Example
rsVariantProps = myProduct.CreateVariant("SKU4005XLA")
Requirements
Namespace: Microsoft.CommerceServer.Interop.Catalog
Platforms: Windows 2000, Windows Server 2003
Assembly: Cataloglib (in Cataloglib.dll)
See Also
Copyright © 2005 Microsoft Corporation.
All rights reserved.