How to disable category in magento 2 programmatically Planned maintenance scheduled April 23, 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
Using audio cues to encourage good posture
Why weren't discrete x86 CPUs ever used in game hardware?
Generate an RGB colour grid
Crossing US/Canada Border for less than 24 hours
What do you call the main part of a joke?
Sum letters are not two different
What initially awakened the Balrog?
How to tell that you are a giant?
Dating a Former Employee
Is a ledger board required if the side of my house is wood?
Is CEO the "profession" with the most psychopaths?
Question about debouncing - delay of state change
Project Euler #1 in C++
Did Krishna say in Bhagavad Gita "I am in every living being"
Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?
Why is Nikon 1.4g better when Nikon 1.8g is sharper?
SF book about people trapped in a series of worlds they imagine
How do living politicians protect their readily obtainable signatures from misuse?
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
What is the difference between globalisation and imperialism?
What would you call this weird metallic apparatus that allows you to lift people?
How does the math work when buying airline miles?
Is there a kind of relay only consumes power when switching?
What is the topology associated with the algebras for the ultrafilter monad?
How to disable category in magento 2 programmatically
Planned maintenance scheduled April 23, 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;
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
add a comment |
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
add a comment |
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
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
magento-2.1 category-products navigation
edited Jul 3 '18 at 7:02
Teja Bhagavan Kollepara
2,99241949
2,99241949
asked Mar 23 '17 at 9:36
The Lord Of The ShellsThe Lord Of The Shells
206
206
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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();
?>
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
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
?>
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
add a comment |
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();
?>
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
add a comment |
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();
?>
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();
?>
answered Mar 23 '17 at 10:20
Dinesh YadavDinesh Yadav
4,0931937
4,0931937
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Jul 3 '18 at 7:17
answered Jul 3 '18 at 6:54
GideonGideon
305316
305316
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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