Filtering with magento2Custom store view range attribute can't be modified in admin panelChanging advanced...

Could gravitational lensing be used to protect a spaceship from a laser?

In a Spin are Both Wings Stalled?

Assassin's bullet with mercury

Today is the Center

Is Lorentz symmetry broken if SUSY is broken?

Will google still index a page if I use a $_SESSION variable?

What is the intuition behind short exact sequences of groups; in particular, what is the intuition behind group extensions?

Fully-Firstable Anagram Sets

Where does SFDX store details about scratch orgs?

Is it canonical bit space?

Why are electrically insulating heatsinks so rare? Is it just cost?

Etiquette around loan refinance - decision is going to cost first broker a lot of money

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Why is Collection not simply treated as Collection<?>

Blender 2.8 I can't see vertices, edges or faces in edit mode

Is "remove commented out code" correct English?

How to prevent "they're falling in love" trope

1960's book about a plague that kills all white people

How could indestructible materials be used in power generation?

Western buddy movie with a supernatural twist where a woman turns into an eagle at the end

A reference to a well-known characterization of scattered compact spaces

Can I ask the recruiters in my resume to put the reason why I am rejected?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?



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;
}







1















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'))









share|improve this question














bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    1















    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'))









    share|improve this question














    bumped to the homepage by Community 9 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      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'))









      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 29 '16 at 12:47









      Szymon SzczypkowskiSzymon Szczypkowski

      61




      61





      bumped to the homepage by Community 9 mins 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 9 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          try this



          $filter_group = [
          $this->filterGroupBuilder
          ->addFilter($filter[0])
          ->create(),
          $this->filterGroupBuilder
          ->addFilter($filter[1])
          ->addFilter($filter[2])
          ->create(),
          ];





          share|improve this answer
























          • 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



















          0














          This doesnt work anymore on 2.1.3
          https://github.com/magento/magento2/issues/8300



          Please reference that ticket






          share|improve this answer
























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            try this



            $filter_group = [
            $this->filterGroupBuilder
            ->addFilter($filter[0])
            ->create(),
            $this->filterGroupBuilder
            ->addFilter($filter[1])
            ->addFilter($filter[2])
            ->create(),
            ];





            share|improve this answer
























            • 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
















            0














            try this



            $filter_group = [
            $this->filterGroupBuilder
            ->addFilter($filter[0])
            ->create(),
            $this->filterGroupBuilder
            ->addFilter($filter[1])
            ->addFilter($filter[2])
            ->create(),
            ];





            share|improve this answer
























            • 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














            0












            0








            0







            try this



            $filter_group = [
            $this->filterGroupBuilder
            ->addFilter($filter[0])
            ->create(),
            $this->filterGroupBuilder
            ->addFilter($filter[1])
            ->addFilter($filter[2])
            ->create(),
            ];





            share|improve this answer













            try this



            $filter_group = [
            $this->filterGroupBuilder
            ->addFilter($filter[0])
            ->create(),
            $this->filterGroupBuilder
            ->addFilter($filter[1])
            ->addFilter($filter[2])
            ->create(),
            ];






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 29 '16 at 13:27









            cieminciemin

            120129




            120129













            • 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



















            • 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

















            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













            0














            This doesnt work anymore on 2.1.3
            https://github.com/magento/magento2/issues/8300



            Please reference that ticket






            share|improve this answer




























              0














              This doesnt work anymore on 2.1.3
              https://github.com/magento/magento2/issues/8300



              Please reference that ticket






              share|improve this answer


























                0












                0








                0







                This doesnt work anymore on 2.1.3
                https://github.com/magento/magento2/issues/8300



                Please reference that ticket






                share|improve this answer













                This doesnt work anymore on 2.1.3
                https://github.com/magento/magento2/issues/8300



                Please reference that ticket







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 27 '17 at 0:23









                CodeNinjaCodeNinja

                111




                111






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                    How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                    夢乃愛華...