Magento – How to perform keyword searches via REST

apiextensionssearch

Does Magento support keyword searches via REST or must it be extended to do so?

I'm very new to Magento, and have been tasked with developing an extension that needs to perform product searches via AJAX requests.

Magento is running and sample data has been imported, the REST endpoints are working but I can't seem to find the correct parameter that performs a search. I've tried something like this but the query params are ignored:

<myhost>/api/rest/products?q=shirt

Data is being returned, but there's absolutely no filtering being applied at all. I've tried other parameters as well but with the same results.

Searching for a solution on the issue through the various Magento wikis and SE threads haven't yielded anything helpful. Any guidance would be appreciated.

Best Answer

I asked a similar question on Stack Overflow as well, and was directed to an article explaining the various available filter options available to the products REST endpoint.

What I was looking for is mostly covered by using the filter parameter, like so:

http://magentohost/api/rest/products?filter[1][attribute]=description&filter[1][in]=%shirt%

Each filter parameter appears to take an identifying number as well as the field to filter against, followed by another filter parameter referencing the desired identifying number, with the actual value to filter against following.

Placing the term to search for inside % applies limited loose matching, allowing for returning records that has a field containing a query term, rather than exactly matching it. The full article on the subject is here, and the Stack Overflow question is here.

Cheers!

Related Topic