Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

How to check if product expired?

Vote:
 

In the Commerce Catalog UI I expire a product by selecting Manage Expiration and Archiving, and setting the expire date to now.

However, loading catalog content from code I see different properties on my products, like Epi_IsPublished, but nothing in regards to an expired status. My question is, how I can check from code, that a product is expired?

Commerce version: 11.8.3.

#200169
Jan 04, 2019 8:10
Vote:
 

I think the meta field "Epi_IsPublished" determines the expired status. IsPublished = true means "not expired".

#200174
Jan 04, 2019 9:31
Vote:
 

Hi Bo,

You can use IPublishedStateAssessor to check a catalog entry is published or not like this:

 var publishedStateAssessor = ServiceLocator.Current.GetInstance<IPublishedStateAssessor>();
 var isPublished = publishedStateAssessor.IsPublished(entryContent, PublishedStateCondition.None);
#200179
Jan 04, 2019 10:11
Vote:
 

Binh's answer is correct. Epi_IsPublished is now considered an internal implementation, and in Commerce 12 you can no longer access it via content.Property. 

#200181
Jan 04, 2019 10:28
Vote:
 

Thanks a lot :-)

#200187
Jan 04, 2019 13:49
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.