GetMainCategory on a variant

Im trying to get a products main category thru variant.GetMainCategory(guid websiteId) but it seems it always returns null. Ive checked in Litium and it has a maincategory set. Ive also tried variant.GetBaseProduct().GetMainCategory() with the same result.

Litium version: 6.2.x

The GetMainCategory extension method will only return the main category if the category is published on the website. Otherwise the method will return null.

1 Like