Share via


AddChildCategory Method

Adds a category as a child category of this category.

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

Syntax

'Declaration
Public Sub AddChildCategory ( _
    categoryName As String _
)
'Usage
Dim instance As StaticCategory
Dim categoryName As String

instance.AddChildCategory(categoryName)
public void AddChildCategory(
    string categoryName
)
public:
void AddChildCategory(
    String^ categoryName
)
public function AddChildCategory(
    categoryName : String
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

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

ValidationException

You cannot add a child category to a root category.

EntityAlreadyExistsException

The category already exists as a child category.

Remarks

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

The categoryName should:

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

  • Not exceed 215 characters.

  • Exist in the catalog.

  • Not already exist as a child category or parent category for this category.

After you add the category as a child category you can also set a rank to the category. Categories in a category can be ranked and the rank can be used to control how categories are displayed to the users. When you add a child category the rank of the category will be set to 0. If this category is in a virtual catalog and you want to add a category from one of the included base catalogs you should pass the categoryName in the format categoryName(BaseCatalogName) For example if you include a category "Autobiographies" from a "Books" catalog in a virtual catalog named AllBooks then to add the category you should use string categoryName = @"Autobiographies(Books)"; category.AddChildCategory(categoryName); You should call the Save method to save the changes to the catalog system. The catalog system will not check for circular dependencies. It is the responsibility of the application developer to ensure that there are no circular dependencies.

Permissions

See Also

Reference

StaticCategory Class

StaticCategory Members

Microsoft.CommerceServer.Catalog Namespace