AddProduct Method

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Adds a product as a child product of the category.

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

Syntax

'Declaration
Public Sub AddProduct ( _
    productId As String _
)
'Usage
Dim instance As StaticCategory
Dim productId As String

instance.AddProduct(productId)
public void AddProduct(
    string productId
)
public:
void AddProduct(
    String^ productId
)
public function AddProduct(
    productId : String
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

The productId is nullNothingnullptra null reference (Nothing in Visual Basic).

ValidationException

The category is a root category.

EntityAlreadyExistsException

The productId already exists in the category.

Remarks

This method adds the product to the category as a child product.

The productId should:

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

  • Not exceed 343 characters.

  • Exist in the catalog.

  • Not already exist as a child product for this category.

After you add the product to the category you can also set a rank to the product. Products in a category can be ranked and the rank can be used to control how products are displayed to the users. When you add a product to a category the rank of the product will be set to 0. If this category is in a virtual catalog and you want to add a product from one of the included base catalogs you should pass the productId in the format productId(BaseCatalogName) For example if you include a product "Book" from a "Books" catalog in a virtual catalog named AllBooks then to add the you should use string productId = @"Book(Books)"; category.AddProduct(productId); You should call the Save method to save the changes to the catalog system.

Permissions

See Also

Reference

StaticCategory Class

StaticCategory Members

Microsoft.CommerceServer.Catalog Namespace