OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce Group restriction

This topic contains 9 replies, has 3 voices, and was last updated by  msalmi.kais 4 years, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #33014

    msalmi.kais
    Participant

    Hello
    I want to create more group by brand. each group will have its own restrection (view product, view promotion).
    my question is: how to affect the client in several groups?
    can we adapt this logic?
    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #33015

    Andrey Yatsenko
    Moderator

    Hi,

    Are you talking about customer groups (for users at storefront) or user groups (for management console users?

    #33016

    msalmi.kais
    Participant

    for users at storefront

    #33017

    Andrey Yatsenko
    Moderator

    Basically, you just need to create custom ACL voter if I understand right your question. Here is the doc How to use Voters.

    But I can’t understand how did you configure permissions per customer group. As I see there is only role based permissions configuration. Do you automatically create roles for each new group or how did you manage this?

    #33019

    seddik.dimassi
    Participant

    THANKS ANDREY,

    Actually, the problem is that our marketplace is selling products from different brands. We need to enable restriction on brands for clients (using groups or other method).
    The best will be able to check or uncheck available brand’s product for every customer.
    Do you think using groups will be the best solution?

    #33021

    Andrey Yatsenko
    Moderator

    Group can have many customers, but you want to configure it per customer.

    So it’s better to have new relation form Customer to Brand, you can create it using schema migration as Customer is an extendable entity, let’s call new relation availableBrands, or you can create relation from the Brand side. Depending on your business logic choose what is better here.

    Then you can just create regular ACL voter for the product entity, as an example you can see this one https://github.com/oroinc/orocommerce/blob/1.6/src/Oro/Bundle/VisibilityBundle/Acl/Voter/ProductVisibilityVoter.php

    Your voter needs to get customerUser from token storage and then check if product.brand exists at customerUser.customer.availableBrands. That’s it.

    #33022

    seddik.dimassi
    Participant

    Thanks a lot ! Great – I think it ll be better to make it by customers @ Kais : What do you think?

    #33023

    msalmi.kais
    Participant

    Hi,
    @Andrey, can we apply this ACL voter for the frontend product by customers ?
    i think this example https://github.com/oroinc/orocommerce/blob/1.6/src/Oro/Bundle/VisibilityBundle/Acl/Voter/ProductVisibilityVoter.php it’s for backend product.
    there is a more detailed example to follow, or a course for voting acl?
    Thank you Andrey for help.

    #33024

    Andrey Yatsenko
    Moderator

    What do you mean by frontend and backend products?

    We use same entity on both UIs.

    This listener used only on front-store according to this check and will be skipped on management console https://github.com/oroinc/orocommerce/blob/1.6/src/Oro/Bundle/VisibilityBundle/Acl/Voter/ProductVisibilityVoter.php#L38
    In case of backend this will just return ACCESS_ABSTAIN, that means that voter doesn’t know how to vote on it.

    As I mentioned above general documentation about voters can be found here How to use Voters.
    I don’t know about any other docs.

    #33025

    msalmi.kais
    Participant

    Thank you very much Andrey.

Viewing 9 replies - 1 through 9 (of 9 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

Back to top

You will be redirected to [title]. Would you like to continue?

Yes No

You will be redirected to [title]. Would you like to continue?

Yes No