5

I have try to create custom theme I have got following error.

Unable to load theme by specified key: 'Yogesh/mytheme'

Below is my folder structure.

\magento2\app\design\frontend\Yogesh\mytheme

  • media
    • preview.jpg
  • composer.json
  • registration.php
  • theme.xml

Following are content of files.

Composer.json

{
    "name": "magento/theme-frontend-blank",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/theme-frontend-blank": "100.0.*",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-theme",
    "version": "100.0.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

registration.php

\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/Yogesh/mytheme',
__DIR__
);

theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
 <title>Yogesh mytheme</title> 
 <parent>Magento/blank</parent>
 <media>
     <preview_image>media/preview.jpg</preview_image> 
 </media>

I have try with php bin/magento setup:upgrade but my module is not registered, not showing in config.php.

After I have try to setup:static-content:deploy but my theme content not deployed.

My theme is not able to load what mistake I have doing?

2
  • have you set your theme inside stores -> configuration -> design tab? May 16, 2016 at 4:53
  • Is your problem solved?
    – Gem
    Nov 16, 2019 at 7:07

6 Answers 6

4
  1. Try clear the cache and run the bin/magento setup:static-content:deploy again.
  2. To add new theme you need to turn in developer mode.
  3. Sometimes new theme added to theme table in our database with param type=1 (virtual theme). Try to set it to 0 (physical theme). For example:

mysql> insert into theme
(parent_id,theme_path,theme_title,preview_image,is_featured,area,type,code) VALUES ('1','MyVendor/Base','MyVendor Base', NULL, 0, 'frontend', 0, 'MyVendor/Base');

We can read more here:

https://github.com/magento/magento2/issues/3409 https://github.com/magento/magento2/issues/2797

5
  • I have already try that not working
    – Yogesh
    May 15, 2016 at 9:04
  • I have just updated my answer: github.com/magento/magento2/issues/2797 May 15, 2016 at 9:12
  • so its magento issue and may be resolved in 2.0.7 ?
    – Yogesh
    May 15, 2016 at 17:41
  • Yes, I believe. May 16, 2016 at 2:10
  • Copy all content from vendor/magento blank theme and paste in your theme except theme.xml , composer.json & registration.php problem partially solved.
    – Yogesh
    May 17, 2016 at 9:38
4

Please check cms_page table in database and check if Yogesh/mytheme is set in custom_theme column then execute this query in phpmyadmin,

UPDATE `cms_page` SET `custom_theme` = NULL WHERE `custom_theme` IS NOT NULL

In my case, I found records in the cms_page table referring to a non-existent theme.

This is work for me properly. I hope this will help you.

4

There is a great change there is still a reference to this theme, I had the same problem. These were the steps I took to solve the problem:

  1. I went to the table theme to see what the original theme_id of the deleted theme was.
  2. I checked several tables for the occurence of this theme_id. Tables I checked: cms_page, layout_link, design_config_grid_flat, core_config_data.
  3. You can check if the ids are correct, using the following SQL:

SELECT * FROM core_config_data WHERE path LIKE '%theme%';

  1. Change all these theme ids to the correct ids. Preferably via an upgrade script.

I used the following:

    $setup->run("
        DELETE FROM theme WHERE `theme_path` LIKE 'Vendor/module';
    ");

    $setup->run("
        UPDATE cms_page SET `custom_theme` = NULL WHERE `custom_theme` IS NOT NULL
    ");

    $setup->run("
        UPDATE design_config_grid_flat SET `theme_theme_id` = 6 WHERE `theme_theme_id` = 4
    ");

    $setup->run("
        UPDATE core_config_data SET `value` = 6 WHERE `path` = 'design/theme/theme_id' AND `value` = 4
    ");

I hope this helps, it's merely a collection of different solutions I found, plus my own interpretation!

1

After trying all other answers here (to no avail) the following order of commands helped (in developer mode):

rm -r pub/static/* var/view_preprocessed/* var/cache/* var/di var/generation
bin/magento cache:clean
bin/magento cache:flush
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy de_DE en_US
0

You have to some error in your composer.json file,

{
    "name": "Yogesh/theme-frontend-mytheme",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/theme-frontend-blank": "100.0.*",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-theme",
    "version": "100.0.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

After set Composer file, You have to set your theme from Stores -> Configuration -> Design.

Now run command,

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

Remove var folder and check again.

3
  • I have check this things not working for me.
    – Yogesh
    May 16, 2016 at 8:10
  • plz check inside database theme table with your theme entry type field equal 0. if its not 0 then set it as 0 May 16, 2016 at 9:09
  • its 0 may be its bug of 2.0.5 because 2.0.2 & 2.0.4 is working fine
    – Yogesh
    May 16, 2016 at 11:35
0

Need log. See bugs Magento 2 : https://github.com/magento/magento2/issues/2547 Ans. AlanKent

1
  • We have extend blank theme not a luma @wise
    – Yogesh
    May 16, 2016 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.