Magento – Magento 2: Required parameter ‘theme_dir’ was not passed

alertexceptionmagento2notificationtheme

I have installed the following module:

https://landofcoder.com/magento-2-out-of-stock-notification.html

It works like it's supposed to but getting an error.

When looking inside the module i see it tries to do the following when trying to send a notification email:

$alertGrid = $this->_appState->emulateAreaCode(
        \Magento\Framework\App\Area::AREA_FRONTEND,
        [$block, 'toHtml']
    );

It does this for each website that has enabled the product notification (and if a product comes back in stock)

I have 3 websites in one magento 2 installation. Each has it's own theme completely different than the other. lets call them theme 1 till theme 3.

When it tries to send a notification email for the website with theme 1, i already get the exception:

Required parameter 'theme_dir' was not passed.

This gets catched and will try to send the email for the websites withtheme 2 and theme 3.

Only the first theme fails and gives me the error.

Any idea which could be the problem? I tried to look in the theme table. but everything looks fine, path and everything. The theme works when i navigate to the website.

I will keep this updated.

Update 1

I have found the problem. It is storeview related.

The $block variable is based on storeid, it doesn't work with my storeId 1 (english). But when i hardcoded it to my storeview id 2 (dutch). It works. Any idea why it only happens with my default store id?

The block variable is build like this:

  $this->_getStockBlock()->setStore($store)->reset();
        foreach ($this->_stockProducts as $product) {
            $this->_getStockBlock()->addProduct($product);
        }
        $block = $this->_getStockBlock();
        $templateId = $this->_scopeConfig->getValue(
            self::XML_PATH_EMAIL_STOCK_TEMPLATE,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $storeId
        );

Best Answer

1) Go to Content -> Configuration, select the scope (global, website, store_view) and change the theme. After you've done that you should also remove it from Content -> Themes.

OR IF ABOVE DOESN'T WORKS

Go to your core_config_data table and search for theme and you will get path = design/theme/theme_id replace your theme id in it.

Related Topic