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.