About the Catalog Feature for Solution Sites
A catalog is a way of organizing the products you want to sell. The Solution Sites provide a mechanism for browsing and searching through single or multiple Commerce Server catalogs. They also allow users to view detailed information on an individual product and provide a link so users can add the product to their baskets.
Both the Retail and Supplier Solution Sites are packaged without any catalogs installed. None of the catalog-related features of the Solution Sites will work until a catalog is either created or imported for the application through Commerce Server Business Desk. You can use a sample catalog, which is provided in the Commerce Server SDK, if you do not have a catalog from which to work. The sample catalog is an XML file.
The topic “Importing an XML Catalog File” in Commerce Server 2002 Help explains how to import the AdvWorks.xml catalog file. The full path to this file is \<Computer Name><Drive>\Program Files\Microsoft Commerce Server 2002\SDK\Samples\Auction\AdvWorksCatalog.xml. Copy this file to the root folder of your computer to make it easier to import.
The Solution Sites rely heavily on caching to improve performance in the catalog. See Catalog Caching for more information about caching catalog data.
- The catalog pages were written assuming that every product in the catalog has a property called name. The Commerce Server Product Catalog System does not enforce this.
The Solution Sites use the Commerce Server Catalogset object to determine which catalogs are available to a user. The Solution Sites distinguish between a catalog set for anonymous users and a catalog set for authenticated users. Catalog sets are managed through Business Desk.
Initialization for the product catalog feature occurs in the following files:
The Main subroutine calls three functions in this file to initialize three application variables for the catalog feature. The InitCatalogManager function is called and the returned CatalogManager object is set to Application scope as MSCSCatalogManager. The dictGetCatalogAttributes function is called and the returned dictionary is set to Application scope as MSCSCatalogAttribs. This dictionary is used as a cache for the CatalogManager object properties. The InitCatalogSets function is called and the returned dictionary is set to Application scope as MSCSCatalogSets.
See Caching Solution Sites for information about initialization of the catalog caches.
The user locates products through the search and browsing catalog features. The menu pane provides two types of search features, full-text search and specification search. Both the template\menu.asp and default.asp pages display either a list of searchable categories if there is only one catalog, or a list of catalogs if there is more than one catalog. Either page can be used as a starting point for browsing the application. Most of the browse-time catalog functionality is in the include\catalog.asp file.
Catalog Search Features
The following files display the catalog search features:
The htmRenderSearchSection function creates a text box, a search button, and a link to Advanced search. When the user clicks the search button, the user is redirected to the search.asp page with the contents of the text box posted to that page. When the user clicks the Advanced link, the user is redirected to the srchdept.asp page.
The bFullTextResultsAreCached function checks for a cached result for the query text. If there is no cached result, the rsFreeTextSearch function constructs a query for the MSCSCatalogManager.FreeTextSearch method and returns a recordset of the results. The RenderSearchResults function converts the recordset into HTML. The CacheFragment function caches the rendered page.
This page selects the category that will be searched. Specification searches are limited to a single category.
The bIsSearchDeptPageCached function checks for a cached page with the catalog set for the user. If there is not a cached page, the arrSearchDept function creates an array of strings; each string is a catalog name separated from a category name by an arbitrary string token. The htmRenderSearchDeptPageContent function renders this array as a list of links to the stepsrch.asp page. Each link contains the catalog and category data for the search.
This page implements the specification search for the catalog and category selected on the srchdept.asp page. When the number of matches is less than the value of the SEARCH_THRESHOLD constant, or the user has previously pressed the View Results button, the matches will be listed; otherwise the page displays a list box for each searchable property in the category. Each list box will list all the values for that property in the category. Users can click the View Results button to display the list or the users can refine their search by changing the values selected.
The PrepareSpecificationSearch function builds the query from the user's selections on the page. The first time the page is displayed there is no user input, so a search is performed with an empty specification search clause. This returns the number of items and the properties and values in the category. When the search is refined the user's selections are posted to this page and the search is run again. The search results are rendered by the htmRenderStepSearchPageContent function.
Catalog Browse Feature
The following files display the catalog browse feature:
The PrepareCatalogSection function returns a recordset of the catalogs available to the user and the number of catalogs in the recordset. The htmRenderCatalogSection function tests for the number of catalogs available to the user. If there is only one catalog it displays a list of the root categories in the catalog. If there are multiple catalogs it displays a list of the catalogs. In either case the links in the list take the user to the category.asp page.
The mscsUserCatalogsetID function returns the CatalogSetID variable. This is used as a key for the page cache. If there is not a cached copy of this page the PrepareDefaultPage function uses the CatalogSetID variable to retrieve a recordset of the catalogs available to the user. The htmRenderDefaultPage function tests for the number of catalogs in the rsCatalogs recordset. If there is only one catalog it calls the htmRenderCategoryPage function to display a list of the root categories in the catalog, and if the number of categories is below a threshold, adds subcategories and products to the list. If there are multiple catalogs it calls the htmRenderCatalogList function to display a list of the catalogs. Each catalog or category is displayed on the page as a link that takes the user to the category.asp page.
This page displays lists of category or product links. The FetchCategoryData subroutine sets several page level variables from the Request object's QueryString property, primarily the catalog and category names. The page obtains the Catalog object from the CatalogManager object and calls the mscsGetCategoryObject function to get the Category object. It calls the mscsGetProductList function to get a recordset of the products in the category. This function supports paging, so it will return a subset of all the products, depending on user input.
The htmCategoryHTML function generates the HTML for the page from the data from the previous functions. This function will display all the subcategories and products in the category. A category will typically contain only subcategories or products, but not both. The subcategories will be displayed as links to the category.asp page, which will display the subcategory. The products will be displayed as links to the product.asp page.
This page displays product details. The page uses calls to the GetRequestString function to retrieve the productID and variantID from the Request object's QueryString property. After checking the cache, the page gets the Catalog object from the MSCSCatalogManager object, and then the Product object from the Catalog object. The page calls methods on the Product object to get a recordset of product properties and a recordset of variants. The page renders the product properties as an HTML fragment in the htmProduct variable. It calls the RenderForm function to build an HTML form containing the list of variants (if available), hidden text defining the product, a text box for the quantity and an Add to Basket button. The HTML fragments are concatenated into the htmPageContent variable. When the user enters a quantity into the text box and clicks the Add to Basket button the form is submitted to the _additem.asp page.
See AlsoCopyright © 2005 Microsoft Corporation.
All rights reserved.