1

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?

  • have you set your theme inside stores -> configuration -> design tab? – Rakesh Jesadiya May 16 '16 at 4:53
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

  • I have already try that not working – Yogesh May 15 '16 at 9:04
  • I have just updated my answer: github.com/magento/magento2/issues/2797 – Khoa TruongDinh May 15 '16 at 9:12
  • so its magento issue and may be resolved in 2.0.7 ? – Yogesh May 15 '16 at 17:41
  • Yes, I believe. – Khoa TruongDinh May 16 '16 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 '16 at 9:38
2

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.

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
1

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!

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.

  • I have check this things not working for me. – Yogesh May 16 '16 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 – Rakesh Jesadiya May 16 '16 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 '16 at 11:35
0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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