GetCatalog Method (String, String)
Returns a ProductCatalog for the specified catalog in the specified language.
Namespace: Microsoft.CommerceServer.Catalog
Assembly: Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)
Syntax
'Declaration
Public Function GetCatalog ( _
catalogName As String, _
language As String _
) As ProductCatalog
'Usage
Dim instance As CatalogContext
Dim catalogName As String
Dim language As String
Dim returnValue As ProductCatalog
returnValue = instance.GetCatalog(catalogName, _
language)
public ProductCatalog GetCatalog(
string catalogName,
string language
)
public:
ProductCatalog^ GetCatalog(
String^ catalogName,
String^ language
)
public function GetCatalog(
catalogName : String,
language : String
) : ProductCatalog
Parameters
- catalogName
Type: System..::.String
The name of the catalog. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).
- language
Type: System..::.String
The culture code indicating the language that is associated with the Catalog.
Return Value
Type: Microsoft.CommerceServer.Catalog..::.ProductCatalog
A ProductCatalog for the specified catalog.
Exceptions
Exception | Condition |
---|---|
EntityDoesNotExistException | The catalogName does not exist in the catalog system. |
NotAuthorizedException | The caller is not authorized to perform this operation. |
Remarks
Use this method to retrieve a specified catalog with the specified language from the Product Catalog System. The language is specified as a RFC 1766 CultureInfo class name. If nullNothingnullptra null reference (Nothing in Visual Basic), the language defaults to the current user interface culture.
You can use the returned ProductCatalog object to access and update information about the catalog. If you make changes to the ProductCatalog object you should call the Save method to save the changes to the catalog system. All the information returned by the properties of the ProductCatalog object will be in the specified language. You can change the language set on the ProductCatalog object by calling the ActiveLanguage property.
The catalogName should:
Not be nullNothingnullptra null reference (Nothing in Visual Basic) or blank.
Not exceed 85 characters.
Not contain the .,"[]'()# characters.
If specified the language should:
Not exceed 10 characters.
Not contain the ,'[] characters.
If the language is nullNothingnullptra null reference (Nothing in Visual Basic) then the ActiveLanguage will be set to the default language of the catalog. If the language is specified and the language exists in the catalog then the ActiveLanguage will be set to the specified language. If the language is specified and the language does not exist in the catalog then the ActiveLanguage will be set to the default language of the catalog. You should compare the ActiveLanguage property on the returned ProductCatalog object with the language to see whether or not the Product object was retrieved in the desired language.
Examples
This example shows how to get a catalog, update its properties, add a language and access its properties.
private void GetCatalog(CatalogContext catalogContext)
{
ProductCatalog productCatalog = catalogContext.GetCatalog("CatalogName", "en-US");
productCatalog.Information.Catalogs[0].DisplayName = "DisplayName";
productCatalog.Information.Catalogs[0].Currency = "Currency";
productCatalog.Addlanguage("fr-FR");
productCatalog.Save();
foreach(CatalogItemsDataSet.CatalogItem rootProducts in productCatalog.RootProducts.CatalogItems)
{
string productId = rootProducts.ProductId;
}
foreach(CatalogItemsDataSet.CatalogItem rootCategories in productCatalog.RootCategories.CatalogItems)
{
string categoryName = rootCategories.CategoryName;
}
foreach(string language in productCatalog.Languages)
{
string catalogLanguage = language;
}
if (productCatalog is BaseCatalog)
{
BaseCatalog baseCatalog = (BaseCatalog)productCatalog;
foreach(CatalogsDataSet.Catalog dependentCatalog in baseCatalog.DependentCatalogs.Catalogs)
{
string dependentCatalogName = dependentCatalog.CatalogName;
}
}
else if (productCatalog is VirtualCatalog)
{
VirtualCatalog virtualCatalog = (VirtualCatalog)productCatalog;
foreach(CatalogsDataSet.Catalog includedCatalog in virtualCatalog.VirtualCatalogRules.VirtualCatalogRules)
{
string includedCatalogName = includedCatalog.CatalogName;
}
foreach(CatalogsDataSet.Catalog pricingCatalog in virtualCatalog.PriceRules.PricingRules)
{
string pricingCatalogName = pricingCatalog.CatalogName;
}
}
}
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.