3

I would like to get more then one product's attributes options in one query I have my url for one attribute option as follow:

http://magento2.dev/rest/V1/products/attributes/size/options

The above I am receiving all the options for size, now the question is:

How do one get attribute options for colour in the same call?

e.g One could do http://magento2.dev/rest/V1/products/attributes/size|colour/options

passing parameters separated by pipe or comma whatever how can one do this in Magento 2?

Thank you in advance.

3 Answers 3

7

I've found out how to get list options I was looking for, it's possible to get attributes groups with array with options like so:

http://magento2.dev/rest/V1/products/attributes?&searchCriteria[filterGroups][0][filters][0][field]=attribute_group_id&searchCriteria[filterGroups][0][filters][0][value]=31

Where 31 is the attribute_group_id of custom attribute group MISC

1
  • 1
    Just to add you need admin rights to access this way
    – MePo
    Commented Feb 20, 2018 at 11:09
3

Might be a little late but...

The following query returns options of MY_ATTR_CODE_1 and MY_ATTR_CODE_2.

products/attributes?searchCriteria[filterGroups][0][filters][0][field]=attribute_code&searchCriteria[filterGroups][0][filters][0][value]=MY_ATTR_CODE_1& searchCriteria[filterGroups][0][filters][1][field]=attribute_code&searchCriteria[filterGroups][0][filters][1][value]=MY_ATTR_CODE_2&fields=items[attribute_code,options]

You can add as many attributes as you like this way.

1

I think Magento2 doesn't allow to pass multiple options in this request. You can use the only one option at a time. You can refer webapi.xml file of catalog module under vendor directory.

You can create custom API for it. Here is an example to create custom REST API in Magento2. https://www.envisionecommerce.com/how-to-use-magento-2-rest-api/

2
  • Thank you for your suggestion. It seems that Magento API isn't so robust yet Commented Sep 27, 2017 at 13:19
  • Perhaps there is another way what about GET attribute size and colour that belongs to an attribute group like a custom attribute e.g "MISC" then it will have size, colour etc.. and get all options is there way can be done Magento? Commented Sep 27, 2017 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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