Hi guys,
I have some rather simple ProductListTemplateExtender
using Dynamicweb;
using Dynamicweb.eCommerce.Products;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace DWCustomCodes
{
public class ProductRemover : ProductListTemplateExtender
{
public override void ExtendTemplate(Dynamicweb.Rendering.Template template)
{
foreach (Product p in this.ProductList)
{
string suffix = p.ID.Substring(0, 3);
if (suffix == "AU_")
{
p.RemoveItem(p.ID);
}
}
this.ProductList.SaveAllProducts();
}
}
}
Issue, p.RemoveItem(p.ID); is not removing product.
Question: is there any method I could try calling, or removing item in another way?
I also tryed to add this.ProductList.SaveAllProducts(); after loop is done, but that didn't help.
During the loop this.ProductList.Remove(p); this cannot Remove product while in the same loop.
Tryed to collect all product I would need to remove, and later loop through that collection, and removing that product from this.ProductList, but no results :-/ I am sure code gets invoked, am quite surprised that something is not OK in here.
Any suggestions, examples, oppinions are more than welcome.
/Dmitrij