In this blog in explain about how we can get current admin user details from session.We need to use session class Magento\Backend\Model\Auth\Sessiont to get current loggedin admin data.Here is simple code is to get admin details. Code is writter with PHP8 and supported to magento 2.4.6 😍 Created one simple class and loaded Session in construct method You can get more details about user with different methods like for get admin user name $this->authSession->getUser()->getUsername();Here is…
In this blog, I created admin role save after event to save custom field data in tablecreate events.xml file at app/code/<Vendor>/<Module>/etc/events.xml Now Create observer PermissionsRolePrepareSave for save field field_name data in database. Create file at path app/code/MageDad/Module/Observer/Backend/Admin/PermissionsRolePrepareSave.php I hope this blog is useful for save role field data in database. In case, I missed anything or need to add some more information, Don’t heisted to leave a comment in this blog, I’ll get back with…
In Magento 2, you can use the built-in logging system to add logs for debugging purposes. Here’s a step-by-step guide on how to add log in Magento2: Initialize the Logger in your class To start logging, you need to instantiate the \Psr\Log\LoggerInterface in your class. You can do this by adding it to the constructor. Add Log Statements Now, you can use the $this->logger object to add log statements. There are different log levels available,…