CreateProduct Method (String, String, Decimal, String, String, Decimal, StockStatus, Decimal)
Creates a root product in the catalog with the specified Product definition, product identifier, List price, parent category name, the display name for the product and adds inventory information for the product.
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, _
displayName As String, _
quantity As Decimal, _
status As StockStatus, _
stockOutThreshold As Decimal _
) As Product
'Usage
Dim instance As BaseCatalog
Dim definitionName As String
Dim productId As String
Dim listPrice As Decimal
Dim parentCategoryName As String
Dim displayName As String
Dim quantity As Decimal
Dim status As StockStatus
Dim stockOutThreshold As Decimal
Dim returnValue As Product
returnValue = instance.CreateProduct(definitionName, _
productId, listPrice, parentCategoryName, _
displayName, quantity, status, stockOutThreshold)
public Product CreateProduct(
string definitionName,
string productId,
decimal listPrice,
string parentCategoryName,
string displayName,
decimal quantity,
StockStatus status,
decimal stockOutThreshold
)
public:
Product^ CreateProduct(
String^ definitionName,
String^ productId,
Decimal listPrice,
String^ parentCategoryName,
String^ displayName,
Decimal quantity,
StockStatus status,
Decimal stockOutThreshold
)
public function CreateProduct(
definitionName : String,
productId : String,
listPrice : decimal,
parentCategoryName : String,
displayName : String,
quantity : decimal,
status : StockStatus,
stockOutThreshold : decimal
) : Product
Parameters
- definitionName
Type: System..::.String
The product definition used to create the product.
- productId
Type: System..::.String
The product identifier.
- 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.
- parentCategoryName
Type: System..::.String
The parent category for the product.
- displayName
Type: System..::.String
The display name for the product. May be nullNothingnullptra null reference (Nothing in Visual Basic).
- quantity
Type: System..::.Decimal
The initial inventory quantity for the product.
- status
Type: Microsoft.CommerceServer.Catalog..::.StockStatus
The initial inventory quantity for the product.
- stockOutThreshold
Type: System..::.Decimal
Initial stock out threshold for this product.
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 use the displayName to associate multilingual display names with the product. When the product is created the display name will be set for the ActiveLanguage of the catalog. If the catalog has multiple languages then the display name for that product in all the other languages will be set to the empty string. If specified the displayName should:
- Not exceed 128 characters.
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.