Resolving ‘Required parameter ‘theme_dir’ was not passed’ in Magento 2

Resolving the error message “Required parameter ‘theme_dir’ was not passed” is a common challenge encountered by developers working with Magento 2 themes. In this article, we will explore the causes of this error and provide step-by-step guidance on how to resolve it in Magento 2. By following these instructions, you will be able to overcome this issue and successfully work with themes in your Magento 2 store. Let’s dive in and learn how to address the ‘Required parameter ‘theme_dir’ was not passed’ error in Magento 2.

The Causes of the ‘Required parameter ‘theme_dir’ was not passed’ Error in Magento 2

The error occurs when the theme folder is deleted in Magento 2 at app/design/frontend/Vendor/theme, but the corresponding theme data is not removed from the database.

The error can also occur when you move your Magento 2 database to another website without including the necessary theme files. Another case is when the theme folder name does not match the theme name in the database.

Magento 2 gives this error when it detects the theme entry in the database but cannot locate the theme folder.

'Required parameter 'theme_dir' was not passed' error in Magento 2
Required parameter ‘theme_dir’ was not passed.

In some cases, when you check the var/log for errors, you might encounter the following message: LogicException: Unable to load theme by specified key: ‘key’ in …

Unable to load theme by specified key

The Solution to Fix the ‘Required parameter ‘theme_dir’ was not passed’ Error

Based on the given causes, we have two solutions for each case – when you can access the admin page and when you cannot access the admin page.

Solution 1: Configuration in Magento 2 admin page

Log in to the Magento 2 admin page, select CONTENT -> Configuration -> Edit.

Configuration in Magento 2 admin page

Select the theme you are using and then Save Configuration.

Configuration theme in Magento 2 admin page

Solution 2: Using MySQL Command

In case this error prevents you from accessing the admin page, here is an effective solution to help you remove the theme from the database.

First, to be able to access MySQL and execute commands, you need to know the database name, username, and password by checking them in the app/etc/env.php file.

After having all the necessary information, you can use the following command to log in to the MySQL account:

mysql -u username -p

Note: Replace “username” with your actual MySQL username. After executing this command, you will be prompted to enter your MySQL password.

Once you have successfully logged in, you can utilize the following command to remove the theme data from the database:

UPDATE dbname.core_config_data SET value=NULL WHERE path='design/theme/theme_id';

Note: Replace “dbname” with the actual name of your database. This command will set the value to NULL for the specified theme path in the “core_config_data” table, effectively removing the theme association from the database.

Then clear the cache and check again

php bin/magento cache:clean

Conclusion

In conclusion, resolving the “Required parameter ‘theme_dir’ was not passed” error in Magento 2 requires a thorough understanding of the underlying causes and implementing the appropriate solutions. By ensuring the necessary theme files are included when migrating the Magento 2 database to another website and verifying the consistency between the theme folder name and the corresponding entry in the database, you can overcome this error successfully.

By following the solutions in the article, you can effectively resolve the “Required parameter ‘theme_dir’ was not passed” error in Magento 2. If you still cannot resolve the error or encounter any further difficulties, please do not hesitate to contact us.

4.5 2 votes
Article Rating

Callula Huy

Callula is the Marketing Executive at Magetop. With more than 5 years of copywriting under her belt, Callula is into creating valuable content that is straight to the point. Life student. Workaholic. Foreign languages and traveling aficionado.

Leave a Reply or put your Question here

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x