Magento 2 - Multiple categories filter on product collectionFilter product collection by multiple categories?Filter Product Collection by BOTH multiple catgeoriesMagento2: Filter product collection by product attributeExcluding products from multiple categories in collectionMagento 2: Filter Product Collection by Multiple Categories (Magento 2.1)Magento 2 get out of stock products in collectionFilter Product Collection by Child product attributemagento 2 get product collection with custom filter on product listing pageFilter product collection by sku or namehow to use filters for new collection

A curve pass via points at TiKz

Why was Endgame Thanos so different than Infinity War Thanos?

How are one-time password generators like Google Authenticator different from having two passwords?

Why was Thor doubtful about his worthiness to Mjolnir?

SSD - Disk is OK, one bad sector

Page contents aligning weirdly in LaTeX/Overleaf

How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?

Size of a folder with du

How to Access data returned from Apex class in JS controller using Lightning web component

How to slow yourself down (for playing nice with others)

What's the word for the soldier salute?

Why not just directly invest in the holdings of an ETF?

Reaction of borax with NaOH

How to minimise the cost of guessing a number in a high/low guess game?

Why is “Ich wusste, dass aus dir mal was wird” grammitally correct?

How could a Lich maintain the appearance of being alive without magic?

Was there ever any real use for a 6800-based Apple I?

How to compact two the parabol commands in the following example?

Surely they can fit?

Ex-manager wants to stay in touch, I don't want to

Light Switch Terminals

Two researchers want to work on the same extension to my paper. Who to help?

How does noise-cancellation work in Mac laptops?

Proof that the inverse image of a single element is a discrete space



Magento 2 - Multiple categories filter on product collection


Filter product collection by multiple categories?Filter Product Collection by BOTH multiple catgeoriesMagento2: Filter product collection by product attributeExcluding products from multiple categories in collectionMagento 2: Filter Product Collection by Multiple Categories (Magento 2.1)Magento 2 get out of stock products in collectionFilter Product Collection by Child product attributemagento 2 get product collection with custom filter on product listing pageFilter product collection by sku or namehow to use filters for new collection






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have a product collection $collection which is created by MagentoCatalogModelResourceModelProductCollection



code is:



$collection = $objectManager->create('MagentoCatalogModelResourceModelProductCollection');
$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter('status', array('eq' => MagentoCatalogModelProductAttributeSourceStatus::STATUS_ENABLED));


How can I add multiple category filter in it?










share|improve this question







New contributor



Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    3















    I have a product collection $collection which is created by MagentoCatalogModelResourceModelProductCollection



    code is:



    $collection = $objectManager->create('MagentoCatalogModelResourceModelProductCollection');
    $collection->addAttributeToSelect('*');
    $collection->addAttributeToFilter('status', array('eq' => MagentoCatalogModelProductAttributeSourceStatus::STATUS_ENABLED));


    How can I add multiple category filter in it?










    share|improve this question







    New contributor



    Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      3












      3








      3








      I have a product collection $collection which is created by MagentoCatalogModelResourceModelProductCollection



      code is:



      $collection = $objectManager->create('MagentoCatalogModelResourceModelProductCollection');
      $collection->addAttributeToSelect('*');
      $collection->addAttributeToFilter('status', array('eq' => MagentoCatalogModelProductAttributeSourceStatus::STATUS_ENABLED));


      How can I add multiple category filter in it?










      share|improve this question







      New contributor



      Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have a product collection $collection which is created by MagentoCatalogModelResourceModelProductCollection



      code is:



      $collection = $objectManager->create('MagentoCatalogModelResourceModelProductCollection');
      $collection->addAttributeToSelect('*');
      $collection->addAttributeToFilter('status', array('eq' => MagentoCatalogModelProductAttributeSourceStatus::STATUS_ENABLED));


      How can I add multiple category filter in it?







      magento2 collection






      share|improve this question







      New contributor



      Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked May 8 at 9:15









      Shan AtifShan Atif

      468




      468




      New contributor



      Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      Shan Atif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          First of all, do not use object manager, create your object from constructor



          $protected $collection;

          public function __construct(
          ...
          MagentoCatalogModelResourceModelProductCollection $collection
          ...
          )

          ...
          $this->collection = $collection;
          ...



          For your category filter use this:



          $categories = "12,13,14"; //Comma separated category IDs
          $collection->addCategoriesFilter(array('in' => $categories));


          Collection will join category table and will add your filter






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



            );






            Shan Atif is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273806%2fmagento-2-multiple-categories-filter-on-product-collection%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            First of all, do not use object manager, create your object from constructor



            $protected $collection;

            public function __construct(
            ...
            MagentoCatalogModelResourceModelProductCollection $collection
            ...
            )

            ...
            $this->collection = $collection;
            ...



            For your category filter use this:



            $categories = "12,13,14"; //Comma separated category IDs
            $collection->addCategoriesFilter(array('in' => $categories));


            Collection will join category table and will add your filter






            share|improve this answer



























              0














              First of all, do not use object manager, create your object from constructor



              $protected $collection;

              public function __construct(
              ...
              MagentoCatalogModelResourceModelProductCollection $collection
              ...
              )

              ...
              $this->collection = $collection;
              ...



              For your category filter use this:



              $categories = "12,13,14"; //Comma separated category IDs
              $collection->addCategoriesFilter(array('in' => $categories));


              Collection will join category table and will add your filter






              share|improve this answer

























                0












                0








                0







                First of all, do not use object manager, create your object from constructor



                $protected $collection;

                public function __construct(
                ...
                MagentoCatalogModelResourceModelProductCollection $collection
                ...
                )

                ...
                $this->collection = $collection;
                ...



                For your category filter use this:



                $categories = "12,13,14"; //Comma separated category IDs
                $collection->addCategoriesFilter(array('in' => $categories));


                Collection will join category table and will add your filter






                share|improve this answer













                First of all, do not use object manager, create your object from constructor



                $protected $collection;

                public function __construct(
                ...
                MagentoCatalogModelResourceModelProductCollection $collection
                ...
                )

                ...
                $this->collection = $collection;
                ...



                For your category filter use this:



                $categories = "12,13,14"; //Comma separated category IDs
                $collection->addCategoriesFilter(array('in' => $categories));


                Collection will join category table and will add your filter







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 8 at 9:19









                Shoaib MunirShoaib Munir

                2,98431141




                2,98431141




















                    Shan Atif is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    Shan Atif is a new contributor. Be nice, and check out our Code of Conduct.












                    Shan Atif is a new contributor. Be nice, and check out our Code of Conduct.











                    Shan Atif is a new contributor. Be nice, and check out our Code of Conduct.














                    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%2f273806%2fmagento-2-multiple-categories-filter-on-product-collection%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

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?