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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form