Try our conversational search powered by Generative AI!

Unpublish product without deleting it

Vote:
 

Hi!

How can I unpublish a product without deleting it? Should I set it's status? And what SaveAction should I use?

#155241
Edited, Sep 13, 2016 9:35
Vote:
 

Hi,

I think you can set the StartPublish and/or StopPublish to make it "not available". Here's an example code:

Snippet

var content = CurrentContent.CreateWritableClone<EntryContentBase>();
content.StopPublish = DateTime.UtcNow.AddDays(-1);
contentRepo.Save(content, SaveAction.Publish, AccessLevel.NoAccess);
#155252
Sep 13, 2016 10:21
Vote:
 

Hi Quan!

Epi_IsPublished will still be true since you use SaveAction.Publish though. But maybe StartPublish and StopPublish will prevent it from showing?

#155284
Sep 13, 2016 13:17
Vote:
 

There is no true way to unpublish a catalog content using content APIs (or at least what I know of). Setting StartPublish to be after current time means it's yet to available, while setting StopPublish to the past means it's expired. It then depends on your front-end code to filter out those entries from being shown.

You can still set IsActive column via CatalogEntryDto and/or setting metaObject["Epi_IsPublished"] to false via MetaObject.

/Q

#155290
Sep 13, 2016 14:48
Vote:
 

Okay. I think in previous versions of EPi, I could set IsPendingPublish to true, which would set IsActive to false on the CatalogEntry. Is this still the case?

#155333
Sep 14, 2016 10:48
Vote:
 

I would recommend to set the StopPublish to the current UTC time and that way expire the content.

It would require you to filter out content upon loading using the IPublishedStateAssessor.IsPublished function, but that is something you should already be doing. :)

#155400
Sep 15, 2016 16:03
* 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.