I was looking at the documentation of CommerceContext.GetCatalogsForUser and there is surprisingly very little documentation compared to what the method actually does. Based on the user browsing the site this method attempts to retrieve the most appropriate list of catalogs for that user. And this is how:
If the user has a profile
1. First try to get the catalogsetid from the user’s profile
Get the value of the catalogSetIdProperty attribute from the
CommerceServer/profiles/userProfile section.If the catalogSetIdProperty is not
specified in web.config set it to AccountInfo.user_catalog_set
Get the catalogsetId defined for the catalogSetIdProperty in the user’s profile
2. If the catalogSetId is null then get the catalogsetid from the user’s Organization profile
CommerceServer/profiles/ organizationProfile section. If the catalogSetIdProperty is
not specified in web.config set it to GeneralInfo.org_catalog_set
Get the catalogsetId defined for the catalogSetIdProperty in the user’s Organization
profile.
End // If the User has a profile
If the catalogSetId is not null Then
Return the list of catalogs in the catalogset defined by this catalogSetId
Else If the catalogSetId is null Then
3. Get the catalogsetName from the commerceserver\catalog\catalogsets section in web.config.
If the user is Authenticated then
Get the value of the catalogsetName from the defaultAuthenticated attribute. If this attribute is not specifed in web.config then set the catalogsetName to “Registered User Default CatalogSet”
Else If the user is an Anonymous user Then
Get the value of the catalogsetName from the defaultAnonymous attribute. If this attribute is not specifed in web.config then set the catalogsetName to “Anonymous User Default CatalogSet”
Return the list of catalogs belonging to this catalogsetName.
End If
Things to note: