Developer forum

Forum » Development » Recommended way to manually remoce products from a result set

Recommended way to manually remoce products from a result set

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

 

What is the best way to remove products from a result set based on custom logic? For example, what if I want to remove products from a Product Catalog list page based on some data in an ERP system? I can write a ProductList extender and remove the products but that affects sorting and paging in the wrong way (at least, it did in the past).

 

Also, when implementing this solution I would like search suggestions / auto complete etc. to take my rules into account as well.

 

Is there a global hook I can use to remove products from a set before they are being handled by the product catalog?

 

Thanks,

 

Imar


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Imar,

 

Well, that depends.

 

If you use Optimized Product Retrieval (OPR), then no, currently that is not possible. At least not if you want your product count to match the actual number of products. The reason is that OPR fetches only the products that are actually displayed on the page, so if you remove products from the collection those won't be replaced by other products. We are looking into ways of making this possible with OPR, but I have no timeframe for this yet.

 

If you don't use OPR then it's possible. The best way is to subscribe to either the Dynamicweb.Notifications.eCommerce.ProductList.BeforePaging notification or the Dynamicweb.Notifications.eCommerce.ProductList.BeforeSort notification -- depending on whether you want to handle custom sorting or not. As you might imagine, sorting happens before paging :)

 

Hope that helps :)

 

- Jeppe

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Jeppe,

 

Yes, that does help. I am not sure (yet) how many products we'll have and whether OPR is a must or not. It sounds like a great feature to have with OPR turned on as well, but I understand this is probably not easy to implement.

 

Thanks,

 

Imar

 

 

You must be logged in to post in the forum