How to disable category in magento 2 programmatically Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do display category icons/images when top-level category is selected?Adding attributes as a dropdown in Main Category NavigationShow category in left navigationParent category and subcategory of active parent categoryadding product to the left-category-navigation in magentoload product in perticular category in magentoOdd behaviour with category anchor and layered navagation in M2Magento 2: How to disable the sidebar for certain category?Magento 2.1: disable category filtersShow sibling child categories in left.phtml navigation in Magento 1.9

How is simplicity better than precision and clarity in prose?

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

Is drag coefficient lowest at zero angle of attack?

How to set letter above or below the symbol?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Slither Like a Snake

What do I do if technical issues prevent me from filing my return on time?

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

Is it possible to ask for a hotel room without minibar/extra services?

Area of a 2D convex hull

How are presidential pardons supposed to be used?

Are my PIs rude or am I just being too sensitive?

Single author papers against my advisor's will?

Can a non-EU citizen traveling with me come with me through the EU passport line?

How do I keep my slimes from escaping their pens?

Complexity of many constant time steps with occasional logarithmic steps

I'm having difficulty getting my players to do stuff in a sandbox campaign

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Can I throw a longsword at someone?

When is phishing education going too far?

3 doors, three guards, one stone

How can players take actions together that are impossible otherwise?



How to disable category in magento 2 programmatically



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How do display category icons/images when top-level category is selected?Adding attributes as a dropdown in Main Category NavigationShow category in left navigationParent category and subcategory of active parent categoryadding product to the left-category-navigation in magentoload product in perticular category in magentoOdd behaviour with category anchor and layered navagation in M2Magento 2: How to disable the sidebar for certain category?Magento 2.1: disable category filtersShow sibling child categories in left.phtml navigation in Magento 1.9



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








0















I would like to disable category from navigation bar under some conditions like for certain customer groups I would like to show certain categories. Is there any way to do that and how can I do that.










share|improve this question
















bumped to the homepage by Community 18 mins ago


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





















    0















    I would like to disable category from navigation bar under some conditions like for certain customer groups I would like to show certain categories. Is there any way to do that and how can I do that.










    share|improve this question
















    bumped to the homepage by Community 18 mins ago


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

















      0












      0








      0








      I would like to disable category from navigation bar under some conditions like for certain customer groups I would like to show certain categories. Is there any way to do that and how can I do that.










      share|improve this question
















      I would like to disable category from navigation bar under some conditions like for certain customer groups I would like to show certain categories. Is there any way to do that and how can I do that.







      magento-2.1 category-products navigation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 3 '18 at 7:02









      Teja Bhagavan Kollepara

      2,99341949




      2,99341949










      asked Mar 23 '17 at 9:36









      The Lord Of The ShellsThe Lord Of The Shells

      156




      156





      bumped to the homepage by Community 18 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 18 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














          You can disable the category with this code.



          <?php 

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $category_id = 'your_category_id';
          $collection = $objectManager ->get('MagentoCatalogModelCategory')->load($category_id);
          $collection->setData('is_active', 0);
          $collection->save();

          ?>





          share|improve this answer























          • Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

            – The Lord Of The Shells
            Mar 23 '17 at 10:24











          • You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

            – Dinesh Yadav
            Mar 23 '17 at 10:39











          • One more question. Do you know which event will be evoked when top menu is rendering?

            – The Lord Of The Shells
            Mar 23 '17 at 10:45











          • there are two events for category collection. 1. _load_before 2. _load_after

            – Dinesh Yadav
            Mar 23 '17 at 10:53



















          -1














          First, create a custom attribute for categories like "show for customer [group]" with yes-no field then you can make use of plugin/interceptor in Magento to achieve this. In the plugin, check the current customer group and filter the categories that are enabled with the custom attribute you just created.



          In this way, you can achieve your requirement. I think this is an ideal way to achieve this.






          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%2f165774%2fhow-to-disable-category-in-magento-2-programmatically%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














            You can disable the category with this code.



            <?php 

            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $category_id = 'your_category_id';
            $collection = $objectManager ->get('MagentoCatalogModelCategory')->load($category_id);
            $collection->setData('is_active', 0);
            $collection->save();

            ?>





            share|improve this answer























            • Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

              – The Lord Of The Shells
              Mar 23 '17 at 10:24











            • You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

              – Dinesh Yadav
              Mar 23 '17 at 10:39











            • One more question. Do you know which event will be evoked when top menu is rendering?

              – The Lord Of The Shells
              Mar 23 '17 at 10:45











            • there are two events for category collection. 1. _load_before 2. _load_after

              – Dinesh Yadav
              Mar 23 '17 at 10:53
















            0














            You can disable the category with this code.



            <?php 

            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $category_id = 'your_category_id';
            $collection = $objectManager ->get('MagentoCatalogModelCategory')->load($category_id);
            $collection->setData('is_active', 0);
            $collection->save();

            ?>





            share|improve this answer























            • Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

              – The Lord Of The Shells
              Mar 23 '17 at 10:24











            • You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

              – Dinesh Yadav
              Mar 23 '17 at 10:39











            • One more question. Do you know which event will be evoked when top menu is rendering?

              – The Lord Of The Shells
              Mar 23 '17 at 10:45











            • there are two events for category collection. 1. _load_before 2. _load_after

              – Dinesh Yadav
              Mar 23 '17 at 10:53














            0












            0








            0







            You can disable the category with this code.



            <?php 

            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $category_id = 'your_category_id';
            $collection = $objectManager ->get('MagentoCatalogModelCategory')->load($category_id);
            $collection->setData('is_active', 0);
            $collection->save();

            ?>





            share|improve this answer













            You can disable the category with this code.



            <?php 

            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $category_id = 'your_category_id';
            $collection = $objectManager ->get('MagentoCatalogModelCategory')->load($category_id);
            $collection->setData('is_active', 0);
            $collection->save();

            ?>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 23 '17 at 10:20









            Dinesh YadavDinesh Yadav

            4,0831937




            4,0831937












            • Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

              – The Lord Of The Shells
              Mar 23 '17 at 10:24











            • You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

              – Dinesh Yadav
              Mar 23 '17 at 10:39











            • One more question. Do you know which event will be evoked when top menu is rendering?

              – The Lord Of The Shells
              Mar 23 '17 at 10:45











            • there are two events for category collection. 1. _load_before 2. _load_after

              – Dinesh Yadav
              Mar 23 '17 at 10:53


















            • Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

              – The Lord Of The Shells
              Mar 23 '17 at 10:24











            • You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

              – Dinesh Yadav
              Mar 23 '17 at 10:39











            • One more question. Do you know which event will be evoked when top menu is rendering?

              – The Lord Of The Shells
              Mar 23 '17 at 10:45











            • there are two events for category collection. 1. _load_before 2. _load_after

              – Dinesh Yadav
              Mar 23 '17 at 10:53

















            Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

            – The Lord Of The Shells
            Mar 23 '17 at 10:24





            Is there any other way to disable category in navigation without changing is_active status? I just want to hide category with some conditions like customer group.

            – The Lord Of The Shells
            Mar 23 '17 at 10:24













            You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

            – Dinesh Yadav
            Mar 23 '17 at 10:39





            You can create a phtml file with above code and your desired conditions, and then call this phtml file in defau.xml of your theme. This might help you.

            – Dinesh Yadav
            Mar 23 '17 at 10:39













            One more question. Do you know which event will be evoked when top menu is rendering?

            – The Lord Of The Shells
            Mar 23 '17 at 10:45





            One more question. Do you know which event will be evoked when top menu is rendering?

            – The Lord Of The Shells
            Mar 23 '17 at 10:45













            there are two events for category collection. 1. _load_before 2. _load_after

            – Dinesh Yadav
            Mar 23 '17 at 10:53






            there are two events for category collection. 1. _load_before 2. _load_after

            – Dinesh Yadav
            Mar 23 '17 at 10:53














            -1














            First, create a custom attribute for categories like "show for customer [group]" with yes-no field then you can make use of plugin/interceptor in Magento to achieve this. In the plugin, check the current customer group and filter the categories that are enabled with the custom attribute you just created.



            In this way, you can achieve your requirement. I think this is an ideal way to achieve this.






            share|improve this answer





























              -1














              First, create a custom attribute for categories like "show for customer [group]" with yes-no field then you can make use of plugin/interceptor in Magento to achieve this. In the plugin, check the current customer group and filter the categories that are enabled with the custom attribute you just created.



              In this way, you can achieve your requirement. I think this is an ideal way to achieve this.






              share|improve this answer



























                -1












                -1








                -1







                First, create a custom attribute for categories like "show for customer [group]" with yes-no field then you can make use of plugin/interceptor in Magento to achieve this. In the plugin, check the current customer group and filter the categories that are enabled with the custom attribute you just created.



                In this way, you can achieve your requirement. I think this is an ideal way to achieve this.






                share|improve this answer















                First, create a custom attribute for categories like "show for customer [group]" with yes-no field then you can make use of plugin/interceptor in Magento to achieve this. In the plugin, check the current customer group and filter the categories that are enabled with the custom attribute you just created.



                In this way, you can achieve your requirement. I think this is an ideal way to achieve this.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 3 '18 at 7:17

























                answered Jul 3 '18 at 6:54









                GideonGideon

                305316




                305316



























                    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%2f165774%2fhow-to-disable-category-in-magento-2-programmatically%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

                    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

                    Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її