CreateCategory Method (String, String, Boolean, 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 _
) As Category
'Usage
Dim instance As ProductCatalog
Dim definitionName As String
Dim categoryName As String
Dim specificationSearchable As Boolean
Dim parentCategoryName As String
Dim returnValue As Category
returnValue = instance.CreateCategory(definitionName, _
categoryName, specificationSearchable, _
parentCategoryName)
public Category CreateCategory(
string definitionName,
string categoryName,
bool specificationSearchable,
string parentCategoryName
)
public:
Category^ CreateCategory(
String^ definitionName,
String^ categoryName,
bool specificationSearchable,
String^ parentCategoryName
)
public function CreateCategory(
definitionName : String,
categoryName : String,
specificationSearchable : boolean,
parentCategoryName : 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).
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 215 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 mark a category as specification searchable by setting the specificationSearchable to true.
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.