cancel
Showing results for 
Search instead for 
Did you mean: 

How to Hide child category product from category product listing if parent category is anchored M2.3

How to Hide child category product from category product listing if parent category is anchored M2.3

Hi,

I need to implement a custom functionality, so that anchored category should not display the child category products on category listing page in frontend.

By default all the anchored category shows the child products automatically. I need to override this functionality.

 

Can anyone help how can I do this customization? Which class or function need to override. I am new to Magento and  tried to explore magento catalog module but not able to get that which function or class need to use.

 

Looking for some valuable response.

Thanks

3 REPLIES 3

Re: How to Hide child category product from category product listing if parent category is anchored

Hi,
Somehow I found that which class is responsible and need to override the function.

So, I found that the function addCategoryFilter() in Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection is responsible for this in Magento 2.4.2

I tried to override this using my custom module using preference but not able to override Fulltext/Collection.

Can anyone help and suggest how to override this?

Re: How to Hide child category product from category product listing if parent category is anchored

I have a woocommerce store on wordpress and I would like to hide a specific category from the frontapge store, I have managed to edit the functions.php file with a code snippet, this has worked to some extent but I would like to be able to access the products via the sub category, however when I navigate through teh sub category the products are  located at I am receiving the following error messge " No products were Speed Test  

Re: How to Hide child category product from category product listing if parent category is anchored


@tuktukange0fe6 wrote:

Hi,
Somehow I found that which class is responsible and need to override the function.

So, I found that the function addCategoryFilter() in Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection is responsible for this in Magento 2.4.2

I tried to override this using my custom module using preference but not able to override Fulltext/Collection.

Can anyone help and suggest how to override this?


Thanks for the information, I will try to figure it out for more. Keep sharing such informative post.