Could you temporarily remove GetContextMode() == ContextMode.Edit || and check if the right list returns ?
I am still facing the same issue even with this:
protected override bool ShouldContentBeExposed(IContent content)
{
// In EditMode, unpublished or expired content is still returned
return base.ShouldContentBeExposed(content);
}
It seems the problem is with something else. could you remove the registration (i.e. use the default loader) to see if it still happens?
When removing this line it works again:
context.Services.AddSingleton<ContentLoaderService, EnhancedContentLoaderService>();
Could this be a bug?
It turns out that there is an internal implemenation of ContentLoaderService named CatalogContentLoaderService which handles the catalog content. if you register like that, it will simply override CatalogContentLoaderService which explains why you get an empty array. the right approach in this case is to use the intercept pattern, and make sure to register your interceptor after calling AddCommerceApi which registers CatalogContentLoaderService
it's fair to question why CatalogContentLoaderService is not override-able, but it is what it is, for now
Hi all,
We have created an enhanced content loader service that enables draft content to be returned from the content delivery api. The enhanced content loader is working fine as expected. However, we noticed that when we inject the service to be used in our project it breaks the ability for variants to be retrieved from the commerce side of things using /children by only recieving an empty array as a response. Ex request url:
https://localhost:5000/catalog/category/product/children
We used this link as a reference to build our service:
https://docs.developers.optimizely.com/content-management-system/v1.5.0-content-delivery-api/docs/customizing-content-delivery-api-for-edit-view#return-draft-and-expired-content
here is the code for our enhanced content loader service:
The service is being injected like this:
Any ideas on what could be the issue?
Thanks in advance