Filtering with magento2Custom store view range attribute can't be modified in admin panelChanging advanced search results query - Magento 2Magento 2 - How to CAST & CONVERT Datatype VARCHAR to INT in query?Magento 2 Error: Base table or view not found: 1146 Table 'dbname.catalog_category_flat_store_1' doesn't existMagento indexing causing website downtimeMagento 2 - Get Swatch Image based on swatch labelHow to write inner join query in collection method (magento2)?Problem with SQLSTATE[42S22]: Column not foundMagento 2.2.5: How to alter main_table before a columnError Filtering grid from joined table collection
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
Watching something be written to a file live with tail
What mechanic is there to disable a threat instead of killing it?
Can a rocket refuel on Mars from water?
How can I fix/modify my tub/shower combo so the water comes out of the showerhead?
How is it possible to have an ability score that is less than 3?
Doing something right before you need it - expression for this?
Why can't we play rap on piano?
What does it mean to describe someone as a butt steak?
Why does Arabsat 6A need a Falcon Heavy to launch
Is "remove commented out code" correct English?
Is it legal for company to use my work email to pretend I still work there?
What's the difference between 'rename' and 'mv'?
Today is the Center
How can I tell someone that I want to be his or her friend?
Why do I get two different answers for this counting problem?
Western buddy movie with a supernatural twist where a woman turns into an eagle at the end
Arrow those variables!
What exploit are these user agents trying to use?
Emailing HOD to enhance faculty application
Brothers & sisters
Is the Joker left-handed?
Combinations of multiple lists
Will google still index a page if I use a $_SESSION variable?
Filtering with magento2
Custom store view range attribute can't be modified in admin panelChanging advanced search results query - Magento 2Magento 2 - How to CAST & CONVERT Datatype VARCHAR to INT in query?Magento 2 Error: Base table or view not found: 1146 Table 'dbname.catalog_category_flat_store_1' doesn't existMagento indexing causing website downtimeMagento 2 - Get Swatch Image based on swatch labelHow to write inner join query in collection method (magento2)?Problem with SQLSTATE[42S22]: Column not foundMagento 2.2.5: How to alter main_table before a columnError Filtering grid from joined table collection
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have problem with magento2 FilterGroupBuilder. I need to set filter where active_until date is between today and March 3 OR active_until before January 5. My code looks like:
public function dot4()
$filter[] = $this->filterBuilder
->setConditionType('gteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s"))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('March 3')))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lt')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('January 5')))
->create();
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
$this->searchCriteriaBuilder->setFilterGroups($filter_group);
$list = $this->vendorInterface->getList(
$this->searchCriteriaBuilder->create()
)->getItems();
return $list;
And MySQL query shows:
'SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:06:25')) AND ((`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))' (length=216)
If i change $filter_group to that structure:
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
Query:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') OR (`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))
But still it's not a solution...
So how to group filters to show query like this:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') AND (`active_until` <= '2016-03-03 00:00:00')) OR ((`active_until` < '2016-01-05 00:00:00'))
magento2 database
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have problem with magento2 FilterGroupBuilder. I need to set filter where active_until date is between today and March 3 OR active_until before January 5. My code looks like:
public function dot4()
$filter[] = $this->filterBuilder
->setConditionType('gteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s"))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('March 3')))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lt')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('January 5')))
->create();
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
$this->searchCriteriaBuilder->setFilterGroups($filter_group);
$list = $this->vendorInterface->getList(
$this->searchCriteriaBuilder->create()
)->getItems();
return $list;
And MySQL query shows:
'SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:06:25')) AND ((`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))' (length=216)
If i change $filter_group to that structure:
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
Query:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') OR (`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))
But still it's not a solution...
So how to group filters to show query like this:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') AND (`active_until` <= '2016-03-03 00:00:00')) OR ((`active_until` < '2016-01-05 00:00:00'))
magento2 database
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have problem with magento2 FilterGroupBuilder. I need to set filter where active_until date is between today and March 3 OR active_until before January 5. My code looks like:
public function dot4()
$filter[] = $this->filterBuilder
->setConditionType('gteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s"))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('March 3')))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lt')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('January 5')))
->create();
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
$this->searchCriteriaBuilder->setFilterGroups($filter_group);
$list = $this->vendorInterface->getList(
$this->searchCriteriaBuilder->create()
)->getItems();
return $list;
And MySQL query shows:
'SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:06:25')) AND ((`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))' (length=216)
If i change $filter_group to that structure:
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
Query:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') OR (`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))
But still it's not a solution...
So how to group filters to show query like this:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') AND (`active_until` <= '2016-03-03 00:00:00')) OR ((`active_until` < '2016-01-05 00:00:00'))
magento2 database
I have problem with magento2 FilterGroupBuilder. I need to set filter where active_until date is between today and March 3 OR active_until before January 5. My code looks like:
public function dot4()
$filter[] = $this->filterBuilder
->setConditionType('gteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s"))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lteq')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('March 3')))
->create();
$filter[] = $this->filterBuilder
->setConditionType('lt')
->setField('active_until')
->setValue(date("Y-m-d H:i:s", strtotime('January 5')))
->create();
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
$this->searchCriteriaBuilder->setFilterGroups($filter_group);
$list = $this->vendorInterface->getList(
$this->searchCriteriaBuilder->create()
)->getItems();
return $list;
And MySQL query shows:
'SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:06:25')) AND ((`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))' (length=216)
If i change $filter_group to that structure:
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->addFilter($filter[1])
->create(),
$this->filterGroupBuilder
->addFilter($filter[2])
->create(),
];
Query:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') OR (`active_until` <= '2016-03-03 00:00:00')) AND ((`active_until` < '2016-01-05 00:00:00'))
But still it's not a solution...
So how to group filters to show query like this:
SELECT `main_table`.* FROM `Training5_VendorRepository` AS `main_table` WHERE ((`active_until` >= '2016-01-29 12:13:38') AND (`active_until` <= '2016-03-03 00:00:00')) OR ((`active_until` < '2016-01-05 00:00:00'))
magento2 database
magento2 database
asked Jan 29 '16 at 12:47
Szymon SzczypkowskiSzymon Szczypkowski
61
61
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
try this
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->addFilter($filter[2])
->create(),
];
It shows: SELECTmain_table
.* FROMTraining5_VendorRepository
ASmain_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.
– Szymon Szczypkowski
Jan 29 '16 at 13:42
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
add a comment |
This doesnt work anymore on 2.1.3
https://github.com/magento/magento2/issues/8300
Please reference that ticket
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f99575%2ffiltering-with-magento2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->addFilter($filter[2])
->create(),
];
It shows: SELECTmain_table
.* FROMTraining5_VendorRepository
ASmain_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.
– Szymon Szczypkowski
Jan 29 '16 at 13:42
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
add a comment |
try this
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->addFilter($filter[2])
->create(),
];
It shows: SELECTmain_table
.* FROMTraining5_VendorRepository
ASmain_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.
– Szymon Szczypkowski
Jan 29 '16 at 13:42
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
add a comment |
try this
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->addFilter($filter[2])
->create(),
];
try this
$filter_group = [
$this->filterGroupBuilder
->addFilter($filter[0])
->create(),
$this->filterGroupBuilder
->addFilter($filter[1])
->addFilter($filter[2])
->create(),
];
answered Jan 29 '16 at 13:27
cieminciemin
120129
120129
It shows: SELECTmain_table
.* FROMTraining5_VendorRepository
ASmain_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.
– Szymon Szczypkowski
Jan 29 '16 at 13:42
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
add a comment |
It shows: SELECTmain_table
.* FROMTraining5_VendorRepository
ASmain_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.
– Szymon Szczypkowski
Jan 29 '16 at 13:42
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
It shows: SELECT
main_table
.* FROM Training5_VendorRepository
AS main_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.– Szymon Szczypkowski
Jan 29 '16 at 13:42
It shows: SELECT
main_table
.* FROM Training5_VendorRepository
AS main_table
WHERE ((active_until
>= '2016-01-29 13:31:12')) AND ((active_until
<= '2016-03-03 00:00:00') OR (active_until
< '2016-01-05 00:00:00')) but still don't show (active_until
< '2016-01-05 00:00:00') rows.– Szymon Szczypkowski
Jan 29 '16 at 13:42
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
I believe your query is [p v (q ^ r)]. Its equal to [(p v q) ^ (p v r)] and this one you can create with searchCriteriaBuilder.
– ciemin
Jan 29 '16 at 15:46
add a comment |
This doesnt work anymore on 2.1.3
https://github.com/magento/magento2/issues/8300
Please reference that ticket
add a comment |
This doesnt work anymore on 2.1.3
https://github.com/magento/magento2/issues/8300
Please reference that ticket
add a comment |
This doesnt work anymore on 2.1.3
https://github.com/magento/magento2/issues/8300
Please reference that ticket
This doesnt work anymore on 2.1.3
https://github.com/magento/magento2/issues/8300
Please reference that ticket
answered Jan 27 '17 at 0:23
CodeNinjaCodeNinja
111
111
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f99575%2ffiltering-with-magento2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown