Hi Guys,
I have a product catalog, that uses new index. DW APP: 8.8.1.18
In product catalog, I have 100 products total.
Showing 20 products per page.
What notification subscriber do I need to use
So that I could remove products from before they are aded to the page.
And making sure it would not leave enpty product gaps, and show completed page with 20 products. Instead of leaving empty gaps by showing 18-19 products, and 20 on another one.
For example, 5 products, have ProductField called "Model"
If they have the same model - than I must show only first product that has the same model.
PROD1 has Model A.
PROD2 has Model B
PROD3 has Model A
PROD4 has Model A
PROD5 has Model C
I would need to show catalog like this;
PROD1
PROD2
PROD5
Here is what I tried so far:
Dynamicweb.Notifications.eCommerce.ProductList.BeforePaging looked very prommising at first.
But when I was removing product from beforePagingArgs.Products - It leaves branks.
This is how my implementation looks like:
[Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.ProductList.BeforePaging)]
public class BeforePaging : Dynamicweb.Extensibility.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
{
Dynamicweb.Notifications.eCommerce.ProductList.BeforePagingArgs beforePagingArgs = args as Dynamicweb.Notifications.eCommerce.ProductList.BeforePagingArgs;
List<string> removeProducts = fetchProductsToRemove(); // populate list with ProductIDs
if (removeProducts.Any())
{
foreach (string pID in removeProducts)
{
var targetInt = beforePagingArgs.Products.IndexOf(pID);
beforePagingArgs.Products.Remove(beforePagingArgs.Products[targetInt]);
}
}
}
}
Logic works, it removes from ProductList, but removes AFTER paging. Result is blank product spaces.
Am I using it wrong, or what?
I also tried subscribing to other events, but than product catalog dissapears completely.
/Dmitrij