1

I am working on custom module for catalog access. It requires only logged in customer to access the assigned category products.

Right now in catalog search result, product collection displays all the category products, but I need to display only selected category products.

See below Example

Suppose customer A has access to only categories Men > Tops > Tshirts. So, he will only see Men > Tops > Tshirts products in catalog search in magento 2. In search results only assigned categories products should display and not any other category products.

0

I had a similar requirement to restrict the access to products in search result based on some customer attribute.

There are 2 classes responsible to filter and build the query for catalog search namely Magento\CatalogSearch\Model\Search\IndexBuilder and Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match, You can add plugin/override to the methods IndexBuilder::build and the method Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match::build to apply the required logic.

  • I have checked but I can't see any category condition here, can you please give me some more ideas for categories access restriction. – Suresh Chikani Aug 1 '17 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.