Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchCriteria too limited in AND/OR filtering #4060

Closed
samtay opened this issue Apr 8, 2016 · 6 comments
Closed

SearchCriteria too limited in AND/OR filtering #4060

samtay opened this issue Apr 8, 2016 · 6 comments

Comments

@samtay
Copy link

samtay commented Apr 8, 2016

From what I understand, filters are combined with an OR logic within a particular filter group, and filter groups are combined with AND logic within search criteria. This is unfortunately not listed in documentation, but is what users on stackoverflow have discovered.

This is very limiting. For example, it is impossible to filter the product repository by two date intervals: suppose I want to grab all the products that are either new or on sale. This would involve logic like so:

(filter['special_price_from', 'to', $now] && filter['special_price_to', 'from', $now])
|| (filter['news_from_date', 'to', $now] && filter['news_to_date', 'from', $now])

But this is impossible to build as searchCriteria. The outer OR would dictate that everything needs to be in one filter group, but within each interval we also need AND combinations, which are impossible within one filter group. Because of these limitations, I have been forced to use collections directly instead of using the repository abstraction layer. Please let me know if there is a more flexible way to have and/or combinations.

@pboisvert
Copy link

@choukalos can you take a look at this one Chuck?

@choukalos
Copy link

Hello @samtay you are correct that's how search criteria works doc link.

What would you like to see for search criteria?

I've created an epic to track this request internally ( MAGETWO-53564 ).

@samtay
Copy link
Author

samtay commented May 27, 2016

Ability to specify nested and/or logic, see above example.

@choukalos
Copy link

Thanks @samtay for the insight. We're tracking internally.

For those on this thread, a change to search criteria would be a breaking change; how big of an impact would this be for you all?

@Ctucker9233
Copy link

@choukalos What do you mean by breaking change? If it breaks the search criteria so it doesn't work that would have a very negative impact. But maybe I don't fully understand the question you are asking.

@vkorotun vkorotun removed the PS label Aug 4, 2016
@piotrekkaminski
Copy link
Contributor

Thank you for your submission.

We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues.

Feature Requests and Improvements should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here).

We are closing this GitHub ticket and have moved your request to the new forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants