Developer forum

Forum » Development » Product Catalog (eCom) - Product List: Delivering different datasets to

Product Catalog (eCom) - Product List: Delivering different datasets to

Michael Antonsen
Reply

Hi everybody!

 

I have a problem with a NotificationSubscriber, that subscribes to Dynamicweb.Notifications.eCommerce.ProductList.BeforeSort and removes som products from an instance of Dynamicweb.Extensibility.NotificationArgs that is delivered to OnNotify, if they are not in stock according to a webservice (livecheck against a stock-service). 

 

When the logic is working correctly (or at least as I expect it to do :) ), the instance of Dynamicweb.Extensibility.NotificationArgs contains a product-list with all products on (not accounting on products pr. page). This is fine, but the problem is that this is not always how the products are delivered in the product-list on Dynamicweb.Extensibility.NotificationArgs. Sometimes the products are limited to the products pr. page, so if the products per page is limited to 10, then I am only handed 10 products in the Dynamicweb.Extensibility.NotificationArgs, even though there are more products. This is not how I expect it to work and obviously this is causing problems when the data is delivered to the frontend.

 

The modules seem to be alike. Can anyone help me figure out why this behaviour is occurring? It would certainly be appreciated :).


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Michael,

The product list has a ProductList.BeforePaging noticifation that will hold all products. This may be of better use in the scenario you describe.

 

Best regards
Morten Snedker

 
Nicolai Pedersen
Reply

Or use a productlist provider - where you deliver the entire amount of products to show.

 
Michael Antonsen
Reply

Hi Morten and thank you for the suggestion!

 

Unfortunately, the behaviour was the same when I switch to ProductList.BeforePaging :-/.

 

I still get a list of the 10 first products instead of 16 when I try to access some of the product listings and a list of all products whenever I visit other product listings.

 
Michael Antonsen
Reply

Hi Nicolai.

 

Thank you for the suggestion as well. I've messed a bit around with the ProductListCollectionProvider, as other threads in the forum suggests that this should be used instead of a ProductListProvider. 

It seems like I can fetch whatever products I would like to from here, but there is also a lot of information I should take into consideration when fetching the products. When I fetch the products by groupid's using your API, I get 145 active products instead of the 16 products I was looking for initially.

 

As there is a lot to take into consideration from the Dynamicweb.eCommerce.Frontend.Renderer object, that is passed along, it seems like there is a high propability, that something else will break if I implement this (This is the first time I will implement a ProductListCollectionProvider, so please let me know if I am misjuding anything here :-) ).

 

Besides this worry I have regarding implementing a ProductListCollectionProvider, I feel like the solution to this problem should be a bit more simple. Like there would be some setting on the module (or somewhere else, for that matter) that controls if all of the products found are passed to the NotificationSubscriber or if they should be cut up before being passed on.

 

Please let me know if there is any setting like this in DW, or if there is no way around using a ProductListCollectionProvider. 

 

Thank you in advance!

 
Michael Antonsen
Reply

Hi again,

 

I managed to find the issue. Whenever I enable the checkbox "Use Lucene to retrieve products regardless of presence of filters" on the productlist-module, the products are delivered in one batch instead of being cut up in page-sizes.

 

Not unlike many other things in our profession, I have no idea why this works :-). I do not feel like this label is self-explanatory regarding this behaviour, so I hope that one of you guys at DW can follow up and enlighten me regarding what actually happens when I enable this checkbox? :).

 

Once again, thank you in advance and thank you for your previous suggestions!

 
Michael Antonsen
Reply

Hi again,

 

Doesn't any of you Dynamicweb-guys want to chip in here? :)

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Michael,

You're quite right: the BeforeSort has the same behavior.

The reason for the productlist not containing a full list is that the list potentially may have all products. So, if you have 500,000 products, you will have a list of 500,000 products - which is not desirable. So, using notifications is not an option.

ProductListProvider, as suggested by Nicolai could be an option, but I probably would not go that way either: firstly you need to have a margin of products in the list to work with, to make sure you have enough (in case items in list are removed). On top on that you'd have to deal with potential performance issues - and products may appear more than once during paging. And what if your webservice does not response?

I would probably prefer updating stock in Dynamicweb at a high frequency. Dynamicweb has its own webservice you can call that would update products. Alternatively you could use Data Integration and update the products (delta or full as best fitted), by importing a CSV/XML containing the updates. If you wanted an extra security regarding "is it in stock", you could limit the the check to be just on the cart.

Finally, you could also just update Dynamicweb stock data by calling the remote webservice frequently.

My personal opionion is that live stock-check, paired with paging, is too shaky.

 

Best regards
Morten

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

PS: If the remote webservice has an underlying and exposed MS SQL Server, you may even use Data Integration to update the Dynamicweb database directly from source.

/Morten

 

You must be logged in to post in the forum