Tutorial On Using Database In Magento 2 Media Files Storage

In the default installation of Magento 2 Open Source, images, compiled CSS files, and JS files of the Magento instance are saved in the file system on the server. Store administrators can store these files in a database on a database server. This method allows you to select between auto-sync and reverse-sync between the web server file system and the database. You can use the default database to store media or create a new one. To use a newly created database as media storage, you must include information about it and its access credentials in the local .xml file.

The database workflow of using database In Magento 2 media files storage below:

  1. Browser requests media: The browser requests the media that is specified in the HTML while opening a page in the store on the browser.
  2. The system looks for media in the file system: The media files will be searched and found in the file system and send to the browser.
  3. The system locates media in database: If the file is not available in the system, a request is sent to the database that is specified in the configuration.
  4. The system locates media in database: A PHP script sends the files from the database to the file system and sent to the browser.

If the server is supported and web server rewrites are enabled for Magento, the PHP script runs only when the requested media files are not in the file system.

If the server is not supported or web server rewrites are disabled for Magento, the PHP script runs even if the requested media files exist in the file system.

To configure a database for media storage, please follow these steps:

On the admin sidebar click Stores, under Settings click Configuration, under Advanced, click System. To apply the configuration at the global level, set Store View to Default Config. Open the Storage Configuration for Media tab and follow these steps:

Storage Configuration for Media (Database)
Storage Configuration for Media (Database)
  • Uncheck the Use system value checkbox
  • Set Media Storage to “Database.”
  • Set Select Media Database to the database you want to use.
  • Click Synchronize, enter the Environment Update Time and click Save Config.

In the next article, we will describe tutorial on using a CDN as a media storage for Magento 2 online store. Keep tracking Magestandard and see you in the next blog post.

What is Alternate Media Storage In Magento 2?

In the previous articles, we described everything about controlling the administrators’ management system, including how to add users, unlock users and creating user roles in Magento 2 admin panel. This article will describe the alternate media storage method in Magento 2.

In Magento 2 default installation, you have two primary option to save media files:

The first method is you can store media files in a database on a database server, or the second method is you can store the media files on a Content Delivery Network (CDN) instead of saving media files on the file system of the web server. The advantage of saving media files in a database on the alternate media storage such as a database server or Content Delivery Network limits the effort required to sync media when multiple instances of the system that are deployed on other servers that need access to the same images, CSS files, and other media files. The advantage of store media files on the database server is the selection of auto-sync and reserve-sync between the web server file system and the database.

Media Storage Configuration
Media Storage Configuration

Each one of these alternate media storages has a specific workflow and also have a specific way to configure. You can do a configuration for both two alternate media storages in Magento 2 admin panel, and we will provide more detail tutorial for these alternate media storages in the next two articles, so you will not confuse in configuring alternate media storage.

Above is an article on two alternate media storages in the default installation of Magento 2 Open Source. We hope that you will know the critical detail of media storage, and prepare a basic knowledge on configuring database and CDN. On the next two articles, we will describe information on using the database for media storage and using a Content Delivery Network. See you in the next blog post.

How To Set Up User Roles In Magento 2 Admin Panel

To restrict the right to access admin of user, first, you have to create a role that has the specific level of permission. Then you save the role and assign users the restricted role to grant them limited access to the Admin.

Roles
Roles

To set up a role, you have two steps, but first, you have to open the User Roles table:

On the admin sidebar, click System >  Under Permission click User Roles > Click Add New Role then follow these steps

Step 1: Define the Role

Enter required information to Role Name and Your Password.

Role Name
Role Name

Step 2: Assign Resources

Don’t forget to disable access to the Permissions if you are restricting access for a given role. Otherwise, users will be able to modify their permissions.

  1. Set Role Scopes to All or Custom.
  2. Under Roles Resources, set Resource Access to “Custom.”
  3. In the folder tree, mark the checkbox of each Resource that the role can control.
  4. Click Save Role after completed and the role will display in the grid to be assigned to new user accounts.

To edit a role:

  1. In the Roles table, open the record in the edit mode.
  2. Enter your password and click Role Users.
  3. To search for a specific user record, you can use the search filter, to return a full list, click Reset Filter
  4. Tick the checkbox of users to be assigned to the role, then click Save Role
Role Users
Role Users

Above is a tutorial on how to set up user roles in Magento 2 admin panel. We hope that you can control the administrators manage the system in Magento 2 platform correctly and effectively. In the next articles, we will describe the other media storage, using database and CDN. Keep tracking Magestandard by subscribing to our blog to read more Magento 2 tutorial article. See you in the next blog post.

How To Add Users In Magento 2 Admin Panel

In the default installation of Magento 2, an Admin account is created that gives you full administrative access. First, you have to create another user account with full Administrator access, so you can use one account for your everyday Administrative activities, and reserve the other as a “Super Admin” account in case you lost access to your main account.

For a team of administrators, you can create a separate account for each, and set restrict access based on their business. To do that, you have to create a role with limited scope and access only to the necessary resources and assign the role to an admin account. After assigned to a restricted role, admin users can see and change data only for websites or stores that are associated with the role, but cannot make changes to any global settings or data.

Example Admin Users
Example Admin Users

Step 1: Create a New User

On the admin sidebar click System > All Users > Add New User. Follow these steps:

New User Account Information
New User Account Information

Enter all required information and set “This account is” as Active, enter your password under Current User Identity Verification.

Step 2: Define the Role

On the left of the panel, click User Role. In the Assigned column, tick the Administrators selection and click Save User.

Add New User Role
Add New User Role

Admin Password Requirements

FIELD DESCRIPTION
Password Length of the password must be seven or more characters long, include both letters and numbers. For further information, please read this article: How To Configure Admin Security In Magento 2 Admin Panel.

Above is a tutorial on adding users in Magento 2 admin panel. We hope that you can manage the Administrators function in Magento 2 installation, and run your online store smoothly. In the next article, we will describe one of the most security function of Magento 2 platform: Lock Admin Account. Keep tracking Magestandard by subscribing to our site to read more Magento 2 tutorial blog post. See you in the next article.