5

I'd like to be able to search products via the API but in my experiments so far I've found that if I am searching for a value of an option attribute (e.g. drop-down list) then I have to specify the ID of the option value. If I search by the text of the option then no records are returned. For example:

searchCriteria[filter_groups][0][filters][0][field]=size&
searchCriteria[filter_groups][0][filters][0][value]=S&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq

Returns no results whereas:

searchCriteria[filter_groups][0][filters][0][field]=size&
searchCriteria[filter_groups][0][filters][0][value]=177&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq

Does return results. Here 177 is the ID of the option value for size 'S' in the sample data set.

I'd rather that my API clients didn't have to know the IDs of option values in order to formulate queries so is there a way to search on the text of an option attribute?

  • Did you get any solutions ? – zed Blackbeard Nov 29 '19 at 7:51
  • Magento 2.3 has GraphQL support. I haven't tried it but that might be an option. – robjingram Dec 15 '19 at 21:13
1

You can get labels to id mapping from OptionManagement service

  • 3
    Link does not open exact service in docs, please provide REST service URL here. GET /V1/products/attributes/{attributeCode}/options I suppose – Alex Paliarush Dec 16 '15 at 17:34
  • I feared that might be the case :) – robjingram Dec 16 '15 at 20:57

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.