Mass update catalog entries

This is something you don’t do daily, but you will probably need one day, so it might come in handy.

Recently we got a question on how to update the code of all entries in the catalog. This is interesting, because even thought you don’t update the codes that often (if at all, as the code is the identity to identify the entries with external system, such as ERPs or PIMs), it raises a question on how to do mass update on catalog entries.

    • Update the code directly via database query. It is supposedly the fastest to do such thing. If you have been following my posts closely, you must be familiar with my note regarding how Episerver does not disclose the database schema. I list it here because it’s an option, but not the good one. It easily goes wrong (and cause catastrophes), you have to deal with versions and cache, and those can be hairy to get right. Direct data manipulation should be only used as the last resort when no other option is available.

Continue reading “Mass update catalog entries”

A curious case of SQL Server function

This time, we will talk about ecfVersion_ListFiltered, again.

This stored procedure was previously the subject of several blog posts regarding SQL Server performance optimizations. When I thought it is perfect (in term of performance), I learned something more.

Recently we received a performance report from a customer asking about an issue after upgrading from Commerce 10.4.2 to Commerce 10.8 (the last version before Commerce 11). The job “Publish Delayed Content Versions” starts to throw timeout exceptions.

This scheduled job calls to a ecfVersion_ListFiltered to load the content versions which are in status DelayedPublish, it looks like this when it reaches SQL Server:

declare @s [udttIdTable]
insert into @s values(6)
exec dbo.ecfVersion_ListFiltered @Statuses = @s, @StartIndex = 0, @MaxRows = 2147483646

This query is known to be slow. The reason is quite obvious – Status contains only 5 or 6 distinct values, so it’s not indexed. SQL Server will have to do a Clustered Index Scan, and if ecfVersion is big enough, it’s inevitably slow.

Continue reading “A curious case of SQL Server function”

Loading carts in a load balancing environment

UPDATE 1: Apparently HttpContext.Current.Request.AnonymousID already uses the cookie internally, so there might be something that makes it stop working. I’ll update when I found out.

Today we received a support ticket as customers seeing corrupted carts data being lost – line items with invalid data, duplicated line items etc. “Corrupted data” is one of the alarming words that we take very seriously, so I decided to jump on it right away.

The setup is a load balancing environment, and the problem only happens with anonymous users. However, it can be “fixed” by turning on the sticky sessions mode. So basically, instead of having sessions on the memory of a server (so sessions on server A can’t be seen by server B, and vice versa), they need a mechanism (can be a database) to share sessions between servers.

Continue reading “Loading carts in a load balancing environment”

Announcing a new book: Episerver Commerce: A problem – solution approach

More than one year ago, I announced that I was working on a book – a first Episerver Commerce book ever. It has been a work in progress until recently – and I am still adding updates here and there. The book has received quite positive feedback (I’m happy to say that everyone is nice enough to not tell me “Your book sucks”. Thanks, everyone). Am I happy with it? Yes, of course, proud even.

But to be completely honest,

I know something was missing.

Continue reading “Announcing a new book: Episerver Commerce: A problem – solution approach”

Why do games need more Elena (Fisher)

Elena’s a strong, independent woman, with her own motivations and thoughts. She’s indeed attractive (very attractive if you think about Uncharted 4), but in terms of being healthy and fit, not being overly sexy as a “fan service” (Japanese games, I’m looking at you)

 

She’s not some female characters who are over-confident, and/or over-powered, to the point they don’t even need men. She does not work alone. She works with Nathan Drake to overcome the odds.

Continue reading “Why do games need more Elena (Fisher)”

The art of asking questions

This is the second part of a series about most important skills for developer. The first part, about searching for answer skill, can be read here.

Searching for the answer is usually the fastest way to solve a problem

But searching on Google might not be enough to find you the answers, you might be the first to encounter the problem, or you might be searching for the wrong keyword. Sometimes, you have to ask the questions, hoping that some one, some where does know about the problem, and is kind enough to spend some time reading your questions, and typing the answers.

For free.

Continue reading “The art of asking questions”

The most important skill (of a good programmer)

Being programmer(*) is hard.

Being a good programmer is, of course, even harder. Unlike countless other jobs where the daily work is a routine, and being good at your job is to be efficient at that routine, being programmer is all about constantly learning and doing new things. Being a good programmer is about being fast at learning, and doing new things well. The process might stay for a while, but the content of the job is constantly changing. (If you keep doing same content over and over again, you are doing it wrong)

Continue reading “The most important skill (of a good programmer)”

Optimizing T-SQL COUNT

This is a continuation of my previous post about paging in SQL Server. When it comes to paging, you would naturally want to know the total number of rows satisfying, so you can display some nice, useful information to your end-users.

You would think, well, it’s just a count, and a simple query like this would be enough:

SELECT COUNT(Id) FROM MySecretTable

There should be nothing to worry about, right? Actually, there is.

Let’s get back to the example in previous post – we have to count the total number of orders in that big table.

SELECT COUNT(ObjectId) FROM OrderGroup_PurchaseOrder

Because ObjectId is the clustered index of OrderGroup_PurchaseOrder, I did expect it to be use that index and be pretty fast. But does it? To my surprises, no.

Continue reading “Optimizing T-SQL COUNT”

Beware of unwanted subscriptions

Updated December 23rd 2017: My wife talked with JustFab UK over the phone last week, and they told her to write an email to them. They promised to refund all of the monthly subscriptions, which they did, today. We are of course happy to get our money back, and I think JustFab UK appears to less “scam-y” then they does before , so I updated this post title to reflect that. Still, beware of your unwanted subscriptions.

The original post as below:

Later tonight I was checking my bank statements – to see how much I have spent and how much I still have in my account – well, for the upcoming Holiday seasons, of course.

And this got my attention:

Normally I would assume this is my wife using my credit card buying something. She did that before, and I was unhappy about it, but she didn’t stop doing that. But there was something telling I might have seen this before, it must be some kind of Déjà vu.

So I checked a little further back, and realized there was a similar transaction last month

Continue reading “Beware of unwanted subscriptions”

Fixing error MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found

When you build a project with MSBUILD Tools 2017 and getting “MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found” error, you probably need to update your MSBUILD Tools components.

Download the latest version of MSBUILD tools from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017, run it, choose Modify and then select “Web development build tools” and “.NET Core build tools”.

If you are getting error CS8107: Feature ‘default literal’ is not available in C# 7.0. Please use language version 7.1 or greater.

or

error CS8107: Feature ‘leading digit separator’ is not available in C# 7.0. Please use language version 7.2 or greater.

You need to add <LangVersion>7.2</LangVersion> to your project file(s). Unless you specifically set up your project, Visual Studio 2017 uses the “C# latest major version (default)” option for C# language, which means you can use only up to C# 7.0:

You can either select C# 7.2 explicitly, or by adding <LangVersion>7.2</LangVersion> to .csproj file manually.

Note that C# 7.2 is not supported with the vanilla version of Visual Studio 2017. When it was released, Visual Studio 2017 only supports C# 7.0. Supports for C# 7.1, and later, 7.2, were introduced in later updates: 15.3 and 15.4, respectively. At this time of this update, 15.6.1 is available and I personally recommend to upgrade to latest version possible.

Make sure to add it to both debug and release configuration. It’s likely that you will run your server builds on release.