1

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

  • use extension attribute for it – Ansar Husain Nov 25 '19 at 12:40
  • @AnsarHusain I have added more explanation in question please check. I have already created custom attribute for customer. – Ajwad Syed Nov 25 '19 at 12:53
1

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

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.