Skip to main content

Posts

Showing posts from May, 2020

Using ACL in Magento2

 Using ACL in Magento2 In the last blog, we’ve discussed how to create an acl and assign a custom role to a user in order to give access or restrict that user. As Magento allows separate access to different users.  In this part we’ll discuss how we can use acl in Menu, Configurations and Controller.  First we’ll create acl.xml as we have discussed in our last blog:- https://magento2withsakshi.blogspot.com/2020/05/using-acl-magento2.htm l  Create ACL Rule 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 = "Custom_Module::menu" title = "CustomMenu" sortOrder = "10" >            < resource id = "Custom_Module::create" title = &q

Using ACL(Access Control List) in Magento2

 Using ACL(Access Control List) in Magento2 ACL is used to add our resource under the resource tree so that we can allow or deny access to the particular users to that resource using ACL rules.  ACL resource tree is visible under System > Permission > User Roles area in the admin section. To add our custom resource under this resource tree we have to create acl.xml inside etc/ folder of our 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 = "Custom_Module::menu" title = "Custom Menu" sortOrder = "10" >           </ resource >         </ resource >      </ resources >    <

Creating a new module in Magento2

Creating a new module in Magento2 We can place modules inside the app/code folder and vendor folder, If we are creating a module for any customization or specific project we will create inside the app/code folder. Whenever you install a module using composer it is added to the vendor folder. These are the required files to create a new module:-  registration.php module.xml Register your module:- Create registration.php inside Vendor/Module folder <?php \Magento\Framework\Component\ ComponentRegistrar :: register ( \Magento\Framework\Component\ ComponentRegistrar ::MODULE, 'Custom_Module' , __DIR__ ); \Magento\Framework\Component\ComponentRegistrar class is used to register the module. module.xml :- Create this file inside etc/module.xml and This file is used to declare name, dependencies and version of the module.  <? xml version = "1.0" ?> < config xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "