2

Problem:

I am trying to display products using below rest api with ref http://devdocs.magento.com/guides/v2.0/rest/retrieve-filtered-responses.html

GET http://192.168.0.133/index.php/rest/V1/products/?searchCriteria[filter_groups][0][filters][0][field]=category_gear&searchCriteria[filter_groups][0][filters][0][value]=8&searchCriteria[filter_groups][0][filters][0][condition_type]=finset&fields=items[sku,name]

I am getting response as

{
"items": null
}

Whereas I have 4 products in category/catalog with id=8

What is the correct way to call the api ?

I am using magento 2.2.1

0

I have read the doc again: category_gear is a product attribute. NOT belong to category attribute.

For example, I'm going to get product with category id 8

$searchCondition = "http://mage220.loc/rest/V1/products/?";
$searchCondition .= "searchCriteria[filter_groups][0][filters][0][field]=category_id&";
$searchCondition .= "searchCriteria[filter_groups][0][filters][0][value]=8&";
$searchCondition .= "searchCriteria[filter_groups][0][filters][0][condition_type]=eq";

Search Criteria:

[search_criteria] => Array
        (
            [filter_groups] => Array
                (
                    [0] => Array
                        (
                            [filters] => Array
                                (
                                    [0] => Array
                                        (
                                            [field] => category_id
                                            [value] => 3
                                            [condition_type] => eq
                                        )

                                )

                        )

                )

        )

My Magento version is 2.2.0

[Note]

the searchCriteria must be specified in the URL of the GET request.

  • Thanks.How should I know which are category attributes? – Hiranya Sarma Dec 19 '17 at 9:18
  • @Hiranya Log in into Admin > STORES > Attributes > Product. You can see it. – Khoa TruongDinh Dec 19 '17 at 9:31

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.