Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?
Colliding particles and activation energy
Historically, were women trained for obligatory wars? Or did they serve some other military function?
Is it possible to Ready a spell to be cast just before the start of your next turn by having the trigger be an ally's attack?
Sci-fi novel series with instant travel between planets through gates. A river runs through the gates
Why do Ichisongas hate elephants and hippos?
Find the coordinate of two line segments that are perpendicular
Why does processed meat contain preservatives, while canned fish needs not?
What does 「再々起」mean?
How to pass attribute when redirecting from lwc to aura component
What does YCWCYODFTRFDTY mean?
Can fracking help reduce CO2?
Why do I get a BootstrapMethodError when trying to call a super class's protected method using method reference from an inner class?
Need help understanding harmonic series and intervals
Do I have an "anti-research" personality?
Given what happens in Endgame, why doesn't Dormammu come back to attack the universe?
How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?
How to back up a running remote server?
Will tsunami waves travel forever if there was no land?
Please, smoke with good manners
Past Perfect Tense
Is thermodynamics only applicable to systems in equilibrium?
Unexpected email from Yorkshire Bank
Stark VS Thanos
What is the difference between `a[bc]d` (brackets) and `ab,cd` (braces)?
Magento2 - How to hide price filter only in specific categories?
Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to hide price filter on some of my category pages.
Can anyone tell me how can I achieve this?
Thanks In Advance..!
magento2 layered-navigation filtered-nav
add a comment |
I want to hide price filter on some of my category pages.
Can anyone tell me how can I achieve this?
Thanks In Advance..!
magento2 layered-navigation filtered-nav
add a comment |
I want to hide price filter on some of my category pages.
Can anyone tell me how can I achieve this?
Thanks In Advance..!
magento2 layered-navigation filtered-nav
I want to hide price filter on some of my category pages.
Can anyone tell me how can I achieve this?
Thanks In Advance..!
magento2 layered-navigation filtered-nav
magento2 layered-navigation filtered-nav
edited Apr 25 at 8:02
Sanjay Gohil
580215
580215
asked Apr 25 at 7:24
YogitaYogita
313215
313215
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
I think you can try using this code
app/design/frontend/YOURPACKAGE/YOURTEMPLATE>template>catalog/layer/view.phtml
<?php if($_filter->getItemsCount()):?>
<?php $show=1;?>
<!-- curern filter price and currentc Cat match -->
<?php if($_filter->getFilter()->getRequestVar()!=='price')?>
<?php if(Mage::registry('current_category') &&(Mage::registry('current_category')->getId()==$catId)):
$show=0;
endif;
?>
<?php ?>
<!-- check show
<?php if($show==1)?>
<?php echo $_filter->getHtml() ?>
<?php ?>
<?php endif;?>
Or you can also refer to this link
add a comment |
Navigate to the following file
app/design/frontend/vendor/your_theme/Magento_LayeredNavigation/templates/layer/view.phtml
Add your logic around the foreach function of $block->getFilters() as shown below
<?php
// create an array of the category ids in which you don't want the price filter
$restricted_categories = [3, 4, 10, 14];
$currentCategoryId = $block->getLayer()->getCurrentCategory()->getId();
?>
.....
.....
.....
<?php foreach ($block->getFilters() as $filter): ?>
<?php
if (in_array($currentCategoryId, $restricted_categories) && $filter->getRequestVar() == 'price')
continue;
?>
.....
.....
.....
<?php endforeach; ?>
Note: It seems that you are using any third party extension for Layered Navigation. If so, you have to use this code in the file of your extension.
add a comment |
You can try using following code. I have created a plugin in custom module.
app/code/Anshu/HideFilters/registration.php
<?php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_HideFilters',
__DIR__
);
app/code/Anshu/HideFilters/etc/module.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_HideFilters">
<sequence>
<module name="Magento_Catalog" />
</sequence>
</module>
</config>
app/code/Anshu/HideFilters/etc/di.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogModelLayerFilterList">
<plugin name="hideFilters_plugin" type="AnshuHideFiltersPluginFilterPlugin" />
</type>
</config>
app/code/Anshu/HideFilters/Plugin/FilterPlugin.php
<?php
declare(strict_types=1);
namespace AnshuHideFiltersPlugin;
use MagentoCatalogModelLayerFilterList;
use MagentoFrameworkAppRequestHttp;
class FilterPlugin
/**
* @var Http
*/
private $request;
public function __construct(
Http $request
)
$this->request = $request;
public function afterGetFilters(FilterList $subject, $result)
$catId = $this->request->getParam('id');
if($catId != '21')
return $result;
$count = 0;
foreach ($result as $r)
if($r->getName() == 'Price')
unset($result[$count]);
return $result;
$count++;
Here I am hiding Price filter for category with ID 21.
Modify it according to your requirement.
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%2f272382%2fmagento2-how-to-hide-price-filter-only-in-specific-categories%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you can try using this code
app/design/frontend/YOURPACKAGE/YOURTEMPLATE>template>catalog/layer/view.phtml
<?php if($_filter->getItemsCount()):?>
<?php $show=1;?>
<!-- curern filter price and currentc Cat match -->
<?php if($_filter->getFilter()->getRequestVar()!=='price')?>
<?php if(Mage::registry('current_category') &&(Mage::registry('current_category')->getId()==$catId)):
$show=0;
endif;
?>
<?php ?>
<!-- check show
<?php if($show==1)?>
<?php echo $_filter->getHtml() ?>
<?php ?>
<?php endif;?>
Or you can also refer to this link
add a comment |
I think you can try using this code
app/design/frontend/YOURPACKAGE/YOURTEMPLATE>template>catalog/layer/view.phtml
<?php if($_filter->getItemsCount()):?>
<?php $show=1;?>
<!-- curern filter price and currentc Cat match -->
<?php if($_filter->getFilter()->getRequestVar()!=='price')?>
<?php if(Mage::registry('current_category') &&(Mage::registry('current_category')->getId()==$catId)):
$show=0;
endif;
?>
<?php ?>
<!-- check show
<?php if($show==1)?>
<?php echo $_filter->getHtml() ?>
<?php ?>
<?php endif;?>
Or you can also refer to this link
add a comment |
I think you can try using this code
app/design/frontend/YOURPACKAGE/YOURTEMPLATE>template>catalog/layer/view.phtml
<?php if($_filter->getItemsCount()):?>
<?php $show=1;?>
<!-- curern filter price and currentc Cat match -->
<?php if($_filter->getFilter()->getRequestVar()!=='price')?>
<?php if(Mage::registry('current_category') &&(Mage::registry('current_category')->getId()==$catId)):
$show=0;
endif;
?>
<?php ?>
<!-- check show
<?php if($show==1)?>
<?php echo $_filter->getHtml() ?>
<?php ?>
<?php endif;?>
Or you can also refer to this link
I think you can try using this code
app/design/frontend/YOURPACKAGE/YOURTEMPLATE>template>catalog/layer/view.phtml
<?php if($_filter->getItemsCount()):?>
<?php $show=1;?>
<!-- curern filter price and currentc Cat match -->
<?php if($_filter->getFilter()->getRequestVar()!=='price')?>
<?php if(Mage::registry('current_category') &&(Mage::registry('current_category')->getId()==$catId)):
$show=0;
endif;
?>
<?php ?>
<!-- check show
<?php if($show==1)?>
<?php echo $_filter->getHtml() ?>
<?php ?>
<?php endif;?>
Or you can also refer to this link
answered Apr 25 at 9:30
surbhi agrsurbhi agr
41411
41411
add a comment |
add a comment |
Navigate to the following file
app/design/frontend/vendor/your_theme/Magento_LayeredNavigation/templates/layer/view.phtml
Add your logic around the foreach function of $block->getFilters() as shown below
<?php
// create an array of the category ids in which you don't want the price filter
$restricted_categories = [3, 4, 10, 14];
$currentCategoryId = $block->getLayer()->getCurrentCategory()->getId();
?>
.....
.....
.....
<?php foreach ($block->getFilters() as $filter): ?>
<?php
if (in_array($currentCategoryId, $restricted_categories) && $filter->getRequestVar() == 'price')
continue;
?>
.....
.....
.....
<?php endforeach; ?>
Note: It seems that you are using any third party extension for Layered Navigation. If so, you have to use this code in the file of your extension.
add a comment |
Navigate to the following file
app/design/frontend/vendor/your_theme/Magento_LayeredNavigation/templates/layer/view.phtml
Add your logic around the foreach function of $block->getFilters() as shown below
<?php
// create an array of the category ids in which you don't want the price filter
$restricted_categories = [3, 4, 10, 14];
$currentCategoryId = $block->getLayer()->getCurrentCategory()->getId();
?>
.....
.....
.....
<?php foreach ($block->getFilters() as $filter): ?>
<?php
if (in_array($currentCategoryId, $restricted_categories) && $filter->getRequestVar() == 'price')
continue;
?>
.....
.....
.....
<?php endforeach; ?>
Note: It seems that you are using any third party extension for Layered Navigation. If so, you have to use this code in the file of your extension.
add a comment |
Navigate to the following file
app/design/frontend/vendor/your_theme/Magento_LayeredNavigation/templates/layer/view.phtml
Add your logic around the foreach function of $block->getFilters() as shown below
<?php
// create an array of the category ids in which you don't want the price filter
$restricted_categories = [3, 4, 10, 14];
$currentCategoryId = $block->getLayer()->getCurrentCategory()->getId();
?>
.....
.....
.....
<?php foreach ($block->getFilters() as $filter): ?>
<?php
if (in_array($currentCategoryId, $restricted_categories) && $filter->getRequestVar() == 'price')
continue;
?>
.....
.....
.....
<?php endforeach; ?>
Note: It seems that you are using any third party extension for Layered Navigation. If so, you have to use this code in the file of your extension.
Navigate to the following file
app/design/frontend/vendor/your_theme/Magento_LayeredNavigation/templates/layer/view.phtml
Add your logic around the foreach function of $block->getFilters() as shown below
<?php
// create an array of the category ids in which you don't want the price filter
$restricted_categories = [3, 4, 10, 14];
$currentCategoryId = $block->getLayer()->getCurrentCategory()->getId();
?>
.....
.....
.....
<?php foreach ($block->getFilters() as $filter): ?>
<?php
if (in_array($currentCategoryId, $restricted_categories) && $filter->getRequestVar() == 'price')
continue;
?>
.....
.....
.....
<?php endforeach; ?>
Note: It seems that you are using any third party extension for Layered Navigation. If so, you have to use this code in the file of your extension.
answered Apr 25 at 9:46
Dinesh YadavDinesh Yadav
4,1031937
4,1031937
add a comment |
add a comment |
You can try using following code. I have created a plugin in custom module.
app/code/Anshu/HideFilters/registration.php
<?php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_HideFilters',
__DIR__
);
app/code/Anshu/HideFilters/etc/module.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_HideFilters">
<sequence>
<module name="Magento_Catalog" />
</sequence>
</module>
</config>
app/code/Anshu/HideFilters/etc/di.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogModelLayerFilterList">
<plugin name="hideFilters_plugin" type="AnshuHideFiltersPluginFilterPlugin" />
</type>
</config>
app/code/Anshu/HideFilters/Plugin/FilterPlugin.php
<?php
declare(strict_types=1);
namespace AnshuHideFiltersPlugin;
use MagentoCatalogModelLayerFilterList;
use MagentoFrameworkAppRequestHttp;
class FilterPlugin
/**
* @var Http
*/
private $request;
public function __construct(
Http $request
)
$this->request = $request;
public function afterGetFilters(FilterList $subject, $result)
$catId = $this->request->getParam('id');
if($catId != '21')
return $result;
$count = 0;
foreach ($result as $r)
if($r->getName() == 'Price')
unset($result[$count]);
return $result;
$count++;
Here I am hiding Price filter for category with ID 21.
Modify it according to your requirement.
add a comment |
You can try using following code. I have created a plugin in custom module.
app/code/Anshu/HideFilters/registration.php
<?php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_HideFilters',
__DIR__
);
app/code/Anshu/HideFilters/etc/module.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_HideFilters">
<sequence>
<module name="Magento_Catalog" />
</sequence>
</module>
</config>
app/code/Anshu/HideFilters/etc/di.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogModelLayerFilterList">
<plugin name="hideFilters_plugin" type="AnshuHideFiltersPluginFilterPlugin" />
</type>
</config>
app/code/Anshu/HideFilters/Plugin/FilterPlugin.php
<?php
declare(strict_types=1);
namespace AnshuHideFiltersPlugin;
use MagentoCatalogModelLayerFilterList;
use MagentoFrameworkAppRequestHttp;
class FilterPlugin
/**
* @var Http
*/
private $request;
public function __construct(
Http $request
)
$this->request = $request;
public function afterGetFilters(FilterList $subject, $result)
$catId = $this->request->getParam('id');
if($catId != '21')
return $result;
$count = 0;
foreach ($result as $r)
if($r->getName() == 'Price')
unset($result[$count]);
return $result;
$count++;
Here I am hiding Price filter for category with ID 21.
Modify it according to your requirement.
add a comment |
You can try using following code. I have created a plugin in custom module.
app/code/Anshu/HideFilters/registration.php
<?php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_HideFilters',
__DIR__
);
app/code/Anshu/HideFilters/etc/module.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_HideFilters">
<sequence>
<module name="Magento_Catalog" />
</sequence>
</module>
</config>
app/code/Anshu/HideFilters/etc/di.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogModelLayerFilterList">
<plugin name="hideFilters_plugin" type="AnshuHideFiltersPluginFilterPlugin" />
</type>
</config>
app/code/Anshu/HideFilters/Plugin/FilterPlugin.php
<?php
declare(strict_types=1);
namespace AnshuHideFiltersPlugin;
use MagentoCatalogModelLayerFilterList;
use MagentoFrameworkAppRequestHttp;
class FilterPlugin
/**
* @var Http
*/
private $request;
public function __construct(
Http $request
)
$this->request = $request;
public function afterGetFilters(FilterList $subject, $result)
$catId = $this->request->getParam('id');
if($catId != '21')
return $result;
$count = 0;
foreach ($result as $r)
if($r->getName() == 'Price')
unset($result[$count]);
return $result;
$count++;
Here I am hiding Price filter for category with ID 21.
Modify it according to your requirement.
You can try using following code. I have created a plugin in custom module.
app/code/Anshu/HideFilters/registration.php
<?php
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_HideFilters',
__DIR__
);
app/code/Anshu/HideFilters/etc/module.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_HideFilters">
<sequence>
<module name="Magento_Catalog" />
</sequence>
</module>
</config>
app/code/Anshu/HideFilters/etc/di.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogModelLayerFilterList">
<plugin name="hideFilters_plugin" type="AnshuHideFiltersPluginFilterPlugin" />
</type>
</config>
app/code/Anshu/HideFilters/Plugin/FilterPlugin.php
<?php
declare(strict_types=1);
namespace AnshuHideFiltersPlugin;
use MagentoCatalogModelLayerFilterList;
use MagentoFrameworkAppRequestHttp;
class FilterPlugin
/**
* @var Http
*/
private $request;
public function __construct(
Http $request
)
$this->request = $request;
public function afterGetFilters(FilterList $subject, $result)
$catId = $this->request->getParam('id');
if($catId != '21')
return $result;
$count = 0;
foreach ($result as $r)
if($r->getName() == 'Price')
unset($result[$count]);
return $result;
$count++;
Here I am hiding Price filter for category with ID 21.
Modify it according to your requirement.
answered Apr 25 at 10:49
Anshu MishraAnshu Mishra
5,70652763
5,70652763
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%2f272382%2fmagento2-how-to-hide-price-filter-only-in-specific-categories%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