Remove downloadable files from a product
To remove a downloadable file form a product, you must perform the following:
- Get instances of the following managers:
Get the specified product.
- Catalog manager
- Content links manager
Get an instance of the specified product. For more information, see For developers: Query products.
Get the product file.
Get the instance of the product file from the Files collection.
Remove the product file.
Remove the ProductFile instance from the Files collection.
Save the product.
Save the changes to the catalog manager.
Get the content link.
Get the content link for the product and the file.
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.
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: