I have one category in system… For example EMT. There are many products assigned to it. Now I want to filter some products for particular customers for that category. I mean only specific products should be display in that category for some customers. It should display all the products to guest users.
How can I do that so all the collection should filter with proper layered navigation and toolbar collection.
Can anyone suggest the way to do this with files I need to override?
Best Answer
I assume you know how to write a plugin and how to write a script in Magento 2. With this in mind, the plan to have your issue resolved would be as follows:
add a product attribute that is a boolean and define for all your products whether they can be displayed to guests or not —> make it layered enabled
update all your products in your catalog with a script
in the block
\Magento\Catalog\Block\Product\ListProduct
, you may change the function that loads the products using a plugin on thefunction getLoadedProductCollection