I'm using Commerce 2 and I have:

  • User A and User B
  • Store X assigned to User A (by entity reference)
  • Store Y assigned to User B

I would like to restrict access to products of stores so that User A only sees products associated to Store X.

What is the way to do that?

  • Hello Pierre, There is "Store" and "Store Type" entity types already defined in Drupal Commerce 2. I am using them. Products are also default Commerce 2 products. docs.drupalcommerce.org/commerce2/developer-guide/stores – Sinan Erdem Nov 10 '17 at 17:33
  • 1
    Merci for confirming what I was more or less guessing (but guessing is not the way to go to produce possible answers ...). Please review my edit, feel free to further improve it, or just rollback if you don't like it at all. – Pierre.Vriens Nov 10 '17 at 17:44
  • 1
    Since products and stores are entities, and your question is about access to them, it SHOULD be possible to use the Group module for this (for which there is a stable D8 version). However, I've not ever tried using the Group module in combination with Commerce 2. Maybe worth some further investigations / experiments? – Pierre.Vriens Nov 10 '17 at 18:29
  • Thanks Pierre. I will definitely have a look into it. I tried Domain module with Domain Access Entity module and having some luck. The only way I have to do now is to connect a subdomain with a store for the user. – Sinan Erdem Nov 12 '17 at 15:06
  • 1
    "Content access rules" would be my first approach. This is what roles are for in Drupal, there are "Store" permissions in D8. If you need something further, this could help: commerceguys.com/blog/selling-node-access-drupal-commerce – Prestosaurus Apr 26 '18 at 14:41

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.