Tuesday, April 24, 2018

Sitecore Experience Commerce - No commerce data in Sitecore indexes

After creating a catalog with product/category data and hooking it up to your Storefront site, you might expect the data to start appearing on the front-end. Even after full index rebuilds of the web and master indexes, this was not working as expected for me. The query I was using on the web index was:
commercesearchitemtype_t:"Category"
Which would be expected to return me all categories as defined in the catalog. Likewise the following, should return all products (sellable items):
commercesearchitemtype_t:"SellableItem"
 In my case I had changed the environment name from "HabitatAuthoring", and had updated the defaultEnvironment setting. However there are a number of index related settings which require the updated environment as well. The following patch file if applied should correctly connect the Sitecore indexer up with the correct commerce environment.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore role:require="Standalone or ContentDelivery or ContentManagement">
        <contentSearch>
            <indexConfigurations>
                <indexUpdateStrategies>
                    <sellableItemsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.SellableItemsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </sellableItemsIntervalAsynchronousStrategyMaster>
                    <sellableItemsIntervalAsynchronousStrategyWeb type="Sitecore.Commerce.Engine.Connect.Search.Strategies.SellableItemsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </sellableItemsIntervalAsynchronousStrategyWeb>
                    <categoriesIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CategoriesIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </categoriesIntervalAsynchronousStrategyMaster>
                    <categoriesIntervalAsynchronousStrategyWeb type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CategoriesIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </categoriesIntervalAsynchronousStrategyWeb>
                    <catalogsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CatalogsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </catalogsIntervalAsynchronousStrategyMaster>
                    <catalogsIntervalAsynchronousStrategyWeb type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CatalogsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </catalogsIntervalAsynchronousStrategyWeb>
                </indexUpdateStrategies>
            </indexConfigurations>
            <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
                <indexes hint="list:AddIndex">
                    <index id="sitecore_master_index">
                        <locations hint="list:AddCrawler">
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.SellableItemsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CategoriesCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                        </locations>
                    </index>
                    <index id="sitecore_web_index">
                        <locations hint="list:AddCrawler">
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.SellableItemsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CategoriesCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                        </locations>
                    </index>
                </indexes>
            </configuration>
        </contentSearch>
    </sitecore>
</configuration>

Sitecore - Failed to create counter

Looking into the logs of my local Sitecore 9 instance, there were a number of warning related to performance counters:
ManagedPoolThread #0 17:13:08 WARN  Failed to create counter 'Sitecore.System\Events | Events Raised / sec'. Sitecore has no necessary permissions for reading/creating counters. Message: Access to the registry key 'Global' is denied.
ManagedPoolThread #1 17:13:08 WARN  Failed to create counter 'Sitecore.System\IO | File Watcher Events / sec'. Sitecore has no necessary permissions for reading/creating counters.Message: Access to the registry key 'Global' is denied.
To resolve this error, we need to add the application pool identity into two groups on your machine. This can be achieved by:
  1. From the start menu, open run and enter 'lusrmgr.msc'
  2. The two groups we are interested in are:
    1. Performance Log Users
    2. Performance Monitor Users
  3. Right click each group and select 'Add to group'
  4. Add the app pool identity of the Sitecore website and xConnect website. In my case these were: 'IIS APPPOOL\prefix.sc' and 'IIS APPPOOL\prefix.xconnect' where prefix is what was set in the Sitecore install PowerShell script.
  5. Restarting IIS via the start menu command (IISRESET) should now allow Sitecore to work correctly with performance counters.

Thursday, April 12, 2018

Sitecore Experience Commerce - Catalog Item of the Storefront catalog Configuration cannot be found

After performing a deployment to a local Sitecore Experience Commerce instance, the Storefront site was not loading and instead showed the following error:
Catalog Item of the Storefront catalog Configuration cannot be found
Catalog Item of the Storefront catalog Configuration cannot be found
The Sitecore back-end was still loading as expected. What caused this error was that at startup of the Sitecore site, the commerce engine services were not started. This caused Sitecore to not be able to load/cache the commerce data. To resolve this error, ensure the commerce engine services are started and restart the IIS web site for the Sitecore instance

Tuesday, April 10, 2018

Sitecore Experience Commerce - Shop CommerceEngineDefaultStorefront does not exist

On a local instance of Sitecore Experience Commerce, the following error was appearing inside the commerce business tools and the front-end Storefront website.
"@odata.context":"https://localhost:5000/Api/$metadata#Sitecore.Commerce.Core.CommandMessage","MessageDate":"2018-04 10T10:03:59.2415572Z","Code":"Error","Text":"Shop 'CommerceEngineDefaultStorefront' does not exist.","CommerceTermKey":"InvalidShop"
Sitecore Experience Commerce - CommerceEngineDefaultStorefront does not exist
This error traces back to the Sitecore.Commerce.Engine.Connect.config configuration file (available in App_Config\Include\Y.Commerce.Engine). The defaultShopName setting should match that of a valid Storefront setting node (available under /sitecore/Commerce/Commerce Control Panel/Storefront Settings/Storefronts).

Sitecore - XConnect XdbCollectionUnavailableException error

Inside the logs of a Sitecore 9 instance the following error was appearing inside the website logs:
ERROR Exception when executing agent aggregation/pathAnalyzerLiveAgentException: Sitecore.XConnect.XdbCollectionUnavailableExceptionMessage: The HTTP response was not successful: ServiceUnavailableSource: Sitecore.Xdb.Common.Web  at Sitecore.Xdb.Common.Web.Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory) at Sitecore.XConnect.Client.XConnectSynchronousExtensions.SuspendContextLock(Func`1 taskFactory) at Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.Initialize(XmlNode configNode)   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert)   at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert)   at Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient(String clientConfigPath)   at Sitecore.PathAnalyzer.Processing.Agents.TreeAggregatorAgent.Execute()   at Sitecore.Analytics.Core.BackgroundService.Run()
Inside the ConnectionStrings.config there were 4 settings which contained a thumbprint (FindByThumbprint) for the xConnect site:
  1. xconnect.collection.certificate
  2. xdb.referencedata.client.certificate
  3. xdb.marketingautomation.reporting.client.certificate
  4. xdb.marketingautomation.operations.client.certificate
For some reason this was incorrectly set, this should match the thumbprint of your xconnect client certificate. This is likely to be name.xconnect_client where name is that of your Sitecore site set in the install PowerShell script. This same thumbprint is also set in the configuration of the xconnect site.

Monday, April 9, 2018

Sitecore - Indexing manager shows no indexes

After installing an update package on a local instance of Sitecore 9 with Experience Commerce. The indexing manager on the Sitecore control panel would appear empty with no indexes listed to rebuild (or view). The logs were showing the following message:
[Content Testing]: Failed to find testing index
It came down to two issues with the configuration:

  1. App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.config needed to have the ContentSearch.Enabled setting set to true.
  2. The App_Config\Sitecore\Marketing.Operations.xMgmt\Sitecore.Marketing.Search.config file needed to be enabled.
The fact that an installation did not complete, might be a cause of this issue and should be investigated. However in my case, it had previously installed correctly and I was only setting some items back to the default.

Sitecore Experience Commerce - Storefront navigation: No catalog data available

After connecting my Sitecore Experience Commerce Storefront to a custom catalog, the navigation menu no longer showed any categories and instead displayed the message:
[No catalog data available]
Sitecore Experience Commerce - no catalog data available
Product detail pages would display the following error:
No catalog data configured and available!
Sitecore Experience Commerce - No catalog data configured and available

The first steps are to ensure the catalog has been configured correctly in Sitecore. The places to check are:
  1. The catalogs item: /sitecore/Commerce/Catalog Management/Catalogs - should correctly have enabled (box checked) the catalog you want available in Sitecore and cached.
  2. Storefront catalog configuration item: /sitecore/Commerce/Commerce Control Panel/Storefront Settings/Storefronts/MyStorefront/Catalog Configuration - This should have the correct catalog configured and in particular Start Navigation Category should also be pointing to a category (such as Departments in the Habitat example).
  3. Site home item: /sitecore/content/Sitecore/NW/Home - should point to the correct Storefront configuration on the Control Panel Configuration field.
  4. Product catalog item for the site: /sitecore/content/Sitecore/MySite/Home/Product Catalog - should correctly point to the same source as Start Navigation Category in point 2.

Once all of these settings appear correct, perform a full publish to ensure all data is present in the web database. In my case by rebuilding the web and master indexes (Sitecore and not commerce), the navigation begun to work as expected. I was able to debug this by checking if my Start Navigation Category item was present in the SOLR index.

This can be achieved by querying the SOLR index with the following query:
sitecoreid_t:5fe593d1-5993-73f9-80d9-97bb2157fb10
Where you replace the GUID with that of the item of your starting navigation category. To check if any categories are actually indexed at all, the following query will suffice:
commercesearchitemtype_t:"Category"
If these queries return no data in the web or master Sitecore indexes, the indexer may not correctly be configured to the right commerce environment.

Tuesday, April 3, 2018

Sitecore 9 install error - You must remove all users with password before setting the containment property to NONE

When attempting to install a Sitecore 9 (update 1) instance the PowerShell installation script failed with the following error:
Install-SitecoreConfiguration : Command C:\Program Files\iis\Microsoft Web Deploy V3\msdeploy.exe returned a non-zero exit code - (-1)At C:\Install\Sitecore9.1\Install.ps1:42 char:1+ Install-SitecoreConfiguration @xconnectParams+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration
Further up in the window it was traced back to the following source error:
Error: .Net SqlClient Data Provider: Msg 12809, Level 16, State 1, Line 5 You must remove all users with password before setting the containment property to NONE.
My deploy script had failed on a previous run (due to invalid SOLR base URL), however databases had been added to SQL. By removing the following 4 databases from SQL, the error above would no longer appear and Sitecore would install as expected.
  1. [prefix]_MarketingAutomation
  2. [prefix]_Messaging
  3. [prefix]_Processing.Pools
  4. [prefix]_ReferenceData
Where [prefix] is as configured in your installation script.