Developer forum

Forum » Development » Filtering on prices with sales-discounts

Filtering on prices with sales-discounts

Søren Heide Larsen
Søren Heide Larsen
Reply

Hi,

I am trying to extend the indexing to include filtering and sorting by price including sales discounts. I know the issue that it cannot be 100 % based on sales discounts such as "Logged in", etc., but I would simply just like the Product.Price.Price.

I have tried to include this, but I get a null-pointer exception which I expect is due to loading from another thread.

Is there anyway around this? Maybe to simulate a context?

/Søren

 


Replies

 
Nicolai Pedersen
Reply

Hi Søren

Product.Price.Price calls prices providers and discounts and you are lacking a ton of context which is not available in the thread executing the indexing. There are 2 issues - missing Dynamicweb context and missing httpcontext (probably).

Much of Dynamicweb is no longer depending on httpcontext, but Ecommerce still does to some extend - we are working on that.

First thing you could try was to create a pageview instance in the indexer. That will give you some context, but might give you issues with missing httpcontext. You might be able to find a way to add a httpcontext to the thread, but it is really difficult.

Most discounts are order discounts - so you might need to just find product discounts and do the math your self.

We have looked into this as well - and I see no good way to do this - and the result will be almost as useles as not doing this...

BR Nicolai

 
Søren Heide Larsen
Søren Heide Larsen
Reply

Hi Nicolai,

Okay, I am looking forward to the state where everything works from another context :)

I ended up writing my own simplified parser of Product Sales Discounts and calculate a index field for each shop-currency combination which seems to be working quite well, though now I have yet another a complex component to maintain :)

/Søren

 
Nicolai Pedersen
Reply

So do we.

Would love to see the code - at the summit?

BR Nicolai

 
Søren Heide Larsen
Søren Heide Larsen
Reply

Sure thing, let us just have a chat at the summit and I can show you my approach :)

 

You must be logged in to post in the forum