volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

AI OnAI Offsmart_toy

How to check if product expired?

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

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

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

Thanks a lot :-)

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