Question

I have a customer with custom attribute as merchant. I want to let that customer to see only my custom module features.

How can I restrict a user to some custom features ?

Edit:

Actually I have created custom APIs to buy giftcodes as merchant (customer). I can test these APIs in Magento Swagger UI with customer token. But when I open swagger documentation I can see all custom APIs with that customer token. I am looking a way by which I could show the merchant(customer) only the custom APIs related to giftcode.

There is one custom module responsible for selling giftcodes. How can I create ACL to show a customer

where customer->isMerchant is TRUE

No correct solution

OTHER TIPS

If you want to create the custom module ACL: Create file in your module at : app/code/Vendor/Module/etc/acl.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Vendor_Module::save" title="Module" sortOrder="10" >
                <resource id="Vendor_Module::module" title="Module" sortOrder="0" />
            </resource>
        </resource>
    </resources>
</acl>
</config>

Note: Please make sure to add comman resource id in your admin Controller:

protected function _isAllowed()
{
  return $this->_authorization->isAllowed('Vendor_Module::save');
 }

This will create a New Permissions in admin=> System =>Roles/Permission section.

For more information refer this link: https://www.mageplaza.com/magento-2-module-development/magento-2-acl-access-control-lists.html

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top