Try our conversational search powered by Generative AI!

Quan Mai
Jul 23, 2020
  1513
(4 votes)

New ReferenceConverter method in Commerce 13.21

As you might have heard - ReferenceConverter is your friend. It is very lightweight way to map between the ContentReference and code of catalog content, instead of having to load the content - which is both slow and expensive. Whenever you have chance, ReferenceConverter should be used.

But it is now even better. In Commerce 13.21, ReferenceConverter has a new method to get multiple codes at once. It looks like this

public virtual IDictionary<ContentReference, string> GetCodes(IEnumerable<ContentReference> contentLinks, CatalogContentType catalogContentType)

A common scenario for this new method is when you need to get all variants of a product (by using IRelationRepository), then get all prices or inventories for those variants. Instead of

var allVariantCodes = allVariantLinks.Select(x => _referenceConverter.GetCode(x));

You can now call

var allVariantCodes = _referenceConverter.GetCodes(allVariantLinks, CatalogContentType.CatalogEntry).Values;

The former can result in multiple database roundtrips - depending on how many variants you have. The latter always results in at most 1 database roundtrip. As we all know each roundtrip adds overhead, so there will be a performance improvement.

Jul 23, 2020

Comments

Stefan Holm Olsen
Stefan Holm Olsen Jul 23, 2020 10:43 AM

This is great news, Quan.

I have been wishing for this for some time.

Aria Zanganeh
Aria Zanganeh Jul 30, 2020 12:31 AM

woohoo .. now my schedule jobs that import catalog can run faster!

Mari Jørgensen
Mari Jørgensen Aug 4, 2020 11:05 AM

Great! Keep em coming! ;)

Stefan Holm Olsen
Stefan Holm Olsen Aug 15, 2020 05:03 PM

@Quan Mai: I have a similar optimization wish for batch loading CMS content without first loading core data.

I once raised this thread related to ContentAreaItem batch loading, which resulted in many roundtrips even when I called IContentLoader.GetItems on the content area items.

Do you know whether the CMS team has something planned for this?

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024