Tuesday, December 30, 2014

Configuring Sitecore xDB using Rackspace's ObjectRocket platform

Standard
As all of us in the Sitecore community are aware, one of the major changes in Sitecore 7.5 and 8 is MongoDB, the new architectural component in Sitecore’s xDB.

If you are starting to work with these newer versions of Sitecore, you will be asked by your clients about the options to consider when deploying and supporting MongoDB.

We at Arke have had tremendous success implemented MongoDB using Rackspace’s ObjectRocket platform. There are however a few tricks to get it configured that I will cover in this post.

The post assumes that you already have an ObjectRocket account. If you don't, go ahead and sign up for their 30 day trial.

Creating a New Instance

Click on the "Add Instance" button within your account's "Instances" dashboard, and then give your instance a name. Make sure that "MongoDB" is selected as the engine, and select the plan that suits your needs.


Adding an Instance User

After your newly created instance is up and running, go ahead and create a new instance user by clicking on the "Actions" button and then "Add User" link.

Note

Something to keep in mind is that we will be using the same credentials that we set up for our instance user, for our Sitecore databases. So once you create the user, keep the username and password handy.



Making the Connection

Within the Instance Details view, you will see that you have a couple of connection strings and an API key. We obviously want to have a secure connection, so we will be using the SSL Connect String.


ConnectionStrings.config

The next thing you want to do is set up the connection strings to point to your new instance. So you want to crack open your ConnectionString.config file, and add the necessary information.

Your new strings will look something like this:

 <add name="analytics" connectionString="mongodb://mongouser:mongopassword@iad-mongos2.objectrocket.com:xxxx/analytics?ssl=true"/>  
 <add name="tracking.live" connectionString="mongodb://mongouser:mongopassword@iad-mongos2.objectrocket.com:xxxx/tracking_live?ssl=true"/>  
 <add name="tracking.history" connectionString="mongodb://mongouser:mongopassword@iad-mongos2.objectrocket.com:xxxx/tracking_history?ssl=true"/>  

Looking at the strings above, mongouser and mongopassword represent the credentials that you set up for your instance user. The port and url (iad-mongos2.objectrocket.com:xxxx) come from your instance's SSL Connect String.

Cranking up the Databases

At this point, we are ready to fire up Sitecore, and let it auto-provision the necessary MongoDB databases.

When Sitecore has finished "booting up", you will notice that the databases have been created in your instance, but they are empty. That's because you need to create a user account for each of the databases, so that Sitecore can start dumping data into them:


Creating Database Users

The final step is to add a user to each of the newly created databases that has the same credentials that we set up for our instance user in the Adding an Instance User step.

Simply click on the various database names on your instance details page, and then click the "Add User" button located in the user's section of the database details page.


Mongo Likey!

After you have added the users to each of the Mongo databases, you will notice that the collections will be created and that the data will start getting populated.


Troubleshooting

If your databases don't get created, or data doesn't start getting populated in them, make sure that you check your Sitecore logs as they will reveal any errors while trying to connect to the ObjectRocket instance.


Monday, December 22, 2014

Sitecore 8 - Taking the Leap

Standard
We made the decision to upgrade one of our current projects from Sitecore 7.5 to the newly released 8. As the architect, it was my job to make sure that all that we had built so far, transitioned smoothly over to the new version.

All of our code and serialized Sitecore items were safely within our Git Repository in the VisualStudio.com cloud.

These are the steps that I took in our upgrade process:
  1. Uninstalled Sitecore 7.5
  2. Deleted the leftover files in my 7.5 instance location in wwwroot
  3. Downloaded and installed 8.0 from dev.sitecore.net (it's not actually on SDN, which was interesting). I gave my 8.0  instance the same name as my 7.5, just to make things easier when syncing things back up using  Team Development for Sitecore (TDS).
  4. Downloaded and installed the modules that we are using. In this case, I downloaded and installed the Commerce Connect 7.5 module.
  5. Updated our Sitecore referenced assemblies to the new versions. We use a hosted NuGet server, so I created a new Sitecore 8 references package and then updated my packages.config files within my solution's projects.
  6. Pulled the updated Web.config into my solution and made sure that my config transformations were in place.
  7. Synced up my Sitecore instance using the TDS projects and did a build to my instance.
Everything seems to be working like a champ! I did notice that the new version took an abnormally long time to start up for the first time.

Experience / Page Editor Changes

So after getting one of my test pages loaded up within the Experience Editor, I noticed that my inline editing didn't seem to be working when I clicked the Edit button.

While exploring the newly designed ribbon, I noticed an "Editing" checkbox in the "View" tab that is turned off by default.  Checking this box, made my experience editor come to life, and I was a happy camper!







Saturday, December 20, 2014

Working with Commerce Connect - Getting Started

Standard

Introduction

We recently started work on a Sitecore 7.5 commerce solution for a large client of ours where we would implement the shiny, new Commerce Connect 7.5 (Connect) module. 

As a good architect / developer, I consulted with the powers of Google but couldn’t really find a whole lot of good information out there about how to get started. So, this blog series will report what I learned when implementing the module. In this article, I’ll explore the setup process and how to perform a simple test to make sure I can add and retrieve products from the product repository.

It’s not free

It is important to note that unlike its predecessors Sitecore E-Commerce Fundamentals Edition (SEFE) and Sitecore E-Commerce Services (SES), Connect is not free. I am not sure of the actual pricing; you would need to contact a Sitecore sales representative to get the details.

Installation

After downloading Connect 7.5, I went ahead and installed it on my local 7.5 development instance.

Next, I went ahead and set up my product repository and index. I followed Sitecore’s Installation
Guide to get my repository up and running: http://sdn.sitecore.net/upload/sdn5/products/sitecore%20commerce%20connect/7.5/sitecore_connect_75_installation_guide_usletter.pdf  
  

The 3 major steps include:

  1. Creating a repository using the Templates/Branches/CommerceConnect/Products/Product Repository branch. I set mine up at the following path:
    /sitecore/content/Data/Product Repository/Products

  2. Updating the search Source for the Manufacturer and ProductType fields of the Product template

  3. Modifying the necessary settings in the config files to let the module know where my new  repository is located in the content tree. Files and locations to update include:    
     
    Sitecore.Commerce.Products.config



    Sitecore.Commerce.Products.Lucene.Index.Master.config AND Sitecore.Commerce.Products.Lucene.Index.Web.configs


      With that behind me, I needed to go ahead and sync my product repository bucket before using it for the first time:



Pulling out a product

Ok, so according to the documentation, I should be ready to roll and can start throwing products into my repository where I can access them using the Sitecore search API.

In the final solution, I want to pull a product out of the repo by product name, because I intend to have a MVC route that will have the product name hanging off the end. Something like this: running/mens/running-shoes/support/wave-inspire-11

With that being said, let me write some code and give it a test.

POCO

The first thing that I need to do is create a POCO that is consumable by the LINQ layer within Sitecore. I have to make sure that I inherit from SearchResultItem:

 public class ProductSearchResultItem : SearchResultItem  
   {  
     public string BrandName { get; set; }  
     public string ExternalID { get; set; }  
     public string Divisions { get; set; }  
     public string FullDescription { get; set; }  
     public string Identification { get; set; }  
     public string Manufacturer { get; set; }  
     public string ModelName { get; set; }  
     public string Product_Name { get; set; }  
     public string ProductClasses { get; set; }  
     public string ProductType { get; set; }  
     public string Short_Description { get; set; }  
   }  

GetProduct Method

Next, I want a method that will take a product name as a parameter, and return the actual Sitecore item from my repository. In my case, I am using Glass Mapper as my ORM of choice. If you are still writing your classes by hand, or are using Custom Item Generator to generate your template based classes, I highly recommend that you look into using Glass.


 public Product GetProduct(string productName)  
     {  
       var index = Settings.Indexes.GetIndex("products");  
       using (var context = index.CreateSearchContext())  
       {  
         IQueryable<ProductSearchResultItem> query = context.GetQueryable<ProductSearchResultItem>()  
           .Where(  
             resultItem =>  
               resultItem.TemplateId == IProductConstants.TemplateId &&  
               resultItem.Product_Name.Equals(productName, StringComparison.InvariantCultureIgnoreCase) &&  
               resultItem.Name != "__Standard Values");  
         SearchResults<ProductSearchResultItem> results = query.GetResults();  
         var queryResults = results.Hits.Select(hit => hit.Document.GetItem());  
         return queryResults.Any() ? queryResults.FirstOrDefault().GlassCast<Product>() : null;  
       }  
     }  


This is what my code looks like that will actually implement the method (some ugly hard-coded values, but remember that this is simply a test):

 var myProduct = new ProductManager().GetProduct("Test Product");  

Creating a Test Product

For the final piece of the puzzle, I need to add a test product to my repository.


Run it!

In my test, I slapped together a quick controller rendering as we are using MVC for the project. If you are using Web Forms, you would simply throw this onto a Layout or Sublayout.

The breakpoint below the line where I called my method confirmed that I am cooking with grease!


In Summary

I was successfully able to:

  1. Install and configure Commerce Connect.
  2. Add a product to the product repository.
  3. Write some code to pull the product out of the repository by product name using the Sitecore.ContentSearch API.
In my next post, I will be showing how to work the Commerce Connect cart, so watch this space.

Happy Coding!