Wednesday, November 25, 2015

Sitecore set the default domain for the login page

By default, the Sitecore login page will automatically use the Sitecore domain. Which works well for accounts such as sitecore\admin as you only need to enter admin to login. However if you are integrated with active directory, you may want to default the domain to the active directory one.

Code first Entity Framework composite key which contains a foreign key

I came across the need for a composite key in a code first Entity Framework database for a raffles system. The first table was the raffle setup and would contain an auto generated numeric raffle id and the raffle ticket table would have a relation back to the raffle table (foreign key which was the raffle id).

Monday, November 23, 2015

Syncing uCommerce data between Sitecore environments using Visual Studio

Because uCommerce data is actually stored directly in the database, syncing that shop data (products and even orders) is not as simple as using a Sitecore package or Team Development for Sitecore. The best method is to sync the actual database tables, of which there a number of tools available both paid and free.

I have found success using SQL Server Data Tools in Visual Studio. A download is available online, however there may be licensing considerations based on which version of visual studio you are using.

Working with the uCommerce API in Sitecore

uCommerce is a very powerful e-commerce module available for both Sitecore and Umbraco. The API that comes out of the box is equally powerful and have methods which make it possible to import a full product catalog from the third party system. This post will provide example calls into the uCommerce API, which should be everything needed to import data for a full catalog. Many of the methods assume one product catalog (which is a static variable).

Wednesday, November 18, 2015

Granting access to uCommerce to users in Sitecore

In a default installation, only administrators will have access to uCommerce in Sitecore. There is some setup that will need to be completed to give relevant users access to use/administer the system. This will be achieved by using custom sitecore group(s), and as with any group you can be granular with the access rights (for example one group may only be able to edit products whilst another has full access to purchase orders etc.).

In this example, one group will have access to all features of uCommerce.

Tuesday, November 17, 2015

Schedule code to run using Agents in Sitecore

In Sitecore the concept of an agent is simply a scheduled task that is managed by Sitecore, which will call a given method on a class. By default Sitecore will already have several agents defined in the web.config file, one example is an agent scheduled every 4 hours to clean up the publishing queue.

A specific example where I have used agents, was to schedule a custom class which synced data into Sitecore from a third party system.

Tuesday, November 10, 2015

Sitecore custom properties on a user profile

In Sitecore, by default there are a number of fields which are set on a user profile. These include such details as: full name, email address, password, comment, etc. It can be a requirement with a specific Sitecore implementation to store a number of custom fields against each user profile, perhaps mailing address details for example.

Instead of using custom SQL databases or Sitecore items, you can actually create a Sitecore template and have that appear on the user profile (as custom properties). To achieve this, you will need to complete the following steps:

Monday, November 9, 2015

Login, logout and registering accounts in Sitecore

The security model in Sitecore is abstracted from the default .NET providers of membership, profiles and roles. This means that it's actually possible to achieve the same functionality (login for example) using the default .NET methods rather than one from the Sitecore API.

A user in Sitecore will always follow the domain\username format, and all references to a username, need to include the relevant domain. That user will come out of the box with a default profile which includes such information as full name or email address, however it is possible to extent the profile with custom properties (using Sitecore's template system).

Friday, November 6, 2015

Indexing a computed field with Sitecore and Lucene

Out of the box it can be easy to configure simple Sitecore Lucene Search Indexes, that is using the standard data types for the fields you want indexed. However when it comes to more complex and even custom types you may need to setup a computed field to be indexed.

Take for example an image field, perhaps each page on your Sitecore web site has a primary image/thumbnail that you would like to expose in the results of your search engine. You could get the full item for each search result to get access to this field. However to save that call and have better performance it is possible to index the image url (and even a version of it with maximum width/height using Sitecore's media library). It is also worth noting that each field added to an index will cause that index to grow (which leads to more serve resources to generate, update and store the index itself). 

Wednesday, November 4, 2015

Sitecore package manager error

The following Sitecore error was occurring in the package designer and package installation wizard:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
This was due to a missing DLL: Mvp.Xml.dll

Monday, November 2, 2015

Configuring Sitecore Lucene Search Indexes


Search indexes are maintained by Sitecore scanning items stored in the database. Whenever an item is created, updated or deleted, a job is run in Sitecore which updates the search index(s). In the example of item creation, the item would be added to the index immediately after it is created.

The search index is a physical file (effectively a searchable database) which is maintained by the crawler and allows for searching of itself - which links to the actual Sitecore items. These index(s) are stored in the data folder for Sitecore, and can actually be viewed (and even queried) via a third party tool such as Luke 3.5.