Friday, August 3, 2018

Sitecore Experience Commerce - index rebuild failure

When attempting to rebuild the web index for an experience commerce instance which contained a number of categories and sellable items, the following error occurred:
Exception: System.NullReferenceExceptionMessage: Object reference not set to an instance of an object.Source: Sitecore.Commerce.Engine.Connectat Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogCrawlerBase`1.<>c__DisplayClass52_1.<AddItemsToIndex>b__0(CommerceCatalogIndexableItem indexable, ParallelLoopState loopState)
In the content editor by updating the data templates (commerce) and clearing the cache, the index would then rebuild to completion.

Friday, July 27, 2018

Sitecore Experience Commerce - SitecoreConnectionManager getitemsbypath failures

In the minions commerce engine role of my Experience Commerce 9 environment, I have an import minion which syncs product data into Sitecore. During it's run it ran into errors connecting to Sitecore (via API) to retrieve settings (via content items).
3 11:14:32 ERROR SitecoreConnectionManager: RETRY 1 out of 3 with ERROR Internal Server Error. Failed to logging. /sitecore/api/ssc/auth/login for GET /sitecore/api/ssc/item/?path=%2Fsitecore%2FCommerce%2FCommerce%20Control%20Panel%2FCommerce%20Engine%20Settings%2FCommerce%20Terms%2FBusinessTools%2FViewPropertyNames&database=master&language=en
4 11:14:32 ERROR SitecoreConnectionManager.Error: Message=RETRY FAILED for GET /sitecore/api/ssc/item/?path=%2Fsitecore%2FCommerce%2FCommerce%20Control%20Panel%2FCommerce%20Engine%20Settings%2FCommerce%20Terms%2FBusinessTools%2FViewPropertyNames&database=master&language=en|Trace=   at Sitecore.Commerce.Plugin.Management.SitecoreConnectionManager.<ProcessRequestAsync>d__15.MoveNext()
4 11:14:32 ERROR Management.block.getitemsbypath: Sitecore Item Service Get item failed, Item /sitecore/Commerce/Commerce Control Panel/Commerce Engine Settings/Commerce Terms/BusinessTools/ViewPropertyNames not found.
This error traced back to the PlugIn.Content.PolicySet-1.0.0.json policy set configuration file inside the commerce engine. In this file I had correctly configured the username and password for the Sitecore index, however the Host setting was still set to the default of sxa.storefront.com. As I don't use this domain, it had not been configured with a valid SSL certificate. By changing this host to the correct one (with a valid certificate) the errors no longer occurred.

Sitecore 9 unable to connect to SXA SOLR indexes

After installing a clean Sitecore 9 (update 2) instance I noticed some errors in the Sitecore log files around web and master indexes for SXA:
ERROR Unable to connect to [https://localhost:8983/solr], Core: [sitecore_sxa_master_index] 
 ERROR Unable to connect to [https://localhost:8983/solr], Core: [sitecore_sxa_web_index]
This was not an error connecting to SOLR, but the fact that these two cores did not exist. Hence the following log line:
Message: The remote server returned an error: (404) Not Found.
To resolve these error, you will need to log into your SOLR application and create the two cores.
SOLR add a core
This will stop the above errors from appearing in the logs.

Thursday, July 26, 2018

Sitecore Experience Commerce - InvalidShopCurrency error on site publish

When attempting to perform a site publish (to the web database) on a Sitecore instance containing Experience Commerce, the following error occurred part way through the publish:
Job started: Publish to 'web'|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.OData.Client.DataServiceQueryException: An error occurred while processing this request. ---> Microsoft.OData.Client.DataServiceClientException: { "@odata.context":"https://localhost:5000/Api/$metadata#Sitecore.Commerce.Core.CommandMessage","MessageDate":"2018-07-25T20:38:11.802773Z","Code":"Error","Text":"Currency 'NZD' for Shop 'MyShop' was not found.","CommerceTermKey":"InvalidShopCurrency"}
This issue relates to the fact that that environment was configured (via the configuration in the commerce engine) to be using NZD (New Zealand dollars) as a currency. The issue then relates to the commerce engine being able to retrieve the currency settings from the Sitecore instance.

This traces back to the shared default currency setting in Sitecore (/sitecore/Commerce/Commerce Control Panel/Shared Settings/Currency Settings/Currency Sets/Default) which OOTB is not set to NZD and does not have NZD configured at all. Updating this and then restarting the commerce engine environment (due to caching) resolved the error.

Sitecore Experience Commerce - Default currency settings

Sitecore Experience Commerce - Site publish to web fails with 401 error

When trying to perform a site publish (to the web database) on a Sitecore instance with Experience Commerce installed, the following error occurred part way through the publishing process.

Sitecore Experience Commerce - 401 on site publish
Job started: Publish to 'web'|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.OData.Client.DataServiceQueryException: An error occurred while processing this request. ---> Microsoft.OData.Client.DataServiceClientException: Status Code: 401; Unauthorized    at Microsoft.OData.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)   at Microsoft.OData.Client.QueryResult.EndExecuteQuery[TElement](Object source, String method, IAsyncResult asyncResult)
Looking in the commerce engine showed:
51 08:17:14 ERROR ClientCertificateValidationMiddleware: Certificate with thumbprint 1D59F02B4279CB000588E905D7162499599632E3 does not have a matching Thumbprint.51 08:17:14 INFO ClientCertificateValidationMiddleware: Certificate with thumbprint 1D59F02B4279CB000588E905D7162499599632E3 is not valid.
This one comes back to our old friend the certificate thumbprint. This is sewt by default in the App_Config/Include/Y.Commerce.Engine/Sitecore.Commerce.Engine.Connect.config configuration file (but of course should be patched). Setting this value to the thumbprint used on the certificate assigned to the commerce engine should allow the publish to proceed.