You can use IContentRepository.GetReferencesToContent, to see if a media is used by any catalog content
Greatness, ill post the final code for future ref! thx Quan, 2 points for you!
Final code for futur reference https://devblog.gosso.se/2020/12/deleting-media-assets-episerver-commerce/
Hi!! Commerce v13.24.0
I have this old code that seems to stopped working.
We have a Delete Media from Commerce entries functionality. But the problem is that it never finds the asset. How do we find the catalog/product/variant that is related if we only have the media ContentReference?
Old code, which is not working anylonger:
All Counts are 0.
Also we used
to remove the relation, but i found out that you should do like this with the new apis: https://support.episerver.com/hc/en-us/articles/115003738211-Deleting-CommerceMedia-leaves-the-asset-row-intact
So, how am i suppose to do to find where an media asset is used? Any ideas?