Welcome to MSDN Blogs Sign in | Join | Help

Adding multilingual display names to property definitions

         The Commerce Server 2007 catalog system supports multilingual display names for Property definitions, catalog definitions, products, categories and variants. This post discusses multilingual display name support for property definitions.

         The following are the steps to add multilingual display names for property definitions

  1. Add the desired langauges to the property definitions
  2. Set the display names for the desired property.

While the above steps can be performed from the Catalog and Inventory Schema Manager, you can programatically achieve this as follows:

/// <summary>

/// Language support for property definitions

/// </summary>

/// <param name="catalogContext"></param>

internal void AddLanguagesToPropertyDefinitions(CatalogContext

              catalogContext)

{

      // Add the languages to the Property definitions

      catalogContext.AddLanguageToPropertyDefinitions("en-US");

      catalogContext.AddLanguageToPropertyDefinitions("fr-FR");

                 

      // Get the langauges added to the Property definitions

      foreach(string language in

      catalogContext.GetPropertyDefinitionLanguages())

      {

            Console.WriteLine(language);

      }

                 

      // To set the displaynames for properties 

      // Get the CatalogProperty object

      CatalogProperty property = catalogContext.GetProperty("Name");

     

      // For a language X, you can get/set the display name in the

      // DisplayName_X property

      property["DisplayName_en-US"] = "Name";

      property["DisplayName_fr-FR"] = "Nom";

     

      // Save the displaynames

      property.Save();

 

      // Get the English display names

      string displayNameEn = null;

 

      // Ensure that the property exists and it has a value

      if ( property.HasProperty("DisplayName_en-US") &&

           !property.IsPropertyNull("DisplayName_en-US"))

      {

          displayNameEn = (string)property["DisplayName_en-US"];

      }

 

      // Remove the language

      catalogContext.RemoveLanguageFromPropertyDefinitions("fr-FR");

                 

}

 

Extending the entites in the Catalog and Inventory Systems

Commerce Server 2007 allows you to extend the different entities in the Catalog and Inventory systems in a straightforward manner. These are the various entities that can be extended

  1. Property Definitions
  2. Catalog  Definitions
  3. Inventory Catalog
  4. Inventory Skus
  5. Product and Categories

All the above entities except 5 can be extended as follows

  1. Create a property. For eg if you want to associate a VendorId with a catalog, create a property named VendorId of datatype string.
  2. Add the property to the appropriate entity
  3. Once the entity has been added to the entity you can access its value using the indexer or the corresponding dataset. For eg. string vendorId  = (string)productCatalog["VendorId"];
  4. You can also enumerate the list of properties added to a particular entity
  5. Note that multilingual properties cannot be added to the first four entities
  6. If your site contains an inventory resource then the properties defined in the catalog system can be used to extend the Inventory Catalog and Inventry Skus entities

      The above operations can be performed from the Catalog and Inventory Schema manager. This is how you can perform the above tasks programatically.

      Assume that you want to add a VendorId property to track vendors for your product catalogs

/// <summary>

/// Extends the ProductCatalog Entity

/// </summary>

/// <param name="catalogContext"></param>

internal void ExtendCatalogEntity(CatalogContext catalogContext)

{

      // Create the property

      CatalogProperty property = catalogContext.CreateProperty("VendorId",

      CatalogDataType.String, 25);

 

      // Add the property  to the ExtensibleEntityType.ProductCatalog entity

      catalogContext.AddPropertyToEntity(ExtensibleEntityType.ProductCatalog,

      "VendorId");

      // Get the properties added to the ExtensibleEntityType.ProductCatalog entity

      CatalogPropertiesDataSet extendedProperties =

      catalogContext.GetEntityProperties(ExtensibleEntityType.ProductCatalog);

      // Iterate through all the extended properties

      foreach(CatalogPropertiesDataSet.CatalogProperty extendedProperty in

               extendedProperties.CatalogProperties)

      {

            string propertyName = extendedProperty.PropertyName;

      }

      // Now assign a value to the VendorId

      ProductCatalog productCatalog = catalogContext.GetCatalog("My Catalog");

      productCatalog["VendorId"] = "My Vendor";

      // You can also use the Information property to do the same thing

      // productCatalog.Information.Catalogs[0]["VendorId"] = "My Vendor"; 

      // save the changes

      productCatalog.Save();

 

      string vendorId = null;

      // Access the value of the "VendorId" property

      // Validate that "VendorId" property has been added to the ProductCatalog

      // entity and its value is not null

      if ( productCatalog.HasProperty("VendorId")

      && !productCatalog.IsPropertyNull("VendorId"))

      {

         vendorId = (string)productCatalog["VendorId"];

         // vendorId = (string)productCatalog.Information.Catalogs[0]["VendorId"];

      }

      // Remove the property from the ProductCatalog entity

      catalogContext.RemovePropertyFromEntity(ExtensibleEntityType.ProductCatalog,

      "VendorId");

                       

}

 

In a similar manner you can extend the other entities. Use

  1. ExtensibleEntityType.PropertyDefinition for Property Definitions
  2. ExtensibleEntityType.ProductCatalog for Catalog  Definitions
  3. ExtensibleEntityType.InventoryCatalog for Inventory Catalog
  4. ExtensibleEntityType.InventorySku for Inventory Skus

 

Implementing the credential prompter

I received a question on my earlier post on implementing the credential prompter. When connecting to the web service you have to specify a CatalogServiceAgent object. When authenticating against a Web service, the default behavior is to first try to make Web service method calls without any authentication credentials.  If an Authentication related exception results (e.g. HTTP 401 response from the Web server), then the next step is to try using the user's default credentials, if available. If those credentials are not available or also fail, and the CatalogServiceAgent has been provided with an IPromptForCredentials  implementation, then the IPromptForCredentials.PromptForCredentials method is invoked to retrieve alternate credentials for the user.  This typically involves displaying a dialog box to a user in order to prompt them to input new credentials. These credentials are then cached in a System.Net.CredentialCache object and re-used when issuing further method calls against the service.

A sample implementation of the credential prompter whcih prompts the user for the login name and password can be done as follows:

 

internal class UserCredentialPrompter : IPromptForCredentials

{

      public NetworkCredential PromptForCredentials(string url,

      string authType)

      {

            // Set the network credentials

            NetworkCredential myCredentials = null;

            // Launch dialog to capture the user name and password

            Login form = new Login();

            // Show the Login dialog

            DialogResult result = form.ShowDialog();

            if (result == DialogResult.OK)

            {

                // Create the NetworkCredential based on user input

                myCredentials = new NetworkCredential(form.UserName,

                  form.Password, form.Domain); 

            }

            // Return the obtained credentials

            return myCredentials;

      }

}

 

You can then instantiate the CatalogServiceAgent as

CatalogServiceAgent catalogServiceAgent = new CatalogServiceAgent(@"http://Servername/CatalogWebservice/CatalogWebservice.asmx", ServiceAgent.DefaultAuthMethods, new UserCredentialPrompter());
CatalogContext context = CatalogContext.Create(catalogServiceAgent);
 
 

Programming the Commerce Server 2007 catalog system: Creating the CatalogContext

      The objects in the catalog system can now be programmed in two modes. In the first mode the catalog server assembly is loaded in the callers appdomain (aka inproc mode). In the second mode the functionality of the catalog system is available remotely via the catalog web service. The programming model and the methods available in both the modes are the same. The only difference is in the way the CatalogContext object is created. The CatalogContext object is the root object in the catalog system. All other objects are obtained from the CatalogContext object.
 
1. The Inproc mode : You use this mode when you are running your code on the web server. The CatalogContext code is initialized by specifying the sitename. The following code sample shows how to create a CatalogContext in this mode. You need to add references to the Microsoft.Commerceserver.catalog, Microsoft.CommerceServer.CrossTierTypes and Microsoft.CommerceServer.Shared assemblies. The objects in the catalog system reside in the Microsoft.CommerceServer.Catalog and Microsoft.CommerceServer namespaces.
 
    CatalogSiteAgent siteInfo = new CatalogSiteAgent();   
    siteInfo.SiteName = "StarterSite";
    siteInfo.AuthorizationMode = AuthorizationMode.ThreadContext;
    siteInfo.AuthorizationPolicyPath = @"E:\Inetpub\wwwroot\CatalogWebService\CatalogAuthorizationStore.xml";
    siteInfo.IgnoreInventorySystem = false;
    CacheConfiguration cacheConfiguration = new CacheConfiguration();
    cacheConfiguration.CacheEnabled =true;
    cacheConfiguration.SchemaCacheTimeout = new TimeSpan(0, 10, 0);
    CatalogContext context = CatalogContext.Create(siteInfo, cacheConfiguration);
 
      Use the CatalogSiteAgent class to specify the site name, the authorization information and the inventory usage option.
 
The AuthorizationMode enumeration has the following values
  • AuthorizationMode.NoAuthorization : Do not perform any authorization checks. This mode should be used on the runtime sites.
  • AuthorizationMode.ThreadContext : Before performing any operation ensure that the user is authorized to perform it. The identity of the user is obtained from the user's thread context. This mode should be used in Console applications.
  • AuthorizationMode.HttpContext : Before performing any operation ensure that the user is authorized to perform it. The identity of the user is obtained from the current Http context. This mode should be used in web applications where users update the catalog system.
 
      The AuthorizationPolicyPath specifies the location of the authorization store. The authorization store is an Xml file which contains which information about the authorized users and the operations they can perform.
 
      Commerce Server 2007 now adds an inventory integration with the catalog system.The inventory system now allows you to store the inventory information like (onhandquantities, status etc) for products and variants in the catalog system. You can use the IgnoreInventorySystem parameter to turn off inventory integration.If the inventory resource exists and IgnoreInventorySystem parameter is set to false no inventory operations or lookups will be performed by the catalog methods.
 
      Use the CacheConfiguration object to specify the caching configuration. Note that caching is turned off by default and is enabled by setting the cacheConfiguration.CacheEnabled  property.
      If you are using the Microsoft.CommerceServer.Runtime BCL then you can specify the cache configuration and the inventory integration option in the web.config of your runtime site.
 
2. The WebService mode: The CatalogContext object can also be initialized in the webservice mode by passing in the url of the catalog webservice.
CatalogServiceAgent catalogServiceAgent = new CatalogServiceAgent(@"http://Servername/CatalogWebservice/CatalogWebservice.asmx");
CatalogContext context = CatalogContext.Create(catalogServiceAgent);
 
      Use the CatalogServiceAgent class to specify the url of the catalog web service. The other overloads on this method allow you to specify the authentication methods and a credential prompter.  
      If you are wondering how to specify the authorization, caching and inventory option this  is specified through the catalogWebService element in web.config. All the attributes and child elements are documented in the  web.config itself.
 
Note: Even though the CatalogContext class has the CreateFromConnectionString method, it exists only for backward compatibility and is now deprecated.

Unable to import a commerce server catalog on Windows XP

I have seen a few customers hit this issue in the newsgroups. If you are using Windows XP as your development environment for Commerce Server 2007 Developer Edition and importing a catalog gives you an error "Value does not fall within the expected range" please contact Microsoft Technical support for the associated hotfix and mention the KB Number 920867 and that the hotfix is private.

 

Posted by vinayakt | 3 Comments
Filed under:

Securing the catalog system

The authorization model is another new feature in the Commerce Server 2007 catalog system which allows you to protect your catalog data from being accessed by unauthorized users. Since we decided to expose the functionality of the catalog system over the web service it became imperative to ensure that only authorized users can access the catalog data. The catalog system in Commerce Server 2007 has two main components: the catalog web service and the catalog database. Both these components can be appropriately secured.

Securing the Catalog web service

First let's talk about securing the catalog web service. Securing the catalog web service involves securing the web methods to ensure that unauthorized users cannot successfully invoke these methods. Instead of reinventing the wheel and introduce another authorization model for users to learn we decided to use the Windows Authorization Manager. There are several articles on Authorization manager on msdn. You can also check out the Authorization Manager Team Blog for overviews, case studies etc.

The catalog system provides various levels of authorization which can be defined by assigning the users to the different roles. Users can be Administrators, catalog editors, language translators etc. You can also create your own user model and still enforce the catalog authorization in the web service. The authorization model also allows you to control which users can view which catalogs and edit which properties. For eg you can disable certain users from editing specific product properties like list price, description etc.

The catalog system supports only the XML store which means that the authorization information is defined in an xml file. The name of the xml file is specified in the catalogWebService element in the web.config via the authorizationPolicyPath attribute. When you unpup the catalog webservice a default xml file named CatalogAuthorizationStore.xml is installed in the web service directory (typically <Drive>:\Inetpub\wwwroot\CatalogWebService). You can use the authorizationPolicyPath attribute to specify a different authorization store. If the specified path is not an absolute path then the path is relative to the catalog web service's directory.

After you install the catalog web service you need to perform the following steps to get the catalog webservice up and running.

1. Application pool: Verify that the catalog web service has been assigned to the desired Application pool. Verify the properties of the application pool especially the Identity. The identity of the application pool is the name of the account under which an application pool's worker process runs.

2. Once the identity of the catalog web service's application pool has ben configured ensure that this account has write access on the catalog authorization store. You can do this by right clicking the CatalogAuthorizationStore.xml, click properties, select the Security tab, add the catalog web service’s account and check the Allow Write checkbox. The catalog system offers catalog level security which means that you can control which users can access which catalogs. This has been implemented by means of scopes in the authorization store. Since the catalogs are dynamically created in the catalog system it becomes necessary to create a new scope in the authorization store every time a catalog is created. Creating the catalog scope needs write permissions on the xml file. This is why you need to ensure that the account running the catalog web service has Write permissions on the catalog authorization store. If this is not done then the catalog web service will throw a configuration exception at startup and none of the methods can be invoked.

3. The final step is to add the user accounts to the appropriate roles. This can be done by the Authorization Manager MMC. To do this

  1. Start->Run->Azman.msc
  2. Right click Authorization Manager
  3. Click Open Authorization Store
  4. Select the CatalogAuthorizationStore.xml
  5. Expand CatalogAuthorizationStore->CatalogAndInventorySystem->Role Assignments
  6. To add a user to a role, right click the role and select "Assign Windows Users or groups" and add the users to the appropriate roles.

Note that adding the user the Administrator role will allow the user to perform any operation in the catalog system.

4. As I mentioned previously we dynamically create scopes for each catalog, language and property in the catalog system to provide a finely grained authorization mode. This means that every time you create a new catalog you need to follow the above steps to ensure that appropriate users have access to this catalog. The only difference is that you need to expand the node named "CatalogScope_<Catalog Name>"->Role Assignments and add the users to the CatalogEditor role.

5. If you are unable to access the catalog web service due to the following exception: System.IO.FileNotFoundException: File or assembly name 0x1gew0n.dll, or one of its dependencies, was not found. File name: "0x1gew0n.dll" at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark) --- LOG: Attempting download of new URL file:///C:/WINDOWS/TEMP/6hg1.dll. The resolution for this issue is to grant write permissions on the temp directory mentioned in the above URL (C:/WINDOWS/TEMP) to the catalog web service account.

The next post will be about the various operations, tasks and roles and how you can create your own tasks and roles to enforce an authorization model which is driven by your business needs. It will also discuss how to define permissions for the various user scenarios.

 

 

Want to try Microsoft Commerce Server 2007 for free?

You can now download the evaluation version of Commerce Server 2007 from here.

Other useful links:

Additional information on general availability and pricing can be found here.

Posted by vinayakt | 7 Comments

Improving the catalog search experience in Commerce Server 2007

Two years back in this post on fulltext search in the catalog system, I had explained how fulltext searches are performed in the catalog system and added the following comment

"Providing an increased number of search features/conditions is something we are looking forward to, in the upcoming releases. This should allow you to specify more complex search phrases."

Commerce Server 2007 now allows you to specify complex search phrases which allow you to customize your searches to the finest level of granularity. If the default freetext search behavior as described in the above link does not work for you, you can now  use the new AdvancedFreeTextSearchPhrase property on the CatalogSearch object. An example of using this property to implement Thesaurus support is provided in this link. Note that when you set this property you should also set the UseAdvancedFreeTextSearch to true. This is to avoid ambiguity on whether the value specified for AdvancedFreeTextSearchPhrase or FreeTextSearchPhrase  property should be used to perform the search.

Here are some additional search scenarios for which you can use this new property.

  • You can perform wild card searches by appending * to the search phrase. For eg to return all the products containing search terms beginning with "Commerce". When passing a compound phrase you need to enclose the phrase in quotes.
             catalogSearch.AdvancedFreeTextSearchPhrase  = "Commerce*";                   catalogSearch.AdvancedFreeTextSearchPhrase  = "\"Commerce Server*\"";

  • To perform exact searches you should enclose the phrase in quotes. For eg to return rows that contain the exact phrase "Commerce Server 2007"

          catalogSearch.AdvancedFreeTextSearchPhrase  = "\"Commerce Server 2007\"";

  • To return all the products containing the phrases "Commerce Server" and "Sql Server"

        catalogSearch.AdvancedFreeTextSearchPhrase=" \"Commerce Server 2007\" AND \"Sql Server\" ";

  • To return all the products containing the phrases "Commerce Server" OR "Sql Server"

         catalogSearch.AdvancedFreeTextSearchPhrase=" \"Commerce Server 2007\"  OR  \"Sql Server\" ";

  • To return all products beginning with Commerce Or Sql server

       catalogSearch.AdvancedFreeTextSearchPhrase=" Commerce*  OR \"Sql Server\" ";

  •  You can also perform proximity searches using the NEAR keyword. For eg to return all products containing the word 2007 near "Commerce Server"

         catalogSearch.AdvancedFreeTextSearchPhrase="2007 NEAR \"Commerce Server\"";

  •  You can perform inflectional searches using the INFLECTIONAL keyword. For eg to return all products with forms of dry like drying, dried etc

      catalogSearch.AdvancedFreeTextSearchPhrase="FORMSOF (Inflectional,dry)";

  •       To return all products containing Commerce or Sql Server and not ASP

     catalogSearch.AdvancedFreeTextSearchPhrase="(\"commerce \" OR \"sql server\") and not ASP\"";  

The above are just some of the scenarios. To truly understand what else you can do take a look at this link. Determine the clause which best reflects your search criteria and pass it to the AdvancedFreeTextSearchPhrase as in the above example. 

For a complete code sample and additional filtering using other criteria like "list price < $100 AND IsActive=1"  see this post.

 

Implementing Thesaurus support in the catalog system

Sql Server 2005 now provides Thesaurus support through configurable xml files. In a nutshell  the Thesaurus feature allows you to search for synonyms of the search phrase or replace the search phrase with a replacement phrase and perform the search using the replacement phrase.  These synonyms and replacements can be configured using the xml files.See this link for configuring the xml files.

If you are using Sql Server 2005 as your Commerce Server database server then you can take advantage of this cool feature when performing catalog searches. 

As an example, suppose  that you have a Books catalog. Assume that Description is a fulltext searchable property in this catalog and that this catalog has various C# books. When performing a search on your site users might search for C# or "C Sharp". You can use the Thesaurus feature to allow searches for "C Sharp" to return C# books.

The first step is to edit the tsENU.xml file located in the SQL_Server_install_path\Microsoft SQL Server\MSSQL.1\MSSQL\FTDATA\ directory and add the following element to it

         <expansion>
                     <sub>C sharp</sub>
                     <sub>C#</sub>
          </expansion>   

 After you edit the xml file you will have to restart the "SQL Server FullText Search (MSSQLSERVER)"  service for the changes to take effect.

The following code sample demonstrates how to perform the catalog search to allow searches for "C Sharp" to return books containing C#:

CatalogSearch catalogSearch = catalogContext.GetCatalogSearch();

catalogSearch.SearchOptions = new CatalogSearchOptions();

// Set appropriate search options

catalogSearch.SearchOptions.SetPaging(1,20);

catalogSearch.UseAdvancedFreeTextSearch = true;

catalogSearch.AdvancedFreeTextSearchPhrase = "FORMSOF(THESAURUS, \"C Sharp\")";

int totalRecords;

CatalogItemsDataSet searchResults = catalogSearch.Search(out totalRecords);

// Iterate through the search results

foreach(CatalogItemsDataSet.CatalogItem searchResult in searchResults.CatalogItems)

      Console.WriteLine(searchResult.CategoryName);

 

New Catalogset features in Commerce Server 2007

The catalogsets feature is probably the least known feature in the catalog system. Unlike in previous versions, the catalogsets feature is now  tightly integrated with the catalog sytsem. We have also provided a managed API to create, edit and delete catalog sets.This functionality is also available through the catalog web service. In addition you can now export and import catalog sets just as you can import and export product catalogs. In addition we have also provided appropriate Azman security for catalogsets. More importantly the ability to manipulate the catalog sets has been added in the Catalog Manager application.

What are catalogsets anyway?

   Catalogsets provide a way to group together a similar set of product catalogs.You can use catalog sets to decide the appropriate list of catalogs to be displayed to your site users based on their profile.  For eg you can create a catalogset containing a list of preferred product catalogs. The catalog set can then be associated to profile of runtime users and when a user browses your site you can then select the list of catalogs the user can browse.This allows you to show a different list of catalogs for anonymous users, registered users or privileged users. See this post for more information and the various fallbacks.

   A new feature in Commerce Server 2007 is the ability to create dynamic catalog sets. A catalog set can now be

  • Static, which contains a static list of catalogs.
  • Dynamic, which allows you to associate an expression with the catalog set. The catalog set will now contain  the list of catalogs which match the expression. A good usage of this feature would be to define a catalog set for active product catalogs. For eg "Active catalogset" can be a dynamic catalogset which has the expression "StartDate> 01/01/2006" and "EndDate<12/31/2006" associated with it. This catalog set will now contain all the catalogs which have a start and end dates that fall in the specified range.

By default the catalog system creates two default catalog sets

  1. Anonymous User Default CatalogSet, is a catalog set for anonymous users
  2. Registered User Default CatalogSet, is a catalog set for registered users

As I previously mentioned you can associate catalogsets to a users profile and use the users profile and the catalog sets to display the list of catalogs for that user. The newly added dynamic catalogset feature can be used here to provide a better user experience, increased flexibility and less maintainence. Once you define your expression you dont have to worry about the contents of the catalog set. 

New in Commerce Server 2007 is the ability to import and export catalog sets from and to xml files. We have also added Azman security to control which users can view and edit the catalogsets. 

 

 

 

Caching in the catalog system

The Commerce Server 2007 catalog system adds a new caching feature which caches frequently used datasets.  

 

What is cached?

            In order to prevent repeated calls to the sql server the catalog system caches the results of various methods in the catalog system. These results are cached in the form of datasets. The catalog system uses the System.Web.Caching.Cache object to cache the various datasets. Each dataset is inserted in the cache with the CacheItemPriority.Normal. The time for which a dataset remains in the cache is configurable. If not specified the default time is 5 minutes.

 

   However in order to account for the relative frequency at which different items in the catalog system are changed we have classified the datasets in six different categories allowing you to specify different timeouts. The goal is to ensure allow for items which change less frequently to remain in the cache much longer that those that change more frequently.

 

The cache configuration can be defined when you create the CatalogContext object

 

CacheConfiguration cacheConfiguration = new CacheConfiguration();

cacheConfiguration.CacheEnabled = true;

cacheConfiguration.SchemaCacheTimeout = new TimeSpan(0, 10, 0);

cacheConfiguration.ItemAssociationsCacheTimeout = new TimeSpan(0, 10, 0);

cacheConfiguration.ItemHierarchyCacheTimeout = new TimeSpan(0, 10, 0);

cacheConfiguration.ItemInformationCacheTimeout = new TimeSpan(0, 10, 0);

cacheConfiguration.ItemRelationshipsCacheTimeout = new TimeSpan(0, 10, 0);

cacheConfiguration.CatalogCollectionCacheTimeout = new TimeSpan(0, 10, 0);

CatalogSiteAgent siteAgent = new CatalogSiteAgent();

siteAgent.SiteName = "SiteName";

CatalogContext cc = CatalogContext.Create(siteAgent, cacheConfiguration);

 

Caching is enabled by setting cacheConfiguration.CacheEnabled property to true.

 

The following are the different categories of datasets and their timeout configuration parameters

  1. CatalogSchema : This applies to datasets that return schema information. These datasets will remain in the cache for the timeout defined by the cacheConfiguration.SchemaCacheTimeout property. Since the catalog schema is less likely to change once it has been defined setting the timeout to a high value can result in improved performance.

The cacheConfiguration.SchemaCacheTimeout  applies to the datasets returned by the following properties/methods

            CatalogContext.GetProperty()

            CatalogContext.GetEntityProperties()

            CatalogContext.GetProperties()

            CatalogContext.GetSearchableProperties()

            CatalogContext.GetPropertiesInCatalog()

            ProductCatalog.PropertiesInCatalog

            CatalogEnumerationProperty.EnumerationValues

            CatalogContext.GetDefinitions()

            CatalogDefinition.DefinitionProperties

           

  1. Item Properties : Almost all the objects in the catalog system expose an Information property which is a dataset containing the properties for that object. For eg ProductCatalog.Information returns a dataset containing the properties of the specified product catalog. The duration the dataset returned by the Information property remains in the cache is controlled by the cacheConfiguration.ItemInformationCacheTimeout property.

The cacheConfiguration.ItemInformationCacheTimeout property applies to the datasets returned by the following properties/methods

            CatalogSet.Information

            Category.Information

            InventoryCatalog.Information

            InventorySku.Information

            Product.Information

            ProductCatalog.Information

            ProductVariant.DataRow

Note that this timeout also applies to the product information stored by the QueryCatalogInfo pipeline component.

 Another thing to note is that if inventory integration is enabled the inventory information also gets cached. 

 

  1. Catalog Hierarchy : The catalog system allows you to define parent child hierarchies between categories and products. This information is returned in the form of datasets. The duration for which these datasets are cached is determined by the cacheConfiguration.ItemHierarchyCacheTimeout property. The cacheConfiguration.ItemHierarchyCacheTimeout  property applies to the following methods/properties :

ProductCatalog.GetRootCategories()

ProductCatalog.GetRootProducts()

Product.AncestorCategories

Category.AncestorCategories

Product.ParentCategories

Category.ParentCategories

Product.CanonicalCategories

Category.CanonicalCategories

Category.Products

Category.ChildCategories        

           

 

  1. Catalog Relationships : The catalog system allows you to define relationships between products and categories. The duration for which the relationships datasets remain in the cache is determined by the cacheConfiguration. ItemRelationshipsCacheTimeout property and applies to the following properties

Category.RelatedCategories

Product.RelatedCategories

Category.RelatedProducts

Product.RelatedProducts

 

 

  1. Associations between different objects: The catalog system allows you to have various types of associations between different objects. For eg product catalogs associated to inventory catalogs, product catalogs to catalog sets, languages associated to product catalogs etc The duration for which these associations datasets remain in the cache is determined by the cacheConfiguration. ItemAssociationsCacheTimeout property and applies to the datasets returned by the following properties:

ProductCatalog.Languages

ProductCatalog.DependentCatalogs

VirtualCatalog.SourceCatalogs

CatalogSet.IncludedCatalogs

CatalogSet.NotIncludedCatalogs

InventoryContext.GetUnassociatedProductCatalogs

InventoryCatalog.AssociatedProductCatalogs

VirtualCatalog.VirtualCatalogRules

VirtualCatalog.PriceRules

 

  1. Catalog Collections : The cacheConfiguration .CatalogCollectionCacheTimeout property controls how long the following datasets remain in the cache

CatalogContext.GetCatalogs()

InventoryContext.GetInventoryCatalogs()

CatalogSetsContext.GetCatalogSets

 

 

     Monitoring the Catalog cache using perfmon

      If you have enabled caching then you can monitor the perfomace of the cache by observing the following performance counters under Commerce : Catalog set of counters. 

1.      CacheTotalHits : The total number of cache hits

2.      CacheTotalMissess: The total number of cache misses

3.      CacheHitRate : The number of cache hits per sec

4.      CacheMissRate : The number of cache misses per sec

5.      CacheHitRatio : The ratio of the cache hits to the total number of cache accesses. This is equal to  CacheTotalHits / (CacheTotalHits + CacheTotalMisses)

6.      CacheTurnOverRate : The number of cache insert and deletes per second

 

Web.Config section for caching

 

The Caching parameters can also be set in web.config of your runtime site using the following element

<catalog>

            <cache

                    enable="true"

                    schemaTimeout="10"

                    itemInformationCacheTimeout ="10"

                    itemHierarchyCacheTimeout ="10"

                    itemRelationshipsCacheTimeout = "10"

                    itemAssociationsCacheTimeout="10"

                    catalogCollectionCacheTimeout="10"

            />

 </catalog>

Here 10 is the duration in minutes, the respective datasets should be in the cache.

 

      Since the catalog system uses the  System.Web.Caching.Cache you can tune the different aspects of the catalog cache using the ASP.NET cache settings.

New Virtual catalog features in Commerce Server 2007

Virtual catalogs is a key feature we improved upon in Commerce Server 2007 to allow you to further customize your base and virtual catalogs. These features will enable additional  scenarios which were not possible in previous versions. If you are not familiar with virtual catalogs, read this post.

The following new features have been added to virtual catalogs in Commerce Server 2007

1. Ability to add rules from another virtual catalog : Commerce Server 2007 now allows you to add inclusion/exclusion/pricing rules to a virtual catalog from another virtual catalog. Note that a virtual catalog can now be created by rules from

  • One or more base catalogs OR
  • Another (and only one)  virtual catalog

This new feature now allows you to create a virtual catalog from one or more base catalogs (possibly coming from different vendors)  and then you can create another customized virtual catalog based off this virtual catalog.

2. Ability to override values of custom properties from inherited catalogs: New in this release is the ability to override the values of custom properties from the inherited catalogs. For eg you can add a product from a base catalog to a virtual catalog and have a different description or display name for the product in the virtual catalog. In addition you can also choose not to override these values and revert back to the original values from the inherited catalogs.

3. Ability to explicitly specify prices for products in the virtual catalog: While you can use flexible pricing rules to define the prices of products and categories in a virtual catalog, you can also explicitly set the prices of products in a virtual catalog. This feature also allows you to revert back this explicit pricing and have the price rule take effect. 

4. Importing and exporting virtual catalogs: Another new feature in this release is the ability to export and import virtual catalogs as virtual catalogs.

The export feature allows you to:

  • Export a virtual catalog as a virtual catalog.  This will export the rules in the virtual catalog and values of the overridden properties.
  • Export a virtual catalog as a base catalog. This will export the current contents of the virtual catalog as a base catalog. 
  • Export source catalogs. This feature allows you to export the source catalogs of the virtual catalog to the same xml file.

The import feature allows you to :

  • Import virtual catalogs as virtual catalogs.
  • Materialize virtual catalogs during import. 

5. Sequencing in virtual catalog

6. In addition we have made notable performance improvements for virtual catalog rebuilds and materialization of virtual catalogs. 

  

New catalog sequencing features in Commerce Server 2007

A while back I had written about sequencing products and categories in the feature pack and mentioned a few features that were not supported. I am happy to say that we have now addressed all the limitations I had mentioned in this post and also added a couple of new features.

The following are the new sequencing features in Commerce Server 2007

1. Sequencing products and categories:

  • You can now sequence child products and categories in any category.
  • You can also sequence root categories and root products.
  • You can sequence variants in a product family
  • Sequencing of child products/categories, root products/categories and variants is also supported in virtual catalogs. When you add a rule from a base catalog to a virtual catalog the existing sequencing for the included items will be inherited from the base catalog. We have also provided the ability to override this inherited sequencing in the virtual catalog so that you can have these items appear in a different sequence in the virtual catalog.

2. Sequencing relationships:

      Just as you can sequence child products and categories you can also sequence product and category relationships. Sequencing of relationships is also supported in virtual catalogs where inherited sequencing of base catalog relationships can be o