1

Been trying to search how to search item in magento 1.x to return JSON output when requesting something like.

www.site.com/api/rest/product?desc=Dress&color=black

Been to their doc and the reference they have isn't very clear, as I tried this example and just changed BlackBerry%208100%20Pearl to the item I have in my store and it returned []. I'm using a data sample from the download section.

http://magentohost/api/rest/products?filter[1][attribute]=name&filter[1][in]=BlackBerry%208100%20Pearl

My question is if its possible to have something like my example when searching for products?

0

Magento documentation isn't very good - it provides an [in] sample with only one parameter. I assume you want to look for blackberry or pearl?

However, I did some googling - Not sure if this will help but the author said it does work:

http://magentohost.com/api/rest/orders?filter[1][attribute]=status&filter[1]
[in][1]=pending&filter[1][in][2]=processing

http://magentoforce.com/2014/08/magento-rest-api-multiple-in-get-filters/

If you want to look for blackberry 8200 pearl then you're doing it correctly according to the documentation - do you have a blackberry 8200 pearl in your catalogue?

http://devdocs.magento.com/guides/m1x/api/rest/get_filters.html

  • No I don't have those values, but when I search for the ones I have it returns an empty [] array. Looks like it needs a full text search rather than by keyword. What I was trying to do is, if I enter a word e.g Pearl it would return all the items with the keyword. – MrNew May 28 '17 at 11:19
0

@mrnew perhaps try using a different parameter to confirm whether the API is returning any data at all. I am not 100% familiar with M1 REST. I have used the SOAP APIs and can confirm that they're reliable.

In regards to your question - it doesn't appear that there is a 'like' operator for Magento 1 REST. But you could try to see if Like '%what you want to search%' works? Perhaps someone else has more experience.

However, there is a like filter for the Magento 1 SOAP API - my advice is to use SOAP because it is the more established of the APIs, has more features and better documentation. There are two versions of the SOAP API for Magento 1 - V1, the original API which can also be used via XML-RPC - which defined methods such as call, multicall, login, etc. V2 defined all services and objects in a WSDL so you can easily generate calls, depending on what you're using to retrieve data.

https://www.fontis.com.au/blog/web-services-api-filter-operators

  • I managed to make it work now, but when filtering for an item like 'Sunglasses' it seems to expect a full name like 'Aviator Sunglasses'. Was wondering if there's a way to do a search parameter by just keywords. like filter...name=Sunglasses and returns every sunglasses items. – MrNew May 28 '17 at 11:53

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.