Sitecore 7 Tips and Tricks
— September 13, 2016Sitecore 7 is finally out to the public and we have already seen an influx of people downloading, testing and evaluating the software. A couple of people have even upgraded their site to Sitecore 7 already! We can see that people are very eager to move to Sitecore 7 straight away.
To make things go as smoothly as possible for you on migrating sites or even testing out the base install, we thought we would offer some tips and tricks, common pitfalls and hints to get up to speed as quick as possible. For the official upgrade path you can get this off the SDN.
This blog is not to show you how to upgrade previous sitecore development versions of Sitecore to Sitecore 7 (comment below if you would like this to be aGoogle Hangout topic) but rather once you have upgraded and want to start playing with things that you can use this post to solve the most common issues. Sitecore 7 is also about performance and scalability so let’s start off with some tips and tricks.
Tips
- Store your query time data in the index so that we don’t have to go to the database to fetch data.
- Avoid looking up
Item
orFields
from the database. Store things you need in the index and only fall back toGetItem()
orGetField()
orGetFields()
when needed e.g. if you would like Page Editor support in the RTP of Sitecore 7.IIndexable
is a generic interface used to work with data that is not Sitecore specific. If you want something Sitecore specific thenSitecoreIndexableItem
isIIndexable
.- Try out your LINQ queries in the LinqScratchPad or LINQPad for quick prototyping. That way you don’t have to reload your pages and wait to the application pool to start up to see your results.
- Become intimate with the
Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config
file if you are using Lucene as your provider andSitecore.ContentSearch.Solr.Indexes.config
if you are using SOLR.- Run a differential of files with a tool like Beyond Compare and run it against Sitecore 6.6 to see the new files. Spend some time studying the new configuration files as they are the entry point to everything working and all the extension points.
- Make it part of your weekly build process to performance test your solution. Sitecore 7 is a powerful tool but used in the wrong way could impact performance. If you are not paging your data then this can easily bring back all the results in memory.
- Use the following prototype as a guide to set-up a good Unit Testing environment with Sitecore 7.
- Use vinegar to get stubborn stains out of white clothes.
- Study this demo site before starting a Sitecore 7 project
- The default configuration in Sitecore 7 is built to be performant on 1 Million Items. Change these settings in configuration according to the amount of content you have.
Common Pitfalls
- When you create POCO’s you must have a get; set; on the properties for us to map the values. If these are also internal, private or protected then we cannot do this. Make your properties public.
- You are executing the LINQ queries outside the scope of an open context. We already have 2 blog posts written on this, so check them out first. Essentially, when you want to run a LINQ query you have to run it in an open context to the index. Due to the nature of LINQ, if you close the context before you have executed the LINQ query then this is not allowed. There are many methods you can utilise to share an open context. Post 1 and Post 2.
- Stored and Indexed content.
- We use
TypeConvertors
to cast a value in the index back to a property. We also useTypeConvertors
to prepare values to go into the index as well. If you are finding that you queries are not returning the right results you could be using the wrong type.- You have the wrong TOKENIZED or UNTOKENIZED flag on fields.
- You are using the wrong
Analyzer
for your fields or language.- When making config changes you may need to rebuild the entire index so that all content items can re-evaluate your changes.
- Don’t be tempted to go and make everything an Item Bucket now. There is a time and a place for those.
- If you are storing a lot of media in the media library then this can significantly slow down the indexing process as by default, if you have the
IFilter
installed on your machine, we will try and index the internal content of the media.- You do not have IFilters installed on your machine.
- Sitecore 7 does not support all of the
IQueryable
interface. In fact if you read most blogs on LINQ and implementing theIQueryable
layer, you will find the experts talk about the expectation that you should not expect all providers to be able to implement all parts of theIQueryable
interface. This could be due to limitations of the provider or just that it does not make sense for that provider to implement that feature. Examples of this in Sitecore 7 RTP is Join, Union and a few more. For the full list of supportedIQueryable
members please refer to our documentation.
If you are sitecore development partner or you manage to find a few more that you think people would benefit from then comment below and we can add them to the list.
Source: Sitecore.net