1

The theme is installed on a fresh Magento-2.1.7 with no data. The system is CentOS-7.3 (VPS@godaddy), MySQL-5.6.37, PHP-5.6.31, Nginx-1.10, PHP-FPM runs as nginx:nginx, file system user is in the nginx group, directories are "g+s"-ed.

Installation steps: switch to developer mode clean, flush and disable cache, disable js/css merge/minification. ./bin/magento setup:upgrade ./bin/magento index:reindex ./bin/magento cache:clean

Now, the store front page shows up with the Magento's default template, but /admin_****** throws the following exception:

 Exception #0 (Magento\Framework\Exception\FileSystemException): File "/composer.json" cannot be opened Warning!fopen(/composer.json): failed to open stream: No such file or directory #0 /.../magento2/app/code/TemplateMonster/ThemeUpdater/Model/ThemeData.php(98): Magento\Framework\Filesystem\Driver\File->fileOpen('/composer.json', 'r') .... 30 lines of the exception trace follow. 

Obviously, it is looking for composer.json in the wrong place. The right place is $MAG_ROOT/app/design/frontend/TemplateMonster/theme###/. Here are the relevant parts of ThemeData.php and what I discovered through some hacking into them.

 protected function getComposerData() { $path = $this->getAbsThemePath() . '/composer.json'; /*98*/ $resource = $this->_fileDriver->fileOpen($path, 'r'); ... } 

The culprit is line #98. Obviously, getAbsThemePath() returns empty string instead of the theme's full path. Here it is:

 public function getAbsThemePath() { $theme = $this->_theme->load($this->getThemeId()); $result = $this->_componentRegistrar->getPath(ComponentRegistrar::THEME, 'frontend/' . $theme->getThemePath() ); return $result; } public function getThemeId() { // should return 4, but returns '' return $this->_scopeConfig->getValue(self::DESIGN_THEME_ID, $this->getScopeType(), $this->getScopeId() ); } 

In getThemeId(): runtime arguments to getValue are ('design/theme/theme_id', 'default', null), and getThemeId() returns null (or ''). Actual theme_id in the magento_db.theme table is 4, and if I hard-code getThemeId() to return 4, then everything works. _scopeConfig is injected \Magento\Framework\App\Config\ScopeConfigInterface

Any ideas as to what's going wrong here and how to fix it?

Also, is it worth fighting with it, or should I just get another template from Template Monster (or some other vendor)?

Thank you for your advice.

1
  • I'm having the same issue. Trying to resolve it with TemplateMonster support but nothing yet. Commented Nov 20, 2017 at 19:46

1 Answer 1

0

I just changed the return of the function getThemeId just to make it work:

public function getThemeId() { // FIXME // return $this->_scopeConfig->getValue(self::DESIGN_THEME_ID, $this->getScopeType(), $this->getScopeId() ); return 4; } 

Just make sure what your theme ID is looking into your database: select * from theme:

+----------+-----------+--------------------------+-----------------------+----------------------------------+-------------+-----------+------+--------------------------+ | theme_id | parent_id | theme_path | theme_title | preview_image | is_featured | area | type | code | +----------+-----------+--------------------------+-----------------------+----------------------------------+-------------+-----------+------+--------------------------+ | 1 | NULL | Magento/backend | Magento 2 backend | NULL | 0 | adminhtml | 0 | Magento/backend | | 2 | NULL | Magento/blank | Magento Blank | preview_image_5a132582769c4.jpeg | 0 | frontend | 0 | Magento/blank | | 3 | 2 | Magento/luma | Magento Luma | preview_image_5a13258285710.jpeg | 0 | frontend | 0 | Magento/luma | | 4 | NULL | TemplateMonster/theme063 | TemplateMonster Theme | preview_image_5a132762b07f7.jpeg | 0 | frontend | 0 | TemplateMonster/theme063 | +----------+-----------+--------------------------+-----------------------+----------------------------------+-------------+-----------+------+--------------------------+ 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.