May282010

Basket & Purchase errors bug in Commerce Server 2009

Published by david at 11:29 AM under Commerce Server | SharePoint 2007

While doing an implementation of Commerce Server 2209 and the extensibility kit for a client of mine, we noticed that during a checkout, no error messages are being returned by the pipelines.

Let me explain:

Let say you write a pipeline component that looks like this:

[ComVisible(true)]
    [GuidAttribute ("D452305E-50C9-4031-BC94-6839BE6066EE")]
    public class MyPipelineComponentClass : IPipelineComponent
    {
        // Status codes for pipeline components
        private const Int32 StatusSuccess = 1; // success
        private const Int32 StatusWarning = 2; // warning
        private const Int32 StatusError = 3; // error

        #region IPipelineComponent Members
        void IPipelineComponent.EnableDesign(int fEnable){}

        int IPipelineComponent.Execute(object pdispOrder, object pdispContext, int lFlags)
        {
            Int32 ReturnValue = StatusWarning;
            // TODO: add code for the pipeline
			
			IDictionary Order = (IDictionary)pdispOrder;			

			string ErrorMessage = "Something is wrong"
			((ISimpleList)Order["_Basket_Errors").Add(ref ErrorMessage);
            return ReturnValue;
        }
        #endregion
    }

 

Very simple and to the point. Always return an error.

Now, since the return status is a warning, in the Order Review Page in the extensibility kit, you’ll always have a null Order. Your basket, however, will not have those error messages in its PurchaseErrors and BasketErrors properties.

Clearly, this is a bug (Which I submitted in Connect and waiting for an official fix)

But, there is a relatively simple solution. You can workaroud this issue by creating a simple operation sequence to copy those messages back to the order form like so:

 

 public override void ExecuteUpdate(Microsoft.Commerce.Contracts.Messages.CommerceUpdateOperation updateOperation,
            Microsoft.Commerce.Broker.OperationCacheDictionary operationCache,
            Microsoft.Commerce.Contracts.Messages.CommerceUpdateOperationResponse response)
    {

        OrderGroup cachedCommerceServerOrderGroup = operationCache.GetCachedCommerceServerOrderGroup();
        OrderForm defaultOrderForm = cachedCommerceServerOrderGroup.GetDefaultOrderForm();
        ISimpleList BasketErrorList = defaultOrderForm["_Basket_Errors"] as ISimpleList;
        ISimpleList PurchaseErrorList = defaultOrderForm["_Purchase_Errors"] as ISimpleList;

        if (((BasketErrorList != null) && (BasketErrorList.Count != 0)))
        {
            if (BasketErrorList.Count > 0)
            {
                List<string> basketerrorstringList = new List<string>();

                foreach (string error in BasketErrorList)
                {
                    basketerrorstringList.Add(error);
                }

                foreach (var entity in response.CommerceEntities)
                {
                    if (entity.ModelName == "Basket")
                    {
                        if (!entity.Properties.ContainsProperty("BasketErrors"))
                        {
                            entity.Properties.Add("BasketErrors", basketerrorstringList.ToArray());
                        }
                        else
                        {
                            entity.Properties["BasketErrors"] = basketerrorstringList.ToArray();
                        }
                    }
                }
            }
        }

        if (((PurchaseErrorList != null) && (PurchaseErrorList.Count != 0)))
        {
            if (PurchaseErrorList.Count > 0)
            {
                List<string> basketerrorstringList = new List<string>();

                foreach (string error in PurchaseErrorList)
                {
                    basketerrorstringList.Add(error);
                }

                foreach (var entity in response.CommerceEntities)
                {
                    if (entity.ModelName == "Basket")
                    {
                        if (!entity.Properties.ContainsProperty("PurchaseErrors"))
                        {
                            entity.Properties.Add("PurchaseErrors", basketerrorstringList.ToArray());
                        }
                        else
                        {
                            entity.Properties["PurchaseErrors"] = basketerrorstringList.ToArray();
                        }
                    }
                }
            }
        }
    }



    public override void ExecuteQuery(CommerceQueryOperation queryOperation, 
            Microsoft.Commerce.Broker.OperationCacheDictionary operationCache,
            CommerceQueryOperationResponse response)
    {



    }

 

Now, add your component just before the basket committer operation in your Channelconfiguration.config file int Basket Update Message section.

Voila, your message are now available.



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Trackback | Post RSSRSS comment feed 2 Responses

Mar022010

The cryptic CSApp.ini

Published by david at 5:39 PM under Commerce Server

Before ASP.Net membership providers, Commerce Server used ISAPI based authentication in conjunction with CommerceAuthentication HTTP module for authentication. This, of course, was rendered obsolete with the introduction of Membership providers and subsequently the UPMProvider. But, nonetheless, this little cryptic file (CSApp.ini) was left each and every time you un=package a Commerce Solution. If you dare delete it, you get a nasty error at your application start-up.

So, what’s the deal? Well, it stands in the fact, that the standard web.config file for Commerce Server 2009 still includes the HTTP Module. So, in order to get rid of the CSApp.ini file, you need to remove the CommerceAuthenticationModule from the HttpModules section in your web.config.

And there you go. Your application is not bound to your CSApp.ini file!



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Jan272010

You cannot target advertisements or discounts to specified page groups by using the Discount Ad Web Part in Commerce Server 2009

Published by david at 4:32 PM under Commerce Server | SharePoint 2007

While working on a Commerce Server 2009 solution, we were trying to create targeted advertisement only on the home page. We noticed that the Page group did not change anything. As it turns out, Microsoft has a fix for that. Here is the link:

http://support.microsoft.com/kb/968758



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses

Jun262009

Modifying the Commerce Server 2009 Contemporary site’s site definition (Part 1)

Published by david at 10:54 AM under SharePoint 2007 | Commerce Server

While building a new site with Commerce Server 2009 SharePoint services, we wanted to redesign the site and modify a lot of pages. The problem is that for us to do that 3 solutions were possible per Microsoft’s documentation:

  1. Use the extensibility kit to edit the pages and master pages
  2. Change the necessary pages directly in the Layouts folder of that SharePoint hive
  3. Modify the pages in SharePoint designer

None of these solutions were suitable for our need and here are the reasons:

  1. I do not recommend using the extensibility kit because we need to re-sign all the assemblies with a new key and change all references to the public key token. Also, if you modify the extensibility kit, you are making it very difficult to upgrade to future versions of CS 09, unless you only add web parts or pages. Finally, the extensibility kit does not include the contemporary site, which is the one we want to keep as a basis.
  2. Changing the pages in the layouts folder is not a good idea because you basically change it for all of your sites. Of course it’s not an issue because usually there is only one CS site per machine. but still it can be an issue in a dev machine or if ever CS 09 should be used as Saas (Software as a service). Finally, this solution is not re-deployable.
  3. Modifying the pages in SharePoint is also a plausible solution but again it is not deployable and it breaks the site definition.

So, what is the solution? It is to repackage the Contemporary site SharePoint solution and adding your custom features and modified pages. The following modifications were done in MOSS and not in WSS. I’m sure it is possible in WSS though. Also, for the packaging in wsp, I’m using WspBuilder.

So, here we go:

1. Un-pack the MicrosoftCommerceMOSSDefaultSiteV2.WSP file to any folder, let’s say “C:\ContemporarySite”. Your contents should look like this:

image 

2. Now you need to restructure the features and files for WspBuilder. So essentially you would have:

Copy the following folders in 12\Templates\Features:

CommerceServerContemporarySiteCheckOutStepsInstance CommerceServerContemporarySiteImages CommerceServerContemporarySiteProvisioner CommerceServerContemporarySiteResourceDeployment CommerceServerContemporarySiteResources CommerceServerContemporarySiteSPListSampleData CommerceServerContemporarySiteXslts CommerceServerMyAccountSiteMapProvider

Copy the following folders in 12\Templates:

1033
CONTROLTEMPLATES
IMAGES
LAYOUTS
SiteTemplates

Copy the following folder in 12:
Resources
Copy the following files in the GAC folder:

Microsoft.Commerce.Portal.ContemporarySite.dll
Microsoft.Commerce.Portal.ContemporarySiteCommon.dll

 

Now that the basic structure is done, you are able to re-create the Contemporary site’s WSP solution and deploy it using Commerce Server SharePoint Services configurations tool. Before that though you will need to modify the SharePointCommerceServicesConfiguration.exe.config to take the new WSP file:

<sharePointSolutionGroup name="DefaultSiteAndWebPartsMoss" sharePointPlatform="moss" defaultInSilentMode="True">
            <sharePointSolutions>
                <sharePointSolution id="7b93b2ca-e1e4-4783-a038-14094933c002" file="MicrosoftCommerceWebParts.wsp" version="1.0.0.0" wspKey="1"/>
                <sharePointSolution id="Your solution ID Here" file="Your Solution Name Here.wsp" version="1.0.0.0" wspKey="2"/>
            </sharePointSolutions>
            <defaultWebApplicationSettings name="SharePoint - 8088" port="8088" extendedName="SharePoint - 8089" extendedPort="8089" appPoolId="SharePoint - Pool 8088" appPoolUser="domain\someone"/>
            <defaultSiteCollectionSettings create="True" title="Home" name="ContemporarySite" admin="domain\someone" template="MOSSCSContemporarySite"/>
            <defaultCommerceServerSiteSettings create="True" name="ContemporarySite" description="Commerce Server Site for Commerce SharePoint Contemporary Web Site" siteWithSampleData="False" databaseServer="."/>
</sharePointSolutionGroup>

 

Now you can use the configuration tool to deploy your site. Please be advised though that your MOSS environement needs to be clean because you are essentially redeploying the same feature as the contemporary site. Also, do not modify the name of the Contemporary Site’s site definition configuration names such as “MOSSCSContemporarySite” because the receivers look for those configurations.

In the next part of my post, I’ll show you how to modify the master pages and add new features to your site.



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,

E-mail | Permalink | Trackback | Post RSSRSS comment feed 3 Responses

Mar252009

Promoting your site through a search provider

Published by david at 5:47 PM under .NET Framework | ASP.NET

The importance of search today in e-commerce websites has become one of the backbone of this industry. For that is important that your site can provide an easy way to search through it. One of those ways is using OpenSearch.

OpenSearch provides a way to expose a search provider compatible with most recent browsers such as Internet Explorer 7, 8 and Firefox 3+.

So to do that here are the basic steps:

1. Create an open search XML file that respects the following:

Value Description
ShortName (required) This is the search provider's name that is displayed in the Instant Search box when your provider is selected.
URL (required) The URL for basic search queries to your search provider. It has to be an absolute URL.
Image (optional) Pointer to a favicon file of your search provider on your Web site. This icon is displayed next to the provider name in the Instant Search box. The icon must be a valid shortcut icon file otherwise a generic icon will be used.
Suggestions URL (JSON) (optional) This is the URL where JavaScript Object Notation (JSON) suggestions can be retrieved.
Suggestions URL (XML) (optional) This is the URL where XML-based suggestions can be retrieved.
PreviewUrl (optional) URL to display results in an Accelerator Preview Window.

 

The following sample OpenSearch Description file defines the type of search services you intent to offer:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription 
       xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:ie="http://schemas.microsoft.com/Search/2008/">
    <ShortName>My Custom Search</ShortName>
    <Image height="16" width="16" type="image/icon">http://example.com/example.ico</Image>
    <Url type="text/html" 
                template="http://example.com/search.aspx?q={searchTerms}&amp;source=IE"/>   
    <Url type="application/x-suggestions+json" 
                template="http://suggestions.example.com/search.aspx?q={searchTerms}"/>
    <Url type="application/x-suggestions+xml" 
                template="http://suggestions.example.com/search.aspx?q={searchTerms}"/>
    <ie:PreviewUrl type="text/html" 
                template="http://suggestions.example.com/search.aspx?q={searchTerms}"/>
</OpenSearchDescription> 

2. Add the appropriate tags int you <head> element to your pages

<link title="My Provider" rel="search"
type="application/opensearchdescription+xml"
href="http://www.example.com/provider.xml">

 

That’s it. Users can now have access to your provider through the dropdown.



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Mar252009

Using the store locator in Commerce Server 2009 (Updated)

Published by david at 2:31 PM under Commerce Server

Here is a great video walkthrough on how to use the store locator webpart in Commerce Server 2009. I followed to the letter what Tom is doing and it worked flawlessly. Thanks Tom for the tip. Commerce Server 2009’s webparts are really working well for us.

Get Microsoft Silverlight

Original Post:

http://blogs.msdn.com/tschultz/archive/2009/03/15/commerce-server-2009-web-cast-using-store-locator-web-part.aspx

UPDATE: I updated the video to the Channel 9 version because it is of much higher resolution



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Mar052009

Important bug in Commerce Server 2009 RTM

Published by david at 12:23 PM under Commerce Server

Here at Orckestra, Commerce Server is an important part of our offering. Evidently, any new release of Commerce Server is analysed and validated against any of our solutions. In this process, We have discovered a very important bug in the new Commerce Server 2009.

Most of our solutions depend on the Free-Text search capabilities of Commerce Server. In this optic, I tried creating a simple search using the API:

var query = new CommerceQuery<CatalogEntity, CommerceCatalogFullTextSearchBuilder>(); 
query.SearchCriteria.Catalogs.Add("My_Catalog"); 
query.SearchCriteria.FirstItemIndex = 0; 
query.SearchCriteria.FullTextSearchType = CommerceFullTextSearchType.FreeText; 
query.SearchCriteria.NumberOfItemsToReturn = 500; 
query.SearchCriteria.Phrase =”My Criteria”; 

query.SearchCriteria.ReturnTotalItemCount = true; 
query.SearchCriteria.WhereClause = "[Active] = 1"; 

As it turns out I was constantly getting an unknown error. Digging through the code and using the SQL Profiler I discovered this line in the [dbo].[ctlg_GetFTSQuery] stored procedure of the catalogue database:

IF @IsVirtualCatalog = 1 or @SQLClause < 1 or (CHARINDEX(N'CONTAINS',@SQLClause) = 0 ) 

where @SQLClause is defined as an nvarchar(MAX). Well, @SQLClause < 1  is wrong and should then read: LEN(@SQLClause) < 1

So in that regard here is the entire line:

IF @IsVirtualCatalog = 1 or LEN(@SQLClause) < 1 or (CHARINDEX(N'CONTAINS',@SQLClause) = 0 ) 

Please remember that this bug is in the RTM so I would advise you to fix immediately or any Free-Text search will fail if it contains a where clause. Here is Microsoft’s official response by the way on the Connect site:

Hello David,
Thanks for reporting this. We have identified it is indeed a product defect.
As you already mentioned here, there is a syntax error inside ctlg_GetFTSQuery. Your suggested fix is correct and probably you have already done such modification from your side.
Unfortunately, the same error is also inside RTM release. We are building official fix for this problem. Please contact Microsoft CTS (Commercial Technical Support) for the official fix.
Thanks
Hao



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: , ,

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses

Mar052009

Microsoft Commerce Server 2009 goes RTM

Published by david at 12:06 PM under Commerce Server

Microsoft, yesterday, officially announced that Microsoft Commerce Server 2009 has been released to manufacturing with broad availability in April 2009. The bits are available now on MSDN. I suggest to anyone dealing With Commerce Server to take a look at this release. Here is the official announcement:

via the Microsoft e-commerce blog:

Microsoft® Commerce Server 2009 is Now Available on MSDN!

Published 03 March 09 10:28 PM | Lynnette McL

Commerce Server 2009 is now available for download to MSDN subscribers.
Commerce Server 2009 delivers the ability to increase your business reach by making it possible to sell via multiple channels by using an out-of-the-box shopping site, SharePoint® Commerce Services, and the Multi-Channel Commerce Foundation. The new out-of-the-box shopping site leverages SharePoint Commerce Services, which provides a gallery of ASP.NET 3.5 Web parts and controls, a comprehensive e-commerce shopping feature-set, and technology integration between Commerce Server and SharePoint technologies. The Multi-Channel Commerce Foundation provides a new unified, extensible run-time programming model for Commerce Server, including new run-time e-commerce capabilities. 
Download the following Commerce Server 2009 online materials today!
Readme and Installation Guide
Default SharePoint Site Performance Guide
Multi-Channel Foundation Samples
Partner Software Development Kit (SDK)

Commerce Server 2009 will be available to order from the Microsoft Price List effective April 1, 2009 through the normal Microsoft channels and Microsoft Volume Licensing Programs.

Note: Microsoft Commerce Server 2007 Enterprise Edition is also available for download to MSDN subscribers.



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Feb242009

Welcome to our new home

Published by david at 9:07 PM under General

I would like to welcome you all to our new blog .NET for thoughts.

This blog is the fruit of a bunch of .NET very talented programmers, architects and analysts. I guess this all started because in the course of working together we came to the realization that it was time for us to contribute to the mass knowledge out there. Given the complexity and vast offerings we've been working on, I hope we can make this blog a great resource for any level of .NET coder out there. Our main focus will be on SharePoint, Microsoft Commerce Server, Microsoft BizTalk Server, Fast and Endeca IAS, Microsoft CRM and pretty much anything in the current and future .NET frameworks.

Well without further due,

Enjoy!



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags:

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses