In Magento2 API, how would I filter by multiple categories?


When the category ids are 105,106,107 I am getting results, but if the category ids are 107,106,105 I am getting empty items.

How can I search for different categories in Magento2 API?


For multiple values need to use in please refer below devdocs 

**Note**: In your search criteria it ill take first category id only.
|improve this answer|||||
  • If it takes only first category then it will be a problem. If first category not having any products then we will get the empty results . same happening in my case as well. Any solution for this? – Dinesh Feb 25 '19 at 8:55
  • If you use eq it will happen like that yous should use in while you are using multiple categories – Sairam Sigirisetty Feb 25 '19 at 12:34

Example with Guzzle:

        $response = $this->client->get('/rest/V1/products', [
        'search_criteria' => [
            'current_page' => $currentPage,
            'page_size' => $pageSize,
            'filter_groups' => [
                    'filters' => [
                            'field' => 'category_id',
                            'value' => '23356,23355',
                            'condition_type' => 'in'
|improve this answer|||||

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.