Developer forum

Forum » Ecommerce - Standard features » Query variant size in stock

Query variant size in stock

Lars Pham
Reply

Hi..

I can't seem to wrap my head around this. 
I'm using Repositories > Index & Queries to filter products on frontend. 
So I'm using Facets for choosing "Clothes sizes" S / M / L. 

When a user searches for size "M" I want it to show the products that have M sizes in stock. 

My query looks like this now: 

[Size variant group] MatchAny [Size parameter(s) chosen by the user]
Stock (System.Double) GreaterThan 0

It gets all products that have the chosen sizes and are also in stock - but I think the stock field is the stock sum of all variables. 
How do I set up the query, so I get the products that has the chosen size in stock? 

Hope it makes sense! :) 

 


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Lars,

Make sure that under Settings -> Ecommerce -> Advanced configuration -> Fields: here you must have checked "In stock / Across all variants". If that is the case it should work. If it is indeed checked, and still returns something wrong, let me know.

Notice, however, that stock is based on stock saved in index, not stock from the database. When a product is sold, its stock is deducted from database, but remains the same in the index until it has been updated. So it will require frequent updates to reflect actual stock correctly.

/Morten

 
Lars Pham
Reply

Hi Morten,

The "In stock / Across all variants" is already checked. 

And I'm aware of it looking at the stock in the index.
But even with an updated index, it still returns products where queried variant's stock < 0.

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Lars,

Send mail to support@dynamicweb.dk with link to a URL where a product is shown that should not be shown. Att the support ticket to me, then I'll take a look.

Best regards
Morten Snedker

 

You must be logged in to post in the forum