3

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.

3 Answers 3

3

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!

3

Also be sure to urlencode the %

http://magentohost/api/rest/products?order=name&filter[1][attribute]=name&filter[1][like]=%25shirt%25
2

Standard magento has no "q" search keyword, you have to define the exact attribute in your search:

Try:

<myhost>/api/rest/products?name=shirt%

or

<myhost>/api/rest/products?name=shirt
1
  • how to filter with status=1 and visiblity=4 ? Mar 18, 2015 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.