Category Archives: Sitecore Marketplace Modules

Information on Sitecore Marketplace modules that I have built or recommend.

Sitecore Developer Toolbox Chunk

Sitecore Developer Toolbox Module for Sitecore 7.2+

Have you ever tried to remember what the URL is to the Show Config or the Cache page in your Sitecore instance when using the Administration Tools?

Did you know that there is a Database Browser that the old-schoolers use to Brute Force work they need to get done with Sitecore OR an XPath building tool you can lean on to help you with Sitecore queries?

If you don’t know what I am speaking of, I am eluding to some old-school tools that can be very useful for every day administration and development. For example, the Administration tools page with links to all kinds of tools from the backend, XPath Builder to help you write and validate queries/fast queries, and File Explorer to help you view Website folders/files on the Sitecore instance you have the Sitecore Developer Toolbox (SDT) installed on. When you install the Sitecore Developer Toolbox, you get quick access to these tools via the Developer tab in the Content Editor.

Here is a look at what the module will add to your Content Editor Contextual Ribbon:

Sitecore Developer Toolbox Chunk

Sitecore Developer Toolbox – Chunk

Administration Tools:

Sitecore Developer Toolbox Admin Tools

Sitecore Developer Toolbox – Admin Tools

XPath Builder:

Sitecore Developer Toolbox XPath Builder

Sitecore Developer Toolbox – XPath Builder

File Explorer:

Sitecore Developer Toolbox File Explorer

Sitecore Developer Toolbox – File Explorer

Here is the link to the module on the Sitecore Marketplace: https://marketplace.sitecore.net/en/Modules/S/Sitecore_Developer_Toolbox.aspx

If you like the module please recommend to the community, provide a rating, and/or review. Thanks and happy coding!

Lucene Spatial Search Support Module

Lucene Spatial Search Support Module with Sitecore 8.1

I came across a need to implement a search based on zip code, latitude, longitude, and a radius. I quickly found out that this is a tall order in a short amount of time if implementing this type of functionality from scratch. However, the Lucene Spatial Search Support module came to the rescue…or did it? I am implementing a Sitecore 8.1 instance and it looks like the module was only good through 7.5 at the time of this post. There is an option to use SOLR Spatial Search Support module, and that IS updated through 8.1, but I didn’t have a driving need for SOLR on this project since my records being indexed were low in nature. So what is a Sitecore developer to do? Luckily, the Lucene Spatial Search Support module source code was available on GitHub, so I set out to get this module upgraded to 8.1. Time to get our hands dirty!

After cloning the repository from GitHub, I tried to build the project and there were many references missing, so I quickly grabbed a vanilla instance of Sitecore 8.1 rev. 160302 and added the references I needed to build the project. They are below:

Added to Sitecore.ContentSearch.Spatial project:

  • Sitecore.ContentSearch.dll
  • Sitecore.ContentSearch.Linq.dll
  • Sitecore.ContentSearch.Linq.Lucene.dll
  • Sitecore.ContentSearch.LuceneProvider.dll
  • Sitecore.Kernel.dll
  • Sitecore.Logging.dll

Added to Sitecore.ContentSearch.Spatial.DataTypes project:

  • Sitecore.ContentSearch.dll
  • Sitecore.Kernel.dll

I then had a build issue in this constructor in the LuceneSearchWithSpatialContext.cs:

protected LuceneSearchWithSpatialContext(ILuceneProviderIndex index, CreateSearcherOption options = CreateSearcherOption.Writeable, SearchSecurityOptions securityOptions = SearchSecurityOptions.EnableSecurityCheck)
: base(index, options, securityOptions)
{
Assert.ArgumentNotNull(index, "index");
this.index = index;
this.settings = this.index.Locator.GetInstance();
}

The Sitecore community never fails, and I found this on the Sitecore Stack Exchange where another developer simply commented out this constructor. I did the same and rebuilt the project but was missing a reference to a Sitecore.Abstractions.dll:

Sitecore.Abstractions Reference Missing

Sitecore.Abstractions Reference Missing

After adding in the Sitecore.Abstractions.dll to the Sitecore.ContentSearch.Spatial project, my project was successfully building. So I added this to the list of project references in addition to what was listed above:

Added to Sitecore.ContentSearch.Spatial project:

  • Sitecore.Abstractions.dll

Now it was time to make sure that the Sitecore.ContentSearch.Spatial.config was configured properly for 8.1. To my joy, it looks like there is a .config setup for version 8 that is disabled when I pulled from GitHub. I disabled Sitecore.ContentSearch.Spatial.config and enabled Sitecore.ContentSearch.Spatial.v8.config. Next, I added in my template criteria for my locations with the Template ID, LatitudeField, and LongitudeFields and then modified the index to use “sitecore_master_index” since I am testing this out locally and in live mode.

I added in the following .dll’s and .config file to the project I am working on that needs the spatial search feature:

  • Lucene.Net.Contrib.Spatial.dll
  • Sitecore.ContentSearch.Spatial.DataTypes.dll
  • Sitecore.ContentSearch.Spatial.dll
  • Spatial4nCore.dll
  • Sitecore.ContentSearch.Spatial.v8.config

After publishing my files and testing out, I got an error that said, “Current Index is not configured to use Spatial Search.

After some research, I realized that my index was set to use the wrong index earlier in code. Not only that, but one that wasn’t setup properly to for spatial search at all. After pointing to the correct index, publishing from Visual Studio, and then rebuilding my “sitecore_master_index” I was getting results back.

As I stated earlier, you can also perform spatial search with SOLR. If you have a client that has this type of environment (which is most right!?), I would take a hard look at SOLR for your client’s search provider.

You must use Solr if you have a scaled environment. This means you have:

  • two or more content delivery servers
  • two or more content authoring severs
  • separate servers for email, processing, reporting and publishing

Solr supports calls over HTTP(S) which means that the indexes are available to all servers in the environment that require it (content management and processing servers).

Big shout out to Ahmed Okour for the help that he provided for questions I had during the process. Happy coding!

TDS Code Generation Best Practice for Images and Links Using Glass.Mapper

Just a few weeks ago, I ran into an issue with TDS where all the “Image” fields in my solution were not generated correctly by TDS during code generation. Hence, I had hundreds of “Image” fields that had no reference.

If you are not familiar with using TDS for code generation with Glass.Mapper, I would highly recommend you take a look here, as it truly is a phenomenal tool for rapid development by generating models from Sitecore items:

http://www.glass.lu/Mapper/Sc/Tutorials/Tutorial24

I was stumped as to why this might have happened. After taking a look around my Sitecore instance, and getting some tips from the Sitecore Community on Slack in room “TDS”, I was able to find out what the problem was. I had an “ImageBase” base template that was originally setup on a template. However, I inadvertently created another Image field on the template itself with the same field title. Hence, when it came time to code generate, TDS threw up an error, but then couldn’t come back from the code generation “Image” fields issue. Basically, I had hundreds of mis-referenced “Image” fields in my code generated models file.

After speaking with Kamruz Jaman, he gave me a pointer to possibly just explicitly reference the Image object. Great Idea right!? So my solution to this issue was by going into my glassv3item.tt file and searching for Image. Once I found it, I changed it from:

case "image":
    return "Image";
 
case "general link":
case "general link with search":
    return "Link";

to

case "image":
    return "Glass.Mapper.Sc.Fields.Image";

case "general link":
case "general link with search":
    return "Glass.Mapper.Sc.Fields.Link";

I did this for both the Image and Link so if me or my development team ever ran into this issue of double creating a field with the same name, working with bases and the template item, that TDS code generation would not break on the referencing of Image and Link fields. Hence, I consider it a best practice to explicitly reference those fields just for safe measure in all your projects with TDS & Glass.Mapper code generation. Happy coding!

10 Steps to Setup MongoDB as a Windows Service with Sitecore 7.5+

If you are doing development work with SItecore 7.5+ and beyond, you may want to set up MongoDB to connect to Sitecore locally or on your DEV, QA, STAGING servers. This is just a brief tutorial on the steps needed to set up MongoDB on your as a service, and then validate that it is connected to your local SItecore instance via RoboMongo. This post relates to Sitecore versions 7.5 and up.

  1. Download the MongoDB installer here: MongoDB
  2. Install using the Custom installation so you can change the default location. Typically, I put all my projects and websites on a separate non-operating system drive such as a D: drive. I installed to D:/MongoDB/.
  3. In the folder “MongoDB” create a folder called “data” and inside that folder, create a folder called “db”. These will not be created for you during install so you will need to create them.
  4. Create a new .config file in the “MongoDB” folder and name it “mongo.config”. This is where we will store the configurations for MongoDB.
  5. Copy/paste the configuration into the new “mongo.config” file and modify to your specific workstation:
    dbpath=D:\MongoDB\data\db
    logpath=D:\MongoDB\log\mongo.log
    smallfiles=true
  6. Next, look in the “MongoDB” folder. You may need to create the “log” folder and put a “mongo.log” file in the that folder for the next line to succeed if it was not created during the installation of MongoDB.Now, install MongoDB as a Windows Service, so it will start every time you start-up Windows and stay running. Open up a Command Prompt (Run As Administrator) and type in the following (modify if needed for your filepaths):
    D:\MongoDB\bin\Mongod.exe --config D:\MongoDB\mongo.config --install
  7. This will create a new windows service called MongoDB. Now, to start the service simply type in the following:
    net start MongoDB
  8. You can use GUI tools like RoboMongo to work with Mongo data. Typically, Sitecore connections strings are already setup OOTB so you really just need to set up MongoDB. If you want to verify that your data is being stored then simply download RoboMongo. The example below is using MongoVUE, but I don’t recommend as it has been problematic in the past to download from their website. However, the process is basically the same for RoboMongo.
  9. Once installed you simply click the green plus icon to add a connection, then type in the name of the connection, and the server. Since, you this is on your local workstation you will use localhost OR 127.0.0.1 then save.

    Add Connection In MongoVUE

    Add Connection In MongoVUE

  10. Now you should be able to see your connection listed in MongoVUE, and if you expand the connection you will see your tables and data being captured from Sitecore.

    Sitecore Experience Data Is Connected

    Sitecore Experience Data Is Connected

During the making of this blog post, I referred to these blog posts below, which helped me to achieve setting up my local developer workstation to run MongoDB as a Windows Service and connect it to a Sitecore 7.5+ instance. One last thing, if you are using SIM (Sitecore Instance Manager), you can also perform all the above in one click. Happy coding!

Setting up MongoDB on Developer Machine:
https://briancaos.wordpress.com/2014/10/01/sitecore-and-xdb-setting-up-mongodb-on-your-developer-machine/

Install MongoDB on Windows:
http://www.mkyong.com/mongodb/how-to-install-mongodb-on-windows/

Upgrade strategy for Sitecore using RAZL

Tasked with performing an upgrade from Sitecore 6.5 to Sitecore 7.2 I was researching ways to 1) minimize the content freeze that my client would endure and 2) easily integrate the changes from the production databases into my locally upgraded databases (initially pulled down from production at the start of the upgrade process). I knew that RAZL from TDS could help with this but I had never used it before and an automated process of merging content changes especially between and upgraded database (7.2) and a legacy version (6.5) was suspect at best for the process to not work at all or fail.  After a bit of learning the product, I was amazed at how simple and easy the process was and I was able to merge the changes all the way through saving me a bunch of time.

Below are simple steps to performing a merge with the tool and some key points to make your life easy with RAZL:

  • Download the latest version and get a license at https://www.razl.net/download.aspx
  • When you open up RAZL you will need to setup 2 connections of which should be local on your machine.  So for me I had to initiate a content freeze with the client, setup another site in 6.5, pull down the backups of the production databases, and then configure my 6.5 Sitecore instance to now use these fresh databases. My first connection is my locally upgraded Sitecore instance (7.2) named Local.Master. My second connection is a vanilla Sitecore instance (6.5) named LocalProd.Master with the most updated content changes from production.
    RAZL Connections

    RAZL Connections

    Once the sites are configured in IIS and setup in RAZL you can then start the merging process.

  • Using this bit of documentation from TDS on RAZL for comparing items you can see what is same, different, deleted, and moved. Being that there are additional fields in one version and not in the other there will always be a difference even after the merge takes place. However, in 2 databases of the same version the double arrows should go away after you perform a merge.
  • When I started the process I was unable to merge anything and thought that the process would not work.  I kept getting an error message stating that the parent item was missing even if I clicked on the top-level sitecore item and tried to merge. This was because I was not going in the correct order for merging.  As a key point, the correct order is below for merging:
    1. Templates
    2. System
    3. Layout
    4. Media Library
    5. Content
  • Once I went in that order the error never appeared again.
  • Now, I wanted to not just merge one item at a time, I wanted to merge an item and it’s children to make it really easy.  This was not readily apparent as I thought that I would have to click on each item and merge…oh what a nightmare that would be!  However, when I right-clicked on an item, there was an option for “Get All From Right”, which I hovered over and then I clicked on Merge.  That was able to merge an entire parent and it’s children. Take this as a key point as well.

Upgrades are almost always a mundane and meticulous task for Sitecore developers. Finding a way to make things more simplistic and easy is the approach I like to take, and RAZL has helped me with this.  Hopefully, you can make use of this awesome tool for your Sitecore upgrades and day to day Sitecore duties as well.  A must have for your Sitecore toolbox.  Happy coding!

Excel Transfer Utility for Sitecore

During my tenure working with Sitecore I have had a few clients that wanted the ability to import data into Sitecore items from an Excel spreadsheet as well as export Sitecore item/s data to an excel spreadsheet.  I was unable to find a shared source module that would do this simple transfer easily so I ended up having to build a utility for every client.  I finally decided to build a Shared Source Module for this basic task, http://marketplace.sitecore.net/en/Modules/Excel_Transfer_Utility.aspx.  The Excel Transfer Utility is a simple module that will give you the ability to import data from an Excel spreadsheet that are converted into newly created Sitecore items in the content tree. Also, the export functionality will export the data from a Sitecore item (single item or all children items) data to a .csv file for use with an Excel spreadsheet. This post will detail out the utility and how to use it.

Import

The Import functionality is intended to be used given the following requirements:

  • Microsoft Excel 97-2003 files only (Newer Excel files must be converted to 97-2003 before uploading)
  • Headers are in the first row of the spreadsheet
  • Item name is the first column of the spreadsheet

In this example we are going to import a simple spreadsheet into a folder item called “Excel Transfer Folder” in the Sitecore content tree as seen below:

Import Folder

Import Folder with ID: {A91FD891-C477-45F5-B20A-7CFA7F8B53E5}

We will also need to know the template ID of the template we want to use for the imported items. Below is the template we will use:

Sample Template

Sample Template with ID: {D2775315-00DC-4CF4-8B68-E9748127D188}

Below is an example with a simple spreadsheet with 3 fields (Single Line Text Field, Checkbox Field, and MultiList Field) and data for those fields:

Sample Excel Spreadsheet

Spreadsheet with 3 fields and sample data.

Now that we have a spreadsheet with data ready to import we simply open up the Excel Transfer Utility from the Sitecore admin area using the Desktop view:

Excel Transfer Utility Shortcut

Excel Transfer Utility Shortcut in Applications

Once clicked on the application will open up in a new window:

Excel Transfer Utility Home

Excel Transfer Utility Home Screen

Click the Import button and you will see the following options. Choose your file and click the Upload button:

File Selection for Import

File Selection for Import

Once the file is uploaded the sheet names in the Excel spreadsheet will be in the DropDownList.  Select the sheet with the data to import. Next, enter the template ID to use for the imported items and click the Next button:

Sheet & Template Selection

Sheet & Template Selection

Now select the Header name to be used for the item names.  Then select the Template Item Fields that are to be mapped with each of the spreadsheet fields (picked up from the Header in the first column). Next, enter the parent item ID where all items in the spreadsheet will be imported to as children and click Import:

Mapping & Item Selections

Mapping & Item Selections

If the import was a success then you will see the success screen as seen below:

Import Success Message

Import Success Message

Now when we take a look at the “Excel Transfer Folder” in the Sitecore content tree we can see the imported items, in this case since there is only one one row of data, there is only one item that was created:

Imported Items

Imported Items

When we look in the item at the field data we can see the data was imported into the fields for the item:

Imported Item Field Data

Imported Item Field Data

Text is imported as text, values for checkboxes are either “true” or “false” in the spreadsheet not 0 or 1, and lastly multilist values in the spreadsheet must be a pipe separated list of GUID’s.  Please note: mapping data to incorrect fields will product unexpected results such as a text field to a checkbox field in a Sitecore item.

Export

In this example we will export the item created in the Import example to a .csv file for use with Microsoft Excel:

Imported Items

Item to Export

Again, we simply open up the Excel Transfer Utility from the Sitecore admin area using the Desktop view and click on the Export button this time. Now, we select multiple items because I want to select all the items in the Excel Transfer Folder, which is one, but if there were several items all of them would get exported:

Initial Export Selection

Initial Export Selection

Next, we either insert the item ID (if single item) or the parent item ID (if multiple items) and the children items of the parent will be exported:

Multiple Items Export

Multiple Items Export

Once we enter the ID we click on the Export button and the items are exported to a .csv file:

Export Success with File Path

Export Success with File Path

Copy the file path into Windows Explorer and the file should open up in Microsoft Excel as seen below:

Exported Items

Exported Items

If you have any questions or ideas on how to make to the tool better please comment.  Thanks and happy coding!