Condividi tramite


CreateProduct Method (String, String, Decimal, String)

Creates a root product in the catalog with the specified Product definition, product identifier, List price, and parent category name.

Namespace:  Microsoft.CommerceServer.Catalog
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Function CreateProduct ( _
    definitionName As String, _
    productId As String, _
    listPrice As Decimal, _
    parentCategoryName As String _
) As Product
'Usage
Dim instance As BaseCatalog
Dim definitionName As String
Dim productId As String
Dim listPrice As Decimal
Dim parentCategoryName As String
Dim returnValue As Product

returnValue = instance.CreateProduct(definitionName, _
    productId, listPrice, parentCategoryName)
public Product CreateProduct(
    string definitionName,
    string productId,
    decimal listPrice,
    string parentCategoryName
)
public:
Product^ CreateProduct(
    String^ definitionName, 
    String^ productId, 
    Decimal listPrice, 
    String^ parentCategoryName
)
public function CreateProduct(
    definitionName : String, 
    productId : String, 
    listPrice : decimal, 
    parentCategoryName : String
) : Product

Parameters

  • definitionName
    Type: System..::.String
    The product definition used to create the product.
  • listPrice
    Type: System..::.Decimal
    The list price for the product. The price that should be applied to any product that references this productId. Units for this value are determined by the currency attribute of the containing catalog.

Return Value

Type: Microsoft.CommerceServer.Catalog..::.Product
A new Product containing the new product.

Exceptions

Exception Condition
EntityDoesNotExistException

The parentCategoryName does not exist.

InvalidDefinitionUseException

The definitionName contains a variant property which is being used as a IdentifyingProductProperty for the catalog or the definitionName contains a normal property which is being used as a IdentifyingVariantProperty for the catalog.

EntityAlreadyExistsException

The productId already exists.

NotAuthorizedException

The caller is not authorized to perform this operation.

Remarks

This method creates a new product in the catalog which can be identified by the productId and returns a Product object. You do not have to call the Save method after you call this method. You can use the returned Product object to access and update information on the product. If you make any changes to the product object you should call the Save method to save the changes to the catalog system.

The definitionName should:

  • Not be nullNothingnullptra null reference (Nothing in Visual Basic) or blank.

  • Not exceed 128 characters.

  • Be an existing product definition in the catalog system.

The productId should:

  • Not be nullNothingnullptra null reference (Nothing in Visual Basic) or blank.

  • Not exceed 256 characters.

  • Not already exist in the catalog.

The parentCategoryName should:

  • Not be nullNothingnullptra null reference (Nothing in Visual Basic) or blank.

  • Not exceed 128 characters.

  • Exist as a category in the catalog.

You can set the list price for the product by setting the listPrice. If the definitionName does not contain variant properties then the product will be created as a regular product and cannot contain variants. If the definitionName contains variant properties then the product will be created as a product family and can contain variants. If the definitionName contains variant properties and one of the variant properties is the sane as the IdentifyingProductProperty of the catalog or one of the normal properties in the definitionName is the same as the IdentifyingVariantProperty of the catalog the product cannot be created in the catalog.

Permissions

See Also

Reference

BaseCatalog Class

BaseCatalog Members

CreateProduct Overload

Microsoft.CommerceServer.Catalog Namespace