Remove downloadable files from a product

To remove a downloadable file form a product, you must perform the following:

  1. Get instances of the following managers:
    • Catalog manager
    • Content links manager
  2. Get the specified product.
    Get an instance of the specified product. For more information, see For developers: Query products.
  3. Get the product file.
    Get the instance of the product file from the Files collection.
  4. Remove the product file.
    Remove the ProductFile instance from the Files collection.
  5. Save the product.
    Save the changes to the catalog manager.
  6. Get the content link.
    Get the content link for the product and the file.
  7. Mark the content link to be deleted.
    To mark the content link to be deleted, call the Delete method of the content links manager and pass the content link as an argument.
  8. Delete the content link.
    To delete the content link, save the changes to the content links manager.

NOTE: For more information about how to delete a file from the Downloadable goods library, see For developers: Delete documents. Note that you have to use the libraries manager with the system libraries provider. Before deleting the file, make sure that it is removed form the product and the content link between them is deleted.

Use the following code sample:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?