7

Fetching attribute info, if I apply multiple filters in a single search criteria, it does not work. But in case of single filter it works perfectly.

Multiple filters HTTP request:

http://192.168.1.180/magento/index.php/rest/V1/products/attributes?searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][1][field]=attribute_code&searchCriteria[filter_groups][0][filters][1][value]=size&searchCriteria[filter_groups][0][filters][1][condition_type]=eq

Output: 
{
 "items": [],
 "search_criteria": {
 "filter_groups": [
 {
 "filters": [
 {
 "field": "attribute_code",
 "value": "size",
 "condition_type": "eq"
 },
 {
 "field": "attribute_code",
 "value": "color",
 "condition_type": "eq"
 }
 ]
 }
 ]
 },
 "total_count": 0
}

But when I hit the single filter one, I get results for both size as well as color.

Single filter:

http://192.168.1.180/magento/index.php/rest/V1/products/attributes?searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color&searchCriteria[filter_groups][0][filters][0][condition_type]=eq

UPDATE: Tried the in filter but still no results

{
 "items": [],
 "search_criteria": {
 "filter_groups": [
 {
 "filters": [
 {
 "field": "attribute_code",
 "value": "color,size",
 "condition_type": "in"
 }
 ]
 }
 ]
 },
 "total_count": 0
}

UPDATE 2: Tried "in" in different filters

{
 "items": [],
 "search_criteria": {
 "filter_groups": [
 {
 "filters": [
 {
 "field": "attribute_code",
 "value": "color",
 "condition_type": "in"
 },
 {
 "field": "attribute_code",
 "value": "size",
 "condition_type": "in"
 }
 ]
 }
 ]
 },
 "total_count": 0
}

UPDATE 3: Tried "in" filter in separate filter groups

{
 "items": [],
 "search_criteria": {
 "filter_groups": [
 {
 "filters": [
 {
 "field": "attribute_code",
 "value": "color",
 "condition_type": "in"
 }
 ]
 },
 {
 "filters": [
 {
 "field": "attribute_code",
 "value": "size",
 "condition_type": "in"
 }
 ]
 }
 ]
 },
 "total_count": 0
}
asked Dec 22, 2015 at 11:24
3
  • What is expected output and what you get? Commented Dec 22, 2015 at 11:31
  • updated the question Commented Dec 22, 2015 at 11:33
  • @AlexPaliarush did you find anything on this ? Commented Dec 24, 2015 at 9:56

2 Answers 2

1

Here is the fix for the "in" problem, this will probably be fixed in next release: https://github.com/magento/magento2/commit/65819d2f61a63e4fa9fc978220f8662ee5472791

answered Mar 4, 2016 at 8:19
0

The problem seems to be that the same field is used in 2 filters of the same filter group. In this particular case replace 2 eq filters with one in filter:

searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color,size&searchCriteria[filter_groups][0][filters][0][condition_type]=in
answered Dec 22, 2015 at 13:11
11
  • I tried but still no results '{ "items": [], "search_criteria": { "filter_groups": [ { "filters": [ { "field": "attribute_code", "value": "color,size", "condition_type": "in" } ] } ] }, "total_count": 0 }' Commented Dec 23, 2015 at 6:03
  • Request seems to be correct. What if specify separately 'in' filter with value 'color' and then value 'size'? Commented Dec 24, 2015 at 10:00
  • Edited question with both the API response Commented Dec 24, 2015 at 11:57
  • I meant searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color&searchCriteria[filter_groups][0][filters][0][condition_type]=in Commented Dec 24, 2015 at 13:14
  • 1
    Not sure you can track internal tickets, but you can create a ticket here and put as a note that MAGETWO-47450 and MAGETWO-47451 are created internally. Commented Dec 29, 2015 at 10:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.