Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Filter Item search results on inventory?

Vote:
 

Hi Forum

Is there an easy way to search for items (products/variants) that are in stock in a specific warehouse?

We have multiple warehouses where items can be in stock, but in certain scenarios I only want to see items that are in stock in the local warehouse.

Based on this page, I can search for Variants that are available in a specific market: 

var result = SearchClient.Instance.Search<VariationContent>() .Filter(x => x.AvailableMarkets().MatchContained(v => v.Value, "market"));

(https://docs.developers.optimizely.com/customized-commerce/docs/filtering-catalog-content)

But what would I do, to search for items in stock on a specific Warehouse?

Thank you for your help.

Regards

Anders

#331891
Oct 24, 2024 7:50
Vote:
 

if you install Find.Commerce, you can use Inventories() which is an extension method on IStockPlacement content (variant etc.)

#331897
Oct 24, 2024 9:06
Vote:
 

Yes, of course. I just needed to find the correct syntax for my query.

This seems to work just fine:

query = query.Filter(x => x.Inventories(), x => x.WarehouseCode.Match("XYZ") & x.InStockQuantity.GreaterThan(0));
#331899
Oct 24, 2024 10:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.