Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi,
This should be posted to Commerce subforum instead :).
To clear the asset collection of a product, you'll need to do this:
foreach (CatalogEntryDto.CatalogItemAssetRow row in entryDto.CatalogItemAsset.Rows)
{
if (row.RowState == DataRowState.Deleted)
continue;
row.Delete();
}
to actually delete the row.
Regards.
/Q
Hi,
Can some admin pls move this post to the correct forum.
Thank you for your response.
I have tried that too, but I cannot make it work. I have tried all the different combinations of marking the row as deleted and removing it from the collection. Am I missing some other step? What am I supposed to do after I’ve marked a row for deletion? Right now I use AcceptChanges and then SaveCatalogEntry but my changes doesn’t stick. When I’m adding an image I use AddCatalogItemAssetRow followed by SaveCatalogEntry and that works just fine.
Regards
How do I delete an image asset? Is there a way to delete the image and unlink it from all its products, or is that something I have to do manually?
Right now, I can delete an image but I cannot remove its link to a product, or rather, the products link to the image. I am trying to use a CatalogEntryDto because I hope to modify the collection of assets.
var entry = _catalogSystem.GetCatalogEntryDto(book.LoadEntry().ID, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Assets));
var asset = entry.CatalogItemAsset.FirstOrDefault();
// Delete image
var imageRef = PermanentLinkUtility.FindContentReference(new Guid(asset.AssetKey));
_contentRepository.Delete(imageRef, true, AccessLevel.NoAccess);
// Trying to remove the link
entry.CatalogItemAsset.RemoveCatalogItemAssetRow(asset);
entry.CatalogItemAsset.AcceptChanges();
_catalogSystem.SaveCatalogEntry(entry);