Loading (and deleting) all content of a certain type

Vote:
 

Hi! We have this scenario:

  • A custom content provider with a few custom content type classes, inheriting for example ImageData and VideoData:
[ContentType(GUID = "...", DisplayName = "My custom content type"]
public class MyImageType : ImageData {
 // ...
}
  • We utilize DDS+blob storage to save image data locally, both JSON properties and binary data
  • We want to be able to completely remove and clean up all this stored data via a scheduled job

Searching around, I've found some approaches using IContentTypeRepository and IContentModelUsage to load all content of a specific type like so:

var type = _contentTypeRepository.Load<MyImageType>();
var usages = _contentModelUsage.ListContentOfContentType(type);

However, despite using a few images on the site and the type seemlingly loading correctly, usages always end up empty.

  • Is this still a correct approach?
  • Is it possible to load all usages even if, like in our case, a lot of usages are in other blocks, content areas and so on?
  • Any ideas of why the list of content type usages always end up empty?
#307995
Sep 05, 2023 7:25
Vote:
 

Custom content provider means "CMS don't know anything about the content, and you provide all the necesary information about content through your custom content provider implementation" - some details can be seen here https://docs.developers.optimizely.com/content-management-system/docs/content-providers

So for methods you mention to work, you need to implement necessary logic inside your custom content provider.

For example, DefaultContentModelUsageService.ListContentOfContentType internally goes through all the registered content providers, and calls ListContentOfContentType for those - so you need to implement that logic in your custom content provider to receive those content, etc.

#307998
Sep 05, 2023 8:00
Vote:
 

Thanks, Vladimir.

The problem then becomes how to implement that listing in out content provider. Again, the end goal is to simply(?) list all the content of a certain type. I was hoping that it would be registrered by CMS internals somewhere for easy retrieval, but it sounds like that might not be the case here.

#308000
Sep 05, 2023 9:08
Vote:
 

Unless if your content provider overrides and implements ListContentOfContentType, it will fall back to the base class which returns empty. otherwise it sounds like a correct approach.

A word of caution though - avoid using DDS, as it's terrible for performance Dynamic data store is slow, (but) you can do better. – Quan Mai's blog (vimvq1987.com) . but maybe you know that already 

#308005
Sep 05, 2023 11:32
* 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.