Monday 6 August 2018

Sitecore Commerce 9u1 : One or more exception occurred while processing the subscribers to the ‘packageinstall:items:ended’ event


Hello Devs,

While Installing Sitecore Commerce 9 update 1, I faced below error -





This error seems to be from the Sitecore side.The log file from Sitecore showed below Stacktrace

Exception [1]: Microsoft.OData.Client.DataServiceQueryException  Message[1]: An error occurred while processing this request.  Source[1]: Sitecore.Commerce.ServiceProxy     at Sitecore.Commerce.ServiceProxy.Proxy.GetValue[T](DataServiceQuerySingle`1 query)    at Sitecore.Commerce.Engine.Connect.DataProvider.CatalogRepository.GetLanguages()    at Sitecore.Commerce.Engine.Connect.DataProvider.ReadOnlyCatalogDataProvider.GetItemVersions(ItemDefinition itemDefinition, CallContext context)    at Sitecore.Data.DataProviders.DataProvider.GetItemVersions(ItemDefinition item, CallContext context, DataProviderCollection providers)    at Sitecore.Data.DataSource.LoadVersions(ItemDefinition definition, Language language)    at Sitecore.Data.DataSource.GetVersions(ItemInformation itemInformation, Language language)    at Sitecore.Data.DataSource.GetLatestVersion(ItemInformation itemInformation, Language language)    at Sitecore.Data.DataSource.GetItemData(ID itemID, Language language, Version version) *** 

I tried to google this issue but was not able to find anything concrete. I raised this issue with Sitecore support and they provided me with few steps to resolve the issue.

1. Error that caused this exception is that sitecore can't connect to the Commerce Engine instance (Commerce Authoring). So, please ensure that this instance is up and running. 
Also check that sitecore has configured thumbprint to communicate with Commerce Authoring. You need specify certificate Thumbprint value (certificateThumbprint value of certificate which you've created before installation) in the App_Config\Include\Y.Commerce.Engine\Sitecore.Commerce.Engine.Connect.config
<certificateThumbprint> V A L U E </certificateThumbprint>

In my case it was fine.

2. The other approach is to disable index rebuild temporarily and rebuild all indexes after commerce is installed. To do it, you need to comment out this handler during installation process.

 <event name="packageinstall:items:ended">
        <handler type="Sitecore.ContentSearch.Events.PackagingEventHandler, Sitecore.ContentSearch" method="OnPackageInstallItemsEndHandler" />
</event>

It executes index rebuild after each package is installed. After commenting out this event I re-ran the installation process and was not able to see the error again.

Note : Don’t forget to Re-build indexes after the installation process is completed.

Happy Sitecore Commerce Installation!!! 😄😄😄

Friday 5 January 2018

Experience Editor : & removed while editing rendering parameter field

Hello Devs,

While trying to update rendering parameter field from experience editor and provide special characters like & or @ in the field value it would strip all the content after special character.

Lets re-produce the issue





















Now if we edit the rendering parameter field values with special character from the content editor and save it, text is not stripped. It happens from experience editor.

We raised this issue with the sitecore support and they reported it as a bug in version (8.1 update-1 (151207)).

They provided a patch to resolve it. (click on link to download the sitecore patch)

https://sitecore.box.com/s/pmv261bzomeinex9gtpoxc9tmziq3eda

Now Let's check after providing the patch.




















That's it for now
Happy Coding !!! 😊




Saturday 30 December 2017

Sitecore 9 : No matching command include parameter name signer

Hello Sitecore Devs,

While Installing Sitecore 9 on windows 8.1 machine I faced an error
No matching command include parameter named 'signer'. check the spelling of the parameter name and then try again.




















I found one post regarding above error 
https://neilkillen.com/2017/11/04/sitecore-9-0-sif-windows-8-1-server-2012-gotchas/

It says that windows 8.1 does not have parameter named "signer" and hence the error.
Also IIS 8.0/8.5 does not support creation of certificates automatically. so you need to manually create certificate.

After generating the certificates manually you need to update the installation script as follows :

For Step : #install client certificate for xconnect
remove line Install-SitecoreConfiguration @certParams -Verbose so that it does not try to install certificate automatically and we can get rid of the 'signer' error.

Search for XConnectCert = $certParams.CertificateName instances in your installation script and replace $certParams.CertificateName with the thumbprint of your created certificate (make sure to convert your thumbprint to uppercase and remove space between them).

e.g. XConnectCert ="C28BDFD63F84DAA28CF604345A1A5124F3E535D1"

Re-run your installation script and you should be able to solve certificate related error.

That's all for Now !!!





Thursday 6 April 2017

Solr Keyword Search with hyphen not working

Hello Devs,

While doing hands on with SOLR, faced issues while searching for keywords with hyphen. Just an overview, I have created list of items in Sitecore which has below fields:

Employee Name, Employee Birthdate, Employee City and Employee Bio and I’m reading its values from my custom SOLR Index.

When we search with Employee Name (for e.g. John - Smith), it does’nt give any search results even if its present in index.

The reason is Sitecore field types of “html|rich text|single-line text|multi-line text|text|memo|image|reference” are defined as a text field and it uses solr.StandardTokenizerFactory.

This Standard Tokenizer treats whitespace and punctuation as delimiters and it discards them (except (dots)). To read more about Tokenizers click here.
First, you need to add the Field (e.g. Employee name) in

Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config under

<fieldNames hint="raw:AddFieldByFieldName"> 

section or you can create a custom index configuration file and add the require fields as below:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <!-- Configuration sections for indexes -->
      <indexConfigurations>
        <!-- If an index has no configuration specified, it will use the configuration below. The configuration is not merged if the index also has
         configuration, it is either this configuration or the index configuration. -->
    <defaultSolrIndexConfiguration  type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration,    Sitecore.ContentSearch.SolrProvider">

          <!-- DEFAULT FIELD MAPPING
               This field map allows you to take full control over how your data is stored in the index. This can affect the way data is queried, performance of searching and how data is retrieved and casted to a proper type in the API.
            -->
          <fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
            <fieldNames hint="raw:AddFieldByFieldName">
                   <field fieldName="Employee Name" returnType="string" />
            </fieldNames>
         </fieldMap>
        </defaultSolrIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

In Schema.xml file for the SOLR index you created, comment out

<fieldType name="string" class="solr.StrField" sortMissingLast="true" />

and add,

<fieldType name="string" class="solr.TextField" sortMissingLast="true">
      <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
      </analyzer>
 </fieldType>

Once you make all these changes restart your SOLR Service once and Re-build index. Now Search for keywords with – in it and you would see the results.

Happy Coding 😊

Wednesday 5 April 2017

Issue with Publishing related items from experience editor

Hello Devs,

We faced one issue while publishing related items from Experience Editor. We are passing a datasource item (e.g. XXX) to a component.

The Datasource item have a multilist field where we select the items (Item: A, B) to be displayed.

When we Update field values of the below selected items (Item: A or B) from the experience editor. The values are updated from the experience editor and were reflected in content editor as well but when we publish with (Publish sub Items and Publish Related Items) the changes are not getting reflected.

Question: Is this an intended behaviour? (We raised a support ticket for it)

Yes, Sitecore does’nt process second level reference and therefore it’s not process by Sitecore. The reason is to prevent huge number of items being published. Sitecore doesn't process references of references.

You can customize your solution to implement the behaviour in the following way:

1. Create your custom processor based on the Sitecore.Publishing.Pipelines.GetItemReferences.AddItemLinkReferences 
one (i.e. copy sources of processor).

2. Modify the GetReferences() method so that it would recursively process reference references if item is being referenced by the Renderings field (i.e. reference is a data source item).

3. Replace predefined processor with your custom one.

Click here to download the custom code file provided by Sitecore.

That’s it !!!

Happy Coding 😊

Friday 13 January 2017

Validation error on adding image in Rich-Text field from Experience editor


Validation error on adding image in Rich-Text field from Experience editor 

When we add an image in Rich-Text field through Experience Editor it throws validation error in (Sitecore 8.1 update-1(151207)).






Steps to reproduce:

Add an image in Rich-Text field from Experience Editor

As soon as we save the changes a validation error is thrown in experience editor

In Experience Editor the <img> tag created is,

<img alt="XXX" src="-/media/XXX.ashx?h=111&amp;w=539&amp;hash=CAF8436CA168BC18D2FD5D95597E874E66EDD1DF" style="width: 539px; height: 111px;" />

Open Content Editor

Click on Edit Html -> Click Fix

The Original HTML and Corrected HTML show no difference but if you see the <img> tag / is removed.

<img alt="XXX" src="-/media/XXX.ashx?h=111&amp;w=539&amp;hash=CAF8436CA168BC18D2FD5D95597E874E66EDD1DF" style="width: 539px; height: 111px;" >

/> is removed

After accepting the above changes, it doesn't throw any error in content editor as well as validation error from experience editor is gone.

Solution:

We raised this with Sitecore Support and they reported it as a Bug in Sitecore 8.1 update-1(151207) Thanks to Sitecore support as they provided a patch to resolve this issue.

So the problem appears while decoding the HTML rich text value in System.Net.WebUtility.HtmlDecode method. To let HtmlDecode generate valid output for rich text field apply following patch provided by Sitecore:

1) Backup your \Website\sitecore\shell\client\Sitecore\ExperienceEditor\ExperienceEditor.js

2) Find following code in mentioned ExperienceEditor.js:

encodeHtml: function (htmlSource) {
    htmlSource = htmlSource.replace(/\\/g, '\\\\').replace(/\"/g, "\\\"");
    var encodedHtml = encodeURIComponent(htmlSource);
    return encodedHtml;
},

and replace it with:

encodeHtml: function (htmlSource) {
    htmlSource = htmlSource.replace(/\\/g, '\\\\').replace(/\"/g, "\\\"").replace(/&amp;/g, "&amp;amp;"); // fix 102239
    var encodedHtml = encodeURIComponent(htmlSource);
    return encodedHtml;
},

3) Clear your browser cache. That’s it.

Check by adding image from Experience Editor it wouldn't throw any validation error.

Happy Coding 😊.



Wednesday 17 August 2016

Sitecore - Custom Code Snippets in Rich-Text Editor field

Add Custom Code Snippets in Rich-Text Editor field in Sitecore


Hello Devs,

If you want to have Html Formatting for the content displayed from Rich-Text Editor field in Sitecore than this blog post is for you.

How to add Custom Code Snippet in Rich-Text Editor?


Switch to Core Database in Sitecore.
     Navigate to the below mentioned path in Sitecore Path:/sitecore/system/Settings/Html Editor Profiles/Rich Text Full/Snippets



 
Create a Custom Code Snippet Item in Sitecore as per your requirement from below Template.    
Sitecore Path: /sitecore/templates/System/Html Editor Profiles/Html Editor Snippet

Code Snippet Item would have two fields :
     Header (Name of the Snippet)
     Value (This is the field where you specify predefined block of HTML code)

     In my case I’m creating a PDF Icon Snippet that would display a PDF ICON for the Link.Below is the example of the Snippet.



Header: PDF Icon
Value : <p class="pdf-icon"><a href="#">Add Link</a></p>
I have created a css class named pdf-icon which would display 
the PDF Icon.

.pdf-icon
{
    background: url('/-/media/Test/Images/Icons/icon_pdf')center left no-repeat;
    padding-left: 30px;

}

How to Use the Custom Snippet in the Rich-Text Editor Field?


Switch to the Master Database and navigate to the Rich-Text editor field where you want to use the custom code snippet.
Click on the Insert Code Snippet Icon and click on the PDF Icon snippet.
You can see the Add link text is added.


Right-click the Add Link Text , select Properties
Select the PDF File and provide the Link Text as shown below.

Save and Publish the Item.



That’s it, you are done!!! Just view in Front-End whether your Custom Code Snippet is applied.