Developer forum

Forum » Development » PreparePrices and FindPrice behaving oddly

PreparePrices and FindPrice behaving oddly

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi community,

I’m experiencing an odd behaviour with PreparePrices and FindPrice when doing searches. Mainly where the searchresults contains products with lots of variants. In this case it is a Rapido-based solution. (I have locally upgraded to latest 9.x with same behaviour).

What's happening is that when posting a search by writing in the searchbar, a request is sent and 7 products is returned by the query to populate the dropdown below the searchbar.

This triggers PreparePrices with a collection of 7 product which is correct. Those seven products are sent to BC and prices are retrieved and cached, by the book.

What happendes next is that FindPrice is triggered. First for those seven products and a price is retrieved from the cache, by the book. But FindPrice is also triggered for every other products that matches the search. 

Example: There is a product named “Lido” which has 84 variants. So, when searching for “Lido” we get the seven results as configured. But also 77 additional individual request with FIndPrice to BC to retrieve prices that are not cached with PreparePrices. This of course takes forever.

I cannot find any misconfiguration.

In the request for the productsfeed the pagesize is set to 7 (pagesize=7). In the app the “Products per page” is set to “7”. The GetLoop(“Products”).Count returns 7. But still the “FindPrice” is triggered for the “whole” searchresult or for all the variants if some variants are in the searchresult.

At the moment I have a workaround where I skip FindPrice if the request is a search and the price is not cached.

Has someone else any similar experience? Any ideas about why is't behaving this way? 

Regards / Aki

 


Replies

 
Nicolai Pedersen
Reply

I think it is because the template rendering this has a loop or other tags related to variants - when there, the variants are loaded and so are their prices. So have a look at the result/typeahead template and see if that could be the case.

BR Nicolai

 
Aki Ruuskanen
Aki Ruuskanen
Reply
Thanks, sound logical. I'll check. / Aki

 

You must be logged in to post in the forum