Expire a Product


What is the best way to expire a product/variant in EPiServer Commerce 9?

I used to deactivate products in Commerce 8 as below:

            CatalogEntryDto entry = CatalogContext.Current.GetCatalogEntryDto(entryCode);
            if (entry != null && entry.CatalogEntry.Count > 0)
                CatalogEntryDto.CatalogEntryRow entryrow = entry.CatalogEntry[0];
                entryrow.EndDate = DateTime.Now;
                entryrow.IsActive = false;

But it doesn't work properly in Commerce 9 as new meta fields added to the meta object Epi_StopPublish and Epi_IsPublished.

Appreciate your help guys!

May 25, 2016 20:12


You should be using the Content API for Commerce9, then set VersionStatus, StartPublish and StopPublish with ease. However if it's not an option for you right now, you can load the MetaObject and then

metaObject["Epi_StopPublish"] = DateTime.UtcNow;

metaObject["Epi_IsPublished"]  = false;


You'll have to do this for all language versions,



May 26, 2016 10:12

Islam, are you trying to do this via some service or within the web context? You may need to consider events also if its out of the web context.


May 26, 2016 12:30

Thanks Quan!

I hope calling Content API will not be expensive.

One more question, if I do the following:

metaObject["Epi_IsPublished"]  = false;

What is the proper version status to set?

May 26, 2016 15:47

Thanks Khan for your reply.

It is a custom schedule job that expire products based on specific criteria.

May 26, 2016 15:58


The ContentAPI is not be expensive, the overhead is small compared to the the CatalogEntryDto way.

I think the reasonable status is CheckedOut. It's the same when you set the IsActive to false.



May 26, 2016 16:07
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.