Passing Params to the ServicesConfigurator for DI in Sitecore

We are using the IServicesConfigurator interface to configure our services from code and registering it in the <services> section in the Sitecore config. However I had a situation where I wanted to pass some configuration values (to do with a custom cache) to the ServicesConfigurator in order to do something different. This was my ServicesConfigurator class before I made any changes: public class MvcControllerServicesConfigurator : IServicesConfigurator { public void Configure(IServiceCollection serviceCollection) { serviceCollection.AddMvcControllers(“*.Feature.*”); serviceCollection.AddClassesWithServiceAttribute(“*.Feature.*”); serviceCollection.AddClassesWithServiceAttribute(“*.Foundation.*”); //get my param values here } } This was the config for the pipeline:         Normally in Sitecore pipelines we can just set Params in the config of the Pipeline (e.g <useMyCustomCache>true</useMyCustomCache>) and grab them within the pipeline class like so: public class MvcControllerServicesConfigurator : IServicesConfigurator { public string UseMyCustomCache { get; private set; } public void Configure(IServiceCollection serviceCollection) { … if(bool.Parse(UseMyCustomCache)){ //do something here } …  However the this doesn’t work and causes an error like … Continue reading Passing Params to the ServicesConfigurator for DI in Sitecore

Sitecore Technology MPV Award 2023

This week I was privileged to be presented with the Sitecore Technology MVP award for the 6th year in a Row . There are only 241 MVPs Worldwide and just 8 Technology MVPs in the UK (137 Worldwide), all of which have been awarded for: “demonstrating outstanding engagement and support for the global Sitecore community”. It’s a great Community to be involved in and I’ve enjoyed organising and presenting at the Manchester Sitecore User Group over the past year, meeting other Sitecorian’s and sharing my knowledge on this Blog, YouTube, Twitter, SSE and Slack. You can see all the 2023 MVPs in the Directory here: https://mvp.sitecore.com/Directory Why become an MVP? There are many benefits to being an MVP, here are some of them: Being viewed as a global Sitecore expert & community leader Access to early product release / resources / product teams and kick-off webinars Access to MVP discussion forums Regional … Continue reading Sitecore Technology MPV Award 2023

Using ChatGPT to write SPE

Catchy title huh? it Rhymes and everything. Anyway, my Twitter timeline has been non stop about ChatGPT this, and ChatGPT that for the past few weeks – and I’ve seen it doing some pretty cool stuff. I also keep hearing how it’s going to make Software Developers redundant, so it got me thinking about something I do every few days as a Sitecore Developer: “Can ChatGPT write some decent Sitecore PowerShell Extensions scripts?” TLDR: Yes it can. Not terrible anyway. Read on to find out more. Wait, what is ChatGPT? Chances are that you already know what it is else you probably wouldn’t be reading this, but just in case – ChatGPT is an impressive AI Chatbot created by OpenAI (backed by Microsoft & others) that can take inputs and provide some very comprehensive and usually pretty accurate answers. The Tests – How did ChatGPT do? So I fired up my browser, created … Continue reading Using ChatGPT to write SPE

XM Cloud Demystified

I had heard a lot about XM Cloud over the past year or so at SUGCON and from Symposium as well as from the Sitecore Community, however I realised I didn’t really know that much about it still and wasn’t clear on what was included. Given that XM Cloud was officially released for general availability at Symposium it was about time I learned about if properly and answered some of the questions I had. So I dived into the XM Cloud documentation and watched a lot of Videos and setup the local XM Cloud instance to learn more about it. I then decided I’d try and speak at the next Sitecore user group in Manchester on XM Cloud to share what I learned. Nothing like a deadline to force you to learn about something properly huh? :-). You can see the Slides and Video of my presentation ‘XM Cloud Demystified’ below. Update: … Continue reading XM Cloud Demystified

Adding Items to a Custom Sitecore Seach Index using SiteCron

Over the years working with Sitecore I’ve had to create custom indexes and add items to them for most clients I’ve worked for. I’ve generally written a Search Crawler and Search Indexer to handle this but it’s always seemed like a lot of code to manage just to add a few items to an index and temperamental to control the indexing frequency accurately. I’ve also had many issues with Indexes being out of Sync in the past due to Sitecore Events not firing on CD instances etc. I’ve tried various approaches to simplifying this in the past but unfortunately never got this working. However this came up again on a recent project and I was successful this time – so decided I’d share my approach and code. Note in this example I’m using Solr but in Theory this same code should work with Azure Search also. In simple terms the approach … Continue reading Adding Items to a Custom Sitecore Seach Index using SiteCron

Fixing Solr Azure App Service Core Locking Issues

We have had intermittent issues with our Sitecore Solr instance in Production which runs in an Azure App Service. Every so often it crashes and we see Core Initialisation errors like so: sitecore_web_index: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Index dir ‘D:\home\site\wwwroot\server\solr\sitecore_web_index\data\index/’ of core ‘sitecore_web_index’ is already locked. The most likely cause is another Solr server (or another solr core in this server) also configured to use this directory; other possible causes may be specific to lockType: native Doing some research into this it seems that the consensus is that Azure App Services shouldn’t really be used for Solr:  https://sitecore.stackexchange.com/questions/23466/solr-cores-locking-v-9-0-2 However I couldn’t actually find any official Sitecore documentation that says that Azure App Services are not supported / recommended for Solr and there are plenty of blog posts out there about setting up Solr for Sitecore in Azure App Services. We could have switched it to an VM but we’d rather not do that as it’s easier to manage … Continue reading Fixing Solr Azure App Service Core Locking Issues

Creating Preview / Draft Sites in SXA using SPE

A few weeks ago I was tasked with providing the ability for content editors to be able to have a preview (or draft) site for SXA sites when using the CM Url. The requirement was to be able to view ‘Draft’ content/versions of pages (without publishing them) for stakeholders to be able to preview them before they are published to the CD instance. In an Traditional Sitecore setup this is pretty easy, you would just edit the site definition config in the Sitecore config with a patch file to change the database used to Master when on the CM. For SXA this is a bit trickier as the Site definitions are dynamically built by SXAs site manager when Sitecore starts up (or the SXA Site Manager is ran again in Sitecore). However after reading around it seems it was possible to achieve what I needed to do. I had to … Continue reading Creating Preview / Draft Sites in SXA using SPE

Removing Unneeded Sitecore Versions with SPE

It’s been a while since I had to look how best to manage Sitecore versions, but after seeing some performance issues related to lots of versions for some items on the CM this week It was time to revisit removing unneeded Sitecore versions. Research Amusingly my search turned up an SSE post with an answer from myself from about 5 years ago: https://sitecore.stackexchange.com/questions/507/limiting-version-numbers-copying-old-versions-to-archive-for-easy-access/525 Further Googling shows not much seems to have changed in that time. Some modules are however no longer supported or are compatible with Sitecore 9. I did find some links that gave me a few ideas though. Our requirements were to find any items with more than 10 versions and then remove any versions other than the most recent ten unless an version is the currently published version or the version has been updated on the past 3 months. The idea behind this is that we wanted to remove … Continue reading Removing Unneeded Sitecore Versions with SPE

SUGCON 2022 Thoughts and Takeaways

It’s been 3 years Since the last ‘In-Person’ SUGCON in London 2019, so I was really looking forward to going to Budapest to learn some new Sitecore things and catch up with Sitecore Developers and friends from across the world. I’ve been to Budapest for a weekend once before and It’s a beautiful city. After a long flight with a change at Amsterdam I arrived at the Conference centre in Budapest pretty late but immediately bumped into a bunch of people I know from the Sitecore Community. After a drink in the bar it was time to hit the sack ready for the first day of SUGCON. Day 1. Steve Tzikakis – Opening Keynote There was a notable excitement in the room as Tamas opened up SUGCON to much applause welcomed everyone and introduced Steve Tzikakis to the stage. Steve seemed genuinely happy to be at SUGCON and have the opportunity to … Continue reading SUGCON 2022 Thoughts and Takeaways

Removing Unneeded Tags from RTE fields with Sitecore PowerShell Extensions

This week I had an issue where some items imported from another system into Sitecore had invalid HTML in some of their RTE fields. These tags were breaking the SXA page content component that was being used. I needed to a quick way to remove these tags without having to re-import the content. As usual SPE came to the rescue again and I was able to correct 100s of items in seconds. The script has a function which takes an item and field name as a parameter: Strip-InvalidTags -item $item -fieldName “Details” I’m getting a number of profile items and calling this function in a loop. The function uses HTMLAgilityPack to look for ‘Script’ tag nodes (but can easily be modified to pick up different tags or multiple tags). If the script finds the tags is strips them and then saves the modified html back to the field. Here is the … Continue reading Removing Unneeded Tags from RTE fields with Sitecore PowerShell Extensions