AddProductCatalog Method
Adds a ProductCatalog to the catalog set. The Save method should be called to save the changes in the catalog system.
Namespace: Microsoft.CommerceServer.CatalogSets
Assembly: Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)
Syntax
'Declaration
Public Sub AddProductCatalog ( _
productCatalog As String _
)
'Usage
Dim instance As StaticCatalogSet
Dim productCatalog As String
instance.AddProductCatalog(productCatalog)
public void AddProductCatalog(
string productCatalog
)
public:
void AddProductCatalog(
String^ productCatalog
)
public function AddProductCatalog(
productCatalog : String
)
Parameters
- productCatalog
Type: System..::.String
The catalog to add to the StaticCatalogSet.
Exceptions
Exception | Condition |
---|---|
EntityAlreadyExistsException | The product catalog already exists. |
Remarks
The object must be saved before these changes will be persisted to the database.
Before adding the catalog to the StaticCatalogSet the productCatalog is validated:
To ensure the specified catalog name is not null, has an appropriate length, and does not contain any special characters.
To check if the product catalog already exists.
To check that the price rule does not already exists.
Examples
// Creates a static catalog set
internal StaticCatalogSet CreateStaticCatalogSet(string catalogSetName, string description)
{
try
{
// Create a catalog set
StaticCatalogSet catalogSet = this.catalogSetsContext.CreateStaticCatalogSet(catalogSetName, description);
catalogSet.Description = "new Description";
// Once created product catalogs can be added to the catalog set
catalogSet.AddProductCatalog("catalog1");
// Finally call save to save the changes to the catalog system
catalogSet.Save();
// Iterating the catalogs in the catalog set
foreach (ProductCatalog productCatalog in catalogSet.IncludedCatalogs)
{
Console.WriteLine(productCatalog.Name);
}
// Iterating the catalogs not in the catalog set
foreach (ProductCatalog productCatalog in catalogSet.NotIncludedCatalogs)
{
Console.WriteLine(productCatalog.Name);
}
return catalogSet;
}
catch (EntityAlreadyExistsException ex)
{
Console.WriteLine(ex.Message);
throw;
}
}
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.