Monday, November 5, 2018

Coveo Load More button implementation


Hi Folks,

Today I will try to cover how can we build load more button  functionality in Coveo for Sitecore.
As Coveo provide OOTB auto load result on scroll functionality but in some scenario we need ‘load more’ button.
For that we need to call below function:


Coveo.$('.CoveoResultList').coveo('displayMoreResults', size);

So Assume we have load-more button so on click of that button we have to call below function:



Coveo.$('.loadmore').click(function(e, args) {

               Coveo.$('.CoveoResultList').coveo('displayMoreResults', size);

           });




Above function call displayMoreResult method of Coveo with size parameter here size the number of result which you want to display when someone click on ‘load more’ button.
Here above I am using ‘Coveo.$’ as that is recommended to be execute flawless our Coveo javascript code without any conflicts due to jquery library while we are calling or write any Coveo related javascript.

That above code work perfectly for load more functionality.
But we have to look into the result if there is no more sufficient result then we have to hide ‘load more’ button else we need to show the ‘load more’ button.
For that we check the result number that we can check by below variable:

args.results.totalCount :It gives the total count of result.
args.query.firstResult : The 0-based index position of the first result to return.
args.query.numberOfResults: The number of results to retrieve starting from firstResult.

If resultPerPage variable hold greater value from args.results.totalCount then no need to show button.

In another case you can do use similar below code for this situation before process the result by 'preprocessResults' method:



Coveo.$('#IdOfCoveoSearchInterface').on('preprocessResults', function(e, args){

               if (args.results.totalCount > (args.query.firstResult + args.query.numberOfResults)) {

                   Coveo.$(".loadmore").show();

               } else {

                   Coveo.$(".loadmore").hide();

               }

           });

I hope you enjoy this Sitecore blog. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)


Please leave your comments or share this article if it’s useful for you.

Tuesday, October 9, 2018

Sitecore 9 Installation step by step

Hi Folks,
Today I will try to cover how to install Sitecore Experience Platform 9 Initial Release.
Prerequisites
·       Windows 10
·       Windows PowerShell version 5.1 or later
·       MS SQL Server 2016 SP1 or later
·       MS SQL Management Studio
·       .Net Framework 4.6.2 or later
·       Web Deploy 3.6
·        SOLR 6.6.2
·       Java Runtime Environment
·       NSSM
·       Sitecore Install Framework
·       Packages for XP Single (On Premises deployment)
·       SIFLess.exe (For Quick Installation) optional                               ­­
Installation steps:
At first go with the prerequisites.
If you done with the prerequisites then you need to setup step by step.
1.       Install SQL server and SQL management studio
·       Install MS SQL server and also install MS SQL management studio (ssms) with mix mode authentication and setup password for ‘sa’ user that will be needed for Sitecore installation.
·       MS SQL Server 2017 download from here
·       MS SQL Management Studio 17 down load from here
·       Once you install both above SQL tool then you need to run a new query, for that open ssms and login with ‘SQL Server Authentication’ for user ‘sa’ with the password which you setup in previous step. After login you need to run below query for ‘Contained Database Authentication’
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE;
GO
2.       Install web deploye 3.6 and JRE
After Install JRE setup environment path as below:
Variable Name: JAVA_HOME
Variable Value: C:\Program Files\Java\jre1.8.0_151
3.       Create a new folder F:\Sitecore9_Repository, you can choose your own directory path.
4.       Install Solr 6.6.2
·       Click here for download solr-6.6.2.
·       copy / paste solr-6.6.2.zip to F:\Sitecore9_Repository and unzip it.
·       Open Command prompt as administrator and navigate to bin folder of solr like “F:\Sitecore9_Repository\solr-6.6.2\bin “ and run ‘solr start’ as below:


·       After solr start you need to validate by open browser and navigate to http://localhost:8983/solr/#/
·       That show you running solr instance and showing you dashboard of solr.
5.       For make solr-6.6.2 run as window service instead of manually start all the time need to follow below steps:
·       Click here for download NSSM
·       copy / paste nssm-2.24.zip to F:\Sitecore9_Repository and unzip it
·       Open Command prompt as administrator and navigate to win64  folder of NSSM and run ‘nssm install solr-6.6.2’ command as below and fill the arguments as below:
Application Path: F:\Sitecore9_Repository\solr-6.6.2\bin\solr.cmd
Startup directory: F:\Sitecore9_Repository\solr-6.6.2\bin
Arguments: start –f –p 8983


·       Once you click on Install service a success message come “Service ‘Service Name’ installed Successfully”, now navigate to window service and check with the name ‘solr-6.6.2’ service exist there or not. That service automatically started in case that is stop start it again.





6.       Currently solr working on HTTP , for run solr HTTPS we need to do below steps:
·       Download PowerShell script from here. For download Alt+Click. Paste this script into your Sitecore9_Repository folder.
     Original from here (Thanks kamsar for this contribution).
·       Open PowerShell with Administrator access or in admin mode.
·       Run this command for set unrestricted execution policy else wise you might face “running script is disabled on your system” error.
o   Set-ExecutionPolicy -Scope CurrentUser Unrestricted
·        Now navigate to Sitecore9_Repository folder and run above script as below:
       ./solrssl.ps1
·         After this script will ask to enter path for keytool  if your java sdk or jre not installed on default path.(~program files/java/jre/bin/keytool.exe)
·       Two certificates are generated in Sitecore9_Repository. Copy paste solr-ssl.keystore.jks and solr-ssl.keystore.p12 to F:\Sitecore9_Repository\solr-6.6.2\server\etc
·       open F:\Sitecore9_Repository\solr-6.6.2\bin\solr.in.cmd and add the lines below to it
o   set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
o   set SOLR_SSL_KEY_STORE_PASSWORD=secret
o   set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks
o   set SOLR_SSL_TRUST_STORE_PASSWORD=secret
·       Here above “secret” is password that is set by “solrssl.ps1” script that you can change by edit the script if you need other password.
·       Restart solr-6.6.2 window service.
·        Open a browser, navigate to https://localhost:8983/
·       Congratulation now your solr run on HTTPS instead of HTTP.

7.       SItecore Installation Framework (SIF)
Open PowerShell(Windows PowerShell ISE) as admin: Run these below commands
·        Register-PSRepository -Name SitecoreGallery -SourceLocationhttps://sitecore.myget.org/F/sc-powershell/api/v2
·        Install-Module SitecoreInstallFramework
·       Update-Module SitecoreInstallFramework

8.       Log into https://dev.sitecore.net/  and download the Sitecore XP Sigle package (Sitecore 9.0.0 rev. 171002 (WDP XP0 packages).zip).


o   copy / paste Sitecore 9.0.0 rev. 171002 (OnPrem)_single.scwdp.zip to F:\Sitecore9_Repository
o   copy / paste Sitecore 9.0.0 rev. 171002 (OnPrem)_xp0xconnect.scwdp.zip to F:\Sitecore9_Repository
o   unzip XP0 Configuration files rev.171002.zip and copy / paste all files to F:\Sitecore9_Repository\Config
In Sitecore configs open sitecore-solr.json and xconnect-solr.json and will check "SolrUrl, SolrRoot and SolrService” parameters.
9.       SIFLESS.EXE for easier Sitecore installation.
·       Download SIFLess.zip and extract to F:\Sitecore9_Repository\SIF
·       Run SIFLess.exe and navigate to EZ mode and fill the details as below:



·       Click on test once everything getting green checks, click on Generate button. That will generate a PowerShell Scripts like SIFXXXXX.PS1
·       Now will run generated final script to create sitecore 9 instance.
·        Open PowerShell as admin:
·        Goto to the path ~/Sitecore9_Repository/SIF/
·        ./SIFXXXXX.PS1
Congratulations once you run above script within some time Sitecore 9 will be installed.

If you run any kind of issue then please go through below blog that will cover some issue which you might face during installation:
     
I hope you enjoy this Sitecore blog. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)


Please leave your comments or share this article if it’s useful for you.

     




Friday, September 21, 2018

Computed fields in Coveo for Sitecore

Hi All,

Here below some references and sample code for understanding the computed fields in Coveo for Sitecore.

For get the computed field image
Location

Syntax for mvc:
//For get the image computed index value

{{ if (raw.@(Model.ToCoveoFieldName("imageurl"false))) { }}
                                                    
{{=image(raw.@(Model.ToCoveoFieldName("imageurl"false)), {alt : "Anything",style:"width: 100px;"})   }}
                                               
{{ } }}



//For get the field value
{{=raw.@(Model.ToCoveoFieldName("Sitecore Field"false))}


I hope you enjoy this Sitecore blog. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)


Please leave your comments or share this article if it’s useful for you.

Wednesday, May 16, 2018

Switch Sitecore Lucene Config to Solr the elegant way

When you need to switch your Sitecore instance from Lucene to Solr, you need to disable all Lucene config files and enable the Solr ones. 

Step-by-step guide

Insert your steps.
  1. Open up a powershell window
  2. Change directory to your instance's App_Config\Include 
  3. Execute the following commands:
    1. Disable Lucene Configs
      1
      Dir *.Lucene.*.config -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".config",".config.disabled")}
    2. Enable Solr Configs
      1
      2
      Dir *.Solr.*.disabled -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".disabled","")}
      Dir *.Solr.*.example -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".example","")}
Batch file for easy use: