Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
- productId
Type: System..::.String
The identifier of the product to add.
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
- 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.