Jaa


CreateCategory Method (String, String, Boolean, String, String)

Creates a Category in the current catalog.

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

Syntax

'Declaration
Public Function CreateCategory ( _
    definitionName As String, _
    categoryName As String, _
    specificationSearchable As Boolean, _
    parentCategoryName As String, _
    displayName As String _
) As Category
'Usage
Dim instance As ProductCatalog
Dim definitionName As String
Dim categoryName As String
Dim specificationSearchable As Boolean
Dim parentCategoryName As String
Dim displayName As String
Dim returnValue As Category

returnValue = instance.CreateCategory(definitionName, _
    categoryName, specificationSearchable, _
    parentCategoryName, displayName)
public Category CreateCategory(
    string definitionName,
    string categoryName,
    bool specificationSearchable,
    string parentCategoryName,
    string displayName
)
public:
Category^ CreateCategory(
    String^ definitionName, 
    String^ categoryName, 
    bool specificationSearchable, 
    String^ parentCategoryName, 
    String^ displayName
)
public function CreateCategory(
    definitionName : String, 
    categoryName : String, 
    specificationSearchable : boolean, 
    parentCategoryName : String, 
    displayName : String
) : Category

Parameters

  • definitionName
    Type: System..::.String
    The category definition name. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).
  • categoryName
    Type: System..::.String
    The category name. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).
  • specificationSearchable
    Type: System..::.Boolean
    true to mark this category as specification-searchable; otherwise, false.
  • parentCategoryName
    Type: System..::.String
    The primary parent category for this category. May be nullNothingnullptra null reference (Nothing in Visual Basic).
  • displayName
    Type: System..::.String
    The displayname for this category in the Active language. May be nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

Type: Microsoft.CommerceServer.Catalog..::.Category
A new Category object containing the new category.

Exceptions

Exception Condition
EntityDoesNotExistException

The parentCategoryName does not exist.

InvalidDefinitionUseException

The definitionName is not a category definition.

EntityAlreadyExistsException

The categoryName already exists.

NotAuthorizedException

The caller is not authorized to perform this operation.

Remarks

This method creates a new Category in the catalog based on the definitionName and returns a Category object. You do not need to call Save after you call this method. You can use this object to access and update information about the category. If you make any changes to the category you should call the Save method to save the changes to the category.

The definitionName should:

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

  • Not exceed 128 characters.

  • Be an existing category definition in the catalog system.

The categoryName should:

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

  • Not exceed 128 characters.

  • Not already exist in the catalog.

The parentCategoryName should:

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

  • Not exceed 343 characters.

  • Exist as a category in the catalog.

In a virtual catalog if you want to create a new category under a category inherited from a base catalog the parentcategory should be in the format "parentcategory(BaseCatalog)".For example if a category named "Autobigraphies" in a base catalog "Books" is included in a virtual catalog "AllBooks" then if you want to create a new category in the virtual catalog with the "Autobigraphies" category as the parent category you should specify the parent category as string parentCategory = @"Autobigraphies(Books)";. You can use the displayName to associate multilingual display names with the category. When the category 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 category in all the other languages will be set to the category name.

The displayName should:

  • Not exceed 128 characters.

You can mark a category as specification searchable by setting the specificationSearchable to true.

Permissions

See Also

Reference

ProductCatalog Class

ProductCatalog Members

CreateCategory Overload

Microsoft.CommerceServer.Catalog Namespace