How to search through all WooCommerce products/categories...?

758 Views Asked by At

I'm developing an ASP.NET Core web application using WooCommerce REST APIs (I'm also using the WooCommerceNET library), and I need to implement a search text input field with a simple Search button.

No problems with that, the issue is that WooCommerce returns 100 items max per page, so the following does not work (this code runs after the property Products has been populated, of course):

if (!string.IsNullOrWhiteSpace(searchString))
{
    Products = Products.Where(p => p.name.Contains(searchString)).ToList();
}

Since my WooCommerce website contains 23k+ of products, I can't just do multiple (230+) requests, it would take forever.

I thought about having a parallel local database or something similar which gets populated when it's needed, but then I realized that maybe, if I'm lucky, it exists some sort of parameter that I can pass to the request in order to filter the research directly in the http request, so it would already return 100 results of my research.

I didn't find anything about that googling around, so I'm asking here if this is a thing and if it's not, then how to solve my problem in a different way.

1

There are 1 best solutions below

0
On BEST ANSWER

It was pretty easier to find than I thought, indeed there is a parameter which can be used in the link, here's an example that works for me:

/wp-json/wc/v3/products?search=stringToSearch