How to return a specific downloadable product/document.
Does anyone know how to return a link or a stream to a downloadable product.
I found this code in the documentation:
public
static
DocumentLibrary GetDownloadableGoodsLibrary()
string
providerName =
"SystemLibrariesProvider"
;
Guid downloadableGoodsId =
new
Guid(
"e5915e51-707e-4232-9830-68f2800067f8"
);
LibrariesManager librariesManager = LibrariesManager.GetManager(providerName);
DocumentLibrary downloadableGoods = librariesManager.GetDocumentLibraries().Where(d => d.Id == downloadableGoodsId).SingleOrDefault();
return
downloadableGoods;
Hi Keefe,
The downloadable goods library is just a "system" library. It can be queried, along with its contents, like you would any other public library. The documentation you have is just how to get the entire library. So once you have it you can get documents a few different ways.
Here's an example of a few ways.
public
string
providerName =
"SystemLibrariesProvider"
;
public
DocumentLibrary GetDownloadableGoodsLibrary()
Guid downloadableGoodsId =
new
Guid(
"e5915e51-707e-4232-9830-68f2800067f8"
);
LibrariesManager librariesManager = LibrariesManager.GetManager(providerName);
DocumentLibrary downloadableGoods = librariesManager.GetDocumentLibraries().Where(d => d.Id == downloadableGoodsId).SingleOrDefault();
return
downloadableGoods;
public
IQueryable<Document> GetDownloadableGoodsByLibrary(DocumentLibrary docLib)
return
docLib.Documents();
public
Document GetDownloadableGoodByTitle(
string
title)
var lm = LibrariesManager.GetManager(providerName);
return
lm.GetDocuments().Where(d => d.Title == title).FirstOrDefault();
public
List<Document> GetDownloadableGoodsByProduct(Product product)
var returnList =
new
List<Document>();
var lm = LibrariesManager.GetManager();
foreach
(var file
in
product.Files)
var doc = lm.GetDocuments().Where(d => d.Title == file.Title).FirstOrDefault();
returnList.Add(doc);
return
returnList;