sitecore-ucommerce-blog
Published: 09 October 2017

We are currently working on a new Sitecore uCommerce build, that we have built on Habitat. In the build we are also making use of Unicorn and Synthesis.
This build is using Sitecore 8.2 rev. 170407, with a clean install of Habitat and we have installed Unicorn and Synthesis through NuGet. Everything was sitting nicely until we need to introduce uCommerce.

uCommerce is installed through a Sitecore package and can be found here - https://ucommerce.net/product/download. We had previously installed this package into a test environment, so we knew that everything worked.

The problem came when we tried to install the package. The installer would crash, and the site would then never respond, causing a stack overflow exception which would kill w3p process, a get stuck in a infinite loop.

You would then see this error in the Event Viewer – here’s our example;



A video of this exception during installation can be viewed here: 

 

There was nothing in the Sitecore logs, and uCommerce logs stated several “Initializing the System Data Provider data” that should only happen once. It was becoming a tricky issue to resolve, until we finally had a break through.

When talking with uCommerce we thought it might be because of the Sitecore's SiteManager.GetSites() getting overwritten by some of the services we were adding to the Sitecore solution (even though at first glance it seems strange if it could be e.g. Synthesis).

So in uCommerce GetSites() gives us a list of hostnames:

sitecore-ucommerce-blog2

So we tried to extend SitecoreDomainService with an empty implementation and see if this could resolve the issue as a work around.
We created a class, SitecoreDisabledDomainService that implements IDomainService, but doesn't do anything. It looks like this;
using System.Collections.Generic;
using UCommerce.Content;

namespace SitecoreDisabledDomainService
{
public class SitecoreDisabledDomainService : IDomainService
{
public IEnumerable<Domain> GetDomains()
{
return new List<Domain>();
}

public Domain GetDomain(string domainName)
{
return null;
}

public Domain GetCurrentDomain()
{
return null;
}
}
}

You can overwrite SitecoreDomainService yourself (in your own solution), by adding the SitecoreDisabledDomainService.cs. Then we added a config patch;

<configuration>
<!-- Configuration for SiteCore specific implementations -->
<components>

<component id="DomainService"
service="UCommerce.Content.IDomainService, UCommerce"
type="SitecoreDisabledDomainService.SitecoreDisabledDomainService, SitecoreDisabledDomainService" />

</components>
</configuration>

So the steps you would use to apply this fix (right from the start are);

Setup SiteCore (Habitat + Unicorn + Synthesis)

  1. Try to install Ucommerce. I assume it'll crash as in your video. Let it crash!
  2. Add the attached .dll and .config-file patch (mentioned above) to: [path]\Website\sitecore modules\Shell\uCommerce\Apps
  3. Do an "iisreset"
  4. In your browser go to the website, does the site spin up now? You’re welcome!
  5. Go to "Content Editor"
  6. If you expand to System > uCommerce > Hostnames, you'll now only see "Default" being listed.

Lee Swainsbury

Server-Side Developer

READ MORE FROM LEE SWAINSBURY

Page Name: {% PageName %}

Page Template: {% PageTemplate %}

CampaignID: {% AgentReferrer.ID %}

CampaignName: {% AgentReferrer.Name %}

CampaignPhone: {% AgentReferrer.Phone %}

Item Location: {% PageLocation %}

Search Session Exists: False