ProductCatalog.CreateProduct
Use this method to create a new product within the catalog according to specified parameters.
Definition
Function CreateProduct(strDefinitionName As String,varProductID As Variant,cyListPrice As Currency,Optional strParentCategoryName As Variant) As Product
Parameters
strDefinitionName
A String that contains the name of the product definition for the product.
varProductID
A Variant that contains the unique product ID for the product to be created. The data type must match the property used to uniquely identify products in this catalog.
cyListPrice
A Currency object that contains the list price of the product to be created.
strParentCategoryName
A Variant that contains the name of the category to be designated as the parent category of the product to be created.
Return Values
If this method completes successfully, it returns the Product object that was created.
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_CATEGORY_DEFN_FOR_PRODUCT | &H8898004A | The specified definition was a category definition not a product definition |
E_CAT_CATEGORY_DOESNT_EXIST | &H8898001C | The specified category did not exist. |
E_CAT_DEFINITION_DOESNT_EXIST | &H8898000B | The specified definition did not exist. |
E_CAT_PRODUCT_EXISTS | &H8898001B | The specified product ID was already in use.
The product ID must be unique throughout the catalog. |
E_CAT_INVALID_PRODUCTID | &H8898005B | The length of the ProductID exceeded 256 characters. |
E_CAT_INVALIDVALUE_FOR_PRODUCTID | &H8898004E | An invalid value was specified for the ProductID |
Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.
Remarks
A product family is a product that has variants.
The properties of the definition on which a new product is based will determine whether the product being created is a single product or a product family. If the definition used to create the product has variant properties, the newly created product will be a product family.
For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.
Example
SET oMyNewProduct = myProductCatalog.CreateProduct("BasicProduct", "SKU3004", cyListPrice, "Apparel")