I associate all my products to at least 1 category (visible from menu) + 1 'special' category (not visible from menu). There are many 'special' categories, they are special because not visible form menu, and because I associate 2 special categories to each my registered customer. (they're aware, no secrete). When a registered customer visit any category page (frontend) or when he makes a search, I'd like to always filter products based on the 2 special categories this customer is associated to! Basically a customer can visit any category, but shall only see products which belong to that category AND one of the 2 special categories assigned to him.

Let's say "customer 1" is linked to cat X and Y, I provide some pseudo code to better explain my need:

  1. if customer visits 'category A' page, products shall be filtered like this: "CAT A AND (CAT X OR Y)" =>i.e. all products attached to Cat A, but also to X OR Y
  2. if customer visits 'category B' page, products shall be filtered like this: "CAT B AND (CAT X OR Y)" =>i.e. all products attached to Cat B, but also to X OR Y
  3. if customer makes a search for name=foo, then search shall be like "name=foo and (CAT X OR CAT Y)" =>i.e. all products with a relevant score linked to "foo", but associated to Cat X OR Cat Y

Of course:

  1. all layered navigation shall consider this additional filtering behind the scene to be consistent
  2. if another customer is associated to Cat W and Cat Z, then same scenarios as above will apply but with W and Z instead of X and Y.

I'm on magento 2.4.1 with ES7. I spent many (many) hours to search where to update core, but I'm failing. The learning curve is hard, so if anyone can help me to point out where I can add such restriction for search, catalog view and layered navigation that would be awesome. I don't need detail code. I know also how to store and retrieve the per customer categories.


Your Answer

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

Browse other questions tagged or ask your own question.