Pricing Issue
Problem:
We have a item collection that has minimum and maximum price with max discount across different stores.
{
"item_id":1,
"price":{
"min":1500.00,
"max":3000.00
},
"max_discount":50
}
Now, we have different store with different pricing, Consider Store S1 has 0% discount & S2 has 50% discount & S3 has 20% discount. Here one item can have n number of stores.
Now we have a case where we want to show inventory based on selected store that can be a combination of S1x S2 or S1 or S1xS3 etc.
In above case
Here pricing will changes on every combination, based on above given solution.
Currently, we show min and max pricing in product listing based looking at all stores. We do not show based pricing on listing based on combination of stores.
Is there an effective way to solve this problem at scale?
Based on the id fields I can see in your draft: deduplication and normalization are concepts that will get you not very far in Solr. They tend to make things more complicated and slow. But anyways, back to your issue.
I would model the schema differently. The basic idea is to model the offer for a certain item of each store. So that you can aggregate on that.
<fields>
<field name="offer_id" type="int" indexed="true" stored="true" />
<field name="store_id" type="int" indexed="true" stored="true" />
<field name="item_id" type="int" indexed="true" stored="true" />
<field name="price" type="float" indexed="true" stored="true" />
<field name="msrp" type="float" indexed="true" stored="true" />
</fields>
To perform your calculations you can then make use of the Stats Component. You may also add Currencies.
An example would look like this (offer 1 would be S1, offer 2 would be S2)
q=offer_id:(1 OR 2)&stats=true&stats.field=price
Included in your response you would get
<lst name="stats">
<lst name="stats_fields">
<lst name="price">
<double name="min">1500.0</double>
<double name="max">3000.0</double>
<!-- etc. -->
<lst name="facets"/>
</lst>
</lst>
</lst>
To display the max discount, I would calculate
(min value from the stats component) / (msrp)
e.g. 1500 / 3000 = 0,5 => 50%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With