I had a project with a branch called “develop”. I had a task to create custom theme inherited from the luma theme. I created a new branch for it and switched to the branch I’ve just created. Everything was working fine and I delivered the files of my custom theme to the dev server. I pushed my local branch to the dev server and merged it into “develop”.
Several days later I got a task to make some style changes in the custom theme. I pulled changes into my local “develop” and opened the site in a browser. There weren’t any styles of the theme I created. I switched to the branch I created for this theme before and refreshed the browser page. There weren’t any changes either.
I checked the “Themes” settings in the admin panel of my project and the files of the theme. I checked a history of commits of the project. Everything looked good. Of course, I stayed calm and cleared cache, and made setup: static-content:deploy and etc. Nothing helped.
Theme types in the database
I started to search in the Google and found an advice to check the THEME table in a database. There is a field TYPE in the THEME table. There are three theme types:
0 – physical
1 – virtual
2 – staging
The “physical” means there are files of a theme under a folder.
The “virtual” means there are no files under a theme folder. There is not even a theme folder 🙂 I tried to find how can I create the theme with a such type, but I couldn’t. If I create a theme according to the Magento tutorial. I’ll get a physical type theme. There is no any button in the admin panel in any of sections in the Content->Design. I tried to find the places where the virtual type is set in the code. One of the places is the method
execute in the /vendor/magento/module-theme/Controller/Adminhtml/System/Design/Theme/Save.php. But I couldn’t find any button or link to call this method.
I found the answer of Raphael at Digital Pianism at Stackexchange. He says that it seems this feature’s not fully implemented yet. And if I set the value 1 in the THEME table in the TYPE field for my theme I’ll get the other version of the theme page in the admin panel. I’ll get the CSS Editor and JS Editor tabs and the Save button.
The “staging” corresponds to the value 2. I tried to set it in my db table, but I got an error message “We cannot find theme “9”.” in the admin. The Raphael at Digital Pianism‘s answer that I mentioned above says that it could be related to Magento Commerce only staging feature. Unfortunately, I can’t test it.
Here is the result:
- You can get the problem because of moving your theme’s folder or maybe the nessecary files for the theme registration in Magento CE ver. <= 2.2.2 (It seems this bug is fixed in the 2.3 version, see more at Github)
- If you don’t see your theme on the front of your site, don’t forget to check the THEME table. The field TYPE should contain “0”.
- If you create the theme according to the Magento tutorial there will be always physical type.
- There is no a full implementation of a virtual type of a theme in the Magento CE ver. <= 2.2.2 (I don’t know about higher versions).
I spent 4 hours to find the reason of why my theme isn’t displayed on the front of my site. It’s not half bad compared to the 2 days or 4-5 days the guys from this conversation spent 🙂
I hope my post will save your time!
Certified Magento Developer at Mobecls
4+ years experience
Feel free to ask me anything about this post in the comments below