Try our conversational search powered by Generative AI!

How to determin product is active or not using content loader



I store an item in recently viewied block(cookies involved)
Product has been disabled But still vcan be retrived in recently viewed block.
UrlResolver.Current.GetUrl(contentLink, language) will throw an exception if prodct is not active.

IN CMS 7.5 without involving DB how can I check product is active or NOT.
[product.LoadEntry().IsActive return me is-active but involves a db trip]

var productContent = (ProductContent)contentLoader.Get(contentLink)
productConten.Status is coming as "CheckedOut"

any idea?


Nov 19, 2014 16:50

Versions are
CMS 7.14
Commerce 8.1

Nov 19, 2014 16:51


When implement Catalog content provider, we used some hacks as follow:

- If an entry is active (IsAvailable = true), then it's published. Otherwise it's not.

- The StartDate = Start publishing, EndDate = Stop publishing.

Yes, it's not optimal and a bit confusing, but for now you can check if status of a entry content is published or not to see if it's active or not.



Nov 20, 2014 1:17

I appriciate for this quick solution.

Nov 20, 2014 11:44

HI Khurram

Hope you are doing well. I had a quick favour to ask. I have just started working in depth on the latest version of EPiserver commerce.. 

On a CMS page I want to be able to link to a product. 

For this I am using the "Url to Page" property. 

This works fine and retrieves the url to the product page. However I do not want to redirect to that page but actually just get the product name out. Am I using the correct CMS property.

In general if I want to get a fashion product out using the product code I use something like below

var contentLink = ExtensionMethods.ReferenceConverter.Service.GetContentLink("Tops-Tunics-CowlNeck", CatalogContentType.CatalogEntry);

var fashionProductContent = (FashionProductContent)ExtensionMethods.ContentLoader.Service.Get<IContent>(contentLink);

But I only have a link. Am I using the correct property.



Jan 07, 2015 23:34


Sandeep, Glad to see you again, btw congratulations on the birth of your newborn son.

If i am not understanding wrong, this can help you

var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>(); [Editted]
var content = urlResolver.Route(url);


Edited, Jan 08, 2015 11:34

HI Khurram

Thanks for your wishes. Have you got some code to create a product using content provider in code.



Jan 08, 2015 16:54

var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();

    //Create a new instance of CatalogContentTypeSample that will be a child to the specified parentNode.

    var newSku = contentRepository.GetDefault<CatalogContentTypeSample>(linkToParentNode);

    //Set some required properties.

    newSku.Description = "Great";

    //Publish the new content and return its ContentReference.

    return contentRepository.Save(newSku, SaveAction.Publish, AccessLevel.NoAccess);


Jan 08, 2015 16:59

Hi Khurram Bhai

Thanks once again. Works perfectly. Used the same logic to create catalog, products and variants. All works like a charm.

Kind Regards


Jan 09, 2015 0:59

Hi Khurram

Could you please let me know how to creare a catalog from code too. The same method does not seem to work. It seems to complain we need an implementation of "ICatalogContentCommitter".

Kind Regards

Jan 12, 2015 13:14

Hi Khurram

Found a solution. Aparently this was not supported in version 7.5. In Episerver Version 7.9 and above you can do it using the following. Please note the default properties below are mandatory -

var repository = ServiceLocator.Current.GetInstance<IContentRepository>();
            var referenceConverter = ServiceLocator.Current.GetInstance<Mediachase.Commerce.Catalog.ReferenceConverter>();
            var root = referenceConverter.GetRootLink();
            var catalog = repository.GetDefault<CatalogContent>(root);
            catalog.Name = "My catalog2";
            catalog.DefaultCurrency = "USD";
            catalog.DefaultLanguage = "en";
            catalog.WeightBase = "Pounds";
            repository.Save(catalog, SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

Kind Regards


Jan 12, 2015 22:32

Yes, CatalogContent wasn't supported until recently - IIRC it was added in 7.9 as you pointed out.

Please note that for your own question, you should create another thread to keep all discussions focused.



Edited, Jan 13, 2015 3:34

Hi Quan

Thanks for your reply. Had realised that and hence  I deleted the question from your post and created a new thread for it. Have posted the solution on here also just in case some one read this and wondered if we got to the solution.



Jan 13, 2015 10:22

My current ecommerce solution needs to support multiple market, i'd like to implement some business rule to prevent commerce editor publishing the product in the selected market without having price configured correctly. 

What will be the best way to check the product availability? 

P. s. I am using the latest commerce 9.10

Mar 30, 2016 12:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.