IProductCatalog::CreateProduct
Use this method to create a new product within the catalog according to specified parameters.
Definition
HRESULT IProductCatalog::CreateProduct(BSTRstrDefinitionName,VARIANTvarProductID,CURRENCYcyListPrice,VARIANTstrParentCategoryName,IProduct**ppProduct);
Parameters
strDefinitionName
[in] A BSTR that contains the name of the product definition for the product.
varProductID
[in] 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
[in] A CURRENCY object that contains the list price of the product to be created.
strParentCategoryName
[in, optional] A VARIANT that contains the name of the category to be designated as the parent category of the product to be created.
ppProduct
[out, retval] A pointer to a Product object used to return the properties of the newly created product.
Return Values
This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.
Error Values
This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT 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 | 0x8898004A | The specified definition was a category definition not a product definition |
E_CAT_CATEGORY_DOESNT_EXIST | 0x8898001C | The specified category did not exist. |
E_CAT_DEFINITION_DOESNT_EXIST | 0x8898000B | The specified definition did not exist. |
E_CAT_PRODUCT_EXISTS | 0x8898001B | The specified product ID was already in use.
The product ID must be unique throughout the catalog. |
E_CAT_INVALID_PRODUCTID | 0x8898005B | The length of the ProductID exceeded 256 characters. |
E_CAT_INVALIDVALUE_FOR_PRODUCTID | 0x8898004E | An invalid value was specified for the ProductID |
Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.
Remarks
The ppProduct parameter contains valid data only if the property was accessed successfully.
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.