Hi everyone, I have a small question!
Filtering entities with php criteria is very strait forward, example:
$criteria->addFilter(new EqualsFilter('column1', 'searchString'));
but it only allows us to put a string in the second parameter!
But if I want to get all rows where two columns has the same value, the next example is what I want, but it does not work:
$criteria->addFilter(new EqualsFilter('column1', 'column2')); // this is not working
Does anyone knows how to solve it, or any work around!
Thanks a lot
Hello @omar.bakerly,
you can use the platform/MultiFilter.php at trunk · shopware/platform · GitHub
something like
$criteria->addFilter(
new MultiFilter(
MultiFilter::CONNECTION_AND,
[
new EqualsFilter('column1', 'searchString'),
new EqualsFilter('column2', 'searchString')
]
)
)
best regards
abdullah
Thanks a lot for your help, but that is not what I want!
In a table full of rows,
±----±--------±--------±-----------±-----------+
| id | column1 | column2 | created_at | updated_at |
±----±--------±--------±-----------±-----------+
| … | 55 | 55 | … | … |
±----±--------±--------±-----------±-----------+
| … | 16 | 27 | … | … |
±----±--------±--------±-----------±-----------+
| … | 62 | 62 | … | … |
±----±--------±--------±-----------±-----------+
I simply want the rows that have column1 = column2 , but I do NOT know what is the value in the columns! it could be anything.
Thanks again for your help!
ok now i understand what you want to achieve.
But I’m not sure if this works with the standard Shopware DAL filters.
You could use the Shopware platform/QueryBuilder.php at trunk · shopware/platform · GitHub to create your own query.
Okay, thanks a lot