Locked History Actions

MicrosoftCommerceServerResources/MicrosoftCommerceServer2009TemplatePackForSharePoint2010Hacks

This page is what I hope will eventually be a list of my "hacks" for the Commerce Serer 2009 Template Pack for SharePoint 2010

URL Driven Product Query Web Part Hack

The product query web part generates links to the product detail page for products in a given catalog and category. The product detail page typicaly contains web parts that use query string parameters for the catalog and category in order to determine which product to render contant for. By default (and I don't understand why), the product query web part contains an editable property to specify the catalog. This essentially "hard configures" the category page to render links for only a specific catalog. Given all of the features of Commerce Server to be able to serve up different catalogs to different users, I'm baffled as to why the product query web part is designed this way. This hack is a modification the the Product Query Web Part so that it generates product detail page links using the catalog name from the query string when the catalog name property has not been specified.

Open the file UI\Catalog\WebParts\ProductQuery\ProductQuery.cs within the source code directory for the template pack. Find the Catalog property. By default the code looks like this:

        /// <summary>
        /// Gets or sets the Commerce Server catalog name
        /// </summary>
        [Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        LocalizedWebCategory(CommonPropertyCategories.AdvancedCS),
        DefaultValue(""),
        LocalizedWebDisplayName("CatalogResources", "ProductQueryWebPart_Catalog_WebDisplayName"),
        LocalizedWebDescription("CatalogResources", "ProductQueryWebPart_Catalog_WebDescription")]
        public string Catalog
        {
            get
            {
                return this._catalog;
            }

            set
            {
                this._catalog = value;
            }
        }

Update it so that it looks like this:

        /// <summary>
        /// Gets or sets the Commerce Server catalog name
        /// </summary>
        [Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        LocalizedWebCategory(CommonPropertyCategories.AdvancedCS),
        DefaultValue(""),
        LocalizedWebDisplayName("CatalogResources", "ProductQueryWebPart_Catalog_WebDisplayName"),
        LocalizedWebDescription("CatalogResources", "ProductQueryWebPart_Catalog_WebDescription")]
        public string Catalog
        {
            get
            {
                if(!string.IsNullOrEmpty(this._catalog))
                {
                    return this._catalog;
                }
                else
                {
                    return HttpContext.Current.Request.QueryString[this.CatalogUrlKey];
                }
            }

            set
            {
                this._catalog = value;
            }
        }