- Published on, Time to read
- 🕒 1 min read
Optimizely / Episerver: How to get content from the product/variant code (e.g. SKU number)
How to get content from the code
In Optimizely, in order to get a reference from a product/variant code (that is a string), you may use the ReferenceConverter
class:
string code = "SKU123";
var reference = _referenceConverter.GetContentLink(code);
Note:
ReferenceConverter
is a class with no interface.- Always check if Content Reference is not null (
ContentReference.IsNullOrEmpty
). - Results are internally cached.
Behind the scenes
Basically, the ReferenceConverter runs the stored procedure that make a simple lookup in the database. Internally, it calls the CatalogIdentityResolver.GetIds
method which might call one of the following stored procedures:
ecf_GetCatalogEntryIdsByCodes
ecf_GetCatalogNodeIdsByCodes