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;








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 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.





















    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 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.

















      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 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.






















          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

                    Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

                    Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

                    How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2