0

On Magento 2.0.6 community Using multiple filters to perform an AND operation, I'm getting very unexpected results.

Reproducable steps:

1) Successful GET call to search for abandoned carts with a simple 1 filter group (updated_at greater than equal 2016-06-14):

.../rest/V1/carts/search?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]=2016-06-14&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq

Result of Step 1: Assumed result is correct, it fetched 6 carts (3 Active, 3 InActive).

{"items":[ {"id":384,"created_at":"2016-06-14 02:50:16","updated_at":"2016-06-14 02:59:30","is_active":true,"is_virtual":false,"items_count":1,"items_qty":2,"customer":{"email":null,"firstname":null,"lastname":null},"billing_address":{"id":787,"region":"Ohio","region_id":47,"region_code":"OH","country_id":"US","street":["1880 Quail Nest Ct"],"telephone":"317-496-4113","postcode":"45373","city":"Troy","firstname":"j","lastname":"c","email":null,"same_as_billing":0,"save_in_address_book":0},"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":3,"store_id":1} ,{"id":387,"created_at":"2016-06-14 11:38:10","updated_at":"2016-06-14 11:44:25","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":793,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":388,"created_at":"2016-06-14 11:45:24","updated_at":"2016-06-14 11:46:23","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":795,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":389,"created_at":"2016-06-14 11:46:58","updated_at":"2016-06-14 11:49:13","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":797,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":390,"created_at":"2016-06-14 11:50:00","updated_at":"2016-06-14 11:53:30","is_active":true,"is_virtual":false,"items_count":1,"items_qty":2,"customer":{"email":null,"firstname":null,"lastname":null},"billing_address":{"id":799,"region":"Alaska","region_id":2,"region_code":"AK","country_id":"US","street":["test"],"telephone":"1234567890","postcode":"35008","city":"test","firstname":"test","lastname":"test","email":null,"same_as_billing":0,"save_in_address_book":0},"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":3,"store_id":1} ,{"id":391,"created_at":"2016-06-14 11:53:54","updated_at":"2016-06-14 11:59:20","is_active":true,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"email":null,"firstname":null,"lastname":null},"billing_address":{"id":801,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112","city":"Brownsburg","firstname":"Andy","lastname":"Green","email":null,"same_as_billing":0,"save_in_address_book":0},"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":3,"store_id":1} ] ,"search_criteria":{"filter_groups":[{"filters":[{"field":"updated_at","value":"2016-06-14","condition_type":"gteq"}]}]},"total_count":6}

------------ 2) Performing a second query, adding an additional filter to narrow down the result (+ is_active equals true)

.../rest/V1/carts/search?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]=2016-06-14&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq&searchCriteria[filter_groups][1][filters][0][field]=is_active&searchCriteria[filter_groups][1][filters][0][value]=true&searchCriteria[filter_groups][1][filters][0][condition_type]=eq

Result of Step 2: Although POST transaction was successful, it fetched the exact opposite of what's expected, it returned the 3 carts whose is_active flags are false.

{"items":[ {"id":387,"created_at":"2016-06-14 11:38:10","updated_at":"2016-06-14 11:44:25","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":793,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":388,"created_at":"2016-06-14 11:45:24","updated_at":"2016-06-14 11:46:23","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":795,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":389,"created_at":"2016-06-14 11:46:58","updated_at":"2016-06-14 11:49:13","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":797,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ] ,"search_criteria":{"filter_groups":[{"filters":[{"field":"updated_at","value":"2016-06-14","condition_type":"gteq"}]},{"filters":[{"field":"is_active","value":"true","condition_type":"eq"}]}]},"total_count":3}

------------ 3) Changing the is_active filter value from true to false yielded the same 3 records whose is_active flags are FALSE (presumably generating a set of correct results).

{"items":[ {"id":387,"created_at":"2016-06-14 11:38:10","updated_at":"2016-06-14 11:44:25","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":793,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":388,"created_at":"2016-06-14 11:45:24","updated_at":"2016-06-14 11:46:23","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":795,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ,{"id":389,"created_at":"2016-06-14 11:46:58","updated_at":"2016-06-14 11:49:13","is_active":false,"is_virtual":false,"items_count":1,"items_qty":1,"customer":{"id":1,"group_id":4,"created_at":"2016-02-09 14:49:42","updated_at":"2016-06-14 11:49:33","created_in":"Default Store View","email":"andy@vergecommerce.com","firstname":"Andy","lastname":"Green","gender":1,"store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"IN","region":"Indiana","region_id":24},"region_id":24,"country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green"}],"disable_auto_group_change":0},"billing_address":{"id":797,"region":"Indiana","region_id":24,"region_code":"IN","country_id":"US","street":["619 Hummingbird Dr"],"telephone":"317-695-2566","postcode":"46112-7453","city":"Brownsburg","firstname":"Andy","lastname":"Green","customer_id":1,"email":"andy@vergecommerce.com","same_as_billing":0,"customer_address_id":1,"save_in_address_book":0},"reserved_order_id":0,"orig_order_id":0,"currency":{"global_currency_code":"USD","base_currency_code":"USD","store_currency_code":"USD","quote_currency_code":"USD","store_to_base_rate":0,"store_to_quote_rate":0,"base_to_global_rate":1,"base_to_quote_rate":1},"customer_is_guest":false,"customer_note_notify":true,"customer_tax_class_id":4,"store_id":1} ] ,"search_criteria":{"filter_groups":[{"filters":[{"field":"updated_at","value":"2016-06-14","condition_type":"gteq"}]},{"filters":[{"field":"is_active","value":"false","condition_type":"eq"}]}]},"total_count":3}


Why did the the additional filter condition is_active eq true generate the wrong set of results?

Thanks!

closed as unclear what you're asking by Amit Bera, Marius Jun 18 '16 at 11:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Let me try to summarize, when performing a search query for carts using a single filter condition "updated_at >= 2016-06-17". It returns 5 carts, 2 active, 3 Inactive. – immanuelp Jun 18 '16 at 22:52
1

I am fairly sure that you have encountered a bug that is similar to what has already been reported here as Repository Filter Groups Applied Inconsistently. I notice you have already reported your details as an issue on github as well. The code that should sort carts can be found in the getList method from the QuoteRepository here.

  • That could be Kristoff. And, yes, I re-posted the question on stackexchange to see if anyone else has run into the issue. – immanuelp Jun 18 '16 at 22:58
  • In my follow-up posting (summary description), it seems that there is a bug when M2 is applying those multiple filters, period. – immanuelp Jun 18 '16 at 23:04

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