Tuesday 3 December 2019

Sitecore Commerce 9.2 Business tools error with invalid shop


Problem Description

I was playing with Sitecore Commerce 9.2 recently. installation works perfectly fine it works really well. While playing with it, I was changing a lot of configurations and services to check a few things.
Suddenly I started getting an error on Sitecore Commerce Business tools and not loading any menu on Business tools as shown in the following images.



After a few retries in the loop, we saw for request GetNavigationView() and GetLanguageView() returns 400 Bad requests.

and the response was 

{  "@odata.context":"https://commerceauthoring.commerce.com/Api/$metadata#Sitecore.Commerce.Core.CommandMessage","MessageDate":"2019-12-03T16:37:39.4253344Z","Code":"Error","Text":"Shop 'CommerceEngineDefaultStorefront' does not exist.","CommerceTermKey":"InvalidShop"
}

the similar error I was getting in PostMan request too

{
  "@odata.context""https://localhost:5000/Api/$metadata#Sitecore.Commerce.Core.CommandMessage",
  "MessageDate""2019-12-03T16:26:47.0334391Z",
  "Code""Error",
  "Text""Shop 'CommerceEngineDefaultStorefront' does not exist.",
  "CommerceTermKey""InvalidShop"
}

Solution: 

I have tried  many things but in last in I come to know that Sitecore 9.2 Commerce use Redis cache and if Redis service is not running, you will get above error. So make sure that Redis cache is kept running. As soon as started, Redis cache everything works again. 


Happy commercing..........






Thursday 22 August 2019

Sitecore Commerce: DevOps Tasks Trigger from Sitecore Experience Platform


I have recently started playing and learning Sitecore Commerce. There are few tasks like configuration and administration of Sitecore commerce is needed, there is a special role DevOps associated to perform those tasks.

The DevOps role is an instance of the Commerce Engine that is internal and only available to DevOps personnel. This role can be assigned higher privileges allowing DevOps personnel to perform maintenance tasks that are not permitted to other roles (for example, bootstrapping and environment initialization functions). Sitecore has given lots of  OOTB Postman Collections.  Which is really good for extending pipeline and Pipeline blocks.

I found that it can be painful when you need to run a task very quickly and efficiently on production. There is a possibility to make a mistake in request and it will be time-consuming too.

Sitecore Commerce requires the Sitecore PowerShell module, SXA, and SXA storefront(if you are using it.) So I thought it is better to trigger a few tasks like  Bootstrapping, Rebuild index tasks, Purge tasks, Minion Task(Pending order task, Release order task, Waiting for order task, etc ) from Sitecore directly. This package provides a Sitecore package with PowerShell script.

Note: This module tested on Sitecore 9.1 update 1 released with Sitecore Commerce 9.1 and Powershell 5.0 

There are a few steps to perform

1.  Install-Package (do not install on production without testing to local/dev/test environment)

How to Use it

1. After installing Package go to "/sitecore/system/Modules/PowerShell/Script Library/Commerce DevOps/Commerce DevOps Settings"

And update setting as per your need.


2. Create a new user based on "Sitecore\Commerce Dev  Ops" role
3. Log in with a new user 
4. You can see a new area in a control panel 

5. To Bootstrap environment Click on "Bootstrap Commerce Environment," It will challenge you to enter a password (if you set default password in setting item it will appear if you have not set up default it will be blank).

6. To Run Minon Click on Minion Tasks.  It will give a drop-down list of tasks to select one.


7. You can see task run successfully or not, To see the result  click on "View Script result"


Happy Commercing !!




Tuesday 11 September 2018

Multilist field Index issue When Index only selected field

Problem:

We added a new multi-list field in Sitecore 9 Update 2, (vanilla instance) on the Sample Item and populated it with some content items.
We Added new multi-list field to include the fields section in the index configuration file as: 
            xxxxxxx  


also set
false
under documentOptions node in Sitecore 9 update 2

We rebuild the sitecore_master_index and we queried the index in Solr. We noticed that the field is stored in the index as a string in the format of an array of IDS. - this is not what we expected."multilistitem_t_en":["{Guid1}|{Guid2}"],

If we turn true and rebuild the index we see the field in the index as a string in the format of a list og GUIDs which is what we expect to be the default behaviour."multilistitem_sm":["23442343231423423234abcdbded", "bced4423433231423423234abcdbded"],We don't want to change indexAllFields to true though due to performance issues.

Solution:

Due to this issue, we had to postpone the release by a day and out team needs to change all our multi-list fields code to computed fields. After some time Sitecore has provided a fix


Happy sitecoring........


Tuesday 5 April 2016

Object reference not set error when open Path Analyzer in Sitecore


Issue: Object reference not set error when open Sitecore Path Analyzer  After upgrade from 7.5 to 8.1 update 2

How ever this error was present in 8.1 Initial update too. Thanks to chris who give me direction where to look it save my time. However that solution is not fix actual problem it It show sitecore root in select map dropdown which is not correct list of maps.

When I try to open Path Analyzer for the first time after upgrade to 8.1 update 2 and Initial release, I get an follwong error in the MapSelector.cshtml file, Object reference not set to an instance of an object.
 
helper.MakeTreeDefinition("TreeDefinitionFilter", fieldsWrapper, selectedTreeDefinitionId.ToString(), mapRootId.ToString());
The mapRootId object.  That parameter is empty when launching the Path Analyser, so the method expecting this value but  finds nothing.  This happens on line 32: 
 

 
var mapRootId = parametersHelper.GetMapRootId();
 
 
 
The  problem is that GetMapRootId() is retuning a null value from this command, when that Mapselector Component parameter doesn’t exist. 
 

Solutions:

 

To fix above issue follow the steps below
1. Go Sitecore Desktop
2. switch Database to Core
3. Go  to the path below
 /sitecore/client/Applications/PathAnalyzer/Common/Layouts/Renderings/MapSelector/MapSelector Parameters/__Standard Values
 
4.Find Field called DefaultMapRoot  set following id {6768BE32-A142-4BA4-A02F-01D810FBF7FE}
 
5. close  sitecore clean browser cookies
6. Go to Path Analyzer .................

 
 
Enjoy
 
 

 


 




Tuesday 23 February 2016

Sitecore Zero DownTime Deployment..................Possible?

In Sitecore deployment its alway a issue of downtime may be couple minutes to few miute as both content delivery share same Web Database and content package installed on CM and just code drop on CDs so you alway come in situation  where you need to wait  until template/ layout deploy and then publish and site back on track. Its is Chicken and Egg situation which should deploy first and some times you need to apply some manual steps on some content before you published it.

There are couple of Ways you can deploy without down time one of the way is show in Sitecore Scaling guide for Disaster recovery servers used as temporary/ permanent switch to  live traffic for user after deployment. Which increase servers cost and lots of over heads.

My client do not wants add new servers to infrastructure  as they don't have enough resources to manage all servers and achieve No down time while deployment.

Following Diagram is very common across Sitecore deployment.
Standard Sitecore architecture  is two or more Content Delivery servers one Content Management Server one  Solr with Zookeper to sync Solr Node, Sql Cluster for Load balacing Sql. like below. I assume Core Database is required and all of us know.

There is option for solr and Lucene to switch index while rebuild index no down time for solr content. We can't use that feature as we are having Nutch for site search.




We have automated lots of  step using Teamcity and octopus steps like Sanity Check after deployment complited and generate report of any broken link or page error. I am going in to details but I am showing some basing settings  how to achive. 

There are few steps you need to do

Add new Web Publishing Target. 


Visit John West Blog or Nehemiah Jeyakumar

Add new Web Index or Any costom Index Core.

Copy existing Web Index Named "Sitecore_Web_Index or any custom and got Sitecore_web2_index
folder and find core.properties Open and change Name property  with "Sitecore_Web2_index

Update Index Update Strategies

Go to Sitecore.ContentSearch.DefaultConfigurations.config
Add following new Strategy Which allow to update index to both Solr index same time  while  normal operation of cm. So we hare update content on both solr index.

<onPublishEndAsyncWeb2 type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch">
<param desc="database">web2</param>
<!-- Whether or not a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified
in ContentSearch.FullRebuildItemCountThreshold. -->
<CheckForThreshold>true</CheckForThreshold>
 </onPublishEndAsyncWeb2>


 Configure Solr Index.config

Add following or as per your need

<!-- WEB INDEX configuration -->
          <index id="sitecore_web2_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="core">$(id)</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsyncWeb2" />
            </strategies>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web</Database>
                <Root>/sitecore/content/home</Root>
              </crawler>
            </locations>
           <!-- <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web</Database>
                <Root>/sitecore/content/demo</Root>
              </crawler>
            </locations>-->
          </index>


Change Code  to switch index  

In our case Searcm manager configure based on one of App setting value  so we can chagne index to search content from that index.

Nutch Feeding to both Index Sitecore_Web_Index and Sitecore_Web2_Index.




Now configuration is ready All you need to run deployment in following order. We are using octopus deploy so we have lots of flexibility to chagne configuration using powershellshell script.

1. Remove one Content delivery Server from Load Balancer its depend on load balancer software API.
2. Stop Nutch for feeding index
2. Change App Setting to for Site Search TO Sitecore_Web2_Index on CM and CD both.
3. Set Default publishing target On CM only to Web2 Database. Instead of Web|Web2 in DefaultPublishingTargets in web.config file, you can set mutliple target separated by pipe
4. Set Site Definition Database Attribute to Web2 (CM and one CD)
4. Deploy Sitecore Item to  cm and code to CM and CD
5. Publish content to  Web2 Publishing target
6. Run test script to regression check of you site.


If successful  all above steps run second part of deployment.

1. Add back first server and remove other server from load balancer.

2. Change configuration for search
3. Set Site definition to Web2
3. Deploy code package to content delivery.
4. Add server To Load balancer.

Finally steps
Set DefaultPublishingTargets to Back to web|web2 on CM so manual publish sync content and update index correctly.


In Next deployment just switch web2 to web and deploy to server.

Enjoy No downtime deployment....

I have test this and with Solr index....Not tested with Lucene.













Sitecore Content Editor Search-Tags with User Friendly Facets tags

Its is very surprised that Sitecore beautiful feature people are not using it. Sitecore support very large content using Sitecore Item Bucket which was created as sitecore 6.6 module couple of year ago but now its part of sitecore Sitecore Item bucket. Item Buckets is a system that lets you store millions of content items in one container. You can convert individual items in the content tree into item buckets that can contain any number of subitems. These subitems are not listed in the content tree and do not have a direct parent-child relationship with the item bucket item.

One Really good feature is tagging content and seach based on tagging. We have thousands of pictures and content for one of my client they are struggling to find content. So I introduced them tagging feature. To enabled Tags filter for search Go to Item /sitecore/system/Settings/Buckets/Facets/Tags  and Enabled Checkbox Global.
so we can filter content based on tags applied but we discover that Tags are showing some strange Id like below.




Sitecore Has settiing for enabled User friendly name for Tags.

 Find Sitecore.Bucket.config file and find 
<setting name="BucketConfiguration.ResolveFacetValueToFriendlyName" value="false"/>

Repace with 
<setting name="BucketConfiguration.ResolveFacetValueToFriendlyName" value="true"/>

just rebuild index master index  you will see following.



Its Nice Feature...............

I was looking weather someone has face similar issue but found out yes is very common.
I had implemented computed field and use that field for facets. But after looking more in details find out above configuration out of box from Sitecore.

Thanks for visiting.......






 

Thursday 24 April 2014

Sitecore Rule : Item Saved Actions not showing.

I am really fan of sitecore rule engine and discover some hidden gems for rule engine. I am bit surprise that has sitecore intentionally not added separate templates for each rule type or left it for developer to add themselves. but good things is it works with new template type with same field names...

Created new rule using template: /sitecore/templates/System/Rules/Rule  under /sitecore/system/Settings/Rules/Item Saved/Rules but actions are not showing any action from /sitecore/system/Settings/Rules/Item Saved/Actions  and showing from common actions under /sitecore/system/Settings/Rules/Common/Actions






 
 

Why? its not showing Item Saved/Actions and Showing Common Actions.

Solutions: when we create rule new there is default insert option is "rule" using which use /sitecore/system/Settings/Rules/Item Saved/Rules template with no source specified as below:



By adding new source with item saved path not going to solve the issue and this will applied to all rules and showing item saved action in all rules like item deleted, item created if you customised  pipeline. so this solution not going to work. after digging more and other rules action come to know that you need to create new template same as item insert option or content editor warning etc.

Step 1. Duplicate Rule template in /sitecore/templates/System/Rules/Rule named "Item Saved Rule".
Step 2. Add /sitecore/system/Settings/Rules/Item Saved to source field to rule field.
Step 3: Add Insert option to Rule item  as Item Saved
Step 4 Create rule desire rule under item saved/Rules with new template created in step 1.
Step 5 Add desire action folder or action to item saved/actions.
After Applying this you will see as below.


Sitecore........is...........Amazing........................