Thursday, September 3, 2020

Sitecore Experience Commerce (Postorder components)

Sitecore Experience Commerce (Postorder components)

Recently, I was working on sending the order details to the backend system (SAP), and here is my experience.

Fist, You need to define your pipeline and block, Or if you have any existing feature like Order you can create a new partnership for that - I choose the minion services to pick the Order and send it to the SAP system.

The important part is how to get all the required details and send it to the backend system.

Here are some essential components which we would need to get the information



You may need to add a reference for these components -



       var contactDetails = arg.GetComponent<ContactComponent>();  
       var paymentDetails = arg.GetComponent<FederatedPaymentComponent>();  
       var fulfilmentDetails = arg.GetComponent<FulfillmentComponent>();  
       var listDetails = arg.GetComponent<ListMembershipsComponent>();  
       var listTransientDetails = arg.GetComponent<TransientListMembershipsComponent>();  

For all order line items - We can simply run a for-each loop to get the information.

  foreach (var orderLine in order.Lines)  
           {  
           }  
Fill all the properties in the object, generate the serialized JSON and send it to your backend system.

It's that much simple.

Let me know if need any detail or help on that.

Tuesday, September 1, 2020

Sitecore XC 9.3 - Investigation and fix for Microsoft.OData.Client.DataServiceQueryException



Recently, We have found an issue while deploying the XC changes on a new machine, below are the error details Sitecore XC 9.3
 16164 19:56:24 ERROR Exception <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">     <html xmlns="http://www.w3.org/1999/xhtml">     <head>     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />     <title> IIS 502.5 Error </title><style type="text/css"></style></head>     <body> <div id = "content">      <div class = "content-container"><h3> HTTP Error 502.5 - Process Failure </h3></div>      <div class = "content-container">      <fieldset> <h4> Common causes of this issue: </h4>       <ul><li> The application process failed to start </li>       <li> The application process started but then stopped </li>       <li> The application process started but failed to listen on the configured port </li></ul></fieldset>      </div>      <div class = "content-container">       <fieldset><h4> Troubleshooting steps: </h4>       <ul><li> Check the system event log for error messages </li>       <li> Enable logging the application process' stdout messages </li>       <li> Attach a debugger to the application process and inspect </li></ul></fieldset>       <fieldset><h4> For more information visit:       <a href="https://go.microsoft.com/fwlink/?linkid=808681"> <cite> https://go.microsoft.com/fwlink/?LinkID=808681 </cite></a></h4>       </fieldset>      </div>    </div></body></html> on Execute:https://commerceauthoring.xxx.com.dev.com/api/GetBulkStockInformation  
 16164 19:56:24 ERROR Application error.  
 Exception: System.Web.HttpUnhandledException  
 Message: An unhandled exception occurred.  
 Source: Sitecore.Mvc  
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)  
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)  
   at (Object , Object )  
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)  
   at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)  
   at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)  
   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)  
   at System.Web.Mvc.Controller.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)  
   at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)  
   at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result)  
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)  
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  
 Nested Exception  
 Exception: Microsoft.OData.Client.DataServiceQueryException  
 Message: An error occurred while processing this request.  
 Source: Microsoft.OData.Client  
   at Microsoft.OData.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)  
   at Microsoft.OData.Client.DataServiceContext.InnerSynchExecute[TElement](Uri requestUri, String httpMethod, Nullable`1 singleResult, OperationParameter[] operationParameters)  
   at Microsoft.OData.Client.DataServiceActionQuery`1.Execute()  
   at Sitecore.Commerce.ServiceProxy.Proxy.Execute[T](DataServiceActionQuery`1 query)  
   at Sitecore.Commerce.Engine.Connect.Pipelines.Inventory.GetStockInformation.Process(ServicePipelineArgs args)  
   at (Object , Object )  
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)  
   at Sitecore.Commerce.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)  
   at Sitecore.Commerce.Services.ServiceProvider.RunPipeline[TRequest,TResult](String pipelineName, TRequest request)  
   at Sitecore.Commerce.XA.Foundation.Connect.Managers.InventoryManager.GetStockInformation(CommerceStorefront storefront, IEnumerable`1 products, StockDetailsLevel detailsLevel, Boolean includeBundledItemsInventory, StringPropertyCollection propertyBag)  
   at Sitecore.Commerce.XA.Foundation.Connect.Managers.InventoryManager.GetProductsStockStatusFromConnect(CommerceStorefront storefront, ICollection`1 productEntityList, StringPropertyCollection propertyBag)  
   at Sitecore.Commerce.XA.Feature.Catalog.Repositories.PromotedProductsRepository.AdjustProductStockStatus(ICollection`1 productEntityList)  
   at Sitecore.Commerce.XA.Feature.Catalog.Repositories.PromotedProductsRepository.GetPromotedProductsJsonResult(IVisitorContext visitorContext, String productListId, String relationshipFieldId, String currentItemId, String currentCatalogItemId, Nullable`1 pageSize, Nullable`1 pageNumber, StringPropertyCollection propertyBag)  
   at lambda_method(Closure , ControllerBase , Object[] )  
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_6.<BeginInvokeAction>b__3()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)  
 16164 19:56:24 ERROR Exception <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">     <html xmlns="http://www.w3.org/1999/xhtml">     <head>     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />     <title> IIS 502.5 Error </title><style type="text/css"></style></head>     <body> <div id = "content">      <div class = "content-container"><h3> HTTP Error 502.5 - Process Failure </h3></div>      <div class = "content-container">      <fieldset> <h4> Common causes of this issue: </h4>       <ul><li> The application process failed to start </li>       <li> The application process started but then stopped </li>       <li> The application process started but failed to listen on the configured port </li></ul></fieldset>      </div>      <div class = "content-container">       <fieldset><h4> Troubleshooting steps: </h4>       <ul><li> Check the system event log for error messages </li>       <li> Enable logging the application process' stdout messages </li>       <li> Attach a debugger to the application process and inspect </li></ul></fieldset>       <fieldset><h4> For more information visit:       <a href="https://go.microsoft.com/fwlink/?linkid=808681"> <cite> https://go.microsoft.com/fwlink/?LinkID=808681 </cite></a></h4>       </fieldset>      </div>    </div></body></html> on Execute:https://commerceauthoring.xxxxx.com.dev.com/api/GetBulkStockInformation  
 16164 19:56:24 ERROR Application error.  
 Exception: System.Web.HttpUnhandledException  
 Message: An unhandled exception occurred.  
 Source: Sitecore.Mvc  
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)  
   at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)  
   at (Object , Object )  
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)  
   at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)  
   at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)  
   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)  
   at System.Web.Mvc.Controller.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)  
   at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)  
   at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result)  
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)  
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  
 Nested Exception  
 Exception: Microsoft.OData.Client.DataServiceQueryException  
 Message: An error occurred while processing this request.  
 Source: Microsoft.OData.Client  
   at Microsoft.OData.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)  
   at Microsoft.OData.Client.DataServiceContext.InnerSynchExecute[TElement](Uri requestUri, String httpMethod, Nullable`1 singleResult, OperationParameter[] operationParameters)  
   at Microsoft.OData.Client.DataServiceActionQuery`1.Execute()  
   at Sitecore.Commerce.ServiceProxy.Proxy.Execute[T](DataServiceActionQuery`1 query)  
   at Sitecore.Commerce.Engine.Connect.Pipelines.Inventory.GetStockInformation.Process(ServicePipelineArgs args)  
   at (Object , Object )  
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)  
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)  
   at Sitecore.Commerce.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)  
   at Sitecore.Commerce.Services.ServiceProvider.RunPipeline[TRequest,TResult](String pipelineName, TRequest request)  
   at Sitecore.Commerce.XA.Foundation.Connect.Managers.InventoryManager.GetStockInformation(CommerceStorefront storefront, IEnumerable`1 products, StockDetailsLevel detailsLevel, Boolean includeBundledItemsInventory, StringPropertyCollection propertyBag)  
   at Sitecore.Commerce.XA.Foundation.Connect.Managers.InventoryManager.GetProductsStockStatusFromConnect(CommerceStorefront storefront, ICollection`1 productEntityList, StringPropertyCollection propertyBag)  
   at Sitecore.Commerce.XA.Feature.Catalog.Repositories.PromotedProductsRepository.AdjustProductStockStatus(ICollection`1 productEntityList)  
   at Sitecore.Commerce.XA.Feature.Catalog.Repositories.PromotedProductsRepository.GetPromotedProductsJsonResult(IVisitorContext visitorContext, String productListId, String relationshipFieldId, String currentItemId, String currentCatalogItemId, Nullable`1 pageSize, Nullable`1 pageNumber, StringPropertyCollection propertyBag)  
   at lambda_method(Closure , ControllerBase , Object[] )  
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)  
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_6.<BeginInvokeAction>b__3()  
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)  
Solution -

I compared the solution dlls with the default setup and found diff in .Net core version - After updating the right version this issue has been resolved -


Basically in project solution, the reference has mentioned with 2.1.* and it was not the correct version.



Simple steps to configure - Sitecore.Commerce.Core.AutoApprovePolicy




If Sitecore XC sellable items are not getting published or it automatically removed (weird scenario) - It could be because you have not published sellable items correctly.

For the catalog import, there are a few options available - but if you want to use the Sitecore XC APIs, It's a good option to enable AutoApprovePolicy and remove once you finish your import.

If you are using the commerce core than you can set up this through the AutoApprovePolicy()

 public class ImportCatalogsCommand : CommerceCommand  
 {  
      public IImportCatalogsPipeline ImportCatalogsPipeline  
      {  
           get;  
      }  
      public ImportCatalogsCommand(IImportCatalogsPipeline importCatalogsPipeline, IServiceScopeFactory serviceScopeFactory)  
           : base(serviceScopeFactory)  
      {  
           Condition.Requires(importCatalogsPipeline, "importCatalogsPipeline").IsNotNull();  
           ImportCatalogsPipeline = importCatalogsPipeline;  
      }  
      public virtual async Task  
 <CommerceCommand> Process(CommerceContext commerceContext, IFormFile importFile, string mode, int batchSize, int errorThreshold, bool publishEntities = true)  
      {  
           using (CommandActivity.Start(commerceContext, this))  
           {  
                CommercePipelineExecutionContextOptions pipelineContextOptions = commerceContext.PipelineContextOptions;  
                ImportCatalogsArgument arg = new ImportCatalogsArgument(importFile, mode)  
                {  
                     BatchSize = batchSize,  
                     ErrorThreshold = errorThreshold  
                };  
                if (publishEntities)  
                {  
                     commerceContext.Environment.SetPolicy(new AutoApprovePolicy());  
                }  
                ImportResult importResult = await ImportCatalogsPipeline.Run(arg, pipelineContextOptions).ConfigureAwait(continueOnCapturedContext: false);  
                if (importResult != null)  
                {  
                     base.Messages.AddRange(importResult.Errors);  
                     base.ResponseCode = importResult.ResultCode;  
                }  
                else  
                {  
                     base.ResponseCode = commerceContext.GetPolicy  
      <KnownResultCodes>().Error;  
                }  
                if (publishEntities)  
                {  
                     commerceContext.Environment.RemovePolicy(typeof(AutoApprovePolicy));  
                }  
                return this;  
           }  
      }  
 }  
You can set up this directly in the policy during the import - If you are using the commerce API 

 { "$type": "Sitecore.Commerce.Core.AutoApprovePolicy, Sitecore.Commerce.Core", }   

Friday, August 21, 2020

Sitecore XC (9.3) Fix for Sitecore.XConnect.Client.XdbModelConflictException -One or more local models conflict with the xDB service layer.

 Recently, We have done a scaled environment setup and found this error in the logs (Sitecore XP)

Exception details: Sitecore.XConnect.Client.XdbModelConflictException

Message: One or more local models conflict with the xDB service layer.

'RegisterConnectEventModel, 0.1' does not have a remote version

Source: 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.Analytics.XConnect.DataAccess.BatchEnabledXdbRuntimeContext..ctor(IXdbContextFactory factory)

at Sitecore.Analytics.Events.BatchEventHandler.OnBatchStarting(Object sender, EventArgs args)

at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result)

Steps to fix - the error is pointing that issue withing xConnect models - We checked all the modes in Sitecore rules 

Example path - 

C:\inetpub\wwwroot\xconnect.dev.local\App_Data\Models

C:\inetpub\wwwroot\xconnect.dev.local\App_Data\jobs\continuous\IndexWorker\App_Data\Models

We noticed both models are the same, After investigating it further we noticed that on XP leading site there was only one model, We copied the existing model from below path and updated the xConnect (Removed all others)

C:\inetpub\wwwroot\<siteName>.xconnect\App_data\Models

that change resolved the issue.

Troubleshooting steps and fix - Sitecore XC (9.3) products are not showing in a scaled environment.

Recently, We have done a scaled environment setup and found that the product catalog was not showing in the site.

Investigation steps -  

1. We checked in the Index (sitecore_master_index) and found that product data were missing.

Click on the page, check the sxa URL, solr log and generate the query, As the example below.

https://localhost:8983/solr/axp93_master_index/select?q=((((((((_path:(8174413cc73369a0d61b6ca583c234d4)+AND+commercesearchitemtype_t:(sellableitem))+AND+_latestversion:(True))+AND+excludefromwebsitesearchresults_b:(False))+AND+parentcataloglist_sm:(59ddadc19b88727e9e143f6cf321ae0f))+AND+_parent:(8174413cc73369a0d61b6ca583c234d4))+AND+(_path:(e28e09d9d1534f58a88c66774a19eb5c)+AND+searchable_b:(True)))+AND+_language:(en))+AND+_latestversion:(True))&facet.field=typeofgood_s&facet.field=manufacturer_s&facet.field=brand_s&f.brand_s.facet.mincount=1&start=0&f.typeofgood_s.facet.mincount=1&fq=_indexname:(sitecore_master_index)

2. We verified all logs and found Minion services was trying to hit the wrong master SearchScopeName  name was ( abc_master_index) and showing 404 errors, that points me that something is wrong in the configuration.

We checked the configuration of all four Sitecore roles here, the example below 

C:\inetpub\wwwroot\CommerceAuthoring_xyz\wwwroot\data\Environments\PlugIn.Search.Solr.PolicySet-1.0.0.json

and fixed the index name, it should be the same as XP - master or web.
    



Solution - Please verify the scope in all four roles - PlugIn.Search.Solr.PolicySet-1.0.0.json and correct it that will resolve the issue.

Thursday, July 16, 2020

Sitecore XP 9.3 (Scaled) environment installation with XC 9.3 (Diff roles).

The third time, I got a requirement to set up the infrastructure for my current project, this time the requirement was to go with in-house VMs.


Here are the installation steps and road blockers.

First of all, just wanted to let you know there is no OOTB script available for the XC scaled environment which can mitigate this requirement.

Now, we have two options.

1. Install complete XC setup on CM, CD1 and CD2 and remove all roles other than shop from the CD1 and CD2.

2. Install all roles on CM and only install required roles on CD1 and CD2.

We had a discussion with the Sitecore team and found there is no OOTB script but after some time we got below link for the reference.

https://github.com/CommerceMinion/Sitecore-Commerce-v9.3-Distributed-Installation

If you see the above link, basically it's installing all the modules and removing a few roles based on the roles explicitly.

After checking the above script, and based on my understanding, I have decided to go with the full installation and remove the roles accordingly.

here is my journey now :)

1. Install CM (XP and XC) -  I pointed DB to a diff server and Solr to a diff server as mention in the above diagram.

Install SSL certificate of your company ( in my case it was wild card certificate) get the thumbprint and all update all scaled environment script.

Add Solr host entity to your CM server so that you can access it.

Here are quick steps -


# Change the TLS version

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


# Install Nuget provider(if not installed Visual Studio)

Install-PackageProvider -Name NuGet


# Trust the PSGallery (Skip this)

# Set-PSRepository PSGallery -InstallationPolicy Trusted


# Register the SitecoreGallery

Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2


# Install the SIF

Install-Module -Name SitecoreInstallFramework -Repository SitecoreGallery -RequiredVersion 2.2.0


# Run Prerequisites

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\Prerequisites.json"


# Download .net framework 4.7.1 developer pack

# Download .net framework 4.7.2 developer pack

# Restart server


# Run the query on DB server

EXEC sp_configure 'contained', 1;

RECONFIGURE;

# Run the Sitecore installation for CM/CD

# Identity Server

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\IdentityServer.json"


# Only for CM Server

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\sitecore-XP1-cm.json"


# Only for CD Server

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\sitecore-XP1-cd.json"


# Common

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\sitecore-XP1-prc.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\sitecore-XP1-rep.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\xconnect-xp1-collection.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\xconnect-xp1-collectionsearch.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\xconnect-xp1-MarketingAutomationReporting.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\xconnect-xp1-MarketingAutomation.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\xconnect-xp1-ReferenceData.json"

Install-SitecoreConfiguration –Path "D:\Sitecore\SitecoreInstaller\xconnect-xp1-CortexProcessing.json"


========================

POints CORS in identity Server

*XConnectEnvironment in xp1-collection

"DefaultValue": "Development",


XConnectEnvironment in xp1-collectionsearch

"DefaultValue": "Development",


XConnectEnvironment in xp1-marketing

"DefaultValue": "Development",

All the above steps will install the XP on the CM server,  now to install the XC, I have followed below steps.

Download the XC 9.3 script and update all required parameters, Make sure to point to Solr URL and SQL credential appropriately.

As the SQL is on remote (diff) machine we have to explicitly change the SIF script.

  • SIF\Configuration\Commerce\SitecoreBizFx\SitecoreBizFx.Install.json
  • SIF\Configuration\Commerce\CommerceEngine\CommerceEngine.Instance.Deploy.json 

      {

              "Name": "GlobalDatabaseUserName",

              "Value": "[concat(parameter('UserDomain'), concat('\\\\', parameter('UserName')))]"

            },


        {

              "Name": "SharedDatabaseUserName",

              "Value": "[concat(parameter('UserDomain'), concat('\\\\', parameter('UserName')))]"

            },

   "UserName": "[concat(parameter('UserDomain'), concat('\\', parameter('UserName')))]"


Install the self-signed certificate to the trusted root,  otherwise, you will get below errors 



 Install-SitecoreConfiguration : Cannot validate argument on parameter 'Signer'. The argument is null, empty, or an element of the argument collection contains a null  
 value. Supply a collection that does not contain any null values and then try the command again.  
 At D:\InstallationMaster\Sitecore\SitecoreCommerce\SIF\installProd.ps1:295 char:5  
 +   Install-SitecoreConfiguration @deployCommerceParams -Verbose *>&1 ...  
 +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
   + CategoryInfo     : NotSpecified: (:) [Write-Error], WriteErrorException  
   + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration  
 [TIME] 00:00:47  
 Invoke-NewSignedCertificateTask : Cannot validate argument on parameter 'Signer'. The argument is null, empty, or an element of the argument collection contains a null  
 value. Supply a collection that does not contain any null values and then try the command again.  
 At C:\Program Files\WindowsPowerShell\Modules\SitecoreInstallFramework\2.2.0\Public\Install-SitecoreConfiguration.ps1:641 char:47  
 +             & $entry.Task.Command @paramSet | Out-Default  
 +                        ~~~~~~~~~  
   + CategoryInfo     : InvalidData: (:) [Invoke-NewSignedCertificateTask], ParentContainsErrorRecordException  
   + FullyQualifiedErrorId : ParameterArgumentValidationError,Invoke-NewSignedCertificateTask  
 PS D:\InstallationMaster\Sitecore\SitecoreCommerce\SIF>  

Setup the SMO - otherwise you will get this error -


Sometime, You may need to update the SIF scrip to replace https instead of HTTP explicitly.

And the final steps to remove the unnecessary role and add the correct URL, I go the reference from above scripts, Here are the details for each role.

  { "id", "xc_ma" } {  
     Remove-Item "C:\inetpub\wwwroot\XP1.sc\XConnectFiles" -Recurse -Force -ErrorAction SilentlyContinue  
   }  
   "cd" {  
     Remove-Item "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.XConnect" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\Program Files\Redis" -Recurse -Force -ErrorAction SilentlyContinue  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cd\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<shopsServiceUrl>https://localhost:5000/api/</shopsServiceUrl>" -replace "<shopsServiceUrl>https://commerceshops.sc9.com/api/</shopsServiceUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cd\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<commerceOpsServiceUrl>https://localhost:5000/commerceops/</commerceOpsServiceUrl>" -replace "<commerceOpsServiceUrl>https://commerceops.sc9.com/commerceops/</commerceOpsServiceUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cd\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<commerceMinionsServiceUrl>https://localhost:5000/commerceops/</commerceMinionsServiceUrl>" -replace "<commerceMinionsServiceUrl>https://commerceminions.sc9.com/commerceops/</commerceMinionsServiceUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cd\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<sitecoreIdentityServerUrl>https://sxastorefront-identityserver/</sitecoreIdentityServerUrl>" -replace "<sitecoreIdentityServerUrl>https://xp1.identityserver/</sitecoreIdentityServerUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cd\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<enforceSsl>true</enforceSsl>" -replace "<enforceSsl>false</enforceSsl>"  
   }  
   "cm1" {  
     Remove-Item "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.XConnect" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\Program Files\Redis" -Recurse -Force -ErrorAction SilentlyContinue  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cm\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<configuration>localhost,defaultDatabase=1,allowAdmin=true,syncTimeout=3600000</configuration>" -replace "<configuration>localhost,defaultDatabase=1,allowAdmin=true,abortConnect=false,syncTimeout=3600000</configuration>"  
   }  
   "cm2" {  
     Remove-Item "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.XConnect" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\Program Files\Redis" -Recurse -Force -ErrorAction SilentlyContinue  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cm\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<shopsServiceUrl>https://localhost:5000/api/</shopsServiceUrl>" -replace "<shopsServiceUrl>https://commerceshops.sc9.com/api/</shopsServiceUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cm\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<commerceOpsServiceUrl>https://localhost:5000/commerceops/</commerceOpsServiceUrl>" -replace "<commerceOpsServiceUrl>https://commerceops.sc9.com/commerceops/</commerceOpsServiceUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cm\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<commerceMinionsServiceUrl>https://localhost:5000/commerceops/</commerceMinionsServiceUrl>" -replace "<commerceMinionsServiceUrl>https://commerceminions.sc9.com/commerceops/</commerceMinionsServiceUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cm\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<sitecoreIdentityServerUrl>https://sxastorefront-identityserver/</sitecoreIdentityServerUrl>" -replace "<sitecoreIdentityServerUrl>https://xp1.identityserver/</sitecoreIdentityServerUrl>"  
     WorkAround-Replace-In-File -filePath "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.cm\App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config" -find "<enforceSsl>true</enforceSsl>" -replace "<enforceSsl>false</enforceSsl>"  
   }  
   "prc" {  
     Remove-Item "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.XConnect" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\Program Files\Redis" -Recurse -Force -ErrorAction SilentlyContinue  
   }  
   { "ce_post", "bizfx", "sf" } {  
     Remove-Item "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.sc" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\XP1.xconnect" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\solr-8.1.1" -Recurse -Force -ErrorAction SilentlyContinue  
     Remove-Item "$($Env:SYSTEMDRIVE)\Program Files\Redis" -Recurse -Force -ErrorAction SilentlyContinue  
   }  
After that, I changed the Redis under the LB for the HA.

Let me know if you have any questions. 

Happy Sitecore XP + XC installation on the production.

Monday, June 1, 2020

Sitecore XC 9.3 - Fix for Request URL: GetCatalogMappings(environmentName='')

 Recently, We found below error during the development -

      Message: Access to the registry key 'Global' is denied.  
 8516 10:01:25 INFO Cache created: 'DeviceDictionaryCache' (max size: 100MB, running total: 3908MB)  
 18808 10:01:40 INFO [Path Analyzer](.) Map EnsureAllDeployed started.  
 18808 10:01:40 INFO [Path Analyzer](.) Map EnsureAllDeployed complete.  
 18808 10:02:40 INFO [Path Analyzer](.) Map EnsureAllDeployed started.  
 18808 10:02:40 INFO [Path Analyzer](.) Map EnsureAllDeployed complete.  
 14936 10:02:47 ERROR Commerce.Connector - Request URL: GetCatalogMappings(environmentName='') - Exception: System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.  
   --- End of inner exception stack trace ---  
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)  
   at Sitecore.Commerce.Engine.Connect.DataProvider.CommerceRepository.InvokeHttpClientGet(String serviceCallUrl, Boolean useCommerceOps, Boolean raiseException, String language, String environment, IDictionary`2 headers)  
 ---> (Inner Exception #0) System.Threading.Tasks.TaskCanceledException: A task was canceled.<---  
 Exception: System.AggregateException  
 Message: One or more errors occurred.  
 Source: mscorlib  
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)  
   at Sitecore.Commerce.Engine.Connect.DataProvider.CommerceRepository.InvokeHttpClientGet(String serviceCallUrl, Boolean useCommerceOps, Boolean raiseException, String language, String environment, IDictionary`2 headers)  
 Nested Exception  
 Exception: System.Threading.Tasks.TaskCanceledException  
 Message: A task was canceled.  
Investigation details -

We noticed it was because of deployment, As few dlls were missing, After a full deployment this issue has been resolved.